diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp
deleted file mode 100644
index 32671a6..0000000
--- a/examples/imgui_impl_freeglut.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the 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)
-// 2019-03-25: Misc: Made io.DeltaTime always above zero.
-// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
-// 2018-03-22: Added FreeGLUT Platform binding.
-
-#include "imgui.h"
-#include "imgui_impl_freeglut.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
-#endif
-
-static int g_Time = 0; // Current time, in milliseconds
-
-bool ImGui_ImplFreeGLUT_Init()
-{
- ImGuiIO& io = ImGui::GetIO();
- io.BackendPlatformName ="imgui_impl_freeglut";
-
- g_Time = 0;
-
- // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
- io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
- io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = 127;
- io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
- io.KeyMap[ImGuiKey_Space] = ' ';
- io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
- io.KeyMap[ImGuiKey_Escape] = 27;
- io.KeyMap[ImGuiKey_A] = 'A';
- io.KeyMap[ImGuiKey_C] = 'C';
- io.KeyMap[ImGuiKey_V] = 'V';
- io.KeyMap[ImGuiKey_X] = 'X';
- io.KeyMap[ImGuiKey_Y] = 'Y';
- io.KeyMap[ImGuiKey_Z] = 'Z';
-
- return true;
-}
-
-void ImGui_ImplFreeGLUT_InstallFuncs()
-{
- glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
- glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
- glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
- glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
- glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
- glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
- glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
-}
-
-void ImGui_ImplFreeGLUT_Shutdown()
-{
-}
-
-void ImGui_ImplFreeGLUT_NewFrame()
-{
- // Setup time step
- ImGuiIO& io = ImGui::GetIO();
- int current_time = glutGet(GLUT_ELAPSED_TIME);
- int delta_time_ms = (current_time - g_Time);
- if (delta_time_ms <= 0)
- delta_time_ms = 1;
- io.DeltaTime = delta_time_ms / 1000.0f;
- g_Time = current_time;
-
- // Start the frame
- ImGui::NewFrame();
-}
-
-static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
-{
- ImGuiIO& io = ImGui::GetIO();
- int mods = glutGetModifiers();
- io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
- io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
- io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
-}
-
-void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
-{
- // Send character to imgui
- //printf("char_down_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 32)
- io.AddInputCharacter((unsigned short)c);
-
- // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
- // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
- else
- io.KeysDown[c] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
-{
- //printf("char_up_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
- else
- io.KeysDown[c] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
-{
- //printf("key_down_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
-{
- //printf("key_up_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- int button = -1;
- if (glut_button == GLUT_LEFT_BUTTON) button = 0;
- if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
- if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
- if (button != -1 && state == GLUT_DOWN)
- io.MouseDown[button] = true;
- if (button != -1 && state == GLUT_UP)
- io.MouseDown[button] = false;
-}
-
-void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- if (dir > 0)
- io.MouseWheel += 1.0;
- else if (dir < 0)
- io.MouseWheel -= 1.0;
- (void)button; // Unused
-}
-
-void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize = ImVec2((float)w, (float)h);
-}
-
-void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
-}
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp
deleted file mode 100644
index 32671a6..0000000
--- a/examples/imgui_impl_freeglut.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the 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)
-// 2019-03-25: Misc: Made io.DeltaTime always above zero.
-// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
-// 2018-03-22: Added FreeGLUT Platform binding.
-
-#include "imgui.h"
-#include "imgui_impl_freeglut.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
-#endif
-
-static int g_Time = 0; // Current time, in milliseconds
-
-bool ImGui_ImplFreeGLUT_Init()
-{
- ImGuiIO& io = ImGui::GetIO();
- io.BackendPlatformName ="imgui_impl_freeglut";
-
- g_Time = 0;
-
- // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
- io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
- io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = 127;
- io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
- io.KeyMap[ImGuiKey_Space] = ' ';
- io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
- io.KeyMap[ImGuiKey_Escape] = 27;
- io.KeyMap[ImGuiKey_A] = 'A';
- io.KeyMap[ImGuiKey_C] = 'C';
- io.KeyMap[ImGuiKey_V] = 'V';
- io.KeyMap[ImGuiKey_X] = 'X';
- io.KeyMap[ImGuiKey_Y] = 'Y';
- io.KeyMap[ImGuiKey_Z] = 'Z';
-
- return true;
-}
-
-void ImGui_ImplFreeGLUT_InstallFuncs()
-{
- glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
- glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
- glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
- glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
- glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
- glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
- glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
-}
-
-void ImGui_ImplFreeGLUT_Shutdown()
-{
-}
-
-void ImGui_ImplFreeGLUT_NewFrame()
-{
- // Setup time step
- ImGuiIO& io = ImGui::GetIO();
- int current_time = glutGet(GLUT_ELAPSED_TIME);
- int delta_time_ms = (current_time - g_Time);
- if (delta_time_ms <= 0)
- delta_time_ms = 1;
- io.DeltaTime = delta_time_ms / 1000.0f;
- g_Time = current_time;
-
- // Start the frame
- ImGui::NewFrame();
-}
-
-static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
-{
- ImGuiIO& io = ImGui::GetIO();
- int mods = glutGetModifiers();
- io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
- io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
- io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
-}
-
-void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
-{
- // Send character to imgui
- //printf("char_down_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 32)
- io.AddInputCharacter((unsigned short)c);
-
- // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
- // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
- else
- io.KeysDown[c] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
-{
- //printf("char_up_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
- else
- io.KeysDown[c] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
-{
- //printf("key_down_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
-{
- //printf("key_up_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- int button = -1;
- if (glut_button == GLUT_LEFT_BUTTON) button = 0;
- if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
- if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
- if (button != -1 && state == GLUT_DOWN)
- io.MouseDown[button] = true;
- if (button != -1 && state == GLUT_UP)
- io.MouseDown[button] = false;
-}
-
-void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- if (dir > 0)
- io.MouseWheel += 1.0;
- else if (dir < 0)
- io.MouseWheel -= 1.0;
- (void)button; // Unused
-}
-
-void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize = ImVec2((float)w, (float)h);
-}
-
-void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
-}
diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h
deleted file mode 100644
index 6d565ec..0000000
--- a/examples/imgui_impl_freeglut.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#pragma once
-
-IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_InstallFuncs();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_Shutdown();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_NewFrame();
-
-// You can call ImGui_ImplFreeGLUT_InstallFuncs() to get all those functions installed automatically,
-// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
-//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp
deleted file mode 100644
index 32671a6..0000000
--- a/examples/imgui_impl_freeglut.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the 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)
-// 2019-03-25: Misc: Made io.DeltaTime always above zero.
-// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
-// 2018-03-22: Added FreeGLUT Platform binding.
-
-#include "imgui.h"
-#include "imgui_impl_freeglut.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
-#endif
-
-static int g_Time = 0; // Current time, in milliseconds
-
-bool ImGui_ImplFreeGLUT_Init()
-{
- ImGuiIO& io = ImGui::GetIO();
- io.BackendPlatformName ="imgui_impl_freeglut";
-
- g_Time = 0;
-
- // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
- io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
- io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = 127;
- io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
- io.KeyMap[ImGuiKey_Space] = ' ';
- io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
- io.KeyMap[ImGuiKey_Escape] = 27;
- io.KeyMap[ImGuiKey_A] = 'A';
- io.KeyMap[ImGuiKey_C] = 'C';
- io.KeyMap[ImGuiKey_V] = 'V';
- io.KeyMap[ImGuiKey_X] = 'X';
- io.KeyMap[ImGuiKey_Y] = 'Y';
- io.KeyMap[ImGuiKey_Z] = 'Z';
-
- return true;
-}
-
-void ImGui_ImplFreeGLUT_InstallFuncs()
-{
- glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
- glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
- glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
- glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
- glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
- glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
- glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
-}
-
-void ImGui_ImplFreeGLUT_Shutdown()
-{
-}
-
-void ImGui_ImplFreeGLUT_NewFrame()
-{
- // Setup time step
- ImGuiIO& io = ImGui::GetIO();
- int current_time = glutGet(GLUT_ELAPSED_TIME);
- int delta_time_ms = (current_time - g_Time);
- if (delta_time_ms <= 0)
- delta_time_ms = 1;
- io.DeltaTime = delta_time_ms / 1000.0f;
- g_Time = current_time;
-
- // Start the frame
- ImGui::NewFrame();
-}
-
-static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
-{
- ImGuiIO& io = ImGui::GetIO();
- int mods = glutGetModifiers();
- io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
- io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
- io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
-}
-
-void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
-{
- // Send character to imgui
- //printf("char_down_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 32)
- io.AddInputCharacter((unsigned short)c);
-
- // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
- // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
- else
- io.KeysDown[c] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
-{
- //printf("char_up_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
- else
- io.KeysDown[c] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
-{
- //printf("key_down_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
-{
- //printf("key_up_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- int button = -1;
- if (glut_button == GLUT_LEFT_BUTTON) button = 0;
- if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
- if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
- if (button != -1 && state == GLUT_DOWN)
- io.MouseDown[button] = true;
- if (button != -1 && state == GLUT_UP)
- io.MouseDown[button] = false;
-}
-
-void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- if (dir > 0)
- io.MouseWheel += 1.0;
- else if (dir < 0)
- io.MouseWheel -= 1.0;
- (void)button; // Unused
-}
-
-void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize = ImVec2((float)w, (float)h);
-}
-
-void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
-}
diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h
deleted file mode 100644
index 6d565ec..0000000
--- a/examples/imgui_impl_freeglut.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#pragma once
-
-IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_InstallFuncs();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_Shutdown();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_NewFrame();
-
-// You can call ImGui_ImplFreeGLUT_InstallFuncs() to get all those functions installed automatically,
-// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
-//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_glut.cpp b/examples/imgui_impl_glut.cpp
new file mode 100644
index 0000000..d8bd749
--- /dev/null
+++ b/examples/imgui_impl_glut.cpp
@@ -0,0 +1,208 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the 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)
+// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
+// 2019-03-25: Misc: Made io.DeltaTime always above zero.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-03-22: Added GLUT Platform binding.
+
+#include "imgui.h"
+#include "imgui_impl_glut.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
+#endif
+
+static int g_Time = 0; // Current time, in milliseconds
+
+bool ImGui_ImplGLUT_Init()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendPlatformName ="imgui_impl_glut";
+
+ g_Time = 0;
+
+ // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
+ io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
+ io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = 127;
+ io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
+ io.KeyMap[ImGuiKey_Space] = ' ';
+ io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
+ io.KeyMap[ImGuiKey_Escape] = 27;
+ io.KeyMap[ImGuiKey_A] = 'A';
+ io.KeyMap[ImGuiKey_C] = 'C';
+ io.KeyMap[ImGuiKey_V] = 'V';
+ io.KeyMap[ImGuiKey_X] = 'X';
+ io.KeyMap[ImGuiKey_Y] = 'Y';
+ io.KeyMap[ImGuiKey_Z] = 'Z';
+
+ return true;
+}
+
+void ImGui_ImplGLUT_InstallFuncs()
+{
+ glutReshapeFunc(ImGui_ImplGLUT_ReshapeFunc);
+ glutMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutPassiveMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutMouseFunc(ImGui_ImplGLUT_MouseFunc);
+#ifdef __FREEGLUT_EXT_H__
+ glutMouseWheelFunc(ImGui_ImplGLUT_MouseWheelFunc);
+#endif
+ glutKeyboardFunc(ImGui_ImplGLUT_KeyboardFunc);
+ glutKeyboardUpFunc(ImGui_ImplGLUT_KeyboardUpFunc);
+ glutSpecialFunc(ImGui_ImplGLUT_SpecialFunc);
+ glutSpecialUpFunc(ImGui_ImplGLUT_SpecialUpFunc);
+}
+
+void ImGui_ImplGLUT_Shutdown()
+{
+}
+
+void ImGui_ImplGLUT_NewFrame()
+{
+ // Setup time step
+ ImGuiIO& io = ImGui::GetIO();
+ int current_time = glutGet(GLUT_ELAPSED_TIME);
+ int delta_time_ms = (current_time - g_Time);
+ if (delta_time_ms <= 0)
+ delta_time_ms = 1;
+ io.DeltaTime = delta_time_ms / 1000.0f;
+ g_Time = current_time;
+
+ // Start the frame
+ ImGui::NewFrame();
+}
+
+static void ImGui_ImplGLUT_UpdateKeyboardMods()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ int mods = glutGetModifiers();
+ io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
+ io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
+ io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
+}
+
+void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
+{
+ // Send character to imgui
+ //printf("char_down_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 32)
+ io.AddInputCharacter((unsigned short)c);
+
+ // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
+ // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
+ else
+ io.KeysDown[c] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
+{
+ //printf("char_up_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
+ else
+ io.KeysDown[c] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
+{
+ //printf("key_down_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
+{
+ //printf("key_up_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ int button = -1;
+ if (glut_button == GLUT_LEFT_BUTTON) button = 0;
+ if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
+ if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
+ if (button != -1 && state == GLUT_DOWN)
+ io.MouseDown[button] = true;
+ if (button != -1 && state == GLUT_UP)
+ io.MouseDown[button] = false;
+}
+
+#ifdef __FREEGLUT_EXT_H__
+void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ if (dir > 0)
+ io.MouseWheel += 1.0;
+ else if (dir < 0)
+ io.MouseWheel -= 1.0;
+ (void)button; // Unused
+}
+#endif
+
+void ImGui_ImplGLUT_ReshapeFunc(int w, int h)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.DisplaySize = ImVec2((float)w, (float)h);
+}
+
+void ImGui_ImplGLUT_MotionFunc(int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+}
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp
deleted file mode 100644
index 32671a6..0000000
--- a/examples/imgui_impl_freeglut.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the 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)
-// 2019-03-25: Misc: Made io.DeltaTime always above zero.
-// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
-// 2018-03-22: Added FreeGLUT Platform binding.
-
-#include "imgui.h"
-#include "imgui_impl_freeglut.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
-#endif
-
-static int g_Time = 0; // Current time, in milliseconds
-
-bool ImGui_ImplFreeGLUT_Init()
-{
- ImGuiIO& io = ImGui::GetIO();
- io.BackendPlatformName ="imgui_impl_freeglut";
-
- g_Time = 0;
-
- // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
- io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
- io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = 127;
- io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
- io.KeyMap[ImGuiKey_Space] = ' ';
- io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
- io.KeyMap[ImGuiKey_Escape] = 27;
- io.KeyMap[ImGuiKey_A] = 'A';
- io.KeyMap[ImGuiKey_C] = 'C';
- io.KeyMap[ImGuiKey_V] = 'V';
- io.KeyMap[ImGuiKey_X] = 'X';
- io.KeyMap[ImGuiKey_Y] = 'Y';
- io.KeyMap[ImGuiKey_Z] = 'Z';
-
- return true;
-}
-
-void ImGui_ImplFreeGLUT_InstallFuncs()
-{
- glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
- glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
- glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
- glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
- glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
- glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
- glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
-}
-
-void ImGui_ImplFreeGLUT_Shutdown()
-{
-}
-
-void ImGui_ImplFreeGLUT_NewFrame()
-{
- // Setup time step
- ImGuiIO& io = ImGui::GetIO();
- int current_time = glutGet(GLUT_ELAPSED_TIME);
- int delta_time_ms = (current_time - g_Time);
- if (delta_time_ms <= 0)
- delta_time_ms = 1;
- io.DeltaTime = delta_time_ms / 1000.0f;
- g_Time = current_time;
-
- // Start the frame
- ImGui::NewFrame();
-}
-
-static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
-{
- ImGuiIO& io = ImGui::GetIO();
- int mods = glutGetModifiers();
- io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
- io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
- io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
-}
-
-void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
-{
- // Send character to imgui
- //printf("char_down_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 32)
- io.AddInputCharacter((unsigned short)c);
-
- // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
- // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
- else
- io.KeysDown[c] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
-{
- //printf("char_up_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
- else
- io.KeysDown[c] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
-{
- //printf("key_down_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
-{
- //printf("key_up_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- int button = -1;
- if (glut_button == GLUT_LEFT_BUTTON) button = 0;
- if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
- if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
- if (button != -1 && state == GLUT_DOWN)
- io.MouseDown[button] = true;
- if (button != -1 && state == GLUT_UP)
- io.MouseDown[button] = false;
-}
-
-void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- if (dir > 0)
- io.MouseWheel += 1.0;
- else if (dir < 0)
- io.MouseWheel -= 1.0;
- (void)button; // Unused
-}
-
-void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize = ImVec2((float)w, (float)h);
-}
-
-void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
-}
diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h
deleted file mode 100644
index 6d565ec..0000000
--- a/examples/imgui_impl_freeglut.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#pragma once
-
-IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_InstallFuncs();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_Shutdown();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_NewFrame();
-
-// You can call ImGui_ImplFreeGLUT_InstallFuncs() to get all those functions installed automatically,
-// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
-//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_glut.cpp b/examples/imgui_impl_glut.cpp
new file mode 100644
index 0000000..d8bd749
--- /dev/null
+++ b/examples/imgui_impl_glut.cpp
@@ -0,0 +1,208 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the 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)
+// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
+// 2019-03-25: Misc: Made io.DeltaTime always above zero.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-03-22: Added GLUT Platform binding.
+
+#include "imgui.h"
+#include "imgui_impl_glut.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
+#endif
+
+static int g_Time = 0; // Current time, in milliseconds
+
+bool ImGui_ImplGLUT_Init()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendPlatformName ="imgui_impl_glut";
+
+ g_Time = 0;
+
+ // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
+ io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
+ io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = 127;
+ io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
+ io.KeyMap[ImGuiKey_Space] = ' ';
+ io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
+ io.KeyMap[ImGuiKey_Escape] = 27;
+ io.KeyMap[ImGuiKey_A] = 'A';
+ io.KeyMap[ImGuiKey_C] = 'C';
+ io.KeyMap[ImGuiKey_V] = 'V';
+ io.KeyMap[ImGuiKey_X] = 'X';
+ io.KeyMap[ImGuiKey_Y] = 'Y';
+ io.KeyMap[ImGuiKey_Z] = 'Z';
+
+ return true;
+}
+
+void ImGui_ImplGLUT_InstallFuncs()
+{
+ glutReshapeFunc(ImGui_ImplGLUT_ReshapeFunc);
+ glutMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutPassiveMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutMouseFunc(ImGui_ImplGLUT_MouseFunc);
+#ifdef __FREEGLUT_EXT_H__
+ glutMouseWheelFunc(ImGui_ImplGLUT_MouseWheelFunc);
+#endif
+ glutKeyboardFunc(ImGui_ImplGLUT_KeyboardFunc);
+ glutKeyboardUpFunc(ImGui_ImplGLUT_KeyboardUpFunc);
+ glutSpecialFunc(ImGui_ImplGLUT_SpecialFunc);
+ glutSpecialUpFunc(ImGui_ImplGLUT_SpecialUpFunc);
+}
+
+void ImGui_ImplGLUT_Shutdown()
+{
+}
+
+void ImGui_ImplGLUT_NewFrame()
+{
+ // Setup time step
+ ImGuiIO& io = ImGui::GetIO();
+ int current_time = glutGet(GLUT_ELAPSED_TIME);
+ int delta_time_ms = (current_time - g_Time);
+ if (delta_time_ms <= 0)
+ delta_time_ms = 1;
+ io.DeltaTime = delta_time_ms / 1000.0f;
+ g_Time = current_time;
+
+ // Start the frame
+ ImGui::NewFrame();
+}
+
+static void ImGui_ImplGLUT_UpdateKeyboardMods()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ int mods = glutGetModifiers();
+ io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
+ io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
+ io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
+}
+
+void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
+{
+ // Send character to imgui
+ //printf("char_down_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 32)
+ io.AddInputCharacter((unsigned short)c);
+
+ // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
+ // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
+ else
+ io.KeysDown[c] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
+{
+ //printf("char_up_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
+ else
+ io.KeysDown[c] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
+{
+ //printf("key_down_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
+{
+ //printf("key_up_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ int button = -1;
+ if (glut_button == GLUT_LEFT_BUTTON) button = 0;
+ if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
+ if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
+ if (button != -1 && state == GLUT_DOWN)
+ io.MouseDown[button] = true;
+ if (button != -1 && state == GLUT_UP)
+ io.MouseDown[button] = false;
+}
+
+#ifdef __FREEGLUT_EXT_H__
+void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ if (dir > 0)
+ io.MouseWheel += 1.0;
+ else if (dir < 0)
+ io.MouseWheel -= 1.0;
+ (void)button; // Unused
+}
+#endif
+
+void ImGui_ImplGLUT_ReshapeFunc(int w, int h)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.DisplaySize = ImVec2((float)w, (float)h);
+}
+
+void ImGui_ImplGLUT_MotionFunc(int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+}
diff --git a/examples/imgui_impl_glut.h b/examples/imgui_impl_glut.h
new file mode 100644
index 0000000..8fde9ba
--- /dev/null
+++ b/examples/imgui_impl_glut.h
@@ -0,0 +1,33 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#pragma once
+
+IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
+IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs();
+IMGUI_IMPL_API void ImGui_ImplGLUT_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
+
+// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
+// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
+//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
+IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp
deleted file mode 100644
index 32671a6..0000000
--- a/examples/imgui_impl_freeglut.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the 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)
-// 2019-03-25: Misc: Made io.DeltaTime always above zero.
-// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
-// 2018-03-22: Added FreeGLUT Platform binding.
-
-#include "imgui.h"
-#include "imgui_impl_freeglut.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
-#endif
-
-static int g_Time = 0; // Current time, in milliseconds
-
-bool ImGui_ImplFreeGLUT_Init()
-{
- ImGuiIO& io = ImGui::GetIO();
- io.BackendPlatformName ="imgui_impl_freeglut";
-
- g_Time = 0;
-
- // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
- io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
- io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = 127;
- io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
- io.KeyMap[ImGuiKey_Space] = ' ';
- io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
- io.KeyMap[ImGuiKey_Escape] = 27;
- io.KeyMap[ImGuiKey_A] = 'A';
- io.KeyMap[ImGuiKey_C] = 'C';
- io.KeyMap[ImGuiKey_V] = 'V';
- io.KeyMap[ImGuiKey_X] = 'X';
- io.KeyMap[ImGuiKey_Y] = 'Y';
- io.KeyMap[ImGuiKey_Z] = 'Z';
-
- return true;
-}
-
-void ImGui_ImplFreeGLUT_InstallFuncs()
-{
- glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
- glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
- glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
- glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
- glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
- glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
- glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
-}
-
-void ImGui_ImplFreeGLUT_Shutdown()
-{
-}
-
-void ImGui_ImplFreeGLUT_NewFrame()
-{
- // Setup time step
- ImGuiIO& io = ImGui::GetIO();
- int current_time = glutGet(GLUT_ELAPSED_TIME);
- int delta_time_ms = (current_time - g_Time);
- if (delta_time_ms <= 0)
- delta_time_ms = 1;
- io.DeltaTime = delta_time_ms / 1000.0f;
- g_Time = current_time;
-
- // Start the frame
- ImGui::NewFrame();
-}
-
-static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
-{
- ImGuiIO& io = ImGui::GetIO();
- int mods = glutGetModifiers();
- io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
- io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
- io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
-}
-
-void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
-{
- // Send character to imgui
- //printf("char_down_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 32)
- io.AddInputCharacter((unsigned short)c);
-
- // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
- // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
- else
- io.KeysDown[c] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
-{
- //printf("char_up_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
- else
- io.KeysDown[c] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
-{
- //printf("key_down_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
-{
- //printf("key_up_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- int button = -1;
- if (glut_button == GLUT_LEFT_BUTTON) button = 0;
- if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
- if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
- if (button != -1 && state == GLUT_DOWN)
- io.MouseDown[button] = true;
- if (button != -1 && state == GLUT_UP)
- io.MouseDown[button] = false;
-}
-
-void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- if (dir > 0)
- io.MouseWheel += 1.0;
- else if (dir < 0)
- io.MouseWheel -= 1.0;
- (void)button; // Unused
-}
-
-void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize = ImVec2((float)w, (float)h);
-}
-
-void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
-}
diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h
deleted file mode 100644
index 6d565ec..0000000
--- a/examples/imgui_impl_freeglut.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#pragma once
-
-IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_InstallFuncs();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_Shutdown();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_NewFrame();
-
-// You can call ImGui_ImplFreeGLUT_InstallFuncs() to get all those functions installed automatically,
-// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
-//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_glut.cpp b/examples/imgui_impl_glut.cpp
new file mode 100644
index 0000000..d8bd749
--- /dev/null
+++ b/examples/imgui_impl_glut.cpp
@@ -0,0 +1,208 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the 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)
+// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
+// 2019-03-25: Misc: Made io.DeltaTime always above zero.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-03-22: Added GLUT Platform binding.
+
+#include "imgui.h"
+#include "imgui_impl_glut.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
+#endif
+
+static int g_Time = 0; // Current time, in milliseconds
+
+bool ImGui_ImplGLUT_Init()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendPlatformName ="imgui_impl_glut";
+
+ g_Time = 0;
+
+ // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
+ io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
+ io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = 127;
+ io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
+ io.KeyMap[ImGuiKey_Space] = ' ';
+ io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
+ io.KeyMap[ImGuiKey_Escape] = 27;
+ io.KeyMap[ImGuiKey_A] = 'A';
+ io.KeyMap[ImGuiKey_C] = 'C';
+ io.KeyMap[ImGuiKey_V] = 'V';
+ io.KeyMap[ImGuiKey_X] = 'X';
+ io.KeyMap[ImGuiKey_Y] = 'Y';
+ io.KeyMap[ImGuiKey_Z] = 'Z';
+
+ return true;
+}
+
+void ImGui_ImplGLUT_InstallFuncs()
+{
+ glutReshapeFunc(ImGui_ImplGLUT_ReshapeFunc);
+ glutMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutPassiveMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutMouseFunc(ImGui_ImplGLUT_MouseFunc);
+#ifdef __FREEGLUT_EXT_H__
+ glutMouseWheelFunc(ImGui_ImplGLUT_MouseWheelFunc);
+#endif
+ glutKeyboardFunc(ImGui_ImplGLUT_KeyboardFunc);
+ glutKeyboardUpFunc(ImGui_ImplGLUT_KeyboardUpFunc);
+ glutSpecialFunc(ImGui_ImplGLUT_SpecialFunc);
+ glutSpecialUpFunc(ImGui_ImplGLUT_SpecialUpFunc);
+}
+
+void ImGui_ImplGLUT_Shutdown()
+{
+}
+
+void ImGui_ImplGLUT_NewFrame()
+{
+ // Setup time step
+ ImGuiIO& io = ImGui::GetIO();
+ int current_time = glutGet(GLUT_ELAPSED_TIME);
+ int delta_time_ms = (current_time - g_Time);
+ if (delta_time_ms <= 0)
+ delta_time_ms = 1;
+ io.DeltaTime = delta_time_ms / 1000.0f;
+ g_Time = current_time;
+
+ // Start the frame
+ ImGui::NewFrame();
+}
+
+static void ImGui_ImplGLUT_UpdateKeyboardMods()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ int mods = glutGetModifiers();
+ io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
+ io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
+ io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
+}
+
+void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
+{
+ // Send character to imgui
+ //printf("char_down_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 32)
+ io.AddInputCharacter((unsigned short)c);
+
+ // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
+ // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
+ else
+ io.KeysDown[c] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
+{
+ //printf("char_up_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
+ else
+ io.KeysDown[c] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
+{
+ //printf("key_down_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
+{
+ //printf("key_up_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ int button = -1;
+ if (glut_button == GLUT_LEFT_BUTTON) button = 0;
+ if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
+ if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
+ if (button != -1 && state == GLUT_DOWN)
+ io.MouseDown[button] = true;
+ if (button != -1 && state == GLUT_UP)
+ io.MouseDown[button] = false;
+}
+
+#ifdef __FREEGLUT_EXT_H__
+void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ if (dir > 0)
+ io.MouseWheel += 1.0;
+ else if (dir < 0)
+ io.MouseWheel -= 1.0;
+ (void)button; // Unused
+}
+#endif
+
+void ImGui_ImplGLUT_ReshapeFunc(int w, int h)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.DisplaySize = ImVec2((float)w, (float)h);
+}
+
+void ImGui_ImplGLUT_MotionFunc(int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+}
diff --git a/examples/imgui_impl_glut.h b/examples/imgui_impl_glut.h
new file mode 100644
index 0000000..8fde9ba
--- /dev/null
+++ b/examples/imgui_impl_glut.h
@@ -0,0 +1,33 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#pragma once
+
+IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
+IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs();
+IMGUI_IMPL_API void ImGui_ImplGLUT_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
+
+// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
+// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
+//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
+IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm
index 401e072..f668945 100644
--- a/examples/imgui_impl_metal.mm
+++ b/examples/imgui_impl_metal.mm
@@ -20,7 +20,7 @@
#include "imgui_impl_metal.h"
#import
-// #import // Not suported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
+// #import // Not supported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
#import
#pragma mark - Support classes
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp
deleted file mode 100644
index 32671a6..0000000
--- a/examples/imgui_impl_freeglut.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the 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)
-// 2019-03-25: Misc: Made io.DeltaTime always above zero.
-// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
-// 2018-03-22: Added FreeGLUT Platform binding.
-
-#include "imgui.h"
-#include "imgui_impl_freeglut.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
-#endif
-
-static int g_Time = 0; // Current time, in milliseconds
-
-bool ImGui_ImplFreeGLUT_Init()
-{
- ImGuiIO& io = ImGui::GetIO();
- io.BackendPlatformName ="imgui_impl_freeglut";
-
- g_Time = 0;
-
- // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
- io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
- io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = 127;
- io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
- io.KeyMap[ImGuiKey_Space] = ' ';
- io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
- io.KeyMap[ImGuiKey_Escape] = 27;
- io.KeyMap[ImGuiKey_A] = 'A';
- io.KeyMap[ImGuiKey_C] = 'C';
- io.KeyMap[ImGuiKey_V] = 'V';
- io.KeyMap[ImGuiKey_X] = 'X';
- io.KeyMap[ImGuiKey_Y] = 'Y';
- io.KeyMap[ImGuiKey_Z] = 'Z';
-
- return true;
-}
-
-void ImGui_ImplFreeGLUT_InstallFuncs()
-{
- glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
- glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
- glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
- glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
- glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
- glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
- glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
-}
-
-void ImGui_ImplFreeGLUT_Shutdown()
-{
-}
-
-void ImGui_ImplFreeGLUT_NewFrame()
-{
- // Setup time step
- ImGuiIO& io = ImGui::GetIO();
- int current_time = glutGet(GLUT_ELAPSED_TIME);
- int delta_time_ms = (current_time - g_Time);
- if (delta_time_ms <= 0)
- delta_time_ms = 1;
- io.DeltaTime = delta_time_ms / 1000.0f;
- g_Time = current_time;
-
- // Start the frame
- ImGui::NewFrame();
-}
-
-static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
-{
- ImGuiIO& io = ImGui::GetIO();
- int mods = glutGetModifiers();
- io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
- io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
- io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
-}
-
-void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
-{
- // Send character to imgui
- //printf("char_down_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 32)
- io.AddInputCharacter((unsigned short)c);
-
- // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
- // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
- else
- io.KeysDown[c] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
-{
- //printf("char_up_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
- else
- io.KeysDown[c] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
-{
- //printf("key_down_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
-{
- //printf("key_up_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- int button = -1;
- if (glut_button == GLUT_LEFT_BUTTON) button = 0;
- if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
- if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
- if (button != -1 && state == GLUT_DOWN)
- io.MouseDown[button] = true;
- if (button != -1 && state == GLUT_UP)
- io.MouseDown[button] = false;
-}
-
-void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- if (dir > 0)
- io.MouseWheel += 1.0;
- else if (dir < 0)
- io.MouseWheel -= 1.0;
- (void)button; // Unused
-}
-
-void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize = ImVec2((float)w, (float)h);
-}
-
-void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
-}
diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h
deleted file mode 100644
index 6d565ec..0000000
--- a/examples/imgui_impl_freeglut.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#pragma once
-
-IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_InstallFuncs();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_Shutdown();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_NewFrame();
-
-// You can call ImGui_ImplFreeGLUT_InstallFuncs() to get all those functions installed automatically,
-// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
-//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_glut.cpp b/examples/imgui_impl_glut.cpp
new file mode 100644
index 0000000..d8bd749
--- /dev/null
+++ b/examples/imgui_impl_glut.cpp
@@ -0,0 +1,208 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the 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)
+// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
+// 2019-03-25: Misc: Made io.DeltaTime always above zero.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-03-22: Added GLUT Platform binding.
+
+#include "imgui.h"
+#include "imgui_impl_glut.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
+#endif
+
+static int g_Time = 0; // Current time, in milliseconds
+
+bool ImGui_ImplGLUT_Init()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendPlatformName ="imgui_impl_glut";
+
+ g_Time = 0;
+
+ // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
+ io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
+ io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = 127;
+ io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
+ io.KeyMap[ImGuiKey_Space] = ' ';
+ io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
+ io.KeyMap[ImGuiKey_Escape] = 27;
+ io.KeyMap[ImGuiKey_A] = 'A';
+ io.KeyMap[ImGuiKey_C] = 'C';
+ io.KeyMap[ImGuiKey_V] = 'V';
+ io.KeyMap[ImGuiKey_X] = 'X';
+ io.KeyMap[ImGuiKey_Y] = 'Y';
+ io.KeyMap[ImGuiKey_Z] = 'Z';
+
+ return true;
+}
+
+void ImGui_ImplGLUT_InstallFuncs()
+{
+ glutReshapeFunc(ImGui_ImplGLUT_ReshapeFunc);
+ glutMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutPassiveMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutMouseFunc(ImGui_ImplGLUT_MouseFunc);
+#ifdef __FREEGLUT_EXT_H__
+ glutMouseWheelFunc(ImGui_ImplGLUT_MouseWheelFunc);
+#endif
+ glutKeyboardFunc(ImGui_ImplGLUT_KeyboardFunc);
+ glutKeyboardUpFunc(ImGui_ImplGLUT_KeyboardUpFunc);
+ glutSpecialFunc(ImGui_ImplGLUT_SpecialFunc);
+ glutSpecialUpFunc(ImGui_ImplGLUT_SpecialUpFunc);
+}
+
+void ImGui_ImplGLUT_Shutdown()
+{
+}
+
+void ImGui_ImplGLUT_NewFrame()
+{
+ // Setup time step
+ ImGuiIO& io = ImGui::GetIO();
+ int current_time = glutGet(GLUT_ELAPSED_TIME);
+ int delta_time_ms = (current_time - g_Time);
+ if (delta_time_ms <= 0)
+ delta_time_ms = 1;
+ io.DeltaTime = delta_time_ms / 1000.0f;
+ g_Time = current_time;
+
+ // Start the frame
+ ImGui::NewFrame();
+}
+
+static void ImGui_ImplGLUT_UpdateKeyboardMods()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ int mods = glutGetModifiers();
+ io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
+ io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
+ io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
+}
+
+void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
+{
+ // Send character to imgui
+ //printf("char_down_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 32)
+ io.AddInputCharacter((unsigned short)c);
+
+ // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
+ // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
+ else
+ io.KeysDown[c] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
+{
+ //printf("char_up_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
+ else
+ io.KeysDown[c] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
+{
+ //printf("key_down_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
+{
+ //printf("key_up_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ int button = -1;
+ if (glut_button == GLUT_LEFT_BUTTON) button = 0;
+ if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
+ if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
+ if (button != -1 && state == GLUT_DOWN)
+ io.MouseDown[button] = true;
+ if (button != -1 && state == GLUT_UP)
+ io.MouseDown[button] = false;
+}
+
+#ifdef __FREEGLUT_EXT_H__
+void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ if (dir > 0)
+ io.MouseWheel += 1.0;
+ else if (dir < 0)
+ io.MouseWheel -= 1.0;
+ (void)button; // Unused
+}
+#endif
+
+void ImGui_ImplGLUT_ReshapeFunc(int w, int h)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.DisplaySize = ImVec2((float)w, (float)h);
+}
+
+void ImGui_ImplGLUT_MotionFunc(int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+}
diff --git a/examples/imgui_impl_glut.h b/examples/imgui_impl_glut.h
new file mode 100644
index 0000000..8fde9ba
--- /dev/null
+++ b/examples/imgui_impl_glut.h
@@ -0,0 +1,33 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#pragma once
+
+IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
+IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs();
+IMGUI_IMPL_API void ImGui_ImplGLUT_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
+
+// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
+// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
+//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
+IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm
index 401e072..f668945 100644
--- a/examples/imgui_impl_metal.mm
+++ b/examples/imgui_impl_metal.mm
@@ -20,7 +20,7 @@
#include "imgui_impl_metal.h"
#import
-// #import // Not suported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
+// #import // Not supported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
#import
#pragma mark - Support classes
diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp
index 6b2d313..d5abcc6 100644
--- a/examples/imgui_impl_opengl2.cpp
+++ b/examples/imgui_impl_opengl2.cpp
@@ -114,9 +114,9 @@
glEnable(GL_TEXTURE_2D);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
+ // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
// you may need to backup/reset/restore current shader using the lines below. DO NOT MODIFY THIS FILE! Add the code in your calling function:
- // GLint last_program;
+ // GLint last_program;
// glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
// glUseProgram(0);
// ImGui_ImplOpenGL2_RenderDrawData(...);
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp
deleted file mode 100644
index 32671a6..0000000
--- a/examples/imgui_impl_freeglut.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the 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)
-// 2019-03-25: Misc: Made io.DeltaTime always above zero.
-// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
-// 2018-03-22: Added FreeGLUT Platform binding.
-
-#include "imgui.h"
-#include "imgui_impl_freeglut.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
-#endif
-
-static int g_Time = 0; // Current time, in milliseconds
-
-bool ImGui_ImplFreeGLUT_Init()
-{
- ImGuiIO& io = ImGui::GetIO();
- io.BackendPlatformName ="imgui_impl_freeglut";
-
- g_Time = 0;
-
- // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
- io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
- io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = 127;
- io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
- io.KeyMap[ImGuiKey_Space] = ' ';
- io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
- io.KeyMap[ImGuiKey_Escape] = 27;
- io.KeyMap[ImGuiKey_A] = 'A';
- io.KeyMap[ImGuiKey_C] = 'C';
- io.KeyMap[ImGuiKey_V] = 'V';
- io.KeyMap[ImGuiKey_X] = 'X';
- io.KeyMap[ImGuiKey_Y] = 'Y';
- io.KeyMap[ImGuiKey_Z] = 'Z';
-
- return true;
-}
-
-void ImGui_ImplFreeGLUT_InstallFuncs()
-{
- glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
- glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
- glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
- glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
- glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
- glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
- glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
-}
-
-void ImGui_ImplFreeGLUT_Shutdown()
-{
-}
-
-void ImGui_ImplFreeGLUT_NewFrame()
-{
- // Setup time step
- ImGuiIO& io = ImGui::GetIO();
- int current_time = glutGet(GLUT_ELAPSED_TIME);
- int delta_time_ms = (current_time - g_Time);
- if (delta_time_ms <= 0)
- delta_time_ms = 1;
- io.DeltaTime = delta_time_ms / 1000.0f;
- g_Time = current_time;
-
- // Start the frame
- ImGui::NewFrame();
-}
-
-static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
-{
- ImGuiIO& io = ImGui::GetIO();
- int mods = glutGetModifiers();
- io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
- io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
- io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
-}
-
-void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
-{
- // Send character to imgui
- //printf("char_down_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 32)
- io.AddInputCharacter((unsigned short)c);
-
- // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
- // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
- else
- io.KeysDown[c] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
-{
- //printf("char_up_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
- else
- io.KeysDown[c] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
-{
- //printf("key_down_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
-{
- //printf("key_up_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- int button = -1;
- if (glut_button == GLUT_LEFT_BUTTON) button = 0;
- if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
- if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
- if (button != -1 && state == GLUT_DOWN)
- io.MouseDown[button] = true;
- if (button != -1 && state == GLUT_UP)
- io.MouseDown[button] = false;
-}
-
-void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- if (dir > 0)
- io.MouseWheel += 1.0;
- else if (dir < 0)
- io.MouseWheel -= 1.0;
- (void)button; // Unused
-}
-
-void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize = ImVec2((float)w, (float)h);
-}
-
-void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
-}
diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h
deleted file mode 100644
index 6d565ec..0000000
--- a/examples/imgui_impl_freeglut.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#pragma once
-
-IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_InstallFuncs();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_Shutdown();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_NewFrame();
-
-// You can call ImGui_ImplFreeGLUT_InstallFuncs() to get all those functions installed automatically,
-// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
-//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_glut.cpp b/examples/imgui_impl_glut.cpp
new file mode 100644
index 0000000..d8bd749
--- /dev/null
+++ b/examples/imgui_impl_glut.cpp
@@ -0,0 +1,208 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the 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)
+// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
+// 2019-03-25: Misc: Made io.DeltaTime always above zero.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-03-22: Added GLUT Platform binding.
+
+#include "imgui.h"
+#include "imgui_impl_glut.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
+#endif
+
+static int g_Time = 0; // Current time, in milliseconds
+
+bool ImGui_ImplGLUT_Init()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendPlatformName ="imgui_impl_glut";
+
+ g_Time = 0;
+
+ // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
+ io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
+ io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = 127;
+ io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
+ io.KeyMap[ImGuiKey_Space] = ' ';
+ io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
+ io.KeyMap[ImGuiKey_Escape] = 27;
+ io.KeyMap[ImGuiKey_A] = 'A';
+ io.KeyMap[ImGuiKey_C] = 'C';
+ io.KeyMap[ImGuiKey_V] = 'V';
+ io.KeyMap[ImGuiKey_X] = 'X';
+ io.KeyMap[ImGuiKey_Y] = 'Y';
+ io.KeyMap[ImGuiKey_Z] = 'Z';
+
+ return true;
+}
+
+void ImGui_ImplGLUT_InstallFuncs()
+{
+ glutReshapeFunc(ImGui_ImplGLUT_ReshapeFunc);
+ glutMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutPassiveMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutMouseFunc(ImGui_ImplGLUT_MouseFunc);
+#ifdef __FREEGLUT_EXT_H__
+ glutMouseWheelFunc(ImGui_ImplGLUT_MouseWheelFunc);
+#endif
+ glutKeyboardFunc(ImGui_ImplGLUT_KeyboardFunc);
+ glutKeyboardUpFunc(ImGui_ImplGLUT_KeyboardUpFunc);
+ glutSpecialFunc(ImGui_ImplGLUT_SpecialFunc);
+ glutSpecialUpFunc(ImGui_ImplGLUT_SpecialUpFunc);
+}
+
+void ImGui_ImplGLUT_Shutdown()
+{
+}
+
+void ImGui_ImplGLUT_NewFrame()
+{
+ // Setup time step
+ ImGuiIO& io = ImGui::GetIO();
+ int current_time = glutGet(GLUT_ELAPSED_TIME);
+ int delta_time_ms = (current_time - g_Time);
+ if (delta_time_ms <= 0)
+ delta_time_ms = 1;
+ io.DeltaTime = delta_time_ms / 1000.0f;
+ g_Time = current_time;
+
+ // Start the frame
+ ImGui::NewFrame();
+}
+
+static void ImGui_ImplGLUT_UpdateKeyboardMods()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ int mods = glutGetModifiers();
+ io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
+ io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
+ io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
+}
+
+void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
+{
+ // Send character to imgui
+ //printf("char_down_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 32)
+ io.AddInputCharacter((unsigned short)c);
+
+ // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
+ // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
+ else
+ io.KeysDown[c] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
+{
+ //printf("char_up_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
+ else
+ io.KeysDown[c] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
+{
+ //printf("key_down_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
+{
+ //printf("key_up_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ int button = -1;
+ if (glut_button == GLUT_LEFT_BUTTON) button = 0;
+ if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
+ if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
+ if (button != -1 && state == GLUT_DOWN)
+ io.MouseDown[button] = true;
+ if (button != -1 && state == GLUT_UP)
+ io.MouseDown[button] = false;
+}
+
+#ifdef __FREEGLUT_EXT_H__
+void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ if (dir > 0)
+ io.MouseWheel += 1.0;
+ else if (dir < 0)
+ io.MouseWheel -= 1.0;
+ (void)button; // Unused
+}
+#endif
+
+void ImGui_ImplGLUT_ReshapeFunc(int w, int h)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.DisplaySize = ImVec2((float)w, (float)h);
+}
+
+void ImGui_ImplGLUT_MotionFunc(int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+}
diff --git a/examples/imgui_impl_glut.h b/examples/imgui_impl_glut.h
new file mode 100644
index 0000000..8fde9ba
--- /dev/null
+++ b/examples/imgui_impl_glut.h
@@ -0,0 +1,33 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#pragma once
+
+IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
+IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs();
+IMGUI_IMPL_API void ImGui_ImplGLUT_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
+
+// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
+// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
+//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
+IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm
index 401e072..f668945 100644
--- a/examples/imgui_impl_metal.mm
+++ b/examples/imgui_impl_metal.mm
@@ -20,7 +20,7 @@
#include "imgui_impl_metal.h"
#import
-// #import // Not suported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
+// #import // Not supported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
#import
#pragma mark - Support classes
diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp
index 6b2d313..d5abcc6 100644
--- a/examples/imgui_impl_opengl2.cpp
+++ b/examples/imgui_impl_opengl2.cpp
@@ -114,9 +114,9 @@
glEnable(GL_TEXTURE_2D);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
+ // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
// you may need to backup/reset/restore current shader using the lines below. DO NOT MODIFY THIS FILE! Add the code in your calling function:
- // GLint last_program;
+ // GLint last_program;
// glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
// glUseProgram(0);
// ImGui_ImplOpenGL2_RenderDrawData(...);
diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp
index 179a63a..5911878 100644
--- a/examples/imgui_impl_vulkan.cpp
+++ b/examples/imgui_impl_vulkan.cpp
@@ -14,6 +14,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
+// 2019-04-04: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
// 2019-04-01: Vulkan: Support for 32-bit index buffer (#define ImDrawIdx unsigned int).
// 2019-02-16: Vulkan: Viewport and clipping rectangles correctly using draw_data->FramebufferScale to allow retina display.
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
@@ -81,6 +82,23 @@
// glsl_shader.vert, compiled with:
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
+/*
+#version 450 core
+layout(location = 0) in vec2 aPos;
+layout(location = 1) in vec2 aUV;
+layout(location = 2) in vec4 aColor;
+layout(push_constant) uniform uPushConstant { vec2 uScale; vec2 uTranslate; } pc;
+
+out gl_PerVertex { vec4 gl_Position; };
+layout(location = 0) out struct { vec4 Color; vec2 UV; } Out;
+
+void main()
+{
+ Out.Color = aColor;
+ Out.UV = aUV;
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
+}
+*/
static uint32_t __glsl_shader_vert_spv[] =
{
0x07230203,0x00010000,0x00080001,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b,
@@ -128,6 +146,16 @@
// glsl_shader.frag, compiled with:
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
+/*
+#version 450 core
+layout(location = 0) out vec4 fColor;
+layout(set=0, binding=0) uniform sampler2D sTexture;
+layout(location = 0) in struct { vec4 Color; vec2 UV; } In;
+void main()
+{
+ fColor = In.Color * texture(sTexture, In.UV.st);
+}
+*/
static uint32_t __glsl_shader_frag_spv[] =
{
0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b,
@@ -325,6 +353,12 @@
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
{
+ // Negative offsets are illegal for vkCmdSetScissor
+ if (clip_rect.x < 0.0f)
+ clip_rect.x = 0.0f;
+ if (clip_rect.y < 0.0f)
+ clip_rect.y = 0.0f;
+
// Apply scissor/clipping rectangle
VkRect2D scissor;
scissor.offset.x = (int32_t)(clip_rect.x);
@@ -930,7 +964,7 @@
void ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_WindowData* wd, const VkAllocationCallbacks* allocator, int w, int h)
{
- uint32_t min_image_count = 2; // FIXME: this should become a function parameter
+ uint32_t min_image_count = 2; // FIXME: this should become a function parameter
VkResult err;
VkSwapchainKHR old_swapchain = wd->Swapchain;
@@ -958,7 +992,7 @@
VkSwapchainCreateInfoKHR info = {};
info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
info.surface = wd->Surface;
- info.minImageCount = min_image_count;
+ info.minImageCount = min_image_count;
info.imageFormat = wd->SurfaceFormat.format;
info.imageColorSpace = wd->SurfaceFormat.colorSpace;
info.imageArrayLayers = 1;
@@ -973,9 +1007,9 @@
err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, wd->Surface, &cap);
check_vk_result(err);
if (info.minImageCount < cap.minImageCount)
- info.minImageCount = cap.minImageCount;
- else if (cap.maxImageCount != 0 && info.minImageCount > cap.maxImageCount)
- info.minImageCount = cap.maxImageCount;
+ info.minImageCount = cap.minImageCount;
+ else if (cap.maxImageCount != 0 && info.minImageCount > cap.maxImageCount)
+ info.minImageCount = cap.maxImageCount;
if (cap.currentExtent.width == 0xffffffff)
{
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp
deleted file mode 100644
index 32671a6..0000000
--- a/examples/imgui_impl_freeglut.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the 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)
-// 2019-03-25: Misc: Made io.DeltaTime always above zero.
-// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
-// 2018-03-22: Added FreeGLUT Platform binding.
-
-#include "imgui.h"
-#include "imgui_impl_freeglut.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
-#endif
-
-static int g_Time = 0; // Current time, in milliseconds
-
-bool ImGui_ImplFreeGLUT_Init()
-{
- ImGuiIO& io = ImGui::GetIO();
- io.BackendPlatformName ="imgui_impl_freeglut";
-
- g_Time = 0;
-
- // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
- io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
- io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = 127;
- io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
- io.KeyMap[ImGuiKey_Space] = ' ';
- io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
- io.KeyMap[ImGuiKey_Escape] = 27;
- io.KeyMap[ImGuiKey_A] = 'A';
- io.KeyMap[ImGuiKey_C] = 'C';
- io.KeyMap[ImGuiKey_V] = 'V';
- io.KeyMap[ImGuiKey_X] = 'X';
- io.KeyMap[ImGuiKey_Y] = 'Y';
- io.KeyMap[ImGuiKey_Z] = 'Z';
-
- return true;
-}
-
-void ImGui_ImplFreeGLUT_InstallFuncs()
-{
- glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
- glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
- glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
- glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
- glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
- glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
- glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
-}
-
-void ImGui_ImplFreeGLUT_Shutdown()
-{
-}
-
-void ImGui_ImplFreeGLUT_NewFrame()
-{
- // Setup time step
- ImGuiIO& io = ImGui::GetIO();
- int current_time = glutGet(GLUT_ELAPSED_TIME);
- int delta_time_ms = (current_time - g_Time);
- if (delta_time_ms <= 0)
- delta_time_ms = 1;
- io.DeltaTime = delta_time_ms / 1000.0f;
- g_Time = current_time;
-
- // Start the frame
- ImGui::NewFrame();
-}
-
-static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
-{
- ImGuiIO& io = ImGui::GetIO();
- int mods = glutGetModifiers();
- io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
- io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
- io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
-}
-
-void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
-{
- // Send character to imgui
- //printf("char_down_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 32)
- io.AddInputCharacter((unsigned short)c);
-
- // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
- // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
- else
- io.KeysDown[c] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
-{
- //printf("char_up_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
- else
- io.KeysDown[c] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
-{
- //printf("key_down_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
-{
- //printf("key_up_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- int button = -1;
- if (glut_button == GLUT_LEFT_BUTTON) button = 0;
- if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
- if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
- if (button != -1 && state == GLUT_DOWN)
- io.MouseDown[button] = true;
- if (button != -1 && state == GLUT_UP)
- io.MouseDown[button] = false;
-}
-
-void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- if (dir > 0)
- io.MouseWheel += 1.0;
- else if (dir < 0)
- io.MouseWheel -= 1.0;
- (void)button; // Unused
-}
-
-void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize = ImVec2((float)w, (float)h);
-}
-
-void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
-}
diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h
deleted file mode 100644
index 6d565ec..0000000
--- a/examples/imgui_impl_freeglut.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#pragma once
-
-IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_InstallFuncs();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_Shutdown();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_NewFrame();
-
-// You can call ImGui_ImplFreeGLUT_InstallFuncs() to get all those functions installed automatically,
-// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
-//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_glut.cpp b/examples/imgui_impl_glut.cpp
new file mode 100644
index 0000000..d8bd749
--- /dev/null
+++ b/examples/imgui_impl_glut.cpp
@@ -0,0 +1,208 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the 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)
+// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
+// 2019-03-25: Misc: Made io.DeltaTime always above zero.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-03-22: Added GLUT Platform binding.
+
+#include "imgui.h"
+#include "imgui_impl_glut.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
+#endif
+
+static int g_Time = 0; // Current time, in milliseconds
+
+bool ImGui_ImplGLUT_Init()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendPlatformName ="imgui_impl_glut";
+
+ g_Time = 0;
+
+ // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
+ io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
+ io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = 127;
+ io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
+ io.KeyMap[ImGuiKey_Space] = ' ';
+ io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
+ io.KeyMap[ImGuiKey_Escape] = 27;
+ io.KeyMap[ImGuiKey_A] = 'A';
+ io.KeyMap[ImGuiKey_C] = 'C';
+ io.KeyMap[ImGuiKey_V] = 'V';
+ io.KeyMap[ImGuiKey_X] = 'X';
+ io.KeyMap[ImGuiKey_Y] = 'Y';
+ io.KeyMap[ImGuiKey_Z] = 'Z';
+
+ return true;
+}
+
+void ImGui_ImplGLUT_InstallFuncs()
+{
+ glutReshapeFunc(ImGui_ImplGLUT_ReshapeFunc);
+ glutMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutPassiveMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutMouseFunc(ImGui_ImplGLUT_MouseFunc);
+#ifdef __FREEGLUT_EXT_H__
+ glutMouseWheelFunc(ImGui_ImplGLUT_MouseWheelFunc);
+#endif
+ glutKeyboardFunc(ImGui_ImplGLUT_KeyboardFunc);
+ glutKeyboardUpFunc(ImGui_ImplGLUT_KeyboardUpFunc);
+ glutSpecialFunc(ImGui_ImplGLUT_SpecialFunc);
+ glutSpecialUpFunc(ImGui_ImplGLUT_SpecialUpFunc);
+}
+
+void ImGui_ImplGLUT_Shutdown()
+{
+}
+
+void ImGui_ImplGLUT_NewFrame()
+{
+ // Setup time step
+ ImGuiIO& io = ImGui::GetIO();
+ int current_time = glutGet(GLUT_ELAPSED_TIME);
+ int delta_time_ms = (current_time - g_Time);
+ if (delta_time_ms <= 0)
+ delta_time_ms = 1;
+ io.DeltaTime = delta_time_ms / 1000.0f;
+ g_Time = current_time;
+
+ // Start the frame
+ ImGui::NewFrame();
+}
+
+static void ImGui_ImplGLUT_UpdateKeyboardMods()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ int mods = glutGetModifiers();
+ io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
+ io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
+ io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
+}
+
+void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
+{
+ // Send character to imgui
+ //printf("char_down_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 32)
+ io.AddInputCharacter((unsigned short)c);
+
+ // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
+ // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
+ else
+ io.KeysDown[c] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
+{
+ //printf("char_up_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
+ else
+ io.KeysDown[c] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
+{
+ //printf("key_down_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
+{
+ //printf("key_up_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ int button = -1;
+ if (glut_button == GLUT_LEFT_BUTTON) button = 0;
+ if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
+ if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
+ if (button != -1 && state == GLUT_DOWN)
+ io.MouseDown[button] = true;
+ if (button != -1 && state == GLUT_UP)
+ io.MouseDown[button] = false;
+}
+
+#ifdef __FREEGLUT_EXT_H__
+void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ if (dir > 0)
+ io.MouseWheel += 1.0;
+ else if (dir < 0)
+ io.MouseWheel -= 1.0;
+ (void)button; // Unused
+}
+#endif
+
+void ImGui_ImplGLUT_ReshapeFunc(int w, int h)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.DisplaySize = ImVec2((float)w, (float)h);
+}
+
+void ImGui_ImplGLUT_MotionFunc(int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+}
diff --git a/examples/imgui_impl_glut.h b/examples/imgui_impl_glut.h
new file mode 100644
index 0000000..8fde9ba
--- /dev/null
+++ b/examples/imgui_impl_glut.h
@@ -0,0 +1,33 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#pragma once
+
+IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
+IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs();
+IMGUI_IMPL_API void ImGui_ImplGLUT_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
+
+// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
+// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
+//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
+IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm
index 401e072..f668945 100644
--- a/examples/imgui_impl_metal.mm
+++ b/examples/imgui_impl_metal.mm
@@ -20,7 +20,7 @@
#include "imgui_impl_metal.h"
#import
-// #import // Not suported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
+// #import // Not supported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
#import
#pragma mark - Support classes
diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp
index 6b2d313..d5abcc6 100644
--- a/examples/imgui_impl_opengl2.cpp
+++ b/examples/imgui_impl_opengl2.cpp
@@ -114,9 +114,9 @@
glEnable(GL_TEXTURE_2D);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
+ // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
// you may need to backup/reset/restore current shader using the lines below. DO NOT MODIFY THIS FILE! Add the code in your calling function:
- // GLint last_program;
+ // GLint last_program;
// glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
// glUseProgram(0);
// ImGui_ImplOpenGL2_RenderDrawData(...);
diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp
index 179a63a..5911878 100644
--- a/examples/imgui_impl_vulkan.cpp
+++ b/examples/imgui_impl_vulkan.cpp
@@ -14,6 +14,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
+// 2019-04-04: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
// 2019-04-01: Vulkan: Support for 32-bit index buffer (#define ImDrawIdx unsigned int).
// 2019-02-16: Vulkan: Viewport and clipping rectangles correctly using draw_data->FramebufferScale to allow retina display.
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
@@ -81,6 +82,23 @@
// glsl_shader.vert, compiled with:
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
+/*
+#version 450 core
+layout(location = 0) in vec2 aPos;
+layout(location = 1) in vec2 aUV;
+layout(location = 2) in vec4 aColor;
+layout(push_constant) uniform uPushConstant { vec2 uScale; vec2 uTranslate; } pc;
+
+out gl_PerVertex { vec4 gl_Position; };
+layout(location = 0) out struct { vec4 Color; vec2 UV; } Out;
+
+void main()
+{
+ Out.Color = aColor;
+ Out.UV = aUV;
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
+}
+*/
static uint32_t __glsl_shader_vert_spv[] =
{
0x07230203,0x00010000,0x00080001,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b,
@@ -128,6 +146,16 @@
// glsl_shader.frag, compiled with:
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
+/*
+#version 450 core
+layout(location = 0) out vec4 fColor;
+layout(set=0, binding=0) uniform sampler2D sTexture;
+layout(location = 0) in struct { vec4 Color; vec2 UV; } In;
+void main()
+{
+ fColor = In.Color * texture(sTexture, In.UV.st);
+}
+*/
static uint32_t __glsl_shader_frag_spv[] =
{
0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b,
@@ -325,6 +353,12 @@
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
{
+ // Negative offsets are illegal for vkCmdSetScissor
+ if (clip_rect.x < 0.0f)
+ clip_rect.x = 0.0f;
+ if (clip_rect.y < 0.0f)
+ clip_rect.y = 0.0f;
+
// Apply scissor/clipping rectangle
VkRect2D scissor;
scissor.offset.x = (int32_t)(clip_rect.x);
@@ -930,7 +964,7 @@
void ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_WindowData* wd, const VkAllocationCallbacks* allocator, int w, int h)
{
- uint32_t min_image_count = 2; // FIXME: this should become a function parameter
+ uint32_t min_image_count = 2; // FIXME: this should become a function parameter
VkResult err;
VkSwapchainKHR old_swapchain = wd->Swapchain;
@@ -958,7 +992,7 @@
VkSwapchainCreateInfoKHR info = {};
info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
info.surface = wd->Surface;
- info.minImageCount = min_image_count;
+ info.minImageCount = min_image_count;
info.imageFormat = wd->SurfaceFormat.format;
info.imageColorSpace = wd->SurfaceFormat.colorSpace;
info.imageArrayLayers = 1;
@@ -973,9 +1007,9 @@
err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, wd->Surface, &cap);
check_vk_result(err);
if (info.minImageCount < cap.minImageCount)
- info.minImageCount = cap.minImageCount;
- else if (cap.maxImageCount != 0 && info.minImageCount > cap.maxImageCount)
- info.minImageCount = cap.maxImageCount;
+ info.minImageCount = cap.minImageCount;
+ else if (cap.maxImageCount != 0 && info.minImageCount > cap.maxImageCount)
+ info.minImageCount = cap.maxImageCount;
if (cap.currentExtent.width == 0xffffffff)
{
diff --git a/examples/imgui_impl_vulkan.h b/examples/imgui_impl_vulkan.h
index ec9eb54..ec45dbe 100644
--- a/examples/imgui_impl_vulkan.h
+++ b/examples/imgui_impl_vulkan.h
@@ -47,6 +47,7 @@
//-------------------------------------------------------------------------
// Internal / Miscellaneous Vulkan Helpers
+// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own app.)
//-------------------------------------------------------------------------
// You probably do NOT need to use or care about those functions.
// Those functions only exist because:
@@ -70,6 +71,7 @@
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
// Helper structure to hold the data needed by one rendering frame
+// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own app.)
struct ImGui_ImplVulkanH_FrameData
{
uint32_t BackbufferIndex; // Keep track of recently rendered swapchain frame indices
@@ -83,6 +85,7 @@
};
// Helper structure to hold the data needed by one rendering context into one OS window
+// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own app.)
struct ImGui_ImplVulkanH_WindowData
{
int Width;
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 53f1b2a..ad43c68 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -112,8 +112,11 @@
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int).
+- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
-- Examples: FreeGLUT: Made io.DeltaTime always > 0. (#2430)
+- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott]
+- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott]
+- Examples: GLUT: Made io.DeltaTime always > 0. (#2430)
-----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index 1a70ebf..febacf0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -134,7 +134,7 @@
Frameworks:
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
+- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
- Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336)
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
diff --git a/examples/.gitignore b/examples/.gitignore
index b9e1bb6..428ea44 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -33,6 +33,7 @@
example_glfw_opengl3/example_glfw_opengl3
example_sdl_opengl2/example_sdl_opengl2
example_sdl_opengl3/example_sdl_opengl3
+example_glut_opengl2/example_glut_opengl2
## Dear ImGui Ini files
imgui.ini
diff --git a/examples/README.txt b/examples/README.txt
index 1712e28..0a87075 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -111,7 +111,7 @@
imgui_impl_osx.mm ; macOS native API
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (not recommended unless really miss the 90's)
List of Renderer Bindings in this repository:
@@ -230,9 +230,9 @@
Allegro 5 example.
= main.cpp + imgui_impl_allegro5.cpp
-example_freeglut_opengl2/
- FreeGLUT + OpenGL2.
- = main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
+example_glut_opengl2/
+ GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
+ = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
example_marmalade/
Marmalade example using IwGx.
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
deleted file mode 100644
index e3bd417..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- {F90D0333-5FB1-440D-918D-DD39A1B5187E}
- example_freeglut_opengl2
-
-
-
- Application
- true
- MultiByte
-
-
- Application
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
- Application
- false
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
- $(ProjectDir)$(Configuration)\
- $(ProjectDir)$(Configuration)\
- $(IncludePath)
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- Disabled
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
-
-
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
- msvcrt.lib
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
- Level4
- MaxSpeed
- true
- true
- $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
- false
-
-
- true
- true
- true
- $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
- opengl32.lib;freeglut.lib;%(AdditionalDependencies)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters b/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
deleted file mode 100644
index eb6d852..0000000
--- a/examples/example_freeglut_opengl2/example_freeglut_opengl2.vcxproj.filters
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- sources
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
- imgui
-
-
-
-
- imgui
-
-
- imgui
-
-
- imgui
-
-
- sources
-
-
- sources
-
-
-
-
-
- sources
-
-
-
\ No newline at end of file
diff --git a/examples/example_freeglut_opengl2/main.cpp b/examples/example_freeglut_opengl2/main.cpp
deleted file mode 100644
index 41d9bff..0000000
--- a/examples/example_freeglut_opengl2/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// dear imgui: standalone example application for FreeGLUT + OpenGL2, using legacy fixed pipeline
-// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-#include "imgui.h"
-#include "../imgui_impl_freeglut.h"
-#include "../imgui_impl_opengl2.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed
-#endif
-
-static bool show_demo_window = true;
-static bool show_another_window = false;
-static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
-void my_display_code()
-{
- // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
-
- // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
- {
- static float f = 0.0f;
- static int counter = 0;
-
- ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
-
- ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
- counter++;
- ImGui::SameLine();
- ImGui::Text("counter = %d", counter);
-
- ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
- ImGui::End();
- }
-
- // 3. Show another simple window.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-}
-
-void glut_display_func()
-{
- // Start the Dear ImGui frame
- ImGui_ImplOpenGL2_NewFrame();
- ImGui_ImplFreeGLUT_NewFrame();
-
- my_display_code();
-
- // Rendering
- ImGui::Render();
- ImGuiIO& io = ImGui::GetIO();
- glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
- ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
-
- glutSwapBuffers();
- glutPostRedisplay();
-}
-
-// 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.
-
-int main(int argc, char** argv)
-{
- // Create GLUT window
- glutInit(&argc, argv);
- glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
- glutInitWindowSize(1280, 720);
- glutCreateWindow("Dear ImGui FreeGLUT+OpenGL2 Example");
-
- // Setup GLUT display function
- // We will also call ImGui_ImplFreeGLUT_InstallFuncs() to get all the other functions installed for us,
- // otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
- glutDisplayFunc(glut_display_func);
-
- // Setup Dear ImGui context
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
-
- // Setup Dear ImGui style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // Setup Platform/Renderer bindings
- ImGui_ImplFreeGLUT_Init();
- ImGui_ImplFreeGLUT_InstallFuncs();
- ImGui_ImplOpenGL2_Init();
-
- // Load Fonts
- // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
- // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
- // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
- // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
- // - Read 'misc/fonts/README.txt' for more instructions and details.
- // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
- //io.Fonts->AddFontDefault();
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
- //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
- //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
- //IM_ASSERT(font != NULL);
-
- glutMainLoop();
-
- // Cleanup
- ImGui_ImplOpenGL2_Shutdown();
- ImGui_ImplFreeGLUT_Shutdown();
- ImGui::DestroyContext();
-
- return 0;
-}
diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888..ce7e6f7 100644
--- a/examples/example_glfw_vulkan/glsl_shader.frag
+++ b/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@
layout(set=0, binding=0) uniform sampler2D sTexture;
-layout(location = 0) in struct{
+layout(location = 0) in struct {
vec4 Color;
vec2 UV;
} In;
diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908..9425365 100644
--- a/examples/example_glfw_vulkan/glsl_shader.vert
+++ b/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@
layout(location = 1) in vec2 aUV;
layout(location = 2) in vec4 aColor;
-layout(push_constant) uniform uPushConstant{
+layout(push_constant) uniform uPushConstant {
vec2 uScale;
vec2 uTranslate;
} pc;
-out gl_PerVertex{
+out gl_PerVertex {
vec4 gl_Position;
};
-layout(location = 0) out struct{
+layout(location = 0) out struct {
vec4 Color;
vec2 UV;
} Out;
@@ -21,5 +21,5 @@
{
Out.Color = aColor;
Out.UV = aUV;
- gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1);
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
}
diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp
index 74edf5d..6f2c4cd 100644
--- a/examples/example_glfw_vulkan/main.cpp
+++ b/examples/example_glfw_vulkan/main.cpp
@@ -233,77 +233,77 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
- check_vk_result(err);
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
- info.renderArea.extent.width = wd->Width;
- info.renderArea.extent.height = wd->Height;
- info.clearValueCount = 1;
- info.pClearValues = &wd->ClearValue;
- vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
- }
+ err = vkResetFences(g_Device, 1, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
+ check_vk_result(err);
+ }
+ {
+ VkRenderPassBeginInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ info.renderPass = wd->RenderPass;
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.renderArea.extent.width = wd->Width;
+ info.renderArea.extent.height = wd->Height;
+ info.clearValueCount = 1;
+ info.pClearValues = &wd->ClearValue;
+ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
+ }
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
- vkCmdEndRenderPass(fd->CommandBuffer);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &fd->CommandBuffer;
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
+ // Submit command buffer
+ vkCmdEndRenderPass(fd->CommandBuffer);
+ {
+ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ VkSubmitInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitDstStageMask = &wait_stage;
+ info.commandBufferCount = 1;
+ info.pCommandBuffers = &fd->CommandBuffer;
+ info.signalSemaphoreCount = 1;
+ info.pSignalSemaphores = &fd->RenderCompleteSemaphore;
- err = vkEndCommandBuffer(fd->CommandBuffer);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
- check_vk_result(err);
- }
+ err = vkEndCommandBuffer(fd->CommandBuffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
+ check_vk_result(err);
+ }
}
static void FramePresent(ImGui_ImplVulkanH_WindowData* wd)
{
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
- info.swapchainCount = 1;
- info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
}
static void glfw_error_callback(int error, const char* description)
@@ -315,12 +315,12 @@
{
g_ResizeWanted = true;
g_ResizeWidth = w;
- g_ResizeHeight = h;
+ g_ResizeHeight = h;
}
int main(int, char**)
{
- // Setup window
+ // Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -445,11 +445,11 @@
// - 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.
glfwPollEvents();
- if (g_ResizeWanted)
- {
- ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
- g_ResizeWanted = false;
- }
+ if (g_ResizeWanted)
+ {
+ ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
+ g_ResizeWanted = false;
+ }
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -496,7 +496,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000..25ddc43
--- /dev/null
+++ b/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,65 @@
+#
+# Cross Platform Makefile
+# Compatible with Ubuntu 14.04.1 and Mac OS X
+#
+# Linux:
+# apt-get install freeglut3-dev
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glut_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+UNAME_S := $(shell uname -s)
+
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS = -lGL -lglut
+
+ CXXFLAGS = -I ../ -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS = -framework OpenGL -framework GLUT
+
+ CXXFLAGS = -I .. -I../..
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "Windows"
+ LIBS = -lgdi32 -lopengl32 -limm32 -lglut
+
+ CXXFLAGS = -I ../ -I../../
+ CXXFLAGS += -Wall -Wformat
+ CFLAGS = $(CXXFLAGS)
+endif
+
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000..58599e6
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,175 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+ Application
+ false
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+
+
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ $(GLUT_INCLUDE_DIR);..\..;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories)
+ opengl32.lib;freeglut.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000..290d43d
--- /dev/null
+++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222}
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000..52b10a9
--- /dev/null
+++ b/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,144 @@
+// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+#include "imgui.h"
+#include "../imgui_impl_glut.h"
+#include "../imgui_impl_opengl2.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed
+#endif
+
+static bool show_demo_window = true;
+static bool show_another_window = false;
+static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+void my_display_code()
+{
+ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
+ if (show_demo_window)
+ ImGui::ShowDemoWindow(&show_demo_window);
+
+ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
+ {
+ static float f = 0.0f;
+ static int counter = 0;
+
+ ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
+
+ ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
+ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
+ ImGui::Checkbox("Another Window", &show_another_window);
+
+ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
+ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
+
+ if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
+ counter++;
+ ImGui::SameLine();
+ ImGui::Text("counter = %d", counter);
+
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
+ ImGui::End();
+ }
+
+ // 3. Show another simple window.
+ if (show_another_window)
+ {
+ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
+ ImGui::Text("Hello from another window!");
+ if (ImGui::Button("Close Me"))
+ show_another_window = false;
+ ImGui::End();
+ }
+}
+
+void glut_display_func()
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGLUT_NewFrame();
+
+ my_display_code();
+
+ // Rendering
+ ImGui::Render();
+ ImGuiIO& io = ImGui::GetIO();
+ glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+
+ glutSwapBuffers();
+ glutPostRedisplay();
+}
+
+// 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.
+
+int main(int argc, char** argv)
+{
+ // Create GLUT window
+ glutInit(&argc, argv);
+#ifdef __FREEGLUT_EXT_H__
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
+#endif
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+ glutInitWindowSize(1280, 720);
+ glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
+
+ // Setup GLUT display function
+ // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us,
+ // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves.
+ glutDisplayFunc(glut_display_func);
+
+ // Setup Dear ImGui context
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGLUT_Init();
+ ImGui_ImplGLUT_InstallFuncs();
+ ImGui_ImplOpenGL2_Init();
+
+ // Load Fonts
+ // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
+ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
+ // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
+ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
+ // - Read 'misc/fonts/README.txt' for more instructions and details.
+ // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
+ //io.Fonts->AddFontDefault();
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+
+ glutMainLoop();
+
+ // Cleanup
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGLUT_Shutdown();
+ ImGui::DestroyContext();
+
+ return 0;
+}
diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp
index b5d32bb..42ab4a6 100644
--- a/examples/example_sdl_vulkan/main.cpp
+++ b/examples/example_sdl_vulkan/main.cpp
@@ -223,18 +223,18 @@
static void FrameRender(ImGui_ImplVulkanH_WindowData* wd)
{
- VkResult err;
+ VkResult err;
- VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
- err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
- check_vk_result(err);
+ VkSemaphore& image_acquired_semaphore = wd->Frames[wd->FrameIndex].ImageAcquiredSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
ImGui_ImplVulkanH_FrameData* fd = &wd->Frames[wd->FrameIndex];
{
- err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
+ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
check_vk_result(err);
- err = vkResetFences(g_Device, 1, &fd->Fence);
+ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err);
}
{
@@ -250,7 +250,7 @@
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
- info.framebuffer = wd->Framebuffer[wd->FrameIndex];
+ info.framebuffer = wd->Framebuffer[wd->FrameIndex];
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1;
@@ -258,17 +258,17 @@
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
- // Record Imgui Draw Data and draw funcs into command buffer
- ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
+ // Record Imgui Draw Data and draw funcs into command buffer
+ ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
- // Submit command buffer
+ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer);
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &image_acquired_semaphore;
+ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
@@ -291,8 +291,8 @@
info.pWaitSemaphores = &fd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
- info.pImageIndices = &wd->FrameIndex;
- VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
check_vk_result(err);
}
@@ -482,7 +482,7 @@
// Rendering
ImGui::Render();
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- FrameRender(wd);
+ FrameRender(wd);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp
deleted file mode 100644
index 32671a6..0000000
--- a/examples/imgui_impl_freeglut.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the 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)
-// 2019-03-25: Misc: Made io.DeltaTime always above zero.
-// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
-// 2018-03-22: Added FreeGLUT Platform binding.
-
-#include "imgui.h"
-#include "imgui_impl_freeglut.h"
-#include
-
-#ifdef _MSC_VER
-#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
-#endif
-
-static int g_Time = 0; // Current time, in milliseconds
-
-bool ImGui_ImplFreeGLUT_Init()
-{
- ImGuiIO& io = ImGui::GetIO();
- io.BackendPlatformName ="imgui_impl_freeglut";
-
- g_Time = 0;
-
- // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
- io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
- io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = 127;
- io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
- io.KeyMap[ImGuiKey_Space] = ' ';
- io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
- io.KeyMap[ImGuiKey_Escape] = 27;
- io.KeyMap[ImGuiKey_A] = 'A';
- io.KeyMap[ImGuiKey_C] = 'C';
- io.KeyMap[ImGuiKey_V] = 'V';
- io.KeyMap[ImGuiKey_X] = 'X';
- io.KeyMap[ImGuiKey_Y] = 'Y';
- io.KeyMap[ImGuiKey_Z] = 'Z';
-
- return true;
-}
-
-void ImGui_ImplFreeGLUT_InstallFuncs()
-{
- glutReshapeFunc(ImGui_ImplFreeGLUT_ReshapeFunc);
- glutMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutPassiveMotionFunc(ImGui_ImplFreeGLUT_MotionFunc);
- glutMouseFunc(ImGui_ImplFreeGLUT_MouseFunc);
- glutMouseWheelFunc(ImGui_ImplFreeGLUT_MouseWheelFunc);
- glutKeyboardFunc(ImGui_ImplFreeGLUT_KeyboardFunc);
- glutKeyboardUpFunc(ImGui_ImplFreeGLUT_KeyboardUpFunc);
- glutSpecialFunc(ImGui_ImplFreeGLUT_SpecialFunc);
- glutSpecialUpFunc(ImGui_ImplFreeGLUT_SpecialUpFunc);
-}
-
-void ImGui_ImplFreeGLUT_Shutdown()
-{
-}
-
-void ImGui_ImplFreeGLUT_NewFrame()
-{
- // Setup time step
- ImGuiIO& io = ImGui::GetIO();
- int current_time = glutGet(GLUT_ELAPSED_TIME);
- int delta_time_ms = (current_time - g_Time);
- if (delta_time_ms <= 0)
- delta_time_ms = 1;
- io.DeltaTime = delta_time_ms / 1000.0f;
- g_Time = current_time;
-
- // Start the frame
- ImGui::NewFrame();
-}
-
-static void ImGui_ImplFreeGLUT_UpdateKeyboardMods()
-{
- ImGuiIO& io = ImGui::GetIO();
- int mods = glutGetModifiers();
- io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
- io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
- io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
-}
-
-void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y)
-{
- // Send character to imgui
- //printf("char_down_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 32)
- io.AddInputCharacter((unsigned short)c);
-
- // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
- // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
- else
- io.KeysDown[c] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
-{
- //printf("char_up_func %d '%c'\n", c, c);
- ImGuiIO& io = ImGui::GetIO();
- if (c >= 1 && c <= 26)
- io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
- else if (c >= 'a' && c <= 'z')
- io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
- else if (c >= 'A' && c <= 'Z')
- io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
- else
- io.KeysDown[c] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y)
-{
- //printf("key_down_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = true;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y)
-{
- //printf("key_up_func %d\n", key);
- ImGuiIO& io = ImGui::GetIO();
- if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
- io.KeysDown[key + 256] = false;
- ImGui_ImplFreeGLUT_UpdateKeyboardMods();
- (void)x; (void)y; // Unused
-}
-
-void ImGui_ImplFreeGLUT_MouseFunc(int glut_button, int state, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- int button = -1;
- if (glut_button == GLUT_LEFT_BUTTON) button = 0;
- if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
- if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
- if (button != -1 && state == GLUT_DOWN)
- io.MouseDown[button] = true;
- if (button != -1 && state == GLUT_UP)
- io.MouseDown[button] = false;
-}
-
-void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
- if (dir > 0)
- io.MouseWheel += 1.0;
- else if (dir < 0)
- io.MouseWheel -= 1.0;
- (void)button; // Unused
-}
-
-void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize = ImVec2((float)w, (float)h);
-}
-
-void ImGui_ImplFreeGLUT_MotionFunc(int x, int y)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MousePos = ImVec2((float)x, (float)y);
-}
diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h
deleted file mode 100644
index 6d565ec..0000000
--- a/examples/imgui_impl_freeglut.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// dear imgui: Platform Binding for FreeGLUT
-// This needs to be used along with a Renderer (e.g. OpenGL2)
-
-// !!! GLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
-
-// Issues:
-// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
-// [ ] Platform: Missing clipboard support (not supported by Glut).
-// [ ] Platform: Missing gamepad support.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-#pragma once
-
-IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_InstallFuncs();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_Shutdown();
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_NewFrame();
-
-// You can call ImGui_ImplFreeGLUT_InstallFuncs() to get all those functions installed automatically,
-// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
-//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
-IMGUI_IMPL_API void ImGui_ImplFreeGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_glut.cpp b/examples/imgui_impl_glut.cpp
new file mode 100644
index 0000000..d8bd749
--- /dev/null
+++ b/examples/imgui_impl_glut.cpp
@@ -0,0 +1,208 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the 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)
+// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
+// 2019-03-25: Misc: Made io.DeltaTime always above zero.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-03-22: Added GLUT Platform binding.
+
+#include "imgui.h"
+#include "imgui_impl_glut.h"
+#ifdef __APPLE__
+ #include
+#else
+ #include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
+#endif
+
+static int g_Time = 0; // Current time, in milliseconds
+
+bool ImGui_ImplGLUT_Init()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendPlatformName ="imgui_impl_glut";
+
+ g_Time = 0;
+
+ // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above.
+ io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I
+ io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = 127;
+ io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H
+ io.KeyMap[ImGuiKey_Space] = ' ';
+ io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
+ io.KeyMap[ImGuiKey_Escape] = 27;
+ io.KeyMap[ImGuiKey_A] = 'A';
+ io.KeyMap[ImGuiKey_C] = 'C';
+ io.KeyMap[ImGuiKey_V] = 'V';
+ io.KeyMap[ImGuiKey_X] = 'X';
+ io.KeyMap[ImGuiKey_Y] = 'Y';
+ io.KeyMap[ImGuiKey_Z] = 'Z';
+
+ return true;
+}
+
+void ImGui_ImplGLUT_InstallFuncs()
+{
+ glutReshapeFunc(ImGui_ImplGLUT_ReshapeFunc);
+ glutMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutPassiveMotionFunc(ImGui_ImplGLUT_MotionFunc);
+ glutMouseFunc(ImGui_ImplGLUT_MouseFunc);
+#ifdef __FREEGLUT_EXT_H__
+ glutMouseWheelFunc(ImGui_ImplGLUT_MouseWheelFunc);
+#endif
+ glutKeyboardFunc(ImGui_ImplGLUT_KeyboardFunc);
+ glutKeyboardUpFunc(ImGui_ImplGLUT_KeyboardUpFunc);
+ glutSpecialFunc(ImGui_ImplGLUT_SpecialFunc);
+ glutSpecialUpFunc(ImGui_ImplGLUT_SpecialUpFunc);
+}
+
+void ImGui_ImplGLUT_Shutdown()
+{
+}
+
+void ImGui_ImplGLUT_NewFrame()
+{
+ // Setup time step
+ ImGuiIO& io = ImGui::GetIO();
+ int current_time = glutGet(GLUT_ELAPSED_TIME);
+ int delta_time_ms = (current_time - g_Time);
+ if (delta_time_ms <= 0)
+ delta_time_ms = 1;
+ io.DeltaTime = delta_time_ms / 1000.0f;
+ g_Time = current_time;
+
+ // Start the frame
+ ImGui::NewFrame();
+}
+
+static void ImGui_ImplGLUT_UpdateKeyboardMods()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ int mods = glutGetModifiers();
+ io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0;
+ io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0;
+ io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0;
+}
+
+void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
+{
+ // Send character to imgui
+ //printf("char_down_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 32)
+ io.AddInputCharacter((unsigned short)c);
+
+ // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
+ // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true;
+ else
+ io.KeysDown[c] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y)
+{
+ //printf("char_up_func %d '%c'\n", c, c);
+ ImGuiIO& io = ImGui::GetIO();
+ if (c >= 1 && c <= 26)
+ io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false;
+ else if (c >= 'a' && c <= 'z')
+ io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false;
+ else if (c >= 'A' && c <= 'Z')
+ io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false;
+ else
+ io.KeysDown[c] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y)
+{
+ //printf("key_down_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = true;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y)
+{
+ //printf("key_up_func %d\n", key);
+ ImGuiIO& io = ImGui::GetIO();
+ if (key + 256 < IM_ARRAYSIZE(io.KeysDown))
+ io.KeysDown[key + 256] = false;
+ ImGui_ImplGLUT_UpdateKeyboardMods();
+ (void)x; (void)y; // Unused
+}
+
+void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ int button = -1;
+ if (glut_button == GLUT_LEFT_BUTTON) button = 0;
+ if (glut_button == GLUT_RIGHT_BUTTON) button = 1;
+ if (glut_button == GLUT_MIDDLE_BUTTON) button = 2;
+ if (button != -1 && state == GLUT_DOWN)
+ io.MouseDown[button] = true;
+ if (button != -1 && state == GLUT_UP)
+ io.MouseDown[button] = false;
+}
+
+#ifdef __FREEGLUT_EXT_H__
+void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+ if (dir > 0)
+ io.MouseWheel += 1.0;
+ else if (dir < 0)
+ io.MouseWheel -= 1.0;
+ (void)button; // Unused
+}
+#endif
+
+void ImGui_ImplGLUT_ReshapeFunc(int w, int h)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.DisplaySize = ImVec2((float)w, (float)h);
+}
+
+void ImGui_ImplGLUT_MotionFunc(int x, int y)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2((float)x, (float)y);
+}
diff --git a/examples/imgui_impl_glut.h b/examples/imgui_impl_glut.h
new file mode 100644
index 0000000..8fde9ba
--- /dev/null
+++ b/examples/imgui_impl_glut.h
@@ -0,0 +1,33 @@
+// dear imgui: Platform Binding for GLUT/FreeGLUT
+// This needs to be used along with a Renderer (e.g. OpenGL2)
+
+// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
+// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing clipboard support (not supported by Glut).
+// [ ] Platform: Missing gamepad support.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+#pragma once
+
+IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
+IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs();
+IMGUI_IMPL_API void ImGui_ImplGLUT_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
+
+// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
+// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
+//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
+IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
+IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm
index 401e072..f668945 100644
--- a/examples/imgui_impl_metal.mm
+++ b/examples/imgui_impl_metal.mm
@@ -20,7 +20,7 @@
#include "imgui_impl_metal.h"
#import
-// #import // Not suported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
+// #import // Not supported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...)
#import
#pragma mark - Support classes
diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp
index 6b2d313..d5abcc6 100644
--- a/examples/imgui_impl_opengl2.cpp
+++ b/examples/imgui_impl_opengl2.cpp
@@ -114,9 +114,9 @@
glEnable(GL_TEXTURE_2D);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
+ // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
// you may need to backup/reset/restore current shader using the lines below. DO NOT MODIFY THIS FILE! Add the code in your calling function:
- // GLint last_program;
+ // GLint last_program;
// glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
// glUseProgram(0);
// ImGui_ImplOpenGL2_RenderDrawData(...);
diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp
index 179a63a..5911878 100644
--- a/examples/imgui_impl_vulkan.cpp
+++ b/examples/imgui_impl_vulkan.cpp
@@ -14,6 +14,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
+// 2019-04-04: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like.
// 2019-04-01: Vulkan: Support for 32-bit index buffer (#define ImDrawIdx unsigned int).
// 2019-02-16: Vulkan: Viewport and clipping rectangles correctly using draw_data->FramebufferScale to allow retina display.
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
@@ -81,6 +82,23 @@
// glsl_shader.vert, compiled with:
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
+/*
+#version 450 core
+layout(location = 0) in vec2 aPos;
+layout(location = 1) in vec2 aUV;
+layout(location = 2) in vec4 aColor;
+layout(push_constant) uniform uPushConstant { vec2 uScale; vec2 uTranslate; } pc;
+
+out gl_PerVertex { vec4 gl_Position; };
+layout(location = 0) out struct { vec4 Color; vec2 UV; } Out;
+
+void main()
+{
+ Out.Color = aColor;
+ Out.UV = aUV;
+ gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1);
+}
+*/
static uint32_t __glsl_shader_vert_spv[] =
{
0x07230203,0x00010000,0x00080001,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b,
@@ -128,6 +146,16 @@
// glsl_shader.frag, compiled with:
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
+/*
+#version 450 core
+layout(location = 0) out vec4 fColor;
+layout(set=0, binding=0) uniform sampler2D sTexture;
+layout(location = 0) in struct { vec4 Color; vec2 UV; } In;
+void main()
+{
+ fColor = In.Color * texture(sTexture, In.UV.st);
+}
+*/
static uint32_t __glsl_shader_frag_spv[] =
{
0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b,
@@ -325,6 +353,12 @@
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
{
+ // Negative offsets are illegal for vkCmdSetScissor
+ if (clip_rect.x < 0.0f)
+ clip_rect.x = 0.0f;
+ if (clip_rect.y < 0.0f)
+ clip_rect.y = 0.0f;
+
// Apply scissor/clipping rectangle
VkRect2D scissor;
scissor.offset.x = (int32_t)(clip_rect.x);
@@ -930,7 +964,7 @@
void ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_WindowData* wd, const VkAllocationCallbacks* allocator, int w, int h)
{
- uint32_t min_image_count = 2; // FIXME: this should become a function parameter
+ uint32_t min_image_count = 2; // FIXME: this should become a function parameter
VkResult err;
VkSwapchainKHR old_swapchain = wd->Swapchain;
@@ -958,7 +992,7 @@
VkSwapchainCreateInfoKHR info = {};
info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
info.surface = wd->Surface;
- info.minImageCount = min_image_count;
+ info.minImageCount = min_image_count;
info.imageFormat = wd->SurfaceFormat.format;
info.imageColorSpace = wd->SurfaceFormat.colorSpace;
info.imageArrayLayers = 1;
@@ -973,9 +1007,9 @@
err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, wd->Surface, &cap);
check_vk_result(err);
if (info.minImageCount < cap.minImageCount)
- info.minImageCount = cap.minImageCount;
- else if (cap.maxImageCount != 0 && info.minImageCount > cap.maxImageCount)
- info.minImageCount = cap.maxImageCount;
+ info.minImageCount = cap.minImageCount;
+ else if (cap.maxImageCount != 0 && info.minImageCount > cap.maxImageCount)
+ info.minImageCount = cap.maxImageCount;
if (cap.currentExtent.width == 0xffffffff)
{
diff --git a/examples/imgui_impl_vulkan.h b/examples/imgui_impl_vulkan.h
index ec9eb54..ec45dbe 100644
--- a/examples/imgui_impl_vulkan.h
+++ b/examples/imgui_impl_vulkan.h
@@ -47,6 +47,7 @@
//-------------------------------------------------------------------------
// Internal / Miscellaneous Vulkan Helpers
+// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own app.)
//-------------------------------------------------------------------------
// You probably do NOT need to use or care about those functions.
// Those functions only exist because:
@@ -70,6 +71,7 @@
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
// Helper structure to hold the data needed by one rendering frame
+// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own app.)
struct ImGui_ImplVulkanH_FrameData
{
uint32_t BackbufferIndex; // Keep track of recently rendered swapchain frame indices
@@ -83,6 +85,7 @@
};
// Helper structure to hold the data needed by one rendering context into one OS window
+// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own app.)
struct ImGui_ImplVulkanH_WindowData
{
int Width;
diff --git a/imgui.cpp b/imgui.cpp
index 5db1d8a..c96b2d8 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -1370,7 +1370,7 @@
int ImStrlenW(const ImWchar* str)
{
- //return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bits
+ //return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bits
int n = 0;
while (*str++) n++;
return n;