Port project to Qt6

This commit is contained in:
Shaun Reed 2022-03-06 11:54:05 -05:00
parent aebab76915
commit 22d6ac1b06
24 changed files with 106 additions and 40 deletions

60
.gitignore vendored
View File

@ -15,6 +15,7 @@
*.so.* *.so.*
*.dll *.dll
*.dylib *.dylib
*.exe
# Qt-es # Qt-es
object_script.*.Release object_script.*.Release
@ -56,3 +57,62 @@ compile_commands.json
# QtCreator local machine specific files for imported projects # QtCreator local machine specific files for imported projects
*creator.user* *creator.user*
*~
*.autosave
*.core
*.obj
*.orig
*.rej
*_pch.h.cpp
*_resource.rc
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc

View File

@ -1,7 +1,7 @@
################################################################################ ################################################################################
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ## ## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
## ## ## ##
## Project for working with OpenGL and Qt5 widgets ## ## Project for working with OpenGL and Qt6 widgets ##
################################################################################ ################################################################################
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
@ -19,19 +19,18 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find all Qt package components required for this project #find_package(QT NAMES Qt6 COMPONENTS Widgets REQUIRED)
find_package(Qt5 COMPONENTS Core LinguistTools Gui Widgets REQUIRED) find_package(Qt6 COMPONENTS Widgets OpenGLWidgets OpenGL REQUIRED)
# Add our Qt resources.qrc file to our application # Add our Qt resources.qrc file to our application
set(SOURCES app/main.cpp) set(SOURCES app/main.cpp)
qt5_add_resources(SOURCES resources.qrc) qt6_add_resources(SOURCES resources.qrc)
add_executable( add_executable(
qtk # Executable name qtk # Executable name
${SOURCES} # Executable source code ${SOURCES} # Executable source code
) )
################################################################################ ################################################################################
# External Libraries # External Libraries
################################################################################ ################################################################################
@ -57,23 +56,24 @@ target_link_libraries(main-widget PRIVATE ${OPENGL_LIBRARIES})
# Input # Input
add_library(input lib/input.cpp) add_library(input lib/input.cpp)
target_include_directories(input PUBLIC lib/) target_include_directories(input PUBLIC lib/)
target_link_libraries(input PUBLIC Qt5::Widgets) target_link_libraries(input PUBLIC Qt${QT_VERSION_MAJOR}::Widgets)
# Mesh # Mesh
add_library(mesh lib/mesh.cpp) add_library(mesh lib/mesh.cpp)
target_include_directories(mesh PUBLIC lib/) target_include_directories(mesh PUBLIC lib/)
target_link_libraries(mesh PUBLIC Qt5::Widgets) target_link_libraries(mesh PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
# Texture # Texture
add_library(texture lib/texture.cpp) add_library(texture lib/texture.cpp)
target_include_directories(texture PUBLIC lib/) target_include_directories(texture PUBLIC lib/)
target_link_libraries(texture PUBLIC Qt5::Widgets) target_link_libraries(texture PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
# Object # Object
add_library(object lib/object.cpp) add_library(object lib/object.cpp)
target_include_directories(object PUBLIC lib/) target_include_directories(object PUBLIC lib/)
target_link_libraries(object PUBLIC Qt5::Widgets)
target_link_libraries(object INTERFACE mesh) target_link_libraries(object INTERFACE mesh)
target_link_libraries(object PUBLIC Qt${QT_VERSION_MAJOR}::OpenGL)
target_link_libraries(object PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
# MeshRenderer # MeshRenderer
add_library(meshrenderer lib/meshrenderer.cpp) add_library(meshrenderer lib/meshrenderer.cpp)
@ -84,25 +84,28 @@ target_link_libraries(meshrenderer PUBLIC object)
add_library(camera3d lib/camera3d.cpp) add_library(camera3d lib/camera3d.cpp)
target_include_directories(camera3d PUBLIC lib/) target_include_directories(camera3d PUBLIC lib/)
target_link_libraries(camera3d INTERFACE input) target_link_libraries(camera3d INTERFACE input)
target_link_libraries(camera3d PUBLIC Qt5::Widgets) target_link_libraries(camera3d PUBLIC Qt${QT_VERSION_MAJOR}::Widgets)
# Skybox # Skybox
add_library(skybox lib/skybox.cpp) add_library(skybox lib/skybox.cpp)
# Skybox needs Mesh, Camera3D, and Qt5::Widgets # Skybox needs Mesh, Camera3D, and Qt6::Widgets
target_link_libraries(skybox PRIVATE mesh) target_link_libraries(skybox PRIVATE mesh)
target_link_libraries(skybox PRIVATE camera3d) target_link_libraries(skybox PRIVATE camera3d)
target_link_libraries(skybox PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
# Transform3D # Transform3D
add_library(transform3d lib/transform3D.cpp) add_library(transform3d lib/transform3D.cpp)
target_include_directories(transform3d PUBLIC lib/) target_include_directories(transform3d PUBLIC lib/)
target_link_libraries(transform3d PUBLIC Qt5::Widgets) target_link_libraries(transform3d PUBLIC Qt${QT_VERSION_MAJOR}::Widgets)
# Model # Model
add_library(model lib/model.cpp) add_library(model lib/model.cpp)
target_include_directories(model PUBLIC lib/) target_include_directories(model PUBLIC lib/)
target_link_libraries(model PRIVATE assimp) target_link_libraries(model PRIVATE assimp)
# Model library requires transform3d and Qt5::Widgets target_link_libraries(model PUBLIC Qt${QT_VERSION_MAJOR}::OpenGL)
# Model library requires transform3d and Qt6::Widgets
target_link_libraries(model PUBLIC transform3d) target_link_libraries(model PUBLIC transform3d)
target_link_libraries(model PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
# Scene # Scene
add_library(scene lib/scene.cpp) add_library(scene lib/scene.cpp)
@ -111,13 +114,13 @@ target_link_libraries(scene PUBLIC model)
target_link_libraries(scene PUBLIC meshrenderer) target_link_libraries(scene PUBLIC meshrenderer)
target_link_libraries(scene PUBLIC skybox) target_link_libraries(scene PUBLIC skybox)
target_link_libraries(scene PUBLIC texture) target_link_libraries(scene PUBLIC texture)
target_link_libraries(scene PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
################################################################################ ################################################################################
# Final Application # Final Application
################################################################################ ################################################################################
#target_link_libraries(main-widget PRIVATE input)
target_link_libraries(main-widget PRIVATE mesh) target_link_libraries(main-widget PRIVATE mesh)
target_link_libraries(main-widget PUBLIC scene) target_link_libraries(main-widget PUBLIC scene)

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Fly camera class from tutorials followed at trentreed.net ## ## About: Fly camera class from tutorials followed at trentreed.net ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
@ -22,7 +22,8 @@ const QVector3D Camera3D::LocalRight(1.0f, 0.0f, 0.0f);
const QMatrix4x4 & Camera3D::toMatrix() const QMatrix4x4 & Camera3D::toMatrix()
{ {
mWorld.setToIdentity(); mWorld.setToIdentity();
mWorld.rotate(mTransform.rotation().conjugate()); // Qt6 renamed QMatrix4x4::conjugate() to conjugated()
mWorld.rotate(mTransform.rotation().conjugated());
mWorld.translate(-mTransform.translation()); mWorld.translate(-mTransform.translation());
return mWorld; return mWorld;
} }

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Fly camera class from tutorials followed at trentreed.net ## ## About: Fly camera class from tutorials followed at trentreed.net ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Input class from tutorials followed at trentreed.net ## ## About: Input class from tutorials followed at trentreed.net ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Input class from tutorials followed at trentreed.net ## ## About: Input class from tutorials followed at trentreed.net ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,7 +1,7 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Main window for Qt5 OpenGL widget application ## ## About: Main window for Qt6 OpenGL widget application ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
##############################################################################*/ ##############################################################################*/

View File

@ -1,7 +1,7 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Main window for Qt5 OpenGL widget application ## ## About: Main window for Qt6 OpenGL widget application ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
##############################################################################*/ ##############################################################################*/

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Collection of static mesh data for quick initialization ## ## About: Collection of static mesh data for quick initialization ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Collection of static mesh data for quick initialization ## ## About: Collection of static mesh data for quick initialization ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: MeshRenderer class for quick object creation and drawing ## ## About: MeshRenderer class for quick object creation and drawing ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: MeshRenderer class for quick object creation and drawing ## ## About: MeshRenderer class for quick object creation and drawing ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Model classes for importing with Assimp ## ## About: Model classes for importing with Assimp ##
## From following tutorials on learnopengl.com ## ## From following tutorials on learnopengl.com ##
## ## ## ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Model classes for importing with Assimp ## ## About: Model classes for importing with Assimp ##
## From following tutorials on learnopengl.com ## ## From following tutorials on learnopengl.com ##
## ## ## ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Object class for storing object data ## ## About: Object class for storing object data ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Object class for storing object data ## ## About: Object class for storing object data ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Classes for managing objects and data within a scene ## ## About: Classes for managing objects and data within a scene ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Classes for managing objects and data within a scene ## ## About: Classes for managing objects and data within a scene ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Skybox class using QtOpenGL ## ## About: Skybox class using QtOpenGL ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Skybox class using QtOpenGL ## ## About: Skybox class using QtOpenGL ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Texture class to help with texture and image initializations ## ## About: Texture class to help with texture and image initializations ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
@ -14,6 +14,8 @@
QImage * Texture::initImage(const char * image, bool flipX, bool flipY) QImage * Texture::initImage(const char * image, bool flipX, bool flipY)
{ {
// Qt6 limits loaded images to 256MB by default
QImageReader::setAllocationLimit(512);
auto loadedImage = new QImage(QImage(image).mirrored(flipX, flipY)); auto loadedImage = new QImage(QImage(image).mirrored(flipX, flipY));
if (loadedImage->isNull()) { if (loadedImage->isNull()) {
qDebug() << "Error loading image: " << image << "\n"; qDebug() << "Error loading image: " << image << "\n";

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Texture class to help with texture and image initializations ## ## About: Texture class to help with texture and image initializations ##
## ## ## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Transform3D class to represent object position in 3D space ## ## About: Transform3D class to represent object position in 3D space ##
## From following tutorials at trentreed.net ## ## From following tutorials at trentreed.net ##
## ## ## ##

View File

@ -1,6 +1,6 @@
/*############################################################################## /*##############################################################################
## Author: Shaun Reed ## ## Author: Shaun Reed ##
## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
## About: Transform3D class to represent object position in 3D space ## ## About: Transform3D class to represent object position in 3D space ##
## From following tutorials at trentreed.net ## ## From following tutorials at trentreed.net ##
## ## ## ##