feat(cmake): replaced glew with glad
This commit is contained in:
parent
44c28b6825
commit
11df6595c0
18 changed files with 5964 additions and 27 deletions
|
@ -1,6 +1,8 @@
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#include "logger.h"
|
||||||
#include "objects/part/part.h"
|
#include "objects/part/part.h"
|
||||||
|
#include "panic.h"
|
||||||
#include "rendering/renderer.h"
|
#include "rendering/renderer.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -37,7 +39,13 @@ int main() {
|
||||||
glfwSetFramebufferSizeCallback(window, resizeCallback);
|
glfwSetFramebufferSizeCallback(window, resizeCallback);
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glewInit();
|
int version = gladLoadGL(glfwGetProcAddress);
|
||||||
|
if (version == 0) {
|
||||||
|
Logger::fatalError("Failed to initialize OpenGL context");
|
||||||
|
panic();
|
||||||
|
} else {
|
||||||
|
Logger::debugf("Initialized GL context version %d.%d", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
|
||||||
|
}
|
||||||
|
|
||||||
gDataModel->Init();
|
gDataModel->Init();
|
||||||
renderInit(1200, 900);
|
renderInit(1200, 900);
|
||||||
|
|
|
@ -3,6 +3,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/deps.cmake)
|
||||||
## Sources
|
## Sources
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
src/stb.cpp
|
src/stb.cpp
|
||||||
|
src/glad.cpp
|
||||||
|
|
||||||
src/ptr_helpers.h
|
src/ptr_helpers.h
|
||||||
src/enum/part.h
|
src/enum/part.h
|
||||||
src/enum/surface.cpp
|
src/enum/surface.cpp
|
||||||
|
@ -195,8 +197,8 @@ list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/src/version.cpp)
|
||||||
add_library(openblocks STATIC ${SOURCES})
|
add_library(openblocks STATIC ${SOURCES})
|
||||||
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
|
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
|
||||||
target_link_directories(openblocks PUBLIC ${LUAJIT_LIBRARY_DIRS})
|
target_link_directories(openblocks PUBLIC ${LUAJIT_LIBRARY_DIRS})
|
||||||
target_link_libraries(openblocks libglew_static reactphysics3d pugixml::pugixml Freetype::Freetype glm::glm libluajit ${LuaJIT_LIBRARIES})
|
target_link_libraries(openblocks reactphysics3d pugixml::pugixml Freetype::Freetype glm::glm libluajit ${LuaJIT_LIBRARIES})
|
||||||
target_include_directories(openblocks PUBLIC "src" "../include" ${ReactPhysics3D_SOURCE_DIR}/include ${LUAJIT_INCLUDE_DIRS} ${stb_SOURCE_DIR} ${glew_SOURCE_DIR}/include)
|
target_include_directories(openblocks PUBLIC "src" "../include" "${CMAKE_SOURCE_DIR}/external/glad" ${ReactPhysics3D_SOURCE_DIR}/include ${LUAJIT_INCLUDE_DIRS} ${stb_SOURCE_DIR})
|
||||||
add_dependencies(openblocks autogen_build autogen)
|
add_dependencies(openblocks autogen_build autogen)
|
||||||
|
|
||||||
# Windows-specific dependencies
|
# Windows-specific dependencies
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
include(CPM)
|
include(CPM)
|
||||||
|
|
||||||
CPMAddPackage("gh:Perlmint/glew-cmake#glew-cmake-2.2.0")
|
|
||||||
CPMAddPackage("gh:g-truc/glm#1.0.1")
|
CPMAddPackage("gh:g-truc/glm#1.0.1")
|
||||||
CPMAddPackage(NAME reactphysics3d GITHUB_REPOSITORY "DanielChappuis/reactphysics3d" VERSION 0.10.2 PATCHES ${CMAKE_SOURCE_DIR}/patches/std_chrono.patch)
|
CPMAddPackage(NAME reactphysics3d GITHUB_REPOSITORY "DanielChappuis/reactphysics3d" VERSION 0.10.2 PATCHES ${CMAKE_SOURCE_DIR}/patches/std_chrono.patch)
|
||||||
# https://github.com/StereoKit/StereoKit/blob/0be056efebcee5e58ad1438f4cf6dfdb942f6cf9/CMakeLists.txt#L205
|
# https://github.com/StereoKit/StereoKit/blob/0be056efebcee5e58ad1438f4cf6dfdb942f6cf9/CMakeLists.txt#L205
|
||||||
|
@ -13,6 +12,7 @@ CPMAddPackage(
|
||||||
GIT_REPOSITORY https://github.com/aseprite/freetype2.git
|
GIT_REPOSITORY https://github.com/aseprite/freetype2.git
|
||||||
GIT_TAG VER-2-10-0
|
GIT_TAG VER-2-10-0
|
||||||
VERSION 2.10.0
|
VERSION 2.10.0
|
||||||
|
PATCHES ${CMAKE_SOURCE_DIR}/patches/freetype_cmakever.patch
|
||||||
)
|
)
|
||||||
|
|
||||||
if (freetype_ADDED)
|
if (freetype_ADDED)
|
||||||
|
|
2
core/src/glad.cpp
Normal file
2
core/src/glad.cpp
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
|
#include <glad/gl.h>
|
|
@ -1,8 +1,7 @@
|
||||||
#include "rendering/shader.h"
|
#include "rendering/shader.h"
|
||||||
#include "rendering/texture.h"
|
#include "rendering/texture.h"
|
||||||
#include "timeutil.h"
|
#include "timeutil.h"
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <glm/ext/vector_float4.hpp>
|
#include <glm/ext/vector_float4.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "rendering/shader.h"
|
#include "rendering/shader.h"
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <glm/ext/matrix_clip_space.hpp>
|
#include <glm/ext/matrix_clip_space.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
|
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
|
|
||||||
#include "mesh2d.h"
|
#include "mesh2d.h"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <glm/ext.hpp>
|
#include <glm/ext.hpp>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "texture3d.h"
|
#include "texture3d.h"
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "torus.h"
|
#include "torus.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
|
|
||||||
#define PI 3.1415926535f
|
#define PI 3.1415926535f
|
||||||
|
|
||||||
|
|
2
deps.txt
2
deps.txt
|
@ -1,6 +1,6 @@
|
||||||
opengl (Linux: glvnd, Windows: [built-in/none])
|
opengl (Linux: glvnd, Windows: [built-in/none])
|
||||||
glfw
|
glfw
|
||||||
glew
|
glad
|
||||||
glm
|
glm
|
||||||
stb
|
stb
|
||||||
qt6
|
qt6
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <GL/glew.h>
|
#include <glad/gl.h>
|
||||||
#include <glm/common.hpp>
|
#include <glm/common.hpp>
|
||||||
#include <glm/vector_relational.hpp>
|
#include <glm/vector_relational.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -35,7 +35,13 @@ MainGLWidget::MainGLWidget(QWidget* parent): QOpenGLWidget(parent), contextMenu(
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainGLWidget::initializeGL() {
|
void MainGLWidget::initializeGL() {
|
||||||
glewInit();
|
int version = gladLoaderLoadGL();
|
||||||
|
if (version == 0) {
|
||||||
|
Logger::fatalError("Failed to initialize OpenGL context");
|
||||||
|
panic();
|
||||||
|
} else {
|
||||||
|
Logger::debugf("Initialized GL context version %d.%d", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
|
||||||
|
}
|
||||||
renderInit(width(), height());
|
renderInit(width(), height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5914
external/glad/glad/gl.h
vendored
Normal file
5914
external/glad/glad/gl.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
14
patches/freetype_cmakever.patch
Normal file
14
patches/freetype_cmakever.patch
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 28dc3b3f6..37fd14713 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -85,7 +85,8 @@
|
||||||
|
# FreeType explicitly marks the API to be exported and relies on the compiler
|
||||||
|
# to hide all other symbols. CMake supports a C_VISBILITY_PRESET property
|
||||||
|
# starting with 2.8.12.
|
||||||
|
-cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
+# cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
+cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
if (NOT CMAKE_VERSION VERSION_LESS 3.3)
|
||||||
|
# Allow symbol visibility settings also on static libraries. CMake < 3.3
|
Loading…
Add table
Reference in a new issue