CMake packaging updates

This commit is contained in:
Shaun Reed 2023-01-14 16:33:06 -05:00
parent 4bc0ae22c6
commit cf433ad7fc
18 changed files with 243 additions and 119 deletions

View File

@ -37,7 +37,7 @@ jobs:
- name: Build Qtk
shell: bash
run: |
cmake -S . -B build/ ${{ matrix.cmake }} && cmake --build build/ \
cmake -S . -B build/ ${{ matrix.cmake }} -DQTK_UPDATE_SUBMODULES=ON && cmake --build build/ \
--target qtk-main
Build-Qtk-Assimp-Targets:
@ -47,9 +47,9 @@ jobs:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.3.1/gcc_64/" -DQTK_UPDATE_SUBMODULES=OFF
cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.3.1/gcc_64/"
- os: macos-latest
cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.3.1/gcc_64/" -DASSIMP_NEW_INTERFACE=ON -DQTK_UPDATE_SUBMODULES=OFF
cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.3.1/gcc_64/" -DASSIMP_NEW_INTERFACE=ON
runs-on: ${{ matrix.os }}
steps:

View File

@ -22,6 +22,7 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/wd4131 /wd4127)
@ -32,8 +33,8 @@ endif()
################################################################################
project(
#[[NAME]] Qtk
VERSION 1.0
DESCRIPTION "An example project using QT and OpenGL"
VERSION 0.2
DESCRIPTION "Qt OpenGL library and desktop application."
LANGUAGES CXX C
)
@ -41,16 +42,21 @@ project(
# Options
################################################################################
option(QTK_DEBUG "Enable debugger" ON)
option(QTK_UPDATE_SUBMODULES "Update external project (assimp) submodule" OFF)
option(QTK_SHARED "Build shared libraries" ON)
option(QTK_BUILD_GUI "Build the Qtk desktop application" ON)
# Options for bringing your own assimp installation; Otherwise not needed
option(QTK_BUILD_EXAMPLE "Build the Qtk example desktop application" OFF)
option(QTK_UPDATE_SUBMODULES "Update external project (assimp) submodule" OFF)
# Install Qtk for use within Qt Creator projects only, instead of system-wide.
option(QTK_PREFIX_QTCREATOR "Install Qtk to Qt Creator." OFF)
# Option for bringing your own assimp installation; Otherwise not needed
# + If assimp is available system-wide we can just set QTK_UPDATE_SUBMODULES OFF
option(ASSIMP_NEW_INTERFACE "Use the assimp::assimp interface (WIN / OSX)" OFF)
message(STATUS "[Qtk] ASSIMP_NEW_INTERFACE=${ASSIMP_NEW_INTERFACE}")
option(
QTK_ASSIMP_NEW_INTERFACE
"Use the assimp::assimp interface (WIN / OSX)"
OFF
)
set(QT_DIR "$ENV{HOME}/Code/Clones/Qt/" CACHE PATH "Path to Qt6")
# Qt Designer will look in different locations if WIN / Unix.
# These paths are for using Qt Designer integrated within Qt Creator.
# Standalone Qt Designer may use different paths.
@ -65,12 +71,17 @@ endif()
# This should be set to your Qt6 installation directory.
set(QT_INSTALL_DIR "${QT_DIR}/6.3.1/gcc_64/" CACHE PATH "Path to Qt6 install")
# For CLion builds, point CMAKE_PREFIX_PATH to Qt6 install directory
# + QtCreator will handle this for you if that is used instead
# Point CMAKE_PREFIX_PATH to Qt6 install directory
# If Qtk is built within Qt Creator this is not required.
list(APPEND CMAKE_PREFIX_PATH "${QT_INSTALL_DIR}")
set(QTK_PLUGIN_LIBRARY_DIR "${QT_PLUGIN_LIBRARY_DIR}")
set(QTK_PLUGIN_INSTALL_DIR "${QT_PLUGIN_INSTALL_DIR}")
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install")
if (QTK_PREFIX_QTCREATOR)
# TODO: This might be a bit strange and needs more testing.
set(CMAKE_INSTALL_PREFIX "${QT_INSTALL_DIR}")
endif()
message(STATUS "[Qtk] CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
set(QTK_RESOURCES "${CMAKE_SOURCE_DIR}/resources")
@ -149,5 +160,4 @@ if(WIN32)
file(APPEND ${VSUSER_FILE} " </PropertyGroup>\n")
file(APPEND ${VSUSER_FILE} "</Project>\n")
endif()
endif()

178
README.md
View File

@ -2,54 +2,35 @@
[![All Builds](https://github.com/shaunrd0/qtk/actions/workflows/all-builds.yml/badge.svg)](https://github.com/shaunrd0/qtk/actions/workflows/all-builds.yml)
[![Linting](https://github.com/shaunrd0/qtk/actions/workflows/linting.yml/badge.svg)](https://github.com/shaunrd0/qtk/actions/workflows/linting.yml)
Model loader using [Assimp](https://assimp.org/) within a Qt widget application.
Qtk is a Qt OpenGL graphics library created primarily for my own learning
purposes. The library wraps some QOpenGL functionality in convenience classes
that allow rendering geometry in 2D and 3D using custom GLSL shader programs.
You can import your own models within `app/examplescene.cpp`, inside the
`ExampleScene::init()` function. Rotations and translations
happen in `ExampleScene::update()`.
The long-term goal for this project is to create a tool that I can use to
practice shader coding or graphics programming techniques. In doing this I hope
to also learn more about the Qt UI framework, and the CMake build system.
Key features that are planned:
* Runtime loading of `.obj` or similar 3D models.
* Drag-and-drop interaction for adding objects to the scene.
* Runtime reloading of modified GLSL shaders attached to objects within scenes.
* Multiple views of a scene at one time.
* Camera control modes such as panning, orbiting, or following objects.
* Save / load for scene data. The current inheritance model is temporary.
* Basic text editor for quickly modifying shaders attached to objects.
* Shader / object properties panel to modify related settings.
The Qtk desktop application provides a model loader using [Assimp](https://assimp.org/) within a Qt widget application.
For examples of using the Qtk API, see the `example-app` project in the root of
this repository.
To get textures loading on models look into [material files](http://www.paulbourke.net/dataformats/mtl/)
and see some examples in the `resources/models/` directory.
The syntax for adding shapes and models is seen in the example below.
This would result in a scene with a red cube and a miniature spartan model placed on top.
```C++
// From: qtk/app/examplescene.cpp
void ExampleScene::init() {
// Add a skybox to the scene using default cube map images and settings.
setSkybox(new Qtk::Skybox("Skybox"));
/* Create a red cube with a mini master chief on top. */
auto myCube = new MeshRenderer("My cube", Cube(Qtk::QTK_DRAW_ELEMENTS));
myCube->setColor(RED);
mMeshes.push_back(myCube);
auto mySpartan = new Model("My spartan", ":/models/spartan/spartan.obj");
mySpartan->getTransform().setTranslation(0.0f, 0.5f, 0.0f);
mySpartan->getTransform().setScale(0.5f);
mModels.push_back(mySpartan);
}
```
If we want to make our spartan spin, we need to apply rotation in `update`
```C++
// From: qtk/app/examplescene.cpp
void ExampleScene::update() {
auto mySpartan = Model::getInstance("My spartan");
mySpartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
auto myCube = MeshRenderer::getInstance("My cube");
myCube->getTransform().rotate(-0.75f, 0.0f, 1.0f, 0.0f);
}
```
### Source Builds
Builds are configured for CLion or [Qt Creator](https://github.com/qt-creator/qt-creator).
Qtk was developed and tested using CLion and [Qt Creator](https://github.com/qt-creator/qt-creator).
Simply open the root `CMakeLists.txt` with either of these editors and configurations will be loaded.
This project has been ported to Qt6, which is not yet available in Ubuntu apt repositories.
@ -61,32 +42,74 @@ Be sure to take note of the Qt6 installation directory, as we will need it to co
Once Qt6 is installed, to build and run `qtk` on Ubuntu -
```bash
sudo apt update -y && sudo apt install libassimp-dev cmake build-essential git
git clone https://gitlab.com/shaunrd0/qtk
git clone https://github.com/shaunrd0/qtk
cmake -DCMAKE_PREFIX_PATH=$HOME/Qt/6.3.1/gcc_64 -S qtk/ -B qtk/build/ && cmake --build qtk/build/ -j $(nproc --ignore=2) --target qtk-main
./qtk/build/qtk-main
```
By default, the build will initialize Assimp as a git submodule and build from source.
We can turn this off by setting the `-DQTK_UPDATE_SUBMODULES=OFF` flag when running CMake.
This will greatly increase build speed, but we will need to make sure Assimp is available either system-wide or using a custom `CMAKE_PREFIX_PATH`.
By default, the build will not initialize Assimp as a git submodule and build from source.
We can turn this on by setting the `-DQTK_UPDATE_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_UPDATE_SUBMODULES=ON` supports providing assimp on cross-platform builds (Windows / Mac / Linux) and may be easier to configure.
```bash
sudo apt update -y && sudo apt install freeglut3-dev libassimp-dev cmake build-essential git
git clone https://gitlab.com/shaunrd0/qtk
cmake -DQTK_UPDATE_SUBMODULES=OFF -DCMAKE_PREFIX_PATH=$HOME/Qt/6.3.1/gcc_64 -S qtk/ -B qtk/build/ && cmake --build qtk/build/ -j $(nproc --ignore=2) --target qtk-main
# We can also provide a path to assimp -
#cmake -DQTK_UPDATE_SUBMODULES=OFF -DCMAKE_PREFIX_PATH=$HOME/Qt/6.3.1/gcc_64;/path/to/assimp/ -S qtk/ -B qtk/build/ && cmake --build qtk/build/ -j $(nproc --ignore=2) --target qtk-main
cmake -DQTK_UPDATE_SUBMODULES=ON -DCMAKE_PREFIX_PATH=$HOME/Qt/6.3.1/gcc_64 -S qtk/ -B qtk/build/ && cmake --build qtk/build/ -j $(nproc --ignore=2) --target qtk-main
./qtk/build/qtk-main
```
If any errors are encountered loading plugins, we can debug plugin loading by setting the following environment variable -
```bash
QT_DEBUG_PLUGINS=1 ./qtk-main
```
#### Windows / MacOS
If you are building on **Windows / Mac** and bringing your own installation of Assimp, consider setting the `-DASSIMP_NEW_INTERFACE` build flag.
```bash
cmake -DASSIMP_NEW_INTERFACE=ON -DQTK_UPDATE_SUBMODULES=OFF -DCMAKE_PREFIX_PATH=$HOME/Qt/6.3.1/gcc_64;/path/to/assimp/ -S qtk/ -B qtk/build/ && cmake --build qtk/build/ -j $(nproc --ignore=2) --target qtk-main
cmake -S qtk/ -B qtk/build/ -DASSIMP_NEW_INTERFACE=ON -DCMAKE_PREFIX_PATH=$HOME/Qt/6.3.1/gcc_64;/path/to/assimp/ && cmake --build qtk/build/ -j $(nproc --ignore=2) --target qtk-main
```
### Qtk Plugin Collection
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.
Qt Designer will list Qtk widgets in the side panel when editing a UI file within the designer.
Qtk widgets will also render and behave correctly within the UI preview in designer.
The widgets in the Qtk collection were created by implementing the [QDesignerCustomWidgetInterface](https://doc.qt.io/qt-6/qdesignercustomwidgetinterface.html#details) and [QDesignerCustomWidgetCollectionInterface](https://doc.qt.io/qt-6/qdesignercustomwidgetcollectioninterface.html) interfaces.
To build and install the Qtk plugin collection -
```bash
cmake -S /path/to/qtk -B /path/to/qtk/build -DCMAKE_PREFIX_PATH=$HOME/Qt/6.3.1/gcc_64
cmake --build /path/to/qtk/build --target qtk-collection
cmake --install /path/to/qtk/build
```
To uninstall after a previous installation, we can run the following command from the root of the repository.
```bash
xargs rm < build/install_manifest.txt
```
### Controls
You can fly around the scene if you hold the right mouse button and use WASD.
If you see a small triangle floating by a model it represents the light source
that is being used for the shader rendering the model. These appear on models
using phong, specular, and diffuse lighting techniques.
![](resources/screenshot.png)
Spartan with no normals -
![](resources/spartan-specular.png)
Spartan with normals -
![](resources/spartan-normals.png)
#### Development
@ -101,7 +124,7 @@ cmake --build build -j $(nproc --ignore=2)
sudo cmake --build build -j $(nproc --ignore=2) --target install
```
If this version is any earlier than `15.0.0`, running `clang-format` will fail because this project uses configuration options made available since `15.0.0`.
If the `clang-format` version is any earlier than `15.0.0`, running `clang-format` will fail because this project uses configuration options made available since `15.0.0`.
```bash
clang-format --version
@ -146,43 +169,40 @@ changed files:
src/transform3D.h
```
### Controls
##### Packaging
You can fly around the scene if you hold the right mouse button and use WASD.
If you see a small triangle floating by a model it represents the light source
that is being used for the shader rendering the model. These appear on models
using phong, specular, and diffuse lighting techniques.
Packaging for Qtk is in early development.
This section documents how to package Qtk, but only source builds have been verified on Windows / Mac / Linux.
For this reason, it is recommended to install Qtk by strictly building from source at this time.
![](resources/screenshot.png)
Below are the steps to package a Qtk release.
Spartan with no normals -
```bash
cd /path/to/qtk && cmake -B build
# Package Qtk
cmake --build build --target package
# Package Qtk including source files
cmake --build build --target package_source
```
![](resources/spartan-specular.png)
Alternatively, we can use `cpack` directly -
```bash
cd /path/to/qtk && cmake -B build
# Generate all install packages
cpack -C Release
# Generate a specific install package (ZIP)
cpack -C Release -G ZIP
# Generate a specific install package (DEB)
cpack -C Release -G DEB
```
Spartan with normals -
##### Resources
![](resources/spartan-normals.png)
Some useful links and resources that I have found while working on this project.
[Qt Designer UI file format](https://doc.qt.io/qt-6/designer-ui-file-format.html)
### QtkWidget in Qt Creator
We can add more QtkWidgets to view and render the scene from multiple perspectives.
There is still some work to be done here, so there isn't a builtin way to add an additional view within the application.
![](resources/qtk-views.png)
After building Qtk, we can drag and drop an `OpenGL Widget` onto the `mainwindow.ui`.
Then right-click the new OpenGLWidget and `Promote To->QtkWidget` to add a second view.
![](resources/qtk-views-setup.png)
If we demote or delete all widgets in `mainwindow.ui` and rebuild the project, Qt Creator will drop `QtkWidget` from the list of possible promoted widgets.
Add an `OpenGL Widget` to the UI, right-click it and navigate to `Promote Widget...` and enter the information below.
![](resources/qtk-reference.png)
After you fill out the `New Promoted Class` form, click `Add` *and*`Promote`, then rebuild.
After following these steps Qt Creator will list `QtkWidget` as an option to promote `OpenGL Widgets` again.
[QtPlugin Import / Export plugins](https://doc.qt.io/qt-6/qtplugin.html)
## Model Artists

View File

@ -3,4 +3,7 @@
include("${CMAKE_CURRENT_LIST_DIR}/QtkTargets.cmake")
set_and_check(QTK_EXECUTABLE "${PACKAGE_PREFIX_DIR}/bin/qtk-main")
set_and_check(QTK_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
set_and_check(QTK_LIBRARIES "${PACKAGE_PREFIX_DIR}/lib")
check_required_components(Qtk)

View File

@ -15,44 +15,52 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/wd4131 /wd4127)
endif()
# If you did not install Qtk on a system path, point cmake to installation.
set(QTK_PATH /usr/local CACHE PATH "Path to installation of Qtk")
# If you did not install Qt6 on a system path, point cmake to installation.
set(
QT_INSTALL_DIR
"/home/kapper/Code/Clones/Qt/6.3.1/gcc_64/"
CACHE PATH "Path to Qt6 install"
)
################################################################################
# Project
################################################################################
project(
#[[NAME]] QtkClient
VERSION 1.0
VERSION 0.1
DESCRIPTION "An example project using Qtk"
LANGUAGES CXX C
)
# If you did not install Qtk on a system path, point cmake to installation.
#list(APPEND CMAKE_PREFIX_PATH /home/shaun/Code/qtk/install)
find_package(Qtk 1.0 REQUIRED)
list(APPEND CMAKE_PREFIX_PATH "${QTK_PATH}")
list(APPEND CMAKE_PREFIX_PATH "${QT_INSTALL_DIR}")
find_package(Qtk 0.2 REQUIRED)
# Print all QTK variables
get_cmake_property(VAR_NAMES VARIABLES)
list(FILTER VAR_NAMES INCLUDE REGEX "^QTK_.*$")
list(FILTER VAR_NAMES INCLUDE REGEX "^Q[tT][kK]_.*$")
list(SORT VAR_NAMES)
foreach(VAR_NAME ${VAR_NAMES})
message(STATUS "[Qtk] ${VAR_NAME}=${${VAR_NAME}}")
endforeach()
set(QT_INSTALL_DIR "/home/kapper/Code/Clones/Qt/6.3.1/gcc_64/" CACHE PATH "Path to Qt6 install")
list(APPEND CMAKE_PREFIX_PATH "${QT_INSTALL_DIR}")
find_package(Qt6 COMPONENTS Core Widgets OpenGLWidgets REQUIRED)
set(EXAMPLE_SOURCES
set(
EXAMPLE_SOURCES
main.cpp
examplescene.cpp examplescene.h
examplewidget.cpp examplewidget.h
)
qt_add_resources(EXAMPLE_SOURCES ../../resources/resources.qrc)
add_executable(example ${EXAMPLE_SOURCES})
target_link_libraries(example PUBLIC Qt6::Widgets Qt6::OpenGLWidgets Qt6::Core)

68
example-app/README.md Normal file
View File

@ -0,0 +1,68 @@
This is an example application that is using the Qtk API to create custom Qt
OpenGL widgets. This is very similar to `QtkWidget` in the Qtk desktop
application, but could be modified for different uses if needed.
You can import your own models within `examplescene.cpp`, inside the
`ExampleScene::init()` function. Rotations and translations
are applied in `ExampleScene::update()`.
The syntax for adding shapes and models is seen in the example below.
This would result in a scene with a red cube and a miniature spartan model placed on top.
```C++
void ExampleScene::init() {
// Add a skybox to the scene using default cube map images and settings.
setSkybox(new Qtk::Skybox("Skybox"));
/* Create a red cube with a mini master chief on top. */
auto myCube = new MeshRenderer("My cube", Cube(Qtk::QTK_DRAW_ELEMENTS));
myCube->setColor(RED);
mMeshes.push_back(myCube);
auto mySpartan = new Model("My spartan", "/path/to/spartan/spartan.obj");
mySpartan->getTransform().setTranslation(0.0f, 0.5f, 0.0f);
mySpartan->getTransform().setScale(0.5f);
mModels.push_back(mySpartan);
}
```
If we want to make our spartan spin, we need to apply rotation in `update`
```C++
void ExampleScene::update() {
auto mySpartan = Model::getInstance("My spartan");
mySpartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
auto myCube = MeshRenderer::getInstance("My cube");
myCube->getTransform().rotate(-0.75f, 0.0f, 1.0f, 0.0f);
}
```
Other examples can be found in the source files for this example project.
## Build Instructions
Currently, this application requires manual build and installation of Qtk.
In the future, once a release is published, I will be able to use `FetchContent`
or similar cmake functionality to remove this requirement.
For Qtk build instructions, see the README in the root of this repository.
```bash
cmake -S /path/to/qtk/example-app/ -B /path/to/qtk/example-app/build
cmake --build /path/to/qtk/example-app/build
```
If Qtk was not installed system-wide, we can set `QTK_PATH` to point to the custom installation directory.
```bash
cmake -S /path/to/qtk/example-app/ -B /path/to/qtk/example-app/build -DQTK_PATH=/path/to/qtk/install/
cmake --build /path/to/qtk/example-app/build
```
After this, we can run the example application -
```bash
./path/to/qtk/example-app/build/bin/example
```

View File

@ -22,11 +22,16 @@ void ExampleScene::init() {
auto skybox = new Qtk::Skybox("Skybox");
setSkybox(skybox);
auto spartan = new Model(
"spartan", "/home/kapper/Code/qtk/resources/models/spartan/spartan.obj");
addObject(spartan);
auto mesh = addObject(
new Qtk::MeshRenderer("rightTriangle", Triangle(QTK_DRAW_ELEMENTS)));
new Qtk::MeshRenderer("rightTriangle", Triangle(QTK_DRAW_ARRAYS)));
mesh->getTransform().setTranslation(-5.0f, 0.0f, -2.0f);
addObject(new Qtk::MeshRenderer("centerCube", Cube(QTK_DRAW_ELEMENTS)))
// QTK_DRAW_ARRAYS is the default for generic shapes in qtk/shape.h
addObject(new Qtk::MeshRenderer("centerCube", Cube(QTK_DRAW_ARRAYS)))
->getTransform()
.setTranslation(-7.0f, 0.0f, -2.0f);

View File

@ -28,8 +28,6 @@ install(
"${CMAKE_CURRENT_BINARY_DIR}/QtkConfigVersion.cmake"
DESTINATION lib/cmake/Qtk
)
# Install export
install(
EXPORT qtk-export
FILE QtkTargets.cmake
@ -40,4 +38,7 @@ install(
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VENDOR "Shaun Reed")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics library.")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/shaunrd0/qtk")
include(CPack)

View File

@ -22,7 +22,7 @@ set(
toolbox.h
treeview.h
)
qt_add_library(qtk-plugin-library SHARED)
qt_add_library(qtk-plugin-library STATIC)
target_sources(
qtk-plugin-library PRIVATE
"${QTK_PLUGIN_LIBRARY_SOURCES}"
@ -90,10 +90,10 @@ target_link_libraries(qtk-main PRIVATE qtk-plugin-library)
set_target_properties(
qtk-main PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
install(

View File

@ -11,6 +11,8 @@
#include "qtkmainwindow.h"
int main(int argc, char * argv[]) {
Q_INIT_RESOURCE(resources);
QApplication a(argc, argv);
auto window = MainWindow::getMainWindow();

View File

@ -52,15 +52,12 @@ target_sources(
if(QTK_DEBUG)
target_compile_definitions(qtk-library PUBLIC QTK_DEBUG)
endif()
if(QTK_SHARED)
target_compile_definitions(qtk-library PUBLIC QTK_SHARED)
endif()
set_target_properties(
qtk-library PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
VERSION ${PROJECT_VERSION}
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
VERSION ${PROJECT_VERSION}
)
target_link_libraries(

View File

@ -9,7 +9,8 @@
#ifndef QTK_MODELMESH_H
#define QTK_MODELMESH_H
// QTK
#include <QOpenGLFunctions>
#include "object.h"
#include "transform3D.h"

View File

@ -48,6 +48,7 @@ namespace Qtk {
explicit Object(const char * name, Type type) :
mName(name), mVBO(QOpenGLBuffer::VertexBuffer), mBound(false),
mType(type) {
initResources();
setObjectName(name);
}
@ -55,6 +56,7 @@ namespace Qtk {
Object(const char * name, const ShapeBase & shape, Type type) :
mName(name), mVBO(QOpenGLBuffer::VertexBuffer), mShape(shape),
mBound(false), mType(type) {
initResources();
setObjectName(name);
}

View File

@ -22,6 +22,13 @@
#define QTKAPI
#endif
/**
* Initialize Qt resources required by the Qtk library.
* This cannot be defined within any namespace, but can be called by ctors.
* See object.h for example.
*/
inline void initResources() { Q_INIT_RESOURCE(resources); }
namespace Qtk {
/**
* Flag to set context for debug messages.