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
This commit is contained in:
Shaun Reed 2022-08-01 22:33:33 -04:00
parent c15d064dce
commit ae0e91d36d
6 changed files with 31 additions and 6 deletions

View File

@ -50,7 +50,7 @@ find_package(assimp REQUIRED)
# Mainwidget # Mainwidget
include(GenerateExportHeader) include(GenerateExportHeader)
add_library(main-widget SHARED add_library(main-widget STATIC
src/mainwidget.cpp src/mainwidget.h src/mainwidget.cpp src/mainwidget.h
src/mainwindow.cpp src/mainwindow.h src/mainwindow.ui src/mainwindow.cpp src/mainwindow.h src/mainwindow.ui
src/input.cpp src/input.h src/input.cpp src/input.h
@ -66,9 +66,17 @@ add_library(main-widget SHARED
src/resourcemanager.cpp src/resourcemanager.h src/resourcemanager.cpp src/resourcemanager.h
) )
target_include_directories(main-widget PUBLIC src/) #target_include_directories(main-widget PUBLIC src/)
#if(TARGET assimp)
target_link_libraries(main-widget PRIVATE assimp) target_link_libraries(main-widget PRIVATE assimp)
target_link_libraries(main-widget PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets) #else()
# target_link_libraries(main-widget PRIVATE assimp::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 # Final Application

View File

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

View File

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

View File

@ -7,7 +7,18 @@
##############################################################################*/ ##############################################################################*/
#include "resourcemanager.h" #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 RM::resourcesDir =
std::string(__FILE__).substr(0, std::string(__FILE__).find("src/")) std::string(__FILE__).substr(0, nixPath(__FILE__).find("src/"))
+ "resources/"; + "resources/";

View File

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

View File

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