From 64ed80309329c02e06b6fbe933b04402dd1fa5df Mon Sep 17 00:00:00 2001 From: Victor Bombi Date: Fri, 16 Oct 2020 17:33:05 +0200 Subject: [PATCH] backend_test: dont use glw3 loader on main, add USE_DOCKING define --- backend_test/CMakeLists.txt | 2 +- backend_test/cimgui_extras.h | 5 +---- backend_test/main.c | 17 ++++++----------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/backend_test/CMakeLists.txt b/backend_test/CMakeLists.txt index 5c9aa4c..3a76ac9 100644 --- a/backend_test/CMakeLists.txt +++ b/backend_test/CMakeLists.txt @@ -75,6 +75,6 @@ target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} ${IMGUI_SDL_LIBRARY}) #using library include_directories(../generator/output/) -add_executable(test_sdl main.c ../imgui/examples/libs/gl3w/GL/gl3w.c) +add_executable(test_sdl main.c) target_link_libraries(test_sdl ${IMGUI_SDL_LIBRARY} cimgui_sdl) diff --git a/backend_test/cimgui_extras.h b/backend_test/cimgui_extras.h index 3418447..85dd58f 100644 --- a/backend_test/cimgui_extras.h +++ b/backend_test/cimgui_extras.h @@ -1,9 +1,6 @@ -// GL3W/GLFW -#include // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you. - -//making it accesible for luajit +//making it accesible for main #ifdef _WIN32 __declspec( dllexport ) int Do_gl3wInit(void); #else diff --git a/backend_test/main.c b/backend_test/main.c index 1a88f33..4936273 100644 --- a/backend_test/main.c +++ b/backend_test/main.c @@ -5,7 +5,10 @@ #include #define SDL_MAIN_HANDLED #include +#include +#include +#define USE_DOCKING SDL_Window *window = NULL; @@ -60,15 +63,7 @@ int main(int argc, char* argv[]) SDL_Log("Failed to initialize OpenGL loader for cimgui_sdl!"); return 1; } - - // Initialize OpenGL loader for main - bool err2 = gl3wInit() != 0; - if (err2) - { - SDL_Log("Failed to initialize OpenGL loader for main!"); - return 1; - } - + // check opengl version sdl uses //SDL_Log("opengl version: %s", (char*)glGetString(GL_VERSION)); @@ -79,7 +74,7 @@ int main(int argc, char* argv[]) ImGuiIO* ioptr = igGetIO(); ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls //ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls -#ifdef ImGuiConfigFlags_DockingEnable +#ifdef USE_DOCKING ioptr->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking ioptr->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows #endif @@ -168,7 +163,7 @@ int main(int argc, char* argv[]) glClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w); glClear(GL_COLOR_BUFFER_BIT); ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData()); -#ifdef ImGuiConfigFlags_DockingEnable +#ifdef USE_DOCKING if (ioptr->ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();