From 2d598de5ad5898b5b21a30e75b4c27a3006cc6d0 Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <Joseph.WaltonRivers@falmouth.ac.uk> Date: Tue, 19 Apr 2022 15:51:31 +0100 Subject: [PATCH] it compiles on windows now, but crashes on load --- CMakeLists.txt | 1 + conanfile.txt | 7 ++++--- fggl/data/procedural.cpp | 5 ++++- fggl/gfx/ogl/CMakeLists.txt | 14 +++++++------- fggl/gfx/ogl/renderer.cpp | 2 +- fggl/gfx/ogl/shader.cpp | 5 +++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af9ebf9..deb1a82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") TLS_VERIFY ON) endif() +include(${CMAKE_BINARY_DIR}/conan_paths.cmake) include(${CMAKE_BINARY_DIR}/conan.cmake) conan_cmake_run(CONANFILE conanfile.txt # or relative build/conanfile.txt BASIC_SETUP CMAKE_TARGETS diff --git a/conanfile.txt b/conanfile.txt index 90e6e04..20cf10f 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -6,9 +6,10 @@ glm/0.9.9.8 spdlog/1.10.0 [generators] -CMakeDeps -CMakeToolchain +cmake_find_package +cmake_paths [options] glad:gl_profile=core -glad:gl_version=4.5 \ No newline at end of file +glad:gl_version=4.5 +glad:extensions="GL_ARB_get_program_binary" \ No newline at end of file diff --git a/fggl/data/procedural.cpp b/fggl/data/procedural.cpp index a89ecbb..ab4649b 100644 --- a/fggl/data/procedural.cpp +++ b/fggl/data/procedural.cpp @@ -158,7 +158,8 @@ fggl::data::Mesh fggl::data::make_quad_xz() { constexpr float HALF_PI = M_PI / 2.0F; static void populateMesh(fggl::data::Mesh& mesh, const fggl::math::mat4 transform, const int nIdx, const fggl::math::vec3* pos, const int* idx ) { - int colIdx[nIdx]; + + int* colIdx = new int[nIdx]; // generate mesh for (int i=0; i<nIdx; i++) { @@ -173,6 +174,8 @@ static void populateMesh(fggl::data::Mesh& mesh, const fggl::math::mat4 transfor } computeNormalsDirect( mesh, colIdx, nIdx ); + + delete[] colIdx; } diff --git a/fggl/gfx/ogl/CMakeLists.txt b/fggl/gfx/ogl/CMakeLists.txt index f065ca1..37b3290 100644 --- a/fggl/gfx/ogl/CMakeLists.txt +++ b/fggl/gfx/ogl/CMakeLists.txt @@ -8,19 +8,19 @@ target_sources(fggl types.cpp ) +# Math +# probably shouldn't be graphics dependent... +find_package( glm REQUIRED ) +target_link_libraries(${PROJECT_NAME} PUBLIC glm::glm) + # OpenGL Backend find_package( OpenGL REQUIRED ) include_directories( ${OPENGL_INCLUDE_DIR} ) -target_link_libraries(fggl PUBLIC opengl::opengl) +target_link_libraries(${PROJECT_NAME} PUBLIC opengl::opengl) # GLEW find_package( glad ) -target_link_libraries(${PROJECT_NAME} PRIVATE glad::glad) - -# Math -# probably shouldn't be graphics dependent... -find_package( glm ) -target_link_libraries(${PROJECT_NAME} PRIVATE glm::glm) +target_link_libraries(${PROJECT_NAME} PUBLIC glad::glad) # FreeType #find_package(Freetype REQUIRED ) diff --git a/fggl/gfx/ogl/renderer.cpp b/fggl/gfx/ogl/renderer.cpp index 04c73fc..fea7295 100644 --- a/fggl/gfx/ogl/renderer.cpp +++ b/fggl/gfx/ogl/renderer.cpp @@ -145,7 +145,7 @@ namespace fggl::gfx { OpenGL4Backend::OpenGL4Backend(const Window &owner) : fggl::gfx::Graphics() { // initialise GLEW, or fail // FIXME this binds the graphics stack to GLFW :'( - int version = gladLoadGLLoader(glfwGetProcAddress); + int version = gladLoadGLLoader( (GLADloadproc)glfwGetProcAddress ); if (version == 0) { printf("Failed to initialize OpenGL context\n"); } diff --git a/fggl/gfx/ogl/shader.cpp b/fggl/gfx/ogl/shader.cpp index ec31c41..63e69fa 100644 --- a/fggl/gfx/ogl/shader.cpp +++ b/fggl/gfx/ogl/shader.cpp @@ -1,4 +1,5 @@ +#include "fggl/gfx/ogl/types.hpp" #include <fggl/gfx/ogl/shader.hpp> #include <iostream> @@ -41,8 +42,8 @@ bool ShaderCache::compileShader(const std::string& fname, GLuint sid) { ShaderCache::ShaderCache(std::shared_ptr<fggl::data::Storage> storage) : m_storage(storage), m_shaders(), m_binary(true) { - if ( !GLEW_ARB_get_program_binary ) { - spdlog::warn("the graphics card doesn't support shader caching, disabling"); + if (GLAD_GL_ARB_get_program_binary) { + spdlog::warn("the graphics card doesn support shader caching, disabling"); m_binary = false; } -- GitLab