From c1a4efeb10de5037e037f82973e766f1d2c87b39 Mon Sep 17 00:00:00 2001 From: Victor Bombi Date: Fri, 16 Oct 2020 16:29:47 +0200 Subject: [PATCH] README.md updated with backend_test info --- README.md | 6 ++++++ backend_test/main.c | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 21e9bae..5307e26 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Notes: * using makefile on linux/macOS/mingw (Or use CMake to generate project) * cmake options are IMGUI_STATIC (compiling as static library), IMGUI_FREETYPE (for using Freetype2) and FREETYPE_PATH (Freetype2 cmake install location) * or as in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master/build + + For compiling with backends there is now an example with SDL2 and opengl3 in folder backend_test. It will generate a cimgui_sdl module and a test_sdl executable. You only need to provide SDL_PATH telling cmake where to look for SDL2 cmake installation. # using generator @@ -86,6 +88,10 @@ Notes: * functions that belong to a struct have an extra first argument with a pointer to the struct. * where a function returns UDT (user defined type) by value some compilers complain so the function is generated accepting a pointer to the UDT type as the first argument (or second if belongs to a struct). +# usage with backends + +* look at backend_test folder for a cmake module building with SDL and opengl3. + # example bindings based on cimgui * [LuaJIT-ImGui](https://github.com/sonoro1234/LuaJIT-ImGui) diff --git a/backend_test/main.c b/backend_test/main.c index ce9dd09..1a88f33 100644 --- a/backend_test/main.c +++ b/backend_test/main.c @@ -79,9 +79,10 @@ 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 ioptr->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking ioptr->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows - +#endif ImGui_ImplSDL2_InitForOpenGL(window, gl_context); ImGui_ImplOpenGL3_Init(glsl_version); @@ -167,7 +168,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 if (ioptr->ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow(); @@ -176,7 +177,7 @@ int main(int argc, char* argv[]) igRenderPlatformWindowsDefault(NULL,NULL); SDL_GL_MakeCurrent(backup_current_window, backup_current_context); } - +#endif SDL_GL_SwapWindow(window); }