From 5a13e4dcde7dab1e5a004babf0b97795c7645dc3 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 10 Jun 2018 15:45:54 +0200 Subject: [PATCH] Examples: Renamed imgui_impl_sdl2.cpp to imgui_impl_sdl.cpp (#1870) + changelog bits --- CHANGELOG.txt | 31 +++++++++++++------ examples/README.txt | 10 +++--- examples/example_sdl_opengl2/Makefile | 2 +- examples/example_sdl_opengl2/README.md | 6 ++-- examples/example_sdl_opengl2/build_win32.bat | 2 +- .../example_sdl_opengl2.vcxproj | 4 +-- .../example_sdl_opengl2.vcxproj.filters | 4 +-- examples/example_sdl_opengl2/main.cpp | 2 +- examples/example_sdl_opengl3/Makefile | 2 +- examples/example_sdl_opengl3/README.md | 6 ++-- examples/example_sdl_opengl3/build_win32.bat | 2 +- .../example_sdl_opengl3.vcxproj | 4 +-- .../example_sdl_opengl3.vcxproj.filters | 4 +-- examples/example_sdl_opengl3/main.cpp | 2 +- .../example_sdl_vulkan.vcxproj | 4 +-- .../example_sdl_vulkan.vcxproj.filters | 4 +-- examples/example_sdl_vulkan/main.cpp | 2 +- ...imgui_impl_sdl2.cpp => imgui_impl_sdl.cpp} | 4 +-- .../{imgui_impl_sdl2.h => imgui_impl_sdl.h} | 0 19 files changed, 53 insertions(+), 42 deletions(-) rename examples/{imgui_impl_sdl2.cpp => imgui_impl_sdl.cpp} (98%) rename examples/{imgui_impl_sdl2.h => imgui_impl_sdl.h} (100%) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8a3d06a2..83a4b88e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -39,19 +39,30 @@ Breaking Changes: The only difference is if you were using TreeNodeEx() manually with ImGuiTreeNodeFlags_CollapsingHeader and without ImGuiTreeNodeFlags_NoTreePushOnOpen. In which case you can remove the ImGuiTreeNodeFlags_NoTreePushOnOpen flag from your call (ImGuiTreeNodeFlags_CollapsingHeader & ~ImGuiTreeNodeFlags_NoTreePushOnOpen). (#1864) - ImFontAtlas: Renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set. (#1859) - - Examples Bindings have been refactored to separate them into "Platform" and "Renderer" components that are more easy to combine. - - The "Platform" bindings are in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, etc. - Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl2.cpp). - - The "Renderer" bindings are in charge of: creating the main font texture, rendering imgui draw data. - Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp) - - This is not strictly a breaking change if you keep your old bindings, but _WHEN_ you'll want to fully update your bindings, - expect to have to reshuffle a few things. This refactor will greatly facilitate maintenance and re-usability, and was designed - to get us closer to the upcoming "multi-viewport" feature branch. - - Please read examples/README.txt for details. - + This also apply if you were using internal's TreeNodeBehavior() with the ImGuiTreeNodeFlags_CollapsingHeader flag directly. Other Changes: + - Examples back-ends have been refactored to separate the platform code (e.g. Win32, Glfw, SDL2) from the renderer code (e.g. DirectX11, OpenGL3, Vulkan). + The "Platform" bindings are in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, etc. + The "Renderer" bindings are in charge of: creating the main font texture, rendering imgui draw data. + before: imgui_impl_dx11.cpp --> after: imgui_impl_win32.cpp + imgui_impl_dx11.cpp + before: imgui_impl_dx12.cpp --> after: imgui_impl_win32.cpp + imgui_impl_dx12.cpp + before: imgui_impl_glfw_gl3.cpp --> after: imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp + before: imgui_impl_glfw_vulkan.cpp --> after: imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp + before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl2.cpp + before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp etc. + - The idea is what we can now easily combine and maintain back-ends and reduce code redundancy. Individual files are smaller and more reusable. + Integration of imgui into a new/custom engine may also be easier as there is less overlap between "windowing / inputs" and "rendering" code, + so you may study or grab one half of the code and not the other. + - This change was motivated by the fact that adding support for the upcoming multi-viewport feature requires more work from the Platform and Renderer + back-ends, and the amount of redundancy across files was becoming too difficult to maintain. If you use default back-ends, you'll benefit from an + easy update path to support multi-viewports later. + - This is not strictly a breaking change if you keep your old bindings, but when you'll want to fully update your bindings, + expect to have to reshuffle a few things. + - Each example still has its own main.cpp which you may refer you to understand how to initialize and glue everything together. + - Some frameworks (such as the Allegro, Marmalade) handle both the "platform" and "rendering" part, and your custom engine may as well. + - Please read examples/README.txt for details. - Nav: To keep the navigated item in view we also attempt to scroll the parent window as well as the current window. (#787) - Nav: Added support for PageUp/PageDown (explorer-style: first aim at bottom/top most item, when scroll a page worth of contents). (#787) - TreeNode: Fixed nodes with ImGuiTreeNodeFlags_Leaf flag always returning true which was meaningless. diff --git a/examples/README.txt b/examples/README.txt index ecc9db14..61a496f6 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -65,7 +65,7 @@ You can find binaries of some of those example applications at: Most the example bindings are split in 2 parts: - The "Platform" bindings, in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing. - Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl2.cpp) + Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl.cpp) - The "Renderer" bindings, in charge of: creating the main font texture, rendering imgui draw data. Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp) @@ -109,7 +109,7 @@ Most the example bindings are split in 2 parts: List of officially maintained Platforms Bindings: imgui_impl_glfw.cpp - imgui_impl_sdl2.cpp + imgui_impl_sdl.cpp imgui_impl_win32.cpp List of officially maintained Renderer Bindings: @@ -199,18 +199,18 @@ example_sdl_opengl2/ If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to make things more complicated, will require your code to reset many OpenGL attributes to their initial state, and might confuse your GPU driver. One star, not recommended. - = main.cpp + imgui_impl_sdl2.cpp + imgui_impl_opengl2.cpp + = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp example_sdl_opengl3/ SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+ example. This uses more modern OpenGL calls and custom shaders. Prefer using that if you are using modern OpenGL in your application (anything with shaders). - = main.cpp + imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp + = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp example_sdl_vulkan/ SDL2 (Win32, Mac, Linux, etc.) + Vulkan example. This is quite long and tedious, because: Vulkan. - = main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp + = main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp example_apple/ OSX & iOS example + OpenGL2. diff --git a/examples/example_sdl_opengl2/Makefile b/examples/example_sdl_opengl2/Makefile index 8f008b8a..a295ac22 100644 --- a/examples/example_sdl_opengl2/Makefile +++ b/examples/example_sdl_opengl2/Makefile @@ -15,7 +15,7 @@ #CXX = clang++ EXE = example_sdl_opengl2 -SOURCES = main.cpp ../imgui_impl_sdl2.cpp ../imgui_impl_opengl2.cpp +SOURCES = main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) diff --git a/examples/example_sdl_opengl2/README.md b/examples/example_sdl_opengl2/README.md index 6d4ce25c..a8bfc880 100644 --- a/examples/example_sdl_opengl2/README.md +++ b/examples/example_sdl_opengl2/README.md @@ -5,18 +5,18 @@ ``` set SDL2DIR=path_to_your_sdl2_folder -cl /Zi /MD /I %SDL2DIR%\include /I ..\.. main.cpp ..\imgui_impl_sdl2.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /link /LIBPATH:%SDL2DIR%\lib SDL2.lib SDL2main.lib opengl32.lib /subsystem:console +cl /Zi /MD /I %SDL2DIR%\include /I ..\.. main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /link /LIBPATH:%SDL2DIR%\lib SDL2.lib SDL2main.lib opengl32.lib /subsystem:console ``` - On Linux and similar Unixes ``` -c++ `sdl2-config --cflags` -I ../.. main.cpp ../imgui_impl_sdl2.cpp ../imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL +c++ `sdl2-config --cflags` -I ../.. main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL ``` - On Mac OS X ``` brew install sdl2 -c++ `sdl2-config --cflags` -I ../.. main.cpp ../imgui_impl_sdl2.cpp ../imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl +c++ `sdl2-config --cflags` -I ../.. main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl ``` diff --git a/examples/example_sdl_opengl2/build_win32.bat b/examples/example_sdl_opengl2/build_win32.bat index 0493a72c..bc2eb3b2 100644 --- a/examples/example_sdl_opengl2/build_win32.bat +++ b/examples/example_sdl_opengl2/build_win32.bat @@ -1,3 +1,3 @@ @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\gl3w /I %SDL2_DIR%\include *.cpp ..\imgui_impl_opengl2.cpp ..\imgui_impl_sdl2.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console +cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\gl3w /I %SDL2_DIR%\include *.cpp ..\imgui_impl_opengl2.cpp ..\imgui_impl_sdl.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console diff --git a/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj b/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj index e6d3e79e..bdec85b3 100644 --- a/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj +++ b/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj @@ -154,7 +154,7 @@ - + @@ -162,7 +162,7 @@ - + diff --git a/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters b/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters index f129cc25..602fa0b0 100644 --- a/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters +++ b/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters @@ -22,7 +22,7 @@ sources - + sources @@ -42,7 +42,7 @@ sources - + sources diff --git a/examples/example_sdl_opengl2/main.cpp b/examples/example_sdl_opengl2/main.cpp index 10e9d319..5a4dbd4e 100644 --- a/examples/example_sdl_opengl2/main.cpp +++ b/examples/example_sdl_opengl2/main.cpp @@ -7,7 +7,7 @@ // See imgui_impl_sdl.cpp for details. #include "imgui.h" -#include "imgui_impl_sdl2.h" +#include "imgui_impl_sdl.h" #include "imgui_impl_opengl2.h" #include #include diff --git a/examples/example_sdl_opengl3/Makefile b/examples/example_sdl_opengl3/Makefile index d2f71f69..fb826cbc 100644 --- a/examples/example_sdl_opengl3/Makefile +++ b/examples/example_sdl_opengl3/Makefile @@ -16,7 +16,7 @@ EXE = example_sdl_opengl3 SOURCES = main.cpp -SOURCES += ../imgui_impl_sdl2.cpp ../imgui_impl_opengl3.cpp +SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp SOURCES += ../libs/gl3w/GL/gl3w.c OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) diff --git a/examples/example_sdl_opengl3/README.md b/examples/example_sdl_opengl3/README.md index 8a7741e1..3de6666a 100644 --- a/examples/example_sdl_opengl3/README.md +++ b/examples/example_sdl_opengl3/README.md @@ -5,18 +5,18 @@ ``` set SDL2DIR=path_to_your_sdl2_folder -cl /Zi /MD /I ..\.. /I ..\libs\gl3w /I %SDL2DIR%\include main.cpp ..\imgui_impl_sdl2.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /link /libpath:%SDL2DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console +cl /Zi /MD /I ..\.. /I ..\libs\gl3w /I %SDL2DIR%\include main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /link /libpath:%SDL2DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console ``` - On Linux and similar Unixes ``` -c++ `sdl2-config --cflags` -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl2.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -lGL -ldl +c++ `sdl2-config --cflags` -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -lGL -ldl ``` - On Mac OS X ``` brew install sdl2 -c++ `sdl2-config --cflags` -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl2.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -framework OpenGl -framework CoreFoundation +c++ `sdl2-config --cflags` -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -framework OpenGl -framework CoreFoundation ``` diff --git a/examples/example_sdl_opengl3/build_win32.bat b/examples/example_sdl_opengl3/build_win32.bat index c0403d3f..d2cfa67f 100644 --- a/examples/example_sdl_opengl3/build_win32.bat +++ b/examples/example_sdl_opengl3/build_win32.bat @@ -1,3 +1,3 @@ @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\gl3w /I %SDL2_DIR%\include *.cpp ..\imgui_impl_opengl3.cpp ..\imgui_impl_sdl2.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console +cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\gl3w /I %SDL2_DIR%\include *.cpp ..\imgui_impl_opengl3.cpp ..\imgui_impl_sdl.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console diff --git a/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj b/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj index 3753caca..b194e620 100644 --- a/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj +++ b/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj @@ -154,7 +154,7 @@ - + @@ -163,7 +163,7 @@ - + diff --git a/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters b/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters index 93d321a2..87ae4313 100644 --- a/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters +++ b/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters @@ -31,7 +31,7 @@ sources - + sources @@ -54,7 +54,7 @@ sources - + sources diff --git a/examples/example_sdl_opengl3/main.cpp b/examples/example_sdl_opengl3/main.cpp index 03d82432..57cd0ad0 100644 --- a/examples/example_sdl_opengl3/main.cpp +++ b/examples/example_sdl_opengl3/main.cpp @@ -4,7 +4,7 @@ // (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.) #include "imgui.h" -#include "imgui_impl_sdl2.h" +#include "imgui_impl_sdl.h" #include "imgui_impl_opengl3.h" #include #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. diff --git a/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj b/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj index 42146cd1..3d2a424a 100644 --- a/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj +++ b/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj @@ -153,7 +153,7 @@ - + @@ -161,7 +161,7 @@ - + diff --git a/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters b/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters index 35e8aa1f..4f7c7928 100644 --- a/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters +++ b/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters @@ -19,7 +19,7 @@ imgui - + sources @@ -39,7 +39,7 @@ imgui - + sources diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp index 6ebecf23..2b8b104f 100644 --- a/examples/example_sdl_vulkan/main.cpp +++ b/examples/example_sdl_vulkan/main.cpp @@ -2,7 +2,7 @@ // If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. #include "imgui.h" -#include "imgui_impl_sdl2.h" +#include "imgui_impl_sdl.h" #include "imgui_impl_vulkan.h" #include // printf, fprintf #include // abort diff --git a/examples/imgui_impl_sdl2.cpp b/examples/imgui_impl_sdl.cpp similarity index 98% rename from examples/imgui_impl_sdl2.cpp rename to examples/imgui_impl_sdl.cpp index 8182988c..457734de 100644 --- a/examples/imgui_impl_sdl2.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -12,7 +12,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) -// 2018-06-08: Misc: Extracted imgui_impl_sdl2.cpp/.h away from the old combined SDL2+OpenGL/Vulkan examples. +// 2018-06-08: Misc: Extracted imgui_impl_sdl.cpp/.h away from the old combined SDL2+OpenGL/Vulkan examples. // 2018-06-08: Misc: ImGui_ImplSDL2_InitForOpenGL() now takes a SDL_GLContext parameter. // 2018-05-09: Misc: Fixed clipboard paste memory leak (we didn't call SDL_FreeMemory on the data returned by SDL_GetClipboardText). // 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag. @@ -28,7 +28,7 @@ // 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers. #include "imgui.h" -#include "imgui_impl_sdl2.h" +#include "imgui_impl_sdl.h" // SDL // (the multi-viewports feature requires SDL features supported from SDL 2.0.5+) diff --git a/examples/imgui_impl_sdl2.h b/examples/imgui_impl_sdl.h similarity index 100% rename from examples/imgui_impl_sdl2.h rename to examples/imgui_impl_sdl.h