mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-16 14:28:29 +01:00
README.md updated with backend_test info
This commit is contained in:
@@ -27,6 +27,8 @@ Notes:
|
|||||||
* cmake options are IMGUI_STATIC (compiling as static library), IMGUI_FREETYPE (for using Freetype2) and FREETYPE_PATH (Freetype2 cmake install location)
|
* 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
|
* 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
|
# using generator
|
||||||
|
|
||||||
* this is only needed (before compilation) if you want an imgui version different from the one provided, otherwise generation is already done.
|
* this is only needed (before compilation) if you want an imgui version different from the one provided, otherwise generation is already done.
|
||||||
@@ -86,6 +88,10 @@ Notes:
|
|||||||
* functions that belong to a struct have an extra first argument with a pointer to the struct.
|
* 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).
|
* 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
|
# example bindings based on cimgui
|
||||||
|
|
||||||
* [LuaJIT-ImGui](https://github.com/sonoro1234/LuaJIT-ImGui)
|
* [LuaJIT-ImGui](https://github.com/sonoro1234/LuaJIT-ImGui)
|
||||||
|
@@ -79,9 +79,10 @@ int main(int argc, char* argv[])
|
|||||||
ImGuiIO* ioptr = igGetIO();
|
ImGuiIO* ioptr = igGetIO();
|
||||||
ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
//ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
//ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
#ifdef ImGuiConfigFlags_DockingEnable
|
||||||
ioptr->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
ioptr->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
ioptr->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
ioptr->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
#endif
|
||||||
|
|
||||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
@@ -167,7 +168,7 @@ int main(int argc, char* argv[])
|
|||||||
glClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
|
glClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
|
||||||
|
#ifdef ImGuiConfigFlags_DockingEnable
|
||||||
if (ioptr->ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (ioptr->ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
|
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
|
||||||
@@ -176,7 +177,7 @@ int main(int argc, char* argv[])
|
|||||||
igRenderPlatformWindowsDefault(NULL,NULL);
|
igRenderPlatformWindowsDefault(NULL,NULL);
|
||||||
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
|
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user