Update build instructions in README

+ Clean up CMakeLists and remove some unused includes
 + Remove unused Qt translations file
This commit is contained in:
Shaun Reed 2021-09-12 12:49:59 -04:00
parent 578fcb2bbd
commit fb359060bc
8 changed files with 42 additions and 79 deletions

View File

@ -9,7 +9,7 @@ project(
#[[NAME]] Qtk #[[NAME]] Qtk
VERSION 1.0 VERSION 1.0
DESCRIPTION "An example project using QT and OpenGL" DESCRIPTION "An example project using QT and OpenGL"
LANGUAGES CXX LANGUAGES CXX C
) )
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -26,13 +26,9 @@ find_package(Qt5 COMPONENTS Core LinguistTools Gui Widgets REQUIRED)
set(SOURCES app/main.cpp) set(SOURCES app/main.cpp)
qt5_add_resources(SOURCES resources.qrc) qt5_add_resources(SOURCES resources.qrc)
# Set translation files
set(TS_FILES qtk_en_US.ts)
add_executable( add_executable(
qtk # Executable name qtk # Executable name
${SOURCES} # Executable source code ${SOURCES} # Executable source code
${TS_FILES} # Link translation files
) )
@ -40,36 +36,12 @@ add_executable(
# External Libraries # External Libraries
################################################################################ ################################################################################
# Find and link GLUT package; Otherwise show an error
find_package(GLUT REQUIRED)
if (!GLUT_FOUND)
message(
"Error: CMake was unable to find the GLUT package\n"
"Please install GLUT (freeglut3-dev) and try again\n"
"sudo apt install freeglut3-dev\n"
)
endif()
# Find and link OpenGL package; Otherwise show an error # Find and link OpenGL package; Otherwise show an error
set(OpenGL_GL_PREFERENCE LEGACY) set(OpenGL_GL_PREFERENCE LEGACY)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
if (!OPENGL_FOUND)
message(
"Error: CMake was unable to find the OpenGL package\n"
"Please install OpenGL and try again\n"
"sudo apt install mesa-utils\n"
)
endif()
# https://github.com/assimp/assimp/commit/6ac8279977c3a54118551e549d77329497116f66 # https://github.com/assimp/assimp/commit/6ac8279977c3a54118551e549d77329497116f66
find_package(assimp REQUIRED) find_package(assimp REQUIRED)
if (!assimp_FOUND)
message(
"Error: CMake was unable to find the Assimp package\n"
"Please install Assimp and try again\n"
"sudo apt install libassimp-dev\n"
)
endif()
################################################################################ ################################################################################
@ -79,17 +51,8 @@ endif()
# Mainwidget # Mainwidget
add_library(main-widget lib/mainwidget.cpp) add_library(main-widget lib/mainwidget.cpp)
target_include_directories(main-widget PUBLIC lib/) target_include_directories(main-widget PUBLIC lib/)
#target_link_libraries(main-widget PUBLIC Qt5::Widgets) target_include_directories(main-widget PRIVATE ${OPENGL_INCLUDE_DIR})
# + This lib and all linked targets will also link to OpenGL target_link_libraries(main-widget PRIVATE ${OPENGL_LIBRARIES})
target_include_directories(main-widget PUBLIC ${OPENGL_INCLUDE_DIR})
target_link_libraries(main-widget PUBLIC ${OPENGL_LIBRARIES})
# Model
add_library(model lib/model.cpp)
target_include_directories(model PRIVATE ${ASSIMP_INCLUDE_DIR})
target_link_libraries(model PRIVATE ${ASSIMP_LIBRARIES})
target_link_libraries(model PUBLIC Qt5::Widgets)
target_link_libraries(model PRIVATE main-widget)
# Input # Input
add_library(input lib/input.cpp) add_library(input lib/input.cpp)
@ -101,16 +64,6 @@ 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 Qt5::Widgets)
# Transform3D
add_library(transform3d lib/transform3D.cpp)
target_include_directories(transform3d PUBLIC lib/)
target_link_libraries(transform3d PUBLIC Qt5::Widgets)
# Camera3D
add_library(camera3d lib/camera3d.cpp)
target_include_directories(camera3d PUBLIC lib/)
target_link_libraries(camera3d PUBLIC Qt5::Widgets)
# 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/)
@ -126,27 +79,42 @@ add_library(meshrenderer lib/meshrenderer.cpp)
target_include_directories(meshrenderer PUBLIC lib/) target_include_directories(meshrenderer PUBLIC lib/)
target_link_libraries(meshrenderer PUBLIC Qt5::Widgets) target_link_libraries(meshrenderer PUBLIC Qt5::Widgets)
# Camera3D
add_library(camera3d lib/camera3d.cpp)
target_include_directories(camera3d PUBLIC lib/)
target_link_libraries(camera3d PUBLIC Qt5::Widgets)
# Skybox # Skybox
add_library(skybox lib/skybox.cpp) add_library(skybox lib/skybox.cpp)
target_link_libraries(skybox PUBLIC Qt5::Widgets)
target_link_libraries(skybox PRIVATE mesh) target_link_libraries(skybox PRIVATE mesh)
# Skybox needs Mesh and Camera3D and Qt5::Widgets
target_link_libraries(skybox PRIVATE camera3d) target_link_libraries(skybox PRIVATE camera3d)
# Transform3D
add_library(transform3d lib/transform3D.cpp)
target_include_directories(transform3d PUBLIC lib/)
target_link_libraries(transform3d PUBLIC Qt5::Widgets)
# Model
add_library(model lib/model.cpp)
target_include_directories(model PUBLIC lib/)
target_link_libraries(model PRIVATE assimp)
# Model library requires transform3d and Qt5::Widgets
target_link_libraries(model PUBLIC transform3d)
################################################################################ ################################################################################
# Final Application # Final Application
################################################################################ ################################################################################
target_link_libraries(main-widget PUBLIC model) target_link_libraries(main-widget PUBLIC model)
target_link_libraries(main-widget PUBLIC input) target_link_libraries(main-widget PRIVATE input)
target_link_libraries(main-widget PUBLIC transform3d) target_link_libraries(main-widget PRIVATE transform3d)
target_link_libraries(main-widget PUBLIC object) target_link_libraries(main-widget PRIVATE object)
target_link_libraries(main-widget PUBLIC meshrenderer) target_link_libraries(main-widget PRIVATE meshrenderer)
target_link_libraries(main-widget PUBLIC texture) target_link_libraries(main-widget PRIVATE texture)
target_link_libraries(main-widget PUBLIC skybox) target_link_libraries(main-widget PRIVATE skybox)
target_link_libraries(main-widget PUBLIC mesh) target_link_libraries(main-widget PRIVATE mesh)
# Link qtk executable to main main-widget library # Link qtk executable to main main-widget library
target_link_libraries(qtk PUBLIC main-widget) target_link_libraries(qtk PUBLIC main-widget)
# Set up QT Linguist translation
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})

View File

@ -1,13 +1,12 @@
# Qtk # Qtk
Practice project for learning about using OpenGL in Qt5 widget applications. Practice project for learning about using OpenGL in Qt5 widget applications.
Model loader using [Assimp](https://assimp.org/). Model loader using [Assimp](https://assimp.org/) within a Qt5 widget application.
You can fly around and see the examples I made, or import your own models within You can import your own models within `mainwdget.cpp`, inside the
`mainwdget.cpp`, inside the `MainWidget::initObjects()` function. I've commented `MainWidget::initObjects()` function. I've commented throughout the code there
throughout the code there to explain which model or example I'm modifying. to explain which model or example I'm modifying. Rotations and translations
Rotations and translations happen in `MainWidget::update()`, to get textures happen in `MainWidget::update()`, to get textures loading on models look into
loading on models look into
[material files](http://www.paulbourke.net/dataformats/mtl/) and see some [material files](http://www.paulbourke.net/dataformats/mtl/) and see some
examples in the `resources/models/` directory. examples in the `resources/models/` directory.
@ -17,10 +16,10 @@ Can be built with cmake manually or using
To build and run `qtk` on Ubuntu - To build and run `qtk` on Ubuntu -
```bash ```bash
# Qt Creator # Qt Creator
sudo apt update -y && sudo apt install qttools5-dev freeglut3-dev libassimp-dev sudo apt update -y && sudo apt install qttools5-dev freeglut3-dev libassimp-dev cmake build-essential
git clone https://gitlab.com/shaunrd0/qtk git clone https://gitlab.com/shaunrd0/qtk && cd qtk
mkdir build && cd build mkdir build && cd build
cmake .. && cmake --build cmake .. && cmake --build .
./qtk ./qtk
``` ```
@ -50,7 +49,7 @@ Spartan with normals -
"Survival Guitar Backpack (Low Poly)" (https://skfb.ly/6RnCB) by Berk Gedik is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/). "Survival Guitar Backpack (Low Poly)" (https://skfb.ly/6RnCB) by Berk Gedik is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
Model by Berk Gedik, from: https://sketchfab.com/3d-models/survival-guitar-backpack-low-poly-799f8c4511f84fab8c3f12887f7e6b36 Model by Berk Gedik, from: https://sketchfab.com/3d-models/survival-guitar-backpack-low-poly-799f8c4511f84fab8c3f12887f7e6b36
Modified material assignment (Joey de Vries) for easier load in OpenGL model loading chapter, and renamed albedo to diffuse and metallic to specular to match non-PBR lighting setup. Modified (learnopengl.com) material assignment (Joey de Vries) for easier load in OpenGL model loading chapter, and renamed albedo to diffuse and metallic to specular to match non-PBR lighting setup.
"Terror-bird (NHMW-Geo 2012/0007/0001)" (https://skfb.ly/onAWy) by Natural History Museum Vienna is licensed under Creative Commons Attribution-NonCommercial (http://creativecommons.org/licenses/by-nc/4.0/). "Terror-bird (NHMW-Geo 2012/0007/0001)" (https://skfb.ly/onAWy) by Natural History Museum Vienna is licensed under Creative Commons Attribution-NonCommercial (http://creativecommons.org/licenses/by-nc/4.0/).

View File

@ -12,9 +12,10 @@
#include <QVector2D> #include <QVector2D>
#include <QVector3D> #include <QVector3D>
#include <mainwidget.h>
#include <transform3D.h> #include <transform3D.h>
class MeshRenderer;
class Object;
// Define vertices for drawing a cube using two faces (8 vertex points) // Define vertices for drawing a cube using two faces (8 vertex points)
// Front Vertices // Front Vertices

View File

@ -8,6 +8,7 @@
#include <QImageReader> #include <QImageReader>
#include <mainwidget.h>
#include <texture.h> #include <texture.h>
#include <meshrenderer.h> #include <meshrenderer.h>

View File

@ -13,7 +13,6 @@
#include <QOpenGLTexture> #include <QOpenGLTexture>
#include <QOpenGLVertexArrayObject> #include <QOpenGLVertexArrayObject>
#include <mainwidget.h>
#include <mesh.h> #include <mesh.h>

View File

@ -6,6 +6,7 @@
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
##############################################################################*/ ##############################################################################*/
#include <QDebug>
#include <QImageReader> #include <QImageReader>
#include <texture.h> #include <texture.h>

View File

@ -11,8 +11,6 @@
#include <QOpenGLTexture> #include <QOpenGLTexture>
#include <mainwidget.h>
class Texture { class Texture {
public: public:

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
</TS>