From 93cf23344d6bbb275c41b55b98f94e4eda6a9032 Mon Sep 17 00:00:00 2001 From: hans Date: Fri, 29 Oct 2021 00:53:46 +0200 Subject: [PATCH] Let ImGUI explicitely use GLAD to load OpenGL functionalities --- src/CMakeLists.txt | 2 +- src/main.cpp | 9 ++++++++- vendor/glad/src/glad.c | 2 +- vendor/imgui/include/imconfig.h | 5 ++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5023f33..91479db 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,7 @@ target_sources(yabgbe PUBLIC ${OTHER_SOURCES}) target_include_directories(yabgbe PUBLIC "${CMAKE_SOURCE_DIR}/vendor/imgui/include" - "${CMAKE_SOURCE_DIR}/vendor/glad/include" + "${CMAKE_SOURCE_DIR}/vendor/glad/include/glad/" SDL2 ) diff --git a/src/main.cpp b/src/main.cpp index 99d5173..fe8eb5f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,9 @@ #include #include -#include +#include +#define IMGUI_IMPL_OPENGL_LOADER_GLAD +#include #include static BYTE colormap[4] = { 0b00000000, 0b00100101, 0b01001010, 0b10010011 }; @@ -37,6 +39,11 @@ int main(int argc, char** argv) return -1; } + if(!gladLoadGL()) + { + std::cerr << "Failed to load GL" << std::endl; + } + SDL_Event e; // Initialize ImGui diff --git a/vendor/glad/src/glad.c b/vendor/glad/src/glad.c index 0af2c78..521e7d0 100644 --- a/vendor/glad/src/glad.c +++ b/vendor/glad/src/glad.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include "../glad/glad.h" static void* get_proc(const char *namez); diff --git a/vendor/imgui/include/imconfig.h b/vendor/imgui/include/imconfig.h index ecf4919..65f6a42 100644 --- a/vendor/imgui/include/imconfig.h +++ b/vendor/imgui/include/imconfig.h @@ -8,6 +8,9 @@ #pragma once +// This makes sure imgui uses glad +#define IMGUI_IMPL_OPENGL_LOADER_GLAD + //---- Define assertion handler. Defaults to calling assert(). // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) @@ -99,4 +102,4 @@ namespace ImGui { void MyFunction(const char* name, const MyMatrix44& v); } -*/ \ No newline at end of file +*/