Compare commits

..

5 Commits

Author SHA1 Message Date
Shaun Reed f78e41dc76 Work on texture class
+ Set up TextureManager class to handle static texture map
2022-08-06 15:21:20 -04:00
Shaun Reed 26200d39a2 Work on Texture class 2022-08-06 15:21:20 -04:00
Shaun Reed 132491b28d Refactor 2022-08-06 15:21:18 -04:00
Shaun Reed 52521dc331 Add MacOS CI
+ (@-OgreTransporter) Merge patches from #4
2022-08-06 15:09:59 -04:00
Shaun Reed 5452520324 Windows updates (@OgreTransporter)
+ Fix resource path on Windows
+ Fix missing OpenGL functions on Windows
+ Create static library
+ Fix CMake for newer assimp versions
+ Closes #2
2022-08-01 23:26:13 -04:00
7 changed files with 70 additions and 29 deletions

View File

@ -6,21 +6,40 @@ on:
workflow_dispatch:
jobs:
Ubuntu:
runs-on: ubuntu-latest
Build-Qtk:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
CMAKE_PARAMS: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/6.3.1/gcc_64/
- os: macos-latest
CMAKE_PARAMS: -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/6.3.1/gcc_64/ -DASSIMP_NEW_INTERFACE=on
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: '6.2.3'
version: '6.3.1'
- name: Install Assimp
- name: Install Assimp Linux
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
sudo apt install libassimp-dev -y
- name: Install Assimp MacOS
if: matrix.os == 'macos-latest'
shell: bash
run: |
brew install assimp
- name: Build Qtk
shell: bash
run: |
mkdir build && cd build
cmake .. -DCMAKE_PREFIX_PATH=/home/runner/work/qtk/Qt/6.2.3/gcc_64/ && cmake --build .
cmake .. ${{ matrix.CMAKE_PARAMS }} && cmake --build .

View File

@ -27,27 +27,25 @@ if (NOT Qt6_FOUND)
message(FATAL_ERROR "Specify path to Qt6 with `cmake -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x.x/gcc_64 -S /path/to/qtk -B /path/to/qtk/build && cmake --build /path/to/qtk/build -j $(nprocs)`")
endif()
# Add our Qt resources.qrc file to our application
set(SOURCES app/main.cpp)
qt6_add_big_resources(SOURCES resources.qrc)
add_executable(qtk ${SOURCES})
################################################################################
# External Libraries
################################################################################
# https://github.com/assimp/assimp/commit/6ac8279977c3a54118551e549d77329497116f66
find_package(assimp REQUIRED)
################################################################################
# Custom Libraries
################################################################################
# Mainwidget
option(ASSIMP_NEW_INTERFACE "Use assimp::assimp as target instead of assimp" OFF)
include(GenerateExportHeader)
add_library(main-widget SHARED
################################################################################
# Final Application
################################################################################
# Add our Qt resources.qrc file to our application
set(SOURCES app/main.cpp)
qt6_add_big_resources(SOURCES resources.qrc)
qt_add_executable(qtk ${SOURCES})
set(SOURCES
src/mainwidget.cpp src/mainwidget.h
src/mainwindow.cpp src/mainwindow.h src/mainwindow.ui
src/input.cpp src/input.h
@ -62,21 +60,28 @@ add_library(main-widget SHARED
src/scene.cpp src/scene.h
src/resourcemanager.cpp src/resourcemanager.h
)
qt_add_library(main-widget STATIC ${SOURCES})
target_include_directories(main-widget PUBLIC src/)
target_link_libraries(main-widget PRIVATE assimp)
target_link_libraries(main-widget PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
if(ASSIMP_NEW_INTERFACE)
target_link_libraries(main-widget PRIVATE assimp::assimp)
else()
target_link_libraries(main-widget PRIVATE assimp)
endif()
target_link_libraries(main-widget PUBLIC Qt6::OpenGLWidgets)
if(WIN32)
find_package(OpenGL REQUIRED)
target_link_libraries(main-widget PUBLIC OpenGL::GL)
endif()
################################################################################
# Final Application
################################################################################
# Link qtk executable to main main-widget library
target_link_libraries(qtk PUBLIC main-widget)
# Link qtk executable to main main-widget library
set_target_properties(qtk PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
generate_export_header(main-widget)

View File

@ -31,6 +31,8 @@ Model * Model::getInstance(const char * name)
void ModelMesh::initMesh(const char * vert, const char * frag)
{
initializeOpenGLFunctions();
// Create VAO, VBO, EBO
mVAO->create();
mVBO->create();

View File

@ -16,6 +16,7 @@
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLFunctions>
// Assimp
#include <assimp/Importer.hpp>
@ -44,7 +45,7 @@ struct ModelTexture {
class Model;
class ModelMesh {
class ModelMesh : protected QOpenGLFunctions {
public:
friend Model;
typedef std::vector<ModelVertex> Vertices;

View File

@ -7,7 +7,18 @@
##############################################################################*/
#include "resourcemanager.h"
#include <algorithm>
#include <string>
#include <QtGlobal>
static std::string nixPath(std::string path)
{
#ifdef Q_OS_WINDOWS
std::replace(path.begin(), path.end(), '\\', '/');
#endif
return path;
}
std::string RM::resourcesDir =
std::string(__FILE__).substr(0, std::string(__FILE__).find("src/"))
std::string(__FILE__).substr(0, nixPath(__FILE__).find("src/"))
+ "resources/";

View File

@ -69,6 +69,8 @@ void Skybox::draw()
void Skybox::init()
{
initializeOpenGLFunctions();
// Set up shader program
mProgram.create();
mProgram.addShaderFromSourceFile(QOpenGLShader::Vertex, ":/skybox.vert");

View File

@ -13,12 +13,13 @@
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLFunctions>
#include <camera3d.h>
#include <mesh.h>
class Skybox {
class Skybox : protected QOpenGLFunctions {
public:
// Delegate this constructor to use default skybox images
// + This allows creating a skybox with no arguments ( auto s = new Skybox; )