diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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 93d321a..87ae431 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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 93d321a..87ae431 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 03d8243..57cd0ad 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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 93d321a..87ae431 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 03d8243..57cd0ad 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 42146cd..3d2a424 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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 93d321a..87ae431 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 03d8243..57cd0ad 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 42146cd..3d2a424 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 35e8aa1..4f7c792 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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 93d321a..87ae431 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 03d8243..57cd0ad 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 42146cd..3d2a424 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 35e8aa1..4f7c792 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 6ebecf2..2b8b104 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/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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 93d321a..87ae431 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 03d8243..57cd0ad 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 42146cd..3d2a424 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 35e8aa1..4f7c792 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 6ebecf2..2b8b104 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_sdl.cpp b/examples/imgui_impl_sdl.cpp
new file mode 100644
index 0000000..457734d
--- /dev/null
+++ b/examples/imgui_impl_sdl.cpp
@@ -0,0 +1,282 @@
+// ImGui Platform Binding for: SDL2
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
+
+// Missing features:
+// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 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.
+// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
+// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
+// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
+// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
+// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
+// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
+// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
+// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+
+// SDL
+// (the multi-viewports feature requires SDL features supported from SDL 2.0.5+)
+#include
+#include
+#define SDL_HAS_WARP_MOUSE_GLOBAL SDL_VERSION_ATLEAST(2,0,4)
+
+#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4)
+#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
+#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5)
+#if !SDL_HAS_VULKAN
+static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
+#endif
+
+// Data
+static SDL_Window* g_Window = NULL;
+static Uint64 g_Time = 0;
+static bool g_MousePressed[3] = { false, false, false };
+static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
+static char* g_ClipboardTextData = NULL;
+
+static const char* ImGui_ImplSDL2_GetClipboardText(void*)
+{
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+ g_ClipboardTextData = SDL_GetClipboardText();
+ return g_ClipboardTextData;
+}
+
+static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
+{
+ SDL_SetClipboardText(text);
+}
+
+// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
+// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
+// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
+// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
+bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ switch (event->type)
+ {
+ case SDL_MOUSEWHEEL:
+ {
+ if (event->wheel.x > 0) io.MouseWheelH += 1;
+ if (event->wheel.x < 0) io.MouseWheelH -= 1;
+ if (event->wheel.y > 0) io.MouseWheel += 1;
+ if (event->wheel.y < 0) io.MouseWheel -= 1;
+ return true;
+ }
+ case SDL_MOUSEBUTTONDOWN:
+ {
+ if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
+ if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
+ if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
+ return true;
+ }
+ case SDL_TEXTINPUT:
+ {
+ io.AddInputCharactersUTF8(event->text.text);
+ return true;
+ }
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+ {
+ int key = event->key.keysym.scancode;
+ IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
+ io.KeysDown[key] = (event->type == SDL_KEYDOWN);
+ io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
+ io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
+ io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
+ io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool ImGui_ImplSDL2_Init(SDL_Window* window)
+{
+ g_Window = window;
+
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+#if SDL_HAS_WARP_MOUSE_GLOBAL
+ io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
+#endif
+
+ // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
+ io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
+ io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
+ io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
+ io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
+ io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
+ io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
+ io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
+ io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
+ io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
+ io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
+ io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
+ io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
+ io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
+ io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
+
+ io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
+ io.ClipboardUserData = NULL;
+
+ g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
+ g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
+ g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
+ g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
+
+#ifdef _WIN32
+ SDL_SysWMinfo wmInfo;
+ SDL_VERSION(&wmInfo.version);
+ SDL_GetWindowWMInfo(window, &wmInfo);
+ io.ImeWindowHandle = wmInfo.info.win.window;
+#else
+ (void)window;
+#endif
+
+ return true;
+}
+
+bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
+{
+ (void)sdl_gl_context; // Viewport branch will need this.
+ return ImGui_ImplSDL2_Init(window);
+}
+
+bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
+{
+ #if !SDL_HAS_VULKAN
+ IM_ASSERT(0 && "Unsupported");
+ #endif
+ return ImGui_ImplSDL2_Init(window);
+}
+
+void ImGui_ImplSDL2_Shutdown()
+{
+ g_Window = NULL;
+
+ // Destroy last known clipboard data
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+
+ // Destroy SDL mouse cursors
+ for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
+ SDL_FreeCursor(g_MouseCursors[cursor_n]);
+ memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
+}
+
+static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ const ImVec2 mouse_pos_backup = io.MousePos;
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+
+ // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
+ // (When multi-viewports are enabled, all imgui positions are same as OS positions.)
+#if SDL_HAS_WARP_MOUSE_GLOBAL
+ if (io.WantSetMousePos)
+ SDL_WarpMouseGlobal((int)mouse_pos_backup.x, (int)mouse_pos_backup.y);
+#endif
+
+ int mx, my;
+ Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
+ io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
+ io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
+ g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
+
+#if SDL_HAS_CAPTURE_MOUSE
+ SDL_Window* focused_window = SDL_GetKeyboardFocus();
+ if (g_Window == focused_window)
+ {
+ // SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
+ // The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
+ int wx, wy;
+ SDL_GetWindowPosition(focused_window, &wx, &wy);
+ SDL_GetGlobalMouseState(&mx, &my);
+ mx -= wx;
+ my -= wy;
+ io.MousePos = ImVec2((float)mx, (float)my);
+ }
+
+ // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger the OS window resize cursor.
+ // The function is only supported from SDL 2.0.4 (released Jan 2016)
+ bool any_mouse_button_down = ImGui::IsAnyMouseDown();
+ SDL_CaptureMouse(any_mouse_button_down ? SDL_TRUE : SDL_FALSE);
+#else
+ if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS)
+ io.MousePos = ImVec2((float)mx, (float)my);
+#endif
+}
+
+static void ImGui_ImplSDL2_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
+ return;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ SDL_ShowCursor(SDL_FALSE);
+ }
+ else
+ {
+ // Show OS mouse cursor
+ SDL_SetCursor(g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
+ SDL_ShowCursor(SDL_TRUE);
+ }
+}
+
+void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_ASSERT(io.Fonts->IsBuilt()); // Font atlas needs to be built, call renderer _NewFrame() function e.g. ImGui_ImplOpenGL3_NewFrame()
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ SDL_GetWindowSize(window, &w, &h);
+ SDL_GL_GetDrawableSize(window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
+ static Uint64 frequency = SDL_GetPerformanceFrequency();
+ Uint64 current_time = SDL_GetPerformanceCounter();
+ io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
+ g_Time = current_time;
+
+ ImGui_ImplSDL2_UpdateMousePosAndButtons();
+ ImGui_ImplSDL2_UpdateMouseCursor();
+}
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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 93d321a..87ae431 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 03d8243..57cd0ad 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 42146cd..3d2a424 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 35e8aa1..4f7c792 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 6ebecf2..2b8b104 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_sdl.cpp b/examples/imgui_impl_sdl.cpp
new file mode 100644
index 0000000..457734d
--- /dev/null
+++ b/examples/imgui_impl_sdl.cpp
@@ -0,0 +1,282 @@
+// ImGui Platform Binding for: SDL2
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
+
+// Missing features:
+// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 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.
+// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
+// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
+// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
+// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
+// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
+// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
+// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
+// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+
+// SDL
+// (the multi-viewports feature requires SDL features supported from SDL 2.0.5+)
+#include
+#include
+#define SDL_HAS_WARP_MOUSE_GLOBAL SDL_VERSION_ATLEAST(2,0,4)
+
+#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4)
+#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
+#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5)
+#if !SDL_HAS_VULKAN
+static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
+#endif
+
+// Data
+static SDL_Window* g_Window = NULL;
+static Uint64 g_Time = 0;
+static bool g_MousePressed[3] = { false, false, false };
+static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
+static char* g_ClipboardTextData = NULL;
+
+static const char* ImGui_ImplSDL2_GetClipboardText(void*)
+{
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+ g_ClipboardTextData = SDL_GetClipboardText();
+ return g_ClipboardTextData;
+}
+
+static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
+{
+ SDL_SetClipboardText(text);
+}
+
+// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
+// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
+// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
+// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
+bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ switch (event->type)
+ {
+ case SDL_MOUSEWHEEL:
+ {
+ if (event->wheel.x > 0) io.MouseWheelH += 1;
+ if (event->wheel.x < 0) io.MouseWheelH -= 1;
+ if (event->wheel.y > 0) io.MouseWheel += 1;
+ if (event->wheel.y < 0) io.MouseWheel -= 1;
+ return true;
+ }
+ case SDL_MOUSEBUTTONDOWN:
+ {
+ if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
+ if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
+ if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
+ return true;
+ }
+ case SDL_TEXTINPUT:
+ {
+ io.AddInputCharactersUTF8(event->text.text);
+ return true;
+ }
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+ {
+ int key = event->key.keysym.scancode;
+ IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
+ io.KeysDown[key] = (event->type == SDL_KEYDOWN);
+ io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
+ io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
+ io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
+ io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool ImGui_ImplSDL2_Init(SDL_Window* window)
+{
+ g_Window = window;
+
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+#if SDL_HAS_WARP_MOUSE_GLOBAL
+ io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
+#endif
+
+ // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
+ io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
+ io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
+ io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
+ io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
+ io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
+ io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
+ io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
+ io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
+ io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
+ io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
+ io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
+ io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
+ io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
+ io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
+
+ io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
+ io.ClipboardUserData = NULL;
+
+ g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
+ g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
+ g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
+ g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
+
+#ifdef _WIN32
+ SDL_SysWMinfo wmInfo;
+ SDL_VERSION(&wmInfo.version);
+ SDL_GetWindowWMInfo(window, &wmInfo);
+ io.ImeWindowHandle = wmInfo.info.win.window;
+#else
+ (void)window;
+#endif
+
+ return true;
+}
+
+bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
+{
+ (void)sdl_gl_context; // Viewport branch will need this.
+ return ImGui_ImplSDL2_Init(window);
+}
+
+bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
+{
+ #if !SDL_HAS_VULKAN
+ IM_ASSERT(0 && "Unsupported");
+ #endif
+ return ImGui_ImplSDL2_Init(window);
+}
+
+void ImGui_ImplSDL2_Shutdown()
+{
+ g_Window = NULL;
+
+ // Destroy last known clipboard data
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+
+ // Destroy SDL mouse cursors
+ for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
+ SDL_FreeCursor(g_MouseCursors[cursor_n]);
+ memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
+}
+
+static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ const ImVec2 mouse_pos_backup = io.MousePos;
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+
+ // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
+ // (When multi-viewports are enabled, all imgui positions are same as OS positions.)
+#if SDL_HAS_WARP_MOUSE_GLOBAL
+ if (io.WantSetMousePos)
+ SDL_WarpMouseGlobal((int)mouse_pos_backup.x, (int)mouse_pos_backup.y);
+#endif
+
+ int mx, my;
+ Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
+ io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
+ io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
+ g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
+
+#if SDL_HAS_CAPTURE_MOUSE
+ SDL_Window* focused_window = SDL_GetKeyboardFocus();
+ if (g_Window == focused_window)
+ {
+ // SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
+ // The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
+ int wx, wy;
+ SDL_GetWindowPosition(focused_window, &wx, &wy);
+ SDL_GetGlobalMouseState(&mx, &my);
+ mx -= wx;
+ my -= wy;
+ io.MousePos = ImVec2((float)mx, (float)my);
+ }
+
+ // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger the OS window resize cursor.
+ // The function is only supported from SDL 2.0.4 (released Jan 2016)
+ bool any_mouse_button_down = ImGui::IsAnyMouseDown();
+ SDL_CaptureMouse(any_mouse_button_down ? SDL_TRUE : SDL_FALSE);
+#else
+ if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS)
+ io.MousePos = ImVec2((float)mx, (float)my);
+#endif
+}
+
+static void ImGui_ImplSDL2_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
+ return;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ SDL_ShowCursor(SDL_FALSE);
+ }
+ else
+ {
+ // Show OS mouse cursor
+ SDL_SetCursor(g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
+ SDL_ShowCursor(SDL_TRUE);
+ }
+}
+
+void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_ASSERT(io.Fonts->IsBuilt()); // Font atlas needs to be built, call renderer _NewFrame() function e.g. ImGui_ImplOpenGL3_NewFrame()
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ SDL_GetWindowSize(window, &w, &h);
+ SDL_GL_GetDrawableSize(window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
+ static Uint64 frequency = SDL_GetPerformanceFrequency();
+ Uint64 current_time = SDL_GetPerformanceCounter();
+ io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
+ g_Time = current_time;
+
+ ImGui_ImplSDL2_UpdateMousePosAndButtons();
+ ImGui_ImplSDL2_UpdateMouseCursor();
+}
diff --git a/examples/imgui_impl_sdl.h b/examples/imgui_impl_sdl.h
new file mode 100644
index 0000000..15aac59
--- /dev/null
+++ b/examples/imgui_impl_sdl.h
@@ -0,0 +1,20 @@
+// ImGui Platform Binding for: SDL2
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
+
+// Missing features:
+// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct SDL_Window;
+typedef union SDL_Event SDL_Event;
+
+IMGUI_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
+IMGUI_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
+IMGUI_API void ImGui_ImplSDL2_Shutdown();
+IMGUI_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
+IMGUI_API bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event);
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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 93d321a..87ae431 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 03d8243..57cd0ad 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 42146cd..3d2a424 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 35e8aa1..4f7c792 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 6ebecf2..2b8b104 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_sdl.cpp b/examples/imgui_impl_sdl.cpp
new file mode 100644
index 0000000..457734d
--- /dev/null
+++ b/examples/imgui_impl_sdl.cpp
@@ -0,0 +1,282 @@
+// ImGui Platform Binding for: SDL2
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
+
+// Missing features:
+// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 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.
+// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
+// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
+// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
+// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
+// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
+// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
+// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
+// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+
+// SDL
+// (the multi-viewports feature requires SDL features supported from SDL 2.0.5+)
+#include
+#include
+#define SDL_HAS_WARP_MOUSE_GLOBAL SDL_VERSION_ATLEAST(2,0,4)
+
+#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4)
+#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
+#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5)
+#if !SDL_HAS_VULKAN
+static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
+#endif
+
+// Data
+static SDL_Window* g_Window = NULL;
+static Uint64 g_Time = 0;
+static bool g_MousePressed[3] = { false, false, false };
+static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
+static char* g_ClipboardTextData = NULL;
+
+static const char* ImGui_ImplSDL2_GetClipboardText(void*)
+{
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+ g_ClipboardTextData = SDL_GetClipboardText();
+ return g_ClipboardTextData;
+}
+
+static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
+{
+ SDL_SetClipboardText(text);
+}
+
+// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
+// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
+// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
+// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
+bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ switch (event->type)
+ {
+ case SDL_MOUSEWHEEL:
+ {
+ if (event->wheel.x > 0) io.MouseWheelH += 1;
+ if (event->wheel.x < 0) io.MouseWheelH -= 1;
+ if (event->wheel.y > 0) io.MouseWheel += 1;
+ if (event->wheel.y < 0) io.MouseWheel -= 1;
+ return true;
+ }
+ case SDL_MOUSEBUTTONDOWN:
+ {
+ if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
+ if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
+ if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
+ return true;
+ }
+ case SDL_TEXTINPUT:
+ {
+ io.AddInputCharactersUTF8(event->text.text);
+ return true;
+ }
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+ {
+ int key = event->key.keysym.scancode;
+ IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
+ io.KeysDown[key] = (event->type == SDL_KEYDOWN);
+ io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
+ io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
+ io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
+ io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool ImGui_ImplSDL2_Init(SDL_Window* window)
+{
+ g_Window = window;
+
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+#if SDL_HAS_WARP_MOUSE_GLOBAL
+ io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
+#endif
+
+ // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
+ io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
+ io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
+ io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
+ io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
+ io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
+ io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
+ io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
+ io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
+ io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
+ io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
+ io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
+ io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
+ io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
+ io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
+
+ io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
+ io.ClipboardUserData = NULL;
+
+ g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
+ g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
+ g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
+ g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
+
+#ifdef _WIN32
+ SDL_SysWMinfo wmInfo;
+ SDL_VERSION(&wmInfo.version);
+ SDL_GetWindowWMInfo(window, &wmInfo);
+ io.ImeWindowHandle = wmInfo.info.win.window;
+#else
+ (void)window;
+#endif
+
+ return true;
+}
+
+bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
+{
+ (void)sdl_gl_context; // Viewport branch will need this.
+ return ImGui_ImplSDL2_Init(window);
+}
+
+bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
+{
+ #if !SDL_HAS_VULKAN
+ IM_ASSERT(0 && "Unsupported");
+ #endif
+ return ImGui_ImplSDL2_Init(window);
+}
+
+void ImGui_ImplSDL2_Shutdown()
+{
+ g_Window = NULL;
+
+ // Destroy last known clipboard data
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+
+ // Destroy SDL mouse cursors
+ for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
+ SDL_FreeCursor(g_MouseCursors[cursor_n]);
+ memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
+}
+
+static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ const ImVec2 mouse_pos_backup = io.MousePos;
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+
+ // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
+ // (When multi-viewports are enabled, all imgui positions are same as OS positions.)
+#if SDL_HAS_WARP_MOUSE_GLOBAL
+ if (io.WantSetMousePos)
+ SDL_WarpMouseGlobal((int)mouse_pos_backup.x, (int)mouse_pos_backup.y);
+#endif
+
+ int mx, my;
+ Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
+ io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
+ io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
+ g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
+
+#if SDL_HAS_CAPTURE_MOUSE
+ SDL_Window* focused_window = SDL_GetKeyboardFocus();
+ if (g_Window == focused_window)
+ {
+ // SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
+ // The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
+ int wx, wy;
+ SDL_GetWindowPosition(focused_window, &wx, &wy);
+ SDL_GetGlobalMouseState(&mx, &my);
+ mx -= wx;
+ my -= wy;
+ io.MousePos = ImVec2((float)mx, (float)my);
+ }
+
+ // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger the OS window resize cursor.
+ // The function is only supported from SDL 2.0.4 (released Jan 2016)
+ bool any_mouse_button_down = ImGui::IsAnyMouseDown();
+ SDL_CaptureMouse(any_mouse_button_down ? SDL_TRUE : SDL_FALSE);
+#else
+ if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS)
+ io.MousePos = ImVec2((float)mx, (float)my);
+#endif
+}
+
+static void ImGui_ImplSDL2_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
+ return;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ SDL_ShowCursor(SDL_FALSE);
+ }
+ else
+ {
+ // Show OS mouse cursor
+ SDL_SetCursor(g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
+ SDL_ShowCursor(SDL_TRUE);
+ }
+}
+
+void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_ASSERT(io.Fonts->IsBuilt()); // Font atlas needs to be built, call renderer _NewFrame() function e.g. ImGui_ImplOpenGL3_NewFrame()
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ SDL_GetWindowSize(window, &w, &h);
+ SDL_GL_GetDrawableSize(window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
+ static Uint64 frequency = SDL_GetPerformanceFrequency();
+ Uint64 current_time = SDL_GetPerformanceCounter();
+ io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
+ g_Time = current_time;
+
+ ImGui_ImplSDL2_UpdateMousePosAndButtons();
+ ImGui_ImplSDL2_UpdateMouseCursor();
+}
diff --git a/examples/imgui_impl_sdl.h b/examples/imgui_impl_sdl.h
new file mode 100644
index 0000000..15aac59
--- /dev/null
+++ b/examples/imgui_impl_sdl.h
@@ -0,0 +1,20 @@
+// ImGui Platform Binding for: SDL2
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
+
+// Missing features:
+// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct SDL_Window;
+typedef union SDL_Event SDL_Event;
+
+IMGUI_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
+IMGUI_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
+IMGUI_API void ImGui_ImplSDL2_Shutdown();
+IMGUI_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
+IMGUI_API bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event);
diff --git a/examples/imgui_impl_sdl2.cpp b/examples/imgui_impl_sdl2.cpp
deleted file mode 100644
index 8182988..0000000
--- a/examples/imgui_impl_sdl2.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-// ImGui Platform Binding for: SDL2
-// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
-// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
-
-// Missing features:
-// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-// 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: 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.
-// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
-// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
-// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
-// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
-// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
-// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
-// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
-// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
-
-#include "imgui.h"
-#include "imgui_impl_sdl2.h"
-
-// SDL
-// (the multi-viewports feature requires SDL features supported from SDL 2.0.5+)
-#include
-#include
-#define SDL_HAS_WARP_MOUSE_GLOBAL SDL_VERSION_ATLEAST(2,0,4)
-
-#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4)
-#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
-#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5)
-#if !SDL_HAS_VULKAN
-static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
-#endif
-
-// Data
-static SDL_Window* g_Window = NULL;
-static Uint64 g_Time = 0;
-static bool g_MousePressed[3] = { false, false, false };
-static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
-static char* g_ClipboardTextData = NULL;
-
-static const char* ImGui_ImplSDL2_GetClipboardText(void*)
-{
- if (g_ClipboardTextData)
- SDL_free(g_ClipboardTextData);
- g_ClipboardTextData = SDL_GetClipboardText();
- return g_ClipboardTextData;
-}
-
-static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
-{
- SDL_SetClipboardText(text);
-}
-
-// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
-// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
-// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
-// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
-bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event)
-{
- ImGuiIO& io = ImGui::GetIO();
- switch (event->type)
- {
- case SDL_MOUSEWHEEL:
- {
- if (event->wheel.x > 0) io.MouseWheelH += 1;
- if (event->wheel.x < 0) io.MouseWheelH -= 1;
- if (event->wheel.y > 0) io.MouseWheel += 1;
- if (event->wheel.y < 0) io.MouseWheel -= 1;
- return true;
- }
- case SDL_MOUSEBUTTONDOWN:
- {
- if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
- if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
- if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
- return true;
- }
- case SDL_TEXTINPUT:
- {
- io.AddInputCharactersUTF8(event->text.text);
- return true;
- }
- case SDL_KEYDOWN:
- case SDL_KEYUP:
- {
- int key = event->key.keysym.scancode;
- IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
- io.KeysDown[key] = (event->type == SDL_KEYDOWN);
- io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
- io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
- io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
- io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
- return true;
- }
- }
- return false;
-}
-
-static bool ImGui_ImplSDL2_Init(SDL_Window* window)
-{
- g_Window = window;
-
- // Setup back-end capabilities flags
- ImGuiIO& io = ImGui::GetIO();
- io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
-#if SDL_HAS_WARP_MOUSE_GLOBAL
- io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
-#endif
-
- // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
- io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
- io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
- io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
- io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
- io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
- io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
- io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
- io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
- io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
- io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
- io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
- io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
- io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
- io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
- io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
- io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
- io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
-
- io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
- io.ClipboardUserData = NULL;
-
- g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
- g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
- g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
- g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
- g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
- g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
- g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
-
-#ifdef _WIN32
- SDL_SysWMinfo wmInfo;
- SDL_VERSION(&wmInfo.version);
- SDL_GetWindowWMInfo(window, &wmInfo);
- io.ImeWindowHandle = wmInfo.info.win.window;
-#else
- (void)window;
-#endif
-
- return true;
-}
-
-bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
-{
- (void)sdl_gl_context; // Viewport branch will need this.
- return ImGui_ImplSDL2_Init(window);
-}
-
-bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
-{
- #if !SDL_HAS_VULKAN
- IM_ASSERT(0 && "Unsupported");
- #endif
- return ImGui_ImplSDL2_Init(window);
-}
-
-void ImGui_ImplSDL2_Shutdown()
-{
- g_Window = NULL;
-
- // Destroy last known clipboard data
- if (g_ClipboardTextData)
- SDL_free(g_ClipboardTextData);
-
- // Destroy SDL mouse cursors
- for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
- SDL_FreeCursor(g_MouseCursors[cursor_n]);
- memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
-}
-
-static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
-{
- ImGuiIO& io = ImGui::GetIO();
- const ImVec2 mouse_pos_backup = io.MousePos;
- io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
-
- // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
- // (When multi-viewports are enabled, all imgui positions are same as OS positions.)
-#if SDL_HAS_WARP_MOUSE_GLOBAL
- if (io.WantSetMousePos)
- SDL_WarpMouseGlobal((int)mouse_pos_backup.x, (int)mouse_pos_backup.y);
-#endif
-
- int mx, my;
- Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
- io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
- io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
- g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
-
-#if SDL_HAS_CAPTURE_MOUSE
- SDL_Window* focused_window = SDL_GetKeyboardFocus();
- if (g_Window == focused_window)
- {
- // SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
- // The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
- int wx, wy;
- SDL_GetWindowPosition(focused_window, &wx, &wy);
- SDL_GetGlobalMouseState(&mx, &my);
- mx -= wx;
- my -= wy;
- io.MousePos = ImVec2((float)mx, (float)my);
- }
-
- // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger the OS window resize cursor.
- // The function is only supported from SDL 2.0.4 (released Jan 2016)
- bool any_mouse_button_down = ImGui::IsAnyMouseDown();
- SDL_CaptureMouse(any_mouse_button_down ? SDL_TRUE : SDL_FALSE);
-#else
- if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS)
- io.MousePos = ImVec2((float)mx, (float)my);
-#endif
-}
-
-static void ImGui_ImplSDL2_UpdateMouseCursor()
-{
- ImGuiIO& io = ImGui::GetIO();
- if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
- return;
-
- ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
- if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
- {
- // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
- SDL_ShowCursor(SDL_FALSE);
- }
- else
- {
- // Show OS mouse cursor
- SDL_SetCursor(g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
- SDL_ShowCursor(SDL_TRUE);
- }
-}
-
-void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
-{
- ImGuiIO& io = ImGui::GetIO();
- IM_ASSERT(io.Fonts->IsBuilt()); // Font atlas needs to be built, call renderer _NewFrame() function e.g. ImGui_ImplOpenGL3_NewFrame()
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- SDL_GetWindowSize(window, &w, &h);
- SDL_GL_GetDrawableSize(window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
- static Uint64 frequency = SDL_GetPerformanceFrequency();
- Uint64 current_time = SDL_GetPerformanceCounter();
- io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
- g_Time = current_time;
-
- ImGui_ImplSDL2_UpdateMousePosAndButtons();
- ImGui_ImplSDL2_UpdateMouseCursor();
-}
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 8a3d06a..83a4b88 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -39,19 +39,30 @@
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 ecc9db1..61a496f 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -65,7 +65,7 @@
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 @@
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 @@
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 8f008b8..a295ac2 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 6d4ce25..a8bfc88 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 0493a72..bc2eb3b 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 e6d3e79..bdec85b 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 f129cc2..602fa0b 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 10e9d31..5a4dbd4 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 d2f71f6..fb826cb 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 8a7741e..3de6666 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 c0403d3..d2cfa67 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 3753cac..b194e62 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 93d321a..87ae431 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 03d8243..57cd0ad 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 42146cd..3d2a424 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 35e8aa1..4f7c792 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 6ebecf2..2b8b104 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_sdl.cpp b/examples/imgui_impl_sdl.cpp
new file mode 100644
index 0000000..457734d
--- /dev/null
+++ b/examples/imgui_impl_sdl.cpp
@@ -0,0 +1,282 @@
+// ImGui Platform Binding for: SDL2
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
+
+// Missing features:
+// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 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.
+// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
+// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
+// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
+// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
+// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
+// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
+// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
+// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+
+// SDL
+// (the multi-viewports feature requires SDL features supported from SDL 2.0.5+)
+#include
+#include
+#define SDL_HAS_WARP_MOUSE_GLOBAL SDL_VERSION_ATLEAST(2,0,4)
+
+#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4)
+#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
+#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5)
+#if !SDL_HAS_VULKAN
+static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
+#endif
+
+// Data
+static SDL_Window* g_Window = NULL;
+static Uint64 g_Time = 0;
+static bool g_MousePressed[3] = { false, false, false };
+static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
+static char* g_ClipboardTextData = NULL;
+
+static const char* ImGui_ImplSDL2_GetClipboardText(void*)
+{
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+ g_ClipboardTextData = SDL_GetClipboardText();
+ return g_ClipboardTextData;
+}
+
+static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
+{
+ SDL_SetClipboardText(text);
+}
+
+// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
+// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
+// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
+// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
+bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ switch (event->type)
+ {
+ case SDL_MOUSEWHEEL:
+ {
+ if (event->wheel.x > 0) io.MouseWheelH += 1;
+ if (event->wheel.x < 0) io.MouseWheelH -= 1;
+ if (event->wheel.y > 0) io.MouseWheel += 1;
+ if (event->wheel.y < 0) io.MouseWheel -= 1;
+ return true;
+ }
+ case SDL_MOUSEBUTTONDOWN:
+ {
+ if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
+ if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
+ if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
+ return true;
+ }
+ case SDL_TEXTINPUT:
+ {
+ io.AddInputCharactersUTF8(event->text.text);
+ return true;
+ }
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+ {
+ int key = event->key.keysym.scancode;
+ IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
+ io.KeysDown[key] = (event->type == SDL_KEYDOWN);
+ io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
+ io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
+ io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
+ io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool ImGui_ImplSDL2_Init(SDL_Window* window)
+{
+ g_Window = window;
+
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+#if SDL_HAS_WARP_MOUSE_GLOBAL
+ io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
+#endif
+
+ // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
+ io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
+ io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
+ io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
+ io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
+ io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
+ io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
+ io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
+ io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
+ io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
+ io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
+ io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
+ io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
+ io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
+ io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
+
+ io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
+ io.ClipboardUserData = NULL;
+
+ g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
+ g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
+ g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
+ g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
+
+#ifdef _WIN32
+ SDL_SysWMinfo wmInfo;
+ SDL_VERSION(&wmInfo.version);
+ SDL_GetWindowWMInfo(window, &wmInfo);
+ io.ImeWindowHandle = wmInfo.info.win.window;
+#else
+ (void)window;
+#endif
+
+ return true;
+}
+
+bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
+{
+ (void)sdl_gl_context; // Viewport branch will need this.
+ return ImGui_ImplSDL2_Init(window);
+}
+
+bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
+{
+ #if !SDL_HAS_VULKAN
+ IM_ASSERT(0 && "Unsupported");
+ #endif
+ return ImGui_ImplSDL2_Init(window);
+}
+
+void ImGui_ImplSDL2_Shutdown()
+{
+ g_Window = NULL;
+
+ // Destroy last known clipboard data
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+
+ // Destroy SDL mouse cursors
+ for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
+ SDL_FreeCursor(g_MouseCursors[cursor_n]);
+ memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
+}
+
+static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ const ImVec2 mouse_pos_backup = io.MousePos;
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+
+ // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
+ // (When multi-viewports are enabled, all imgui positions are same as OS positions.)
+#if SDL_HAS_WARP_MOUSE_GLOBAL
+ if (io.WantSetMousePos)
+ SDL_WarpMouseGlobal((int)mouse_pos_backup.x, (int)mouse_pos_backup.y);
+#endif
+
+ int mx, my;
+ Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
+ io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
+ io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
+ g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
+
+#if SDL_HAS_CAPTURE_MOUSE
+ SDL_Window* focused_window = SDL_GetKeyboardFocus();
+ if (g_Window == focused_window)
+ {
+ // SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
+ // The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
+ int wx, wy;
+ SDL_GetWindowPosition(focused_window, &wx, &wy);
+ SDL_GetGlobalMouseState(&mx, &my);
+ mx -= wx;
+ my -= wy;
+ io.MousePos = ImVec2((float)mx, (float)my);
+ }
+
+ // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger the OS window resize cursor.
+ // The function is only supported from SDL 2.0.4 (released Jan 2016)
+ bool any_mouse_button_down = ImGui::IsAnyMouseDown();
+ SDL_CaptureMouse(any_mouse_button_down ? SDL_TRUE : SDL_FALSE);
+#else
+ if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS)
+ io.MousePos = ImVec2((float)mx, (float)my);
+#endif
+}
+
+static void ImGui_ImplSDL2_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
+ return;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ SDL_ShowCursor(SDL_FALSE);
+ }
+ else
+ {
+ // Show OS mouse cursor
+ SDL_SetCursor(g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
+ SDL_ShowCursor(SDL_TRUE);
+ }
+}
+
+void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_ASSERT(io.Fonts->IsBuilt()); // Font atlas needs to be built, call renderer _NewFrame() function e.g. ImGui_ImplOpenGL3_NewFrame()
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ SDL_GetWindowSize(window, &w, &h);
+ SDL_GL_GetDrawableSize(window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
+ static Uint64 frequency = SDL_GetPerformanceFrequency();
+ Uint64 current_time = SDL_GetPerformanceCounter();
+ io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
+ g_Time = current_time;
+
+ ImGui_ImplSDL2_UpdateMousePosAndButtons();
+ ImGui_ImplSDL2_UpdateMouseCursor();
+}
diff --git a/examples/imgui_impl_sdl.h b/examples/imgui_impl_sdl.h
new file mode 100644
index 0000000..15aac59
--- /dev/null
+++ b/examples/imgui_impl_sdl.h
@@ -0,0 +1,20 @@
+// ImGui Platform Binding for: SDL2
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
+
+// Missing features:
+// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
+// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+struct SDL_Window;
+typedef union SDL_Event SDL_Event;
+
+IMGUI_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
+IMGUI_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
+IMGUI_API void ImGui_ImplSDL2_Shutdown();
+IMGUI_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
+IMGUI_API bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event);
diff --git a/examples/imgui_impl_sdl2.cpp b/examples/imgui_impl_sdl2.cpp
deleted file mode 100644
index 8182988..0000000
--- a/examples/imgui_impl_sdl2.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-// ImGui Platform Binding for: SDL2
-// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
-// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
-
-// Missing features:
-// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-// 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: 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.
-// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
-// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
-// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
-// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
-// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
-// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
-// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
-// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
-
-#include "imgui.h"
-#include "imgui_impl_sdl2.h"
-
-// SDL
-// (the multi-viewports feature requires SDL features supported from SDL 2.0.5+)
-#include
-#include
-#define SDL_HAS_WARP_MOUSE_GLOBAL SDL_VERSION_ATLEAST(2,0,4)
-
-#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4)
-#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
-#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5)
-#if !SDL_HAS_VULKAN
-static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
-#endif
-
-// Data
-static SDL_Window* g_Window = NULL;
-static Uint64 g_Time = 0;
-static bool g_MousePressed[3] = { false, false, false };
-static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
-static char* g_ClipboardTextData = NULL;
-
-static const char* ImGui_ImplSDL2_GetClipboardText(void*)
-{
- if (g_ClipboardTextData)
- SDL_free(g_ClipboardTextData);
- g_ClipboardTextData = SDL_GetClipboardText();
- return g_ClipboardTextData;
-}
-
-static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
-{
- SDL_SetClipboardText(text);
-}
-
-// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
-// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
-// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
-// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
-bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event)
-{
- ImGuiIO& io = ImGui::GetIO();
- switch (event->type)
- {
- case SDL_MOUSEWHEEL:
- {
- if (event->wheel.x > 0) io.MouseWheelH += 1;
- if (event->wheel.x < 0) io.MouseWheelH -= 1;
- if (event->wheel.y > 0) io.MouseWheel += 1;
- if (event->wheel.y < 0) io.MouseWheel -= 1;
- return true;
- }
- case SDL_MOUSEBUTTONDOWN:
- {
- if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
- if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
- if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
- return true;
- }
- case SDL_TEXTINPUT:
- {
- io.AddInputCharactersUTF8(event->text.text);
- return true;
- }
- case SDL_KEYDOWN:
- case SDL_KEYUP:
- {
- int key = event->key.keysym.scancode;
- IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
- io.KeysDown[key] = (event->type == SDL_KEYDOWN);
- io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
- io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
- io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
- io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
- return true;
- }
- }
- return false;
-}
-
-static bool ImGui_ImplSDL2_Init(SDL_Window* window)
-{
- g_Window = window;
-
- // Setup back-end capabilities flags
- ImGuiIO& io = ImGui::GetIO();
- io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
-#if SDL_HAS_WARP_MOUSE_GLOBAL
- io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
-#endif
-
- // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
- io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
- io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
- io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
- io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
- io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
- io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
- io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
- io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
- io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
- io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
- io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
- io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
- io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
- io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
- io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
- io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
- io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
-
- io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
- io.ClipboardUserData = NULL;
-
- g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
- g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
- g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
- g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
- g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
- g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
- g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
-
-#ifdef _WIN32
- SDL_SysWMinfo wmInfo;
- SDL_VERSION(&wmInfo.version);
- SDL_GetWindowWMInfo(window, &wmInfo);
- io.ImeWindowHandle = wmInfo.info.win.window;
-#else
- (void)window;
-#endif
-
- return true;
-}
-
-bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
-{
- (void)sdl_gl_context; // Viewport branch will need this.
- return ImGui_ImplSDL2_Init(window);
-}
-
-bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
-{
- #if !SDL_HAS_VULKAN
- IM_ASSERT(0 && "Unsupported");
- #endif
- return ImGui_ImplSDL2_Init(window);
-}
-
-void ImGui_ImplSDL2_Shutdown()
-{
- g_Window = NULL;
-
- // Destroy last known clipboard data
- if (g_ClipboardTextData)
- SDL_free(g_ClipboardTextData);
-
- // Destroy SDL mouse cursors
- for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
- SDL_FreeCursor(g_MouseCursors[cursor_n]);
- memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
-}
-
-static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
-{
- ImGuiIO& io = ImGui::GetIO();
- const ImVec2 mouse_pos_backup = io.MousePos;
- io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
-
- // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
- // (When multi-viewports are enabled, all imgui positions are same as OS positions.)
-#if SDL_HAS_WARP_MOUSE_GLOBAL
- if (io.WantSetMousePos)
- SDL_WarpMouseGlobal((int)mouse_pos_backup.x, (int)mouse_pos_backup.y);
-#endif
-
- int mx, my;
- Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
- io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
- io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
- g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
-
-#if SDL_HAS_CAPTURE_MOUSE
- SDL_Window* focused_window = SDL_GetKeyboardFocus();
- if (g_Window == focused_window)
- {
- // SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
- // The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
- int wx, wy;
- SDL_GetWindowPosition(focused_window, &wx, &wy);
- SDL_GetGlobalMouseState(&mx, &my);
- mx -= wx;
- my -= wy;
- io.MousePos = ImVec2((float)mx, (float)my);
- }
-
- // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger the OS window resize cursor.
- // The function is only supported from SDL 2.0.4 (released Jan 2016)
- bool any_mouse_button_down = ImGui::IsAnyMouseDown();
- SDL_CaptureMouse(any_mouse_button_down ? SDL_TRUE : SDL_FALSE);
-#else
- if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS)
- io.MousePos = ImVec2((float)mx, (float)my);
-#endif
-}
-
-static void ImGui_ImplSDL2_UpdateMouseCursor()
-{
- ImGuiIO& io = ImGui::GetIO();
- if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
- return;
-
- ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
- if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
- {
- // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
- SDL_ShowCursor(SDL_FALSE);
- }
- else
- {
- // Show OS mouse cursor
- SDL_SetCursor(g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
- SDL_ShowCursor(SDL_TRUE);
- }
-}
-
-void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
-{
- ImGuiIO& io = ImGui::GetIO();
- IM_ASSERT(io.Fonts->IsBuilt()); // Font atlas needs to be built, call renderer _NewFrame() function e.g. ImGui_ImplOpenGL3_NewFrame()
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- SDL_GetWindowSize(window, &w, &h);
- SDL_GL_GetDrawableSize(window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
- static Uint64 frequency = SDL_GetPerformanceFrequency();
- Uint64 current_time = SDL_GetPerformanceCounter();
- io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
- g_Time = current_time;
-
- ImGui_ImplSDL2_UpdateMousePosAndButtons();
- ImGui_ImplSDL2_UpdateMouseCursor();
-}
diff --git a/examples/imgui_impl_sdl2.h b/examples/imgui_impl_sdl2.h
deleted file mode 100644
index 15aac59..0000000
--- a/examples/imgui_impl_sdl2.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// ImGui Platform Binding for: SDL2
-// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
-// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
-
-// Missing features:
-// [ ] SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct SDL_Window;
-typedef union SDL_Event SDL_Event;
-
-IMGUI_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
-IMGUI_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
-IMGUI_API void ImGui_ImplSDL2_Shutdown();
-IMGUI_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
-IMGUI_API bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event);