README and build options.
This commit is contained in:
parent
c9004027b9
commit
0f4ebbb0ab
@ -48,9 +48,20 @@ include(GNUInstallDirs)
|
|||||||
################################################################################
|
################################################################################
|
||||||
option(QTK_DEBUG "Enable debugger" OFF)
|
option(QTK_DEBUG "Enable debugger" OFF)
|
||||||
option(QTK_SUBMODULES "Update external project (assimp) submodule" OFF)
|
option(QTK_SUBMODULES "Update external project (assimp) submodule" OFF)
|
||||||
option(QTK_PLUGINS "Install Qtk plugins to Qt Creator path." OFF)
|
|
||||||
option(QTK_EXAMPLE "Build the Qtk example desktop application" ON)
|
option(QTK_EXAMPLE "Build the Qtk example desktop application" ON)
|
||||||
option(QTK_CCACHE "Enable ccache" ON)
|
option(QTK_CCACHE "Enable ccache" ON)
|
||||||
|
# Install Qtk for use within Qt Creator projects only, instead of system-wide.
|
||||||
|
option(QTK_PREFIX_QTCREATOR "Install Qtk to Qt Creator. Untested." OFF)
|
||||||
|
# Option for bringing your own assimp installation; Otherwise not needed
|
||||||
|
# + If assimp is available system-wide we can just set QTK_SUBMODULES OFF
|
||||||
|
option(
|
||||||
|
QTK_ASSIMP_NEW_INTERFACE
|
||||||
|
"Use the assimp::assimp interface (WIN / OSX)"
|
||||||
|
OFF
|
||||||
|
)
|
||||||
|
|
||||||
|
# Qtk Component Options
|
||||||
|
option(QTK_PLUGINS "Install Qtk plugins to Qt Designer path." OFF)
|
||||||
# Options for qtk_gui
|
# Options for qtk_gui
|
||||||
option(QTK_GUI "Build the Qtk desktop application" ON)
|
option(QTK_GUI "Build the Qtk desktop application" ON)
|
||||||
option(QTK_GUI_SCENE
|
option(QTK_GUI_SCENE
|
||||||
@ -61,17 +72,6 @@ if (QTK_CCACHE)
|
|||||||
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
|
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Install Qtk for use within Qt Creator projects only, instead of system-wide.
|
|
||||||
option(QTK_PREFIX_QTCREATOR "Install Qtk to Qt Creator. Untested." OFF)
|
|
||||||
|
|
||||||
# Option for bringing your own assimp installation; Otherwise not needed
|
|
||||||
# + If assimp is available system-wide we can just set QTK_SUBMODULES OFF
|
|
||||||
option(
|
|
||||||
QTK_ASSIMP_NEW_INTERFACE
|
|
||||||
"Use the assimp::assimp interface (WIN / OSX)"
|
|
||||||
OFF
|
|
||||||
)
|
|
||||||
|
|
||||||
if(QTK_DEBUG OR CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$")
|
if(QTK_DEBUG OR CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$")
|
||||||
set(QTK_DEBUG ON)
|
set(QTK_DEBUG ON)
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
141
README.md
141
README.md
@ -3,11 +3,16 @@
|
|||||||
[](https://github.com/shaunrd0/qtk/actions/workflows/all-builds.yml)
|
[](https://github.com/shaunrd0/qtk/actions/workflows/all-builds.yml)
|
||||||
[](https://github.com/shaunrd0/qtk/actions/workflows/linting.yml)
|
[](https://github.com/shaunrd0/qtk/actions/workflows/linting.yml)
|
||||||
|
|
||||||
Qtk is a Qt OpenGL graphics library that wraps some QOpenGL functionality in convenience classes
|
Qtk desktop application provides a model loader using [Assimp](https://assimp.org/) within a Qt widget application.
|
||||||
that allow rendering geometry in 2D and 3D using custom GLSL shader programs.
|
|
||||||
|
|
||||||
The Qtk desktop application provides a model loader using [Assimp](https://assimp.org/) within a Qt widget application.
|
|
||||||
You can fly around the scene using WASD while holding down the left or right mouse button.
|
You can fly around the scene using WASD while holding down the left or right mouse button.
|
||||||
|
[QtkWidget](./src/designer-plugins/qtkwidget.h) is the primary QOpenGLWidget used to render the scene and handle input.
|
||||||
|
|
||||||
|
The underlying shared library [libqtk](./src/qtk) wraps QOpenGL objects in convenience classes that leverage
|
||||||
|
lower-level OpenGL APIs to handle the rendering process manually. Many of these classes offer
|
||||||
|
ways to expand the low-level OpenGL logic within a Qt application without having to set up much scaffolding.
|
||||||
|
|
||||||
|
The Qtk GUI is built using custom [Qt Designer plugins](). These can be installed to Qt Designer for
|
||||||
|
use in other Qt applications, or built exclusively for Qtk. See
|
||||||
|
|
||||||
Object names can be double-clicked in the tree view panel for quick camera navigation.
|
Object names can be double-clicked in the tree view panel for quick camera navigation.
|
||||||
Properties of the object, like shader code and translation / scale, can be viewed and modified in the side panel.
|
Properties of the object, like shader code and translation / scale, can be viewed and modified in the side panel.
|
||||||
@ -25,6 +30,12 @@ The small triangles floating near 3D models represent the light source being use
|
|||||||
These appear on models using phong, specular, and diffuse lighting techniques.
|
These appear on models using phong, specular, and diffuse lighting techniques.
|
||||||
|
|
||||||
The default scene contains basic examples like texture mapping to make a crate from basic cube geometry
|
The default scene contains basic examples like texture mapping to make a crate from basic cube geometry
|
||||||
|
This scene is used in the following screenshots, and can be built locally by enabling
|
||||||
|
the `QTK_GUI_SCENE` [Build Option](#build-options) described below. Because this scene
|
||||||
|
uses large 3D model resources, this option is disabled by default.
|
||||||
|
|
||||||
|
The default scene with this option disabled is empty, but comes with a default skybox.
|
||||||
|
Models can be added to the scene by clicking and dragging an `.obj` into the scene view.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -38,7 +49,7 @@ And more advanced techniques like Phong lighting (ambient + diffuse + specular)
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
| Normal Mapping Disabled | Normal Mapping Enabled |
|
| Normal Mapping Disabled | Normal Mapping Enabled |
|
||||||
|------------------------------------------------------|--------------------------------------------------------|
|
|------------------------------------------------------|--------------------------------------------------------|
|
||||||
| <img src="resources/screenshots/spartan-phong.png"/> | <img src="resources/screenshots/spartan-normals.png"/> |
|
| <img src="resources/screenshots/spartan-phong.png"/> | <img src="resources/screenshots/spartan-normals.png"/> |
|
||||||
|
|
||||||
@ -78,11 +89,60 @@ your system, **version 6.6.0** or later.
|
|||||||
Be sure to take note of the Qt6 installation directory, as we will need it to
|
Be sure to take note of the Qt6 installation directory, as we will need it to
|
||||||
correctly set our `CMAKE_PREFIX_PATH` in the next steps.
|
correctly set our `CMAKE_PREFIX_PATH` in the next steps.
|
||||||
|
|
||||||
|
#### Build Options
|
||||||
|
|
||||||
|
Qtk is composed of three separate components.
|
||||||
|
|
||||||
|
* The shared library libqtk provides classes that leverage QOpenGL functionality
|
||||||
|
while still using lower-level OpenGL APIs to customize the rendering process.
|
||||||
|
Many of these classes can be further expanded, such as [Qtk::Scene](./src/qtk/scene.h).
|
||||||
|
This taget, `qtk_library` in cmake, is always selected to build and install as
|
||||||
|
it is required by all other components in this project.
|
||||||
|
* The Qtk desktop application is built using libqtk within a Qt application.
|
||||||
|
This target, `qtk_gui` in cmake, is optional and can be controlled using the `QTK_GUI` option below.
|
||||||
|
* The GUI for the Qtk desktop application is constructed using a custom set of Qt Designer widget plugins that are also built using libqtk.
|
||||||
|
If `QTK_GUI` is disabled this target (`qtk_plugins`) is optional and can be controlled using the `QTK_PLUGINS` options below.
|
||||||
|
|
||||||
|
|
||||||
|
| Name | Description | Default |
|
||||||
|
|--------------------------|--------------------------------------------------------------|:--------|
|
||||||
|
| QTK_DEBUG | Enable debug mode. | OFF |
|
||||||
|
| QTK_SUBMODULES | Use git submodules to fetch assimp dependency. | OFF |
|
||||||
|
| QTK_EXAMPLE | Build the libqtk example desktop application. | ON |
|
||||||
|
| QTK_CCACHE | Enable CCACHE. | ON |
|
||||||
|
| QTK_ASSIMP_NEW_INTERFACE | Use the assimp::assimp interface. Recommended for WIN / OSX. | OFF |
|
||||||
|
| QTK_PLUGINS* | Install Qtk plugins to Qt Designer. | OFF |
|
||||||
|
| QTK_GUI | Build and install Qtk desktop application. | ON |
|
||||||
|
| QTK_GUI_SCENE | Fetch external 3D model resources for example scene. | OFF |
|
||||||
|
|
||||||
|
*The Qtk plugins are always built if QTK_GUI is enabled. Disabling this option
|
||||||
|
with QTK_GUI set will not mark the plugins for installation if we do
|
||||||
|
`cmake --install build/` without selecting a component. If both QTK_GUI and
|
||||||
|
QTK_PLUGINS are unset, neither will be built.
|
||||||
|
|
||||||
If you are building on **Windows / Mac**, consider setting
|
If you are building on **Windows / Mac**, consider setting
|
||||||
the `-DQTK_ASSIMP_NEW_INTERFACE` cmake build option.
|
the `-DQTK_ASSIMP_NEW_INTERFACE` cmake build option.
|
||||||
|
|
||||||
If the build is configured with all options enabled, we can subsequently install
|
By default, the build will not initialize Assimp as a git submodule and build
|
||||||
individual components as needed with cmake.
|
from source.
|
||||||
|
We can turn this on by setting the `-DQTK_SUBMODULES=ON` flag when running
|
||||||
|
CMake.
|
||||||
|
Building using this option will fetch and build Assimp for us, but builds will
|
||||||
|
take longer as a result.
|
||||||
|
Using `-DQTK_SUBMODULES=ON` supports providing assimp on cross-platform builds (
|
||||||
|
Windows / Mac / Linux) and may be easier to configure.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake -B build-all -DQTK_GUI=ON -DQTK_PLUGINS=ON -DQTK_EXAMPLE=ON -DQTK_SUBMODULES=ON -DCMAKE_PREFIX_PATH=$HOME/Qt/6.6.0/gcc_64
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Qtk Components
|
||||||
|
|
||||||
|
As described in [Build Options](#build-options), Qtk is composed of three separate components.
|
||||||
|
Each component can be individually selected for building or installation.
|
||||||
|
|
||||||
|
For this example we will configure the build with all options enabled.
|
||||||
|
In the separate sections below we can install individual components with cmake.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt update -y && sudo apt install libassimp-dev cmake build-essential git ccache libgl1-mesa-dev libglvnd-dev zlib1g-dev -y
|
sudo apt update -y && sudo apt install libassimp-dev cmake build-essential git ccache libgl1-mesa-dev libglvnd-dev zlib1g-dev -y
|
||||||
@ -94,44 +154,23 @@ cmake -B build-all -DQTK_GUI=ON -DQTK_PLUGINS=ON -DQTK_EXAMPLE=ON -DCMAKE_PREFIX
|
|||||||
cmake --build build-all/
|
cmake --build build-all/
|
||||||
````
|
````
|
||||||
|
|
||||||
By default, the build will not initialize Assimp as a git submodule and build
|
Now that we have all the components fully built, the following sections will
|
||||||
from source.
|
cover installing each component individually.
|
||||||
We can turn this on by setting the `-DQTK_SUBMODULES=ON` flag when running
|
If you want to uninstall a previously installed component, run the following command.
|
||||||
CMake.
|
|
||||||
Building using this option will fetch and build Assimp for us, but builds will
|
|
||||||
take longer as a result.
|
|
||||||
Using `-DQTK_SUBMODULES=ON` supports providing assimp on cross-platform builds (
|
|
||||||
Windows / Mac / Linux) and may be easier
|
|
||||||
to configure.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cmake -B build-all -DQTK_GUI=ON -DQTK_PLUGINS=ON -DQTK_EXAMPLE=ON -DQTK_SUBMODULES=ON -DCMAKE_PREFIX_PATH=$HOME/Qt/6.6.0/gcc_64
|
sudo xargs rm -v < install_manifest.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Qtk GUI
|
##### Qtk Library
|
||||||
|
|
||||||
```bash
|
Qtk provides a simple library for working with lower-level OpenGL to customize the rendering process.
|
||||||
cmake --build build-all/ --target qtk_gui -- -j $(nproc)
|
|
||||||
# Install Qtk desktop application (output removed)
|
|
||||||
# Installation prefix path must be absolute, since Qtk uses Qt deploy tools.
|
|
||||||
cmake --install build-all/ --component qtk_gui --prefix=$(pwd)/install
|
|
||||||
./install/bin/qtk_gui
|
|
||||||
```
|
|
||||||
|
|
||||||
If any errors are encountered loading plugins, we can debug plugin loading by
|
|
||||||
setting the following environment variable -
|
|
||||||
|
|
||||||
```bash
|
|
||||||
QT_DEBUG_PLUGINS=1 ./install/bin/qtk_gui
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Qtk Library
|
|
||||||
|
|
||||||
Qtk provides a simple library for working with QOpenGL.
|
|
||||||
We can install this library on a system path or a custom path and then
|
We can install this library on a system path or a custom path and then
|
||||||
set `CMAKE_PREFIX_PATH` to point to this location when building an application
|
set `CMAKE_PREFIX_PATH` to point to this location when building an application
|
||||||
using libqtk.
|
using libqtk.
|
||||||
|
|
||||||
|
Here we will install to the `/usr/local/` path.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install libqtk only
|
# Install libqtk only
|
||||||
cmake --build build-all/ --target qtk_library -- -j $(nproc)
|
cmake --build build-all/ --target qtk_library -- -j $(nproc)
|
||||||
@ -158,7 +197,26 @@ cmake --install build-all/ --component qtk_library --prefix=/usr/local
|
|||||||
-- Installing: /usr/local/include/qtk/transform3D.h
|
-- Installing: /usr/local/include/qtk/transform3D.h
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Qtk Plugin Collection
|
##### Qtk GUI
|
||||||
|
|
||||||
|
The Qtk desktop application can be built and installed with the following commands.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake --build build-all/ --target qtk_gui -- -j $(nproc)
|
||||||
|
# Install Qtk desktop application (output removed)
|
||||||
|
# Installation prefix path must be absolute, since Qtk uses Qt deploy tools.
|
||||||
|
cmake --install build-all/ --component qtk_gui --prefix=$(pwd)/install
|
||||||
|
./install/bin/qtk_gui
|
||||||
|
```
|
||||||
|
|
||||||
|
If any errors are encountered loading plugins, we can debug plugin loading by
|
||||||
|
setting the following environment variable -
|
||||||
|
|
||||||
|
```bash
|
||||||
|
QT_DEBUG_PLUGINS=1 ./install/bin/qtk_gui
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Qtk Plugin Collection
|
||||||
|
|
||||||
This project defines a collection of widget plugins for use with Qt Designer.
|
This project defines a collection of widget plugins for use with Qt Designer.
|
||||||
These plugins were used to build the interface for the Qtk desktop application.
|
These plugins were used to build the interface for the Qtk desktop application.
|
||||||
@ -184,14 +242,7 @@ cmake --install build-all/ --component qtk_plugins
|
|||||||
-- Up-to-date: /home/shaun/Qt/6.6.0/gcc_64/../../Tools/QtCreator/lib/Qt/plugins/designer/libqtk_collection.so
|
-- Up-to-date: /home/shaun/Qt/6.6.0/gcc_64/../../Tools/QtCreator/lib/Qt/plugins/designer/libqtk_collection.so
|
||||||
```
|
```
|
||||||
|
|
||||||
To uninstall after a previous installation, we can run the following command
|
#### Example libqtk Application
|
||||||
from the root of the repository.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
xargs rm < build/install_manifest.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Qtk Example
|
|
||||||
|
|
||||||
There is a simple example of using libqtk in the [example-app/](example-app)
|
There is a simple example of using libqtk in the [example-app/](example-app)
|
||||||
directory. The example can be built standalone using `find_package` or as a
|
directory. The example can be built standalone using `find_package` or as a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user