CMake packaging updates
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
################################################################################
|
||||
## Example client project using qtk ##
|
||||
## ##
|
||||
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
||||
## All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||
################################################################################
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
|
||||
################################################################################
|
||||
# Constants
|
||||
################################################################################
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
add_compile_options(/wd4131 /wd4127)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
# Project
|
||||
################################################################################
|
||||
project(
|
||||
#[[NAME]] QtkClient
|
||||
VERSION 1.0
|
||||
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)
|
||||
|
||||
# Print all QTK variables
|
||||
get_cmake_property(VAR_NAMES VARIABLES)
|
||||
list(FILTER VAR_NAMES INCLUDE REGEX "^QTK_.*$")
|
||||
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
|
||||
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)
|
||||
target_link_libraries(example PUBLIC Qtk::qtk-library)
|
||||
@@ -1,89 +0,0 @@
|
||||
/*##############################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||
## About: Example Qtk scene ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
##############################################################################*/
|
||||
|
||||
#include "examplescene.h"
|
||||
|
||||
using namespace Qtk;
|
||||
|
||||
ExampleScene::ExampleScene() {
|
||||
setSceneName("Example Scene");
|
||||
getCamera().getTransform().setTranslation(-8.0f, 0.0f, 10.0f);
|
||||
getCamera().getTransform().setRotation(-5.0f, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
ExampleScene::~ExampleScene() {}
|
||||
|
||||
void ExampleScene::init() {
|
||||
auto skybox = new Qtk::Skybox("Skybox");
|
||||
setSkybox(skybox);
|
||||
|
||||
auto mesh = addObject(
|
||||
new Qtk::MeshRenderer("rightTriangle", Triangle(QTK_DRAW_ELEMENTS)));
|
||||
mesh->getTransform().setTranslation(-5.0f, 0.0f, -2.0f);
|
||||
|
||||
addObject(new Qtk::MeshRenderer("centerCube", Cube(QTK_DRAW_ELEMENTS)))
|
||||
->getTransform()
|
||||
.setTranslation(-7.0f, 0.0f, -2.0f);
|
||||
|
||||
mesh = addObject(
|
||||
new Qtk::MeshRenderer("leftTriangle", Triangle(QTK_DRAW_ELEMENTS)));
|
||||
mesh->getTransform().setTranslation(-9.0f, 0.0f, -2.0f);
|
||||
mesh->setDrawType(GL_LINE_LOOP);
|
||||
|
||||
mesh = addObject(
|
||||
new Qtk::MeshRenderer("topTriangle", Triangle(QTK_DRAW_ELEMENTS)));
|
||||
mesh->getTransform().setTranslation(-7.0f, 2.0f, -2.0f);
|
||||
mesh->getTransform().scale(0.25f);
|
||||
|
||||
mesh = addObject(
|
||||
new Qtk::MeshRenderer("bottomTriangle", Triangle(QTK_DRAW_ELEMENTS)));
|
||||
mesh->getTransform().setTranslation(-7.0f, -2.0f, -2.0f);
|
||||
mesh->getTransform().scale(0.25f);
|
||||
mesh->setDrawType(GL_LINE_LOOP);
|
||||
mesh->setColor(GREEN);
|
||||
}
|
||||
|
||||
void ExampleScene::draw() {
|
||||
Scene::draw();
|
||||
}
|
||||
|
||||
void ExampleScene::update() {
|
||||
// Pitch forward and roll sideways
|
||||
MeshRenderer::getInstance("leftTriangle")
|
||||
->getTransform()
|
||||
.rotate(0.75f, 1.0f, 0.0f, 0.0f);
|
||||
MeshRenderer::getInstance("rightTriangle")
|
||||
->getTransform()
|
||||
.rotate(0.75f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
static float translateX = 0.025f;
|
||||
float limit = -9.0f; // Origin position.x - 2.0f
|
||||
float posX = MeshRenderer::getInstance("topTriangle")
|
||||
->getTransform()
|
||||
.getTranslation()
|
||||
.x();
|
||||
if(posX < limit || posX > limit + 4.0f) {
|
||||
translateX = -translateX;
|
||||
}
|
||||
MeshRenderer::getInstance("topTriangle")
|
||||
->getTransform()
|
||||
.translate(translateX, 0.0f, 0.0f);
|
||||
MeshRenderer::getInstance("bottomTriangle")
|
||||
->getTransform()
|
||||
.translate(-translateX, 0.0f, 0.0f);
|
||||
MeshRenderer::getInstance("topTriangle")
|
||||
->getTransform()
|
||||
.rotate(0.75f, 0.2f, 0.0f, 0.4f);
|
||||
MeshRenderer::getInstance("bottomTriangle")
|
||||
->getTransform()
|
||||
.rotate(0.75f, 0.0f, 0.2f, 0.4f);
|
||||
|
||||
MeshRenderer::getInstance("centerCube")
|
||||
->getTransform()
|
||||
.rotate(0.75f, 0.2f, 0.4f, 0.6f);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*##############################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||
## About: Example Qtk scene ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
##############################################################################*/
|
||||
|
||||
#ifndef QTK_EXAMPLE_SCENE_H
|
||||
#define QTK_EXAMPLE_SCENE_H
|
||||
|
||||
#include <qtk/scene.h>
|
||||
|
||||
class ExampleScene : public Qtk::Scene {
|
||||
public:
|
||||
ExampleScene();
|
||||
|
||||
~ExampleScene();
|
||||
|
||||
void init() override;
|
||||
|
||||
void draw() override;
|
||||
|
||||
void update() override;
|
||||
};
|
||||
|
||||
#endif // QTK_EXAMPLE_SCENE_H
|
||||
@@ -1,52 +0,0 @@
|
||||
/*##############################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||
## About: Example Qtk widget ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
##############################################################################*/
|
||||
|
||||
#include <qtk/scene.h>
|
||||
|
||||
#include "examplewidget.h"
|
||||
|
||||
ExampleWidget::ExampleWidget(QWidget * parent) :
|
||||
QOpenGLWidget(parent), mScene(new ExampleScene) {
|
||||
QSurfaceFormat format;
|
||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
format.setVersion(4, 6);
|
||||
format.setSamples(4);
|
||||
format.setDepthBufferSize(16);
|
||||
setFormat(format);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
}
|
||||
|
||||
void ExampleWidget::initializeGL() {
|
||||
initializeOpenGLFunctions();
|
||||
connect(this, SIGNAL(frameSwapped()), this, SLOT(update()));
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDepthRange(0.1f, 1.0f);
|
||||
glClearDepth(1.0f);
|
||||
glClearColor(0.0f, 0.25f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void ExampleWidget::resizeGL(int width, int height) {
|
||||
Qtk::Scene::getProjectionMatrix().setToIdentity();
|
||||
Qtk::Scene::getProjectionMatrix().perspective(
|
||||
45.0f, float(width) / float(height), 0.1f, 1000.0f);
|
||||
}
|
||||
|
||||
void ExampleWidget::paintGL() {
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
mScene->draw();
|
||||
}
|
||||
|
||||
void ExampleWidget::update() {
|
||||
mScene->update();
|
||||
QWidget::update();
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*##############################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||
## About: Example Qtk widget ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
##############################################################################*/
|
||||
|
||||
#ifndef QTKCLIENT_EXAMPLEWIDGET_H
|
||||
#define QTKCLIENT_EXAMPLEWIDGET_H
|
||||
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
#include "examplescene.h"
|
||||
|
||||
class ExampleWidget : public QOpenGLWidget, protected QOpenGLFunctions {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
explicit ExampleWidget(QWidget * parent = nullptr);
|
||||
|
||||
~ExampleWidget() = default;
|
||||
|
||||
void initializeGL() override;
|
||||
|
||||
void resizeGL(int width, int height) override;
|
||||
|
||||
void paintGL() override;
|
||||
|
||||
protected slots:
|
||||
void update();
|
||||
|
||||
private:
|
||||
ExampleScene * mScene;
|
||||
};
|
||||
|
||||
#endif // QTKCLIENT_EXAMPLEWIDGET_H
|
||||
@@ -1,22 +0,0 @@
|
||||
/*##############################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||
## About: Example Qt desktop application using Qtk ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
##############################################################################*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "examplewidget.h"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
auto window = new QMainWindow;
|
||||
window->setCentralWidget(new ExampleWidget);
|
||||
window->show();
|
||||
|
||||
app.exec();
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#ifndef QTK_MODELMESH_H
|
||||
#define QTK_MODELMESH_H
|
||||
|
||||
// QTK
|
||||
#include <QOpenGLFunctions>
|
||||
|
||||
#include "object.h"
|
||||
#include "transform3D.h"
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user