diff --git a/third_party/imgui/.editorconfig b/third_party/imgui/.editorconfig
new file mode 100644
index 0000000000..284ba13fe3
--- /dev/null
+++ b/third_party/imgui/.editorconfig
@@ -0,0 +1,22 @@
+# See http://editorconfig.org to read about the EditorConfig format.
+# - Automatically supported by VS2017+ and most common IDE or text editors.
+# - For older VS2010 to VS2015, install https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig
+
+# top-most EditorConfig file
+root = true
+
+# Default settings:
+# Use 4 spaces as indentation
+[*]
+indent_style = space
+indent_size = 4
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[imstb_*]
+indent_size = 3
+trim_trailing_whitespace = false
+
+[Makefile]
+indent_style = tab
+indent_size = 4
diff --git a/third_party/imgui/.gitattributes b/third_party/imgui/.gitattributes
new file mode 100644
index 0000000000..d48470eeff
--- /dev/null
+++ b/third_party/imgui/.gitattributes
@@ -0,0 +1,30 @@
+* text=auto
+
+*.c text
+*.cpp text
+*.h text
+*.m text
+*.mm text
+*.md text
+*.txt text
+*.html text
+*.bat text
+*.frag text
+*.vert text
+*.mkb text
+*.icf text
+
+*.sln text eol=crlf
+*.vcxproj text eol=crlf
+*.vcxproj.filters text eol=crlf
+*.natvis text eol=crlf
+
+Makefile text eol=lf
+*.sh text eol=lf
+*.pbxproj text eol=lf
+*.storyboard text eol=lf
+*.plist text eol=lf
+
+*.png binary
+*.ttf binary
+*.lib binary
diff --git a/third_party/imgui/.github/CONTRIBUTING.md b/third_party/imgui/.github/CONTRIBUTING.md
deleted file mode 100644
index 984ea521dc..0000000000
--- a/third_party/imgui/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,24 +0,0 @@
-## How to create an Issue
-
-Hello!
-
-You may use the Issue tracker to submit bug reports, feature requests or suggestions. You may ask for help or advices as well, however please read this wall of text before doing so. Thank you!
-
-**Prerequisites for new users of dear imgui:**
-- Please read the FAQ in imgui.cpp.
-- Please read misc/fonts/README.txt if your question relates to fonts or text.
-- Please run ImGui::ShowDemoWindow() to explore the demo and its sources.
-- Please use the Search function to look for similar issues. You may also browse issues by tags.
-- If you get a assert, use a debugger to locate the line triggering it and read the comments around the assert.
-
-**Guidelines to report an issue or ask a question:**
-- Try to provide a Minimal, Complete and Verifiable Example ([MCVE](https://stackoverflow.com/help/mcve)) to demonstrate your problem. An ideal submission includes a small piece of code that anyone can paste in one of the examples/ application to understand and reproduce it. Narrowing your problem to its shortest and purest form is often the easiest way to understand it. Sometimes while creating the MCVE you will end up solving the problem!
-- Try to attach screenshots to clarify the context. They often convey useful information that are omitted by the description. You can drag pictures/files here (prefer github attachments over 3rd party hosting).
-- If you are discussing an assert or a crash, please provide a debugger callstack.
-- Please provide your imgui version number.
-- Please state if you have made substancial modifications to your copy of imgui.
-- When discussing issues related to rendering or inputs, please state which OS you are using, and if you are using a vanilla copy of one of the back end (imgui_impl_xxx files), or modified one, or if you built your own.
-- When requesting a new feature or pushing code, please describe the usage context (how you intend to use it, why you need it, etc.).
-
-If you have been using dear imgui for a while and/or have been using C/C++ for several years and/or have demonstrated good behavior here, it is ok to not fullfill every item to the letter. Those are guidelines and experienced users of dear imgui will know what information are useful in a given context.
-
diff --git a/third_party/imgui/.github/issue_template.md b/third_party/imgui/.github/issue_template.md
index e47ef9e892..3812ad0b01 100644
--- a/third_party/imgui/.github/issue_template.md
+++ b/third_party/imgui/.github/issue_template.md
@@ -1,7 +1,46 @@
-(Please carefully read guidelines in [CONTRIBUTING.md](https://github.com/ocornut/imgui/blob/master/.github/CONTRIBUTING.md) then delete this line)
+(Click "Preview" above ^ to turn URL into clickable links)
-You can include code this way:
-```cpp
-ImGui::Begin("Hello");
-ImGui::ThisIsMoreCode();
+1. PLEASE CAREFULLY READ: [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md)
+
+2. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261)
+
+3. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING/LOADING FONTS, please use the [Discord server](http://discord.dearimgui.org).
+
+4. PLEASE MAKE SURE that you have: read the FAQ; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the link provided in (1) (2).
+
+5. Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users.
+
+6. Delete points 1-6 and PLEASE FILL THE TEMPLATE BELOW before submitting your issue.
+
+Thank you!
+
+----
+
+_(you may also go to Demo>About Window, and click "Config/Build Information" to obtain a bunch of detailed information that you can paste here)_
+
+**Version/Branch of Dear ImGui:**
+
+Version: XXX
+Branch: XXX _(master/viewport/docking/etc.)_
+
+**Back-end/Renderer/Compiler/OS**
+
+Back-ends: imgui_impl_XXX.cpp + imgui_impl_XXX.cpp _(or specify if using a custom engine/back-end)_
+Compiler: XXX _(if the question is related to building or platform specific features)_
+Operating System: XXX
+
+**My Issue/Question:**
+
+XXX _(please provide as much context as possible)_
+
+**Screenshots/Video**
+
+XXX _(you can drag files here)_
+
+**Standalone, minimal, complete and verifiable example:** _(see https://github.com/ocornut/imgui/issues/2261)_
+```
+// Here's some code anyone can copy and paste to reproduce your issue
+ImGui::Begin("Example Bug");
+MoreCodeToExplainMyIssue();
+ImGui::End();
```
diff --git a/third_party/imgui/.github/pull_request_template.md b/third_party/imgui/.github/pull_request_template.md
new file mode 100644
index 0000000000..533027c9ad
--- /dev/null
+++ b/third_party/imgui/.github/pull_request_template.md
@@ -0,0 +1,6 @@
+(Click "Preview" to turn any http URL into a clickable link)
+
+PLEASE CAREFULLY READ:
+https://github.com/ocornut/imgui/issues/2261
+
+(Clear this template before submitting your PR)
diff --git a/third_party/imgui/.github/workflows/build.yml b/third_party/imgui/.github/workflows/build.yml
new file mode 100644
index 0000000000..8edef47bf6
--- /dev/null
+++ b/third_party/imgui/.github/workflows/build.yml
@@ -0,0 +1,433 @@
+name: build
+
+on:
+ push: {}
+ pull_request: {}
+ schedule:
+ - cron: '0 9 * * *'
+
+jobs:
+ Windows:
+ runs-on: windows-2019
+ env:
+ VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
+ MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
+ # Until gh-actions allow us to use env variables inside other env variables (because we need %GITHUB_WORKSPACE%) we have to use relative path to imgui/examples/example_name directory.
+ SDL2_DIR: ..\..\SDL2-devel-2.0.10-VC\SDL2-2.0.10\
+ VULKAN_SDK: ..\..\vulkan-sdk-1.1.121.2\
+ steps:
+ - uses: actions/checkout@v1
+ with:
+ fetch-depth: 1
+
+ - name: Install Dependencies
+ shell: powershell
+ run: |
+ Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip" -OutFile "SDL2-devel-2.0.10-VC.zip"
+ Expand-Archive -Path SDL2-devel-2.0.10-VC.zip
+ Invoke-WebRequest -Uri "https://github.com/ocornut/imgui/files/3789205/vulkan-sdk-1.1.121.2.zip" -OutFile vulkan-sdk-1.1.121.2.zip
+ Expand-Archive -Path vulkan-sdk-1.1.121.2.zip
+
+ - name: Fix Projects
+ shell: powershell
+ run: |
+ # WARNING: This will need updating if toolset/sdk change in project files!
+ gci -recurse -filter "*.vcxproj" | ForEach-Object {
+ # Fix SDK and toolset for most samples.
+ (Get-Content $_.FullName) -Replace "v110","v142" | Set-Content -Path $_.FullName
+ (Get-Content $_.FullName) -Replace "8.1","10.0.18362.0" | Set-Content -Path $_.FullName
+ # Fix SDK and toolset for samples that require newer SDK/toolset. At the moment it is only dx12.
+ (Get-Content $_.FullName) -Replace "v140","v142" | Set-Content -Path $_.FullName
+ (Get-Content $_.FullName) -Replace "10.0.14393.0","10.0.18362.0" | Set-Content -Path $_.FullName
+ }
+
+ # Not using matrix here because it would inflate job count too much. Check out and setup is done for every job and that makes build times way too long.
+ - name: Build example_null (extra warnings, mingw 64-bit)
+ run: mingw32-make -C examples/example_null WITH_EXTRA_WARNINGS=1
+
+ - name: Build example_null (extra warnings, msvc 64-bit)
+ shell: cmd
+ run: |
+ cd examples\example_null
+ "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64 && .\build_win32.bat /W4
+
+ - name: Build example_null (single file build)
+ shell: bash
+ run: |
+ echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp
+
+ - name: Build example_null (with IMGUI_DISABLE_WIN32_FUNCTIONS)
+ shell: bash
+ run: |
+ echo '#define IMGUI_DISABLE_WIN32_FUNCTIONS' > example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp
+
+ - name: Build example_null (as DLL)
+ shell: cmd
+ run: |
+ "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64
+ echo '#ifdef _EXPORT' > example_single_file.cpp
+ echo '# define IMGUI_API __declspec(dllexport)' >> example_single_file.cpp
+ echo '#else' >> example_single_file.cpp
+ echo '# define IMGUI_API __declspec(dllimport)' >> example_single_file.cpp
+ echo '#endif' >> example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ cl.exe /D_USRDLL /D_WINDLL /D_EXPORT /I. example_single_file.cpp /LD /FeImGui.dll /link
+ cl.exe /I. ImGui.lib /Feexample_null.exe examples/example_null/main.cpp
+
+ - name: Build Win32 example_glfw_opengl2
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+
+ - name: Build Win32 example_glfw_opengl3
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build Win32 example_glfw_vulkan
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build Win32 example_sdl_vulkan
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build Win32 example_sdl_opengl2
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build Win32 example_sdl_opengl3
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+
+ - name: Build Win32 example_sdl_directx11
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_directx11/example_sdl_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build Win32 example_win32_directx9
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+
+ - name: Build Win32 example_win32_directx10
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+
+ - name: Build Win32 example_win32_directx11
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build x64 example_glfw_opengl2
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build x64 example_glfw_opengl3
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
+
+ - name: Build x64 example_glfw_vulkan
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
+
+ - name: Build x64 example_sdl_vulkan
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build x64 example_sdl_opengl2
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build x64 example_sdl_opengl3
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build x64 example_sdl_directx11
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_directx11/example_sdl_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
+
+ - name: Build x64 example_win32_directx9
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=x64 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build x64 example_win32_directx10
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=x64 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build x64 example_win32_directx11
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
+ if: github.event_name == 'schedule'
+
+ - name: Build x64 example_win32_directx12
+ shell: cmd
+ run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
+
+ Linux:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v1
+ with:
+ fetch-depth: 1
+
+ - name: Install Dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y libglfw3-dev libsdl2-dev gcc-multilib g++-multilib libfreetype6-dev
+
+ - name: Build example_null (extra warnings, gcc 32-bit)
+ run: |
+ make -C examples/example_null clean
+ CXXFLAGS="$CXXFLAGS -m32 -Werror" make -C examples/example_null WITH_EXTRA_WARNINGS=1
+
+ - name: Build example_null (extra warnings, gcc 64-bit)
+ run: |
+ make -C examples/example_null clean
+ CXXFLAGS="$CXXFLAGS -m64 -Werror" make -C examples/example_null WITH_EXTRA_WARNINGS=1
+
+ - name: Build example_null (extra warnings, clang 32-bit)
+ run: |
+ make -C examples/example_null clean
+ CXXFLAGS="$CXXFLAGS -m32 -Werror" CXX=clang++ make -C examples/example_null WITH_EXTRA_WARNINGS=1
+
+ - name: Build example_null (extra warnings, clang 64-bit)
+ run: |
+ make -C examples/example_null clean
+ CXXFLAGS="$CXXFLAGS -m64 -Werror" CXX=clang++ make -C examples/example_null WITH_EXTRA_WARNINGS=1
+
+ - name: Build example_null (freetype)
+ run: |
+ make -C examples/example_null clean
+ make -C examples/example_null WITH_FREETYPE=1
+
+ - name: Build example_null (single file build)
+ run: |
+ echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with ImWchar32)
+ run: |
+ echo '#define IMGUI_USE_WCHAR32' > example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with large ImDrawIdx)
+ run: |
+ echo '#define ImDrawIdx unsigned int' > example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with IMGUI_DISABLE_OBSOLETE_FUNCTIONS)
+ run: |
+ echo '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' > example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with IMGUI_DISABLE_DEMO_WINDOWS and IMGUI_DISABLE_METRICS_WINDOW)
+ run: |
+ echo '#define IMGUI_DISABLE_DEMO_WINDOWS' > example_single_file.cpp
+ echo '#define IMGUI_DISABLE_METRICS_WINDOW' >> example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with IMGUI_DISABLE_FILE_FUNCTIONS)
+ run: |
+ echo '#define IMGUI_DISABLE_FILE_FUNCTIONS' > example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with IMGUI_USE_BGRA_PACKED_COLOR)
+ run: |
+ echo '#define IMGUI_USE_BGRA_PACKED_COLOR' > example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with IM_VEC2_CLASS_EXTRA and IM_VEC4_CLASS_EXTRA)
+ run: |
+ echo 'struct MyVec2 { float x; float y; MyVec2(float x, float y) : x(x), y(y) { } };' > example_single_file.cpp
+ echo 'struct MyVec4 { float x; float y; float z; float w;' >> example_single_file.cpp
+ echo 'MyVec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } };' >> example_single_file.cpp
+ echo '#define IM_VEC2_CLASS_EXTRA \' >> example_single_file.cpp
+ echo ' ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \' >> example_single_file.cpp
+ echo ' operator MyVec2() const { return MyVec2(x, y); }' >> example_single_file.cpp
+ echo '#define IM_VEC4_CLASS_EXTRA \' >> example_single_file.cpp
+ echo ' ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \' >> example_single_file.cpp
+ echo ' operator MyVec4() const { return MyVec4(x, y, z, w); }' >> example_single_file.cpp
+ echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (without c++ runtime, Clang)
+ run: |
+ echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
+ echo '#define IMGUI_DISABLE_DEMO_WINDOWS' >> example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp
+
+ - name: Build example_glfw_opengl2
+ run: make -C examples/example_glfw_opengl2
+
+ - name: Build example_glfw_opengl3
+ run: make -C examples/example_glfw_opengl3
+ if: github.event_name == 'schedule'
+
+ - name: Build example_sdl_opengl2
+ run: make -C examples/example_sdl_opengl2
+ if: github.event_name == 'schedule'
+
+ - name: Build example_sdl_opengl3
+ run: make -C examples/example_sdl_opengl3
+
+ MacOS:
+ runs-on: macOS-latest
+ steps:
+ - uses: actions/checkout@v1
+ with:
+ fetch-depth: 1
+
+ - name: Install Dependencies
+ run: |
+ brew install glfw3
+ brew install sdl2
+
+ - name: Build example_null (extra warnings, clang 64-bit)
+ run: make -C examples/example_null WITH_EXTRA_WARNINGS=1
+
+ - name: Build example_null (single file build)
+ run: |
+ echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ clang++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (without c++ runtime)
+ run: |
+ echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp
+ echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
+ echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
+ clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp
+
+ - name: Build example_glfw_opengl2
+ run: make -C examples/example_glfw_opengl2
+
+ - name: Build example_glfw_opengl3
+ run: make -C examples/example_glfw_opengl3
+ if: github.event_name == 'schedule'
+
+ - name: Build example_glfw_metal
+ run: make -C examples/example_glfw_metal
+
+ - name: Build example_sdl_metal
+ run: make -C examples/example_sdl_metal
+
+ - name: Build example_sdl_opengl2
+ run: make -C examples/example_sdl_opengl2
+ if: github.event_name == 'schedule'
+
+ - name: Build example_sdl_opengl3
+ run: make -C examples/example_sdl_opengl3
+
+ - name: Build example_apple_metal
+ run: xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos
+
+ - name: Build example_apple_opengl2
+ run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
+
+ iOS:
+ runs-on: macOS-latest
+ steps:
+ - uses: actions/checkout@v1
+ with:
+ fetch-depth: 1
+
+ - name: Build example_apple_metal
+ run: |
+ # Code signing is required, but we disable it because it is irrelevant for CI builds.
+ xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_ios CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
+
+ Emscripten:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v1
+ with:
+ fetch-depth: 1
+
+ - name: Install Dependencies
+ run: |
+ wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
+ tar -xvf master.tar.gz
+ emsdk-master/emsdk update
+ emsdk-master/emsdk install latest-fastcomp
+ emsdk-master/emsdk activate latest-fastcomp
+
+ - name: Build example_emscripten
+ run: |
+ source emsdk-master/emsdk_env.sh
+ make -C examples/example_emscripten
+
+ Static-Analysis:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v1
+ with:
+ fetch-depth: 1
+
+ - name: Install Dependencies
+ env:
+ PVS_STUDIO_LICENSE: ${{ secrets.PVS_STUDIO_LICENSE }}
+ run: |
+ if [[ "$PVS_STUDIO_LICENSE" != "" ]];
+ then
+ echo "$PVS_STUDIO_LICENSE" > pvs-studio.lic
+ wget -q https://files.viva64.com/etc/pubkey.txt
+ sudo apt-key add pubkey.txt
+ sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list
+ sudo apt-get update
+ sudo apt-get install -y pvs-studio
+ fi
+
+ - name: PVS-Studio static analysis
+ run: |
+ if [[ ! -f pvs-studio.lic ]];
+ then
+ echo "PVS Studio license is missing. No analysis will be performed."
+ echo "If you have a PVS Studio license please create a project secret named PVS_STUDIO_LICENSE with your license."
+ echo "You may use a free license. More information at https://www.viva64.com/en/b/0457/"
+ exit 0
+ fi
+ cd examples/example_null
+ pvs-studio-analyzer trace -- make WITH_EXTRA_WARNINGS=1
+ pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log
+ plog-converter -a 'GA:1,2;OP:1' -t errorfile -w pvs-studio.log
diff --git a/third_party/imgui/.gitignore b/third_party/imgui/.gitignore
new file mode 100644
index 0000000000..84014850bb
--- /dev/null
+++ b/third_party/imgui/.gitignore
@@ -0,0 +1,49 @@
+## OSX artifacts
+.DS_Store
+
+## Dear ImGui artifacts
+imgui.ini
+
+## General build artifacts
+*.o
+*.obj
+*.exe
+examples/build/*
+examples/*/Debug/*
+examples/*/Release/*
+examples/*/x64/*
+
+## Visual Studio artifacts
+.vs
+ipch
+*.opensdf
+*.log
+*.pdb
+*.ilk
+*.user
+*.sdf
+*.suo
+*.VC.db
+*.VC.VC.opendb
+
+## Xcode artifacts
+project.xcworkspace
+xcuserdata
+
+## Emscripten artifacts
+examples/*.o.tmp
+examples/*.out.js
+examples/*.out.wasm
+examples/example_emscripten/example_emscripten.*
+
+## JetBrains IDE artifacts
+.idea
+cmake-build-*
+
+## Unix executables from our example Makefiles
+examples/example_glfw_opengl2/example_glfw_opengl2
+examples/example_glfw_opengl3/example_glfw_opengl3
+examples/example_glut_opengl2/example_glut_opengl2
+examples/example_null/example_null
+examples/example_sdl_opengl2/example_sdl_opengl2
+examples/example_sdl_opengl3/example_sdl_opengl3
diff --git a/third_party/imgui/.travis.yml b/third_party/imgui/.travis.yml
deleted file mode 100644
index f4de9ecae3..0000000000
--- a/third_party/imgui/.travis.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-language: cpp
-sudo: required
-dist: trusty
-
-os:
- - linux
- - osx
-
-compiler:
- - gcc
- - clang
-
-before_install:
- - if [ $TRAVIS_OS_NAME == linux ]; then
- sudo apt-get update -qq;
- sudo apt-get install -y --no-install-recommends libxrandr-dev libxi-dev libxxf86vm-dev libsdl2-dev;
- wget https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.zip;
- unzip glfw-3.2.1.zip && cd glfw-3.2.1;
- cmake -DBUILD_SHARED_LIBS=true -DGLFW_BUILD_EXAMPLES=false -DGLFW_BUILD_TESTS=false -DGLFW_BUILD_DOCS=false .;
- sudo make -j $CPU_NUM install && cd ..;
- fi
- - if [ $TRAVIS_OS_NAME == osx ]; then
- brew update;
- brew install glfw3;
- brew install sdl2;
- fi
-
-script:
- - make -C examples/opengl2_example
- - make -C examples/opengl3_example
- - make -C examples/sdl_opengl3_example
diff --git a/third_party/imgui/CHANGELOG.txt b/third_party/imgui/CHANGELOG.txt
deleted file mode 100644
index a0f0e2a7ff..0000000000
--- a/third_party/imgui/CHANGELOG.txt
+++ /dev/null
@@ -1,699 +0,0 @@
-dear imgui
-CHANGELOG
-
------------------------------------------------------------------------
-
-This document holds the programmer changelog that we also use in release notes.
-We generally fold multiple commits pertaining to the same topic as a single entry, and simplify various things.
-
-Release notes: (with links and screenshots)
- https://github.com/ocornut/imgui/releases
-
-Changes to the examples/bindings are included within the individual .cpp files in examples.
-
-Individual commits:
- https://github.com/ocornut/imgui/commits/master
-
-Report issues, ask questions:
- https://github.com/ocornut/imgui/issues
-
------------------------------------------------------------------------
-
-WHEN TO UPDATE?
-
-It is generally safe to sync to the latest commit in master. The library is fairly stable and regressions tends to be fixed fast when reported.
-Keeping your copy of dear imgui updated once in a while is recommended.
-
-HOW TO UPDATE?
-
-- Overwrite every file except imconfig.h (if you have modified it).
-- You may also locally branch to modify imconfig.h and merge latest into your branch.
-- Read the `Breaking Changes` section (in imgui.cpp or here in the Changelog).
-- If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it.
-- If you are dropping this repository in your codebase, please leave the demo and text files in there, they will be useful.
-- You may diff your previous Changelog with the one you just copied and read that diff.
-- You may enable `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in imconfig.h to forcefully disable legacy names and symbols. Doing it every once in a while is a good way to make sure you are not using obsolete symbols. Dear ImGui is in active development API updates have a little more frequent lately. They are carefully documented and should not affect all users.
-- Please report any issue!
-
------------------------------------------------------------------------
-
-VERSION 1.60 WIP (Latest, currently in development)
-
-The gamepad/keyboard navigation branch (which has been in the work since July 2016) has been merged.
-Gamepad/keyboard navigation is still marked as Beta and has to be enabled explicitely.
-Various internal refactors have also been done, as part of the navigation work and as part of the upcoing viewport/docking work.
-
-Breaking Changes:
-(IN PROGRESS, WILL ADD TO THIS LIST AS WE WORK ON 1.60)
-
- - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
- - Obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display.
- - Reorganized context handling to be more explicit,
- - YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
- - removed Shutdown() function, as DestroyContext() serve this purpose.
- - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwhise CreateContext() will create its own font atlas instance.
- - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
- - removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts.
- - Moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths.
- - Obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
- - Obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete).
- - Renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData.
- - Removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it it's easy to replicate on your side.
-
-Other Changes:
-(IN PROGRESS, WILL ADD TO THIS LIST AS WE WORK ON 1.60)
-
-- Navigation: merged in the gamepad/keyboard navigation (about one million changes!). (#787, #323)
- The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable.
- - To use Keyboard Navigation:
- - Set io.NavFlags |= ImGuiNavFlags_EnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeyDown[] + io.KeyMap[] arrays.
- - When keyboard navigation is active (io.NavActive + NavFlags_EnableKeyboard), the io.WantCaptureKeyboard flag will be set.
- For more advanced uses, you may want to read from io.NavActive or io.NavVisible. Read imgui.cpp for more details.
- - To use Gamepad Navigation:
- - Set io.NavFlags |= ImGuiNavFlags_EnableGamepad to enable. Fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
- - See https://github.com/ocornut/imgui/issues/1599 for recommended gamepad mapping.
- - See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. Read imgui.cpp for more details.
-- Navigation: SetItemDefaultFocus() sets the navigation position in addition to scrolling. (#787)
-- Navigation: Added IsItemFocused(), added IsAnyItemFocused(). (#787)
-- Navigation: Added window flags: ImGuiWindowFlags_NoNav (ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus).
-- Navigation: Style: Added ImGuiCol_NavHighlight, ImGuiCol_NavWindowingHighlight colors. (#787)
-- Navigation: TreeNode: Added ImGuiTreeNodeFlags_NavLeftJumpsBackHere flag to allow Nav Left direction to jump back to parent tree node from any of its child. (#1079)
-- Navigation: IO: Added io.NavFlags (input), io.NavActive (output), io.NavVisible (output). (#787)
-- Context: Removed the default global context and font atlas instances, which caused various problems to users of multiple contexts and DLL users. (#1565)
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. Existing apps will assert/crash without it.
-- Context: Removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions() and shared by all contexts. (#1565, #586, #992, #1007, #1558)
-- Context: You may pass a ImFontAtlas to CreateContext() to specify a font atlas to share. Shared font atlas are not owned by the context and not destroyed along with it.
-- Context: Added IMGUI_DISABLE_DEFAULT_ALLOCATORS to disable linking with malloc/free. (#1565, #586, #992, #1007, #1558)
-- IO: Added ImGuiKey_Insert, ImGuiKey_Space keys. Setup in all example bindings. (#1541)
-- IO: Added Horizontal Mouse Wheel support for horizontal scrolling. (#1463) [@tseeker]
-- IO: Added IsAnyMouseDown() helper which is helpful for bindings to handle mouse capturing.
-- Window: Clicking on a window with the ImGuiWIndowFlags_NoMove flags takes an ActiveId so we can't hover something else when dragging afterwards. (ref #1381, #1337)
-- Window: IsWindowHovered(): Added ImGuiHoveredFlags_AnyWindow, ImGuiFocusedFlags_AnyWindow flags (See Breaking Changes). Added to demo. (#1382)
-- Window: Added SetNextWindowBgAlpha() helper. Particularly helpul since the legacy 5-parameters version of Begin() has been marked as obsolete in 1.53. (#1567)
-- Window: Fixed SetNextWindowContentSize() with 0.0f on Y axis (or SetNextWindowContentWidth()) overwriting the contents size. Got broken on Dec 10 (1.53). (#1363)
-- Window: CloseButton: Fixed cross positioning being a little off.
-- InputText: Added alternative clipboard shortcuts: Shift+Delete (cut), Ctrl+Insert (copy), Shift+Insert (paste). (#1541)
-- InputText: Fixed losing Cursor X position when clicking outside on an item that's submitted after the InputText(). It was only noticeable when restoring focus programmatically. (#1418, #1554)
-- Style: Enable window border by default. (#707)
-- Style: Exposed ImGuiStyleVar_WindowTitleAlign, ImGuiStyleVar_ScrollbarSize, ImGuiStyleVar_ScrollbarRounding, ImGuiStyleVar_GrabRounding + added an assert to reduce accidental breakage. (#1181)
-- Style: Added style.MouseCursorScale help when using the software mouse cursor facility. (#939).
-- Popup: OpenPopup() Always reopen existing popup. (Removed imgui_internal.h's OpenPopupEx() which was used for this.) (#1497, #1533).
-- Popup: BeginPopupContextItem(), BeginPopupContextWindow(), BeginPopupContextVoid(), OpenPopupOnItemClick() all react on mouse release instead of mouse press. (~#439)
-- Popup: Better handling of user mistakenly calling OpenPopup() every frame (with reopen_existing option). The error will now be more visible and easier to understand. (#1497)
-- Popup: BeginPopup(): Exposed extra_flags parameter that are passed through to Begin(). (#1533)
-- Popup: BeginPopupModal: fixed the conditional test for SetNextWindowPos() which was polling the wrong window, which in practice made the test succeed all the time.
-- Tooltip: BeginTooltip() sets NoInputs flag.
-- Scrollbar: Fixed ScrollbarY enable test after ScrollbarX has been enabled being a little off (small regression from Nov 2017). (#1574)
-- Scrollbar: Fixed ScrollbarX enable test subtracting WindowPadding.x (this has been there since the addition of horizontal scroll bar!).
-- Columns: Clear offsets data when columns count changed. (#1525)
-- Columns: Fixed a memory leak of ImGuiColumnsSet's Columns vector. (#1529) [@unprompted]
-- MenuBar: Fixed menu bar pushing a clipping rect outside of its allocated bound (usually unnoticeable).
-- TreeNode: nodes with the ImGuiTreeNodeFlags_Leaf flag correctly disable highlight when DragDrop is active. (#143, #581)
-- Drag and Drop: Increased payload type string to 12 characters instead of 8. (#143)
-- Drag and Drop: TreeNode as drop target displays rectangle over full frame. (#1597, #143)
-- DragFloat: Fix/workaround for backends which do not preserve a valid mouse position when dragged out of bounds. (#1559)
-- PlotLines: plot a flat line if scale_min==scale_max. (#1621)
-- ImFontAtlas: Handle stb_truetype stbtt_InitFont() and stbtt_PackBegin() possible failures more gracefully, GetTexDataAsRGBA32() won't crash during conversion. (#1527)
-- ImFontAtlas: Moved mouse cursor data out of ImGuiContext, fix drawing them with multiple contexts. Also remove the last remaining undesirable dependency on ImGui in imgui_draw.cpp. (#939)
-- ImFontAtlas: Added ImFontAtlasFlags_NoPowerOfTwoHeight flag to disable padding font height to nearest power of two. (#1613)
-- ImFontAtlas: Added ImFontAtlasFlags_NoMouseCursors flag to disable baking software mouse cursors, mostly to save texture memory on very low end hardware. (#1613)
-- ImDrawList: Fixed AddRect() with antialiasing disabled (lower-right corner pixel was often missing, rounding looks a little better.) (#1646)
-- Misc: Functions passed to libc qsort are explicitely marked cdecl to support compiling with vectorcall as the default calling convention. (#1230, #1611) [@RandyGaul]
-- Misc: ImVec2: added [] operator. This is becoming desirable for some types of code, better added sooner than later.
-- Misc: Exposed IM_OFFSETOF() helper in imgui.h.
-- Misc: NewFrame(): Added an assert to detect incorrect filling of the io.KeyMap[] array earlier. (#1555)
-- Misc: Added obsolete redirection function GetItemsLineHeightWithSpacing() (which redirects to GetFrameHeightWithSpacing()), as intended and stated in docs of 1.53.
-- Misc: Added misc/natvis/imgui.natvis for visual studio debugger users to easily visualizer imgui internal types. Added to examples projects.
-- Misc: Added IMGUI_USER_CONFIG to define a custom configuration filename. (#255, #1573, #1144, #41)
-- Misc: Updated stb_rect_pack from 0.10 to 0.11 (minor changes).
-- Fonts: Updated stb_truetype from 1.14 to stb_truetype 1.19. (w/ include fix from some platforms #1622)
-- Fonts: Added optional FreeType rasterizer in misc/freetype. Moved from imgui_club repo. (#618) [@Vuhdo, @mikesart, @ocornut]
-- Fonts: Moved extra_fonts/ to misc/fonts/.
-- Demo: Improved Selectable() examples. (#1528)
-- Demo: Tweaked the Child demos, added a menu bar to the second child to test some navigation functions.
-- Demo: Console: Using ImGuiCol_Text to be more friendly to color changes.
-- Demo: Using IM_COL32() instead of ImColor() in ImDrawList centric contexts. Trying to phase out use of the ImColor helper whenever possible.
-- Examples: Files in examples/ now include their own changelog so it is easier to occasionally update your bindings if needed.
-- Examples: Using Dark theme by default. (#707). Tweaked demo code.
-- Examples: Added support for horizontal mouse wheel for API that allows it. (#1463)
-- Examples: DirectX12: Added DirectX 12 example. (#301) [@jdm3]
-- Examples: OpenGL3+GLFW,SDL: Changed GLSL shader version to 150 (#1466, #1504).
-- Examples: OpenGL3+GLFW,SDL: Creating VAO in the render function so it can be more easily used by multiple shared OpenGL contexts. (#1217)
-- Examples: OpenGL3+GLFW: Using 3.2 context instead of 3.3. (#1466)
-- Examples: OpenGL: Setting up glPixelStorei() explicitly before uploading texture.
-- Examples: OpenGL: Calls to glPolygonMode() are casting parameters as GLEnum to not fail with more strict bindings. (#1628) [@ilia-glushchenko]
-- Examples: Win32 (DirectX9,10,11,12): Added support for mouse cursor shapes. (#1495)
-- Examples: Win32 (DirectX9,10,11,12: Support for windows using the CS_DBLCLKS class flag by handling the double-click messages (WM_LBUTTONDBLCLK etc.). (#1538, #754) [@ndandoulakis]
-- Examples: Win32 (DirectX9,10,11,12): Made the Win32 proc handlers not assert if there is no active context yet, to be more flexible with creation order. (#1565)
-- Examples: GLFW: Added support for mouse cursor shapes (the diagonal resize cursors are unfortunately not supported by GLFW at the moment. (#1495)
-- Examples: SDL: Added support for mouse cursor shapes. (#1626) [@olls]
-- Examples: SDL: Using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging (SDL 2.0.4+ only, otherwise using SDL_WINDOW_INPUT_FOCUS instead of previously SDL_WINDOW_MOUSE_FOCUS). (#1559)
-- Examples: SDL: Enabled vsync by default so people don't come at us with demoes running at 2000 FPS burning a cpu core.
-- Examples: SDL: Using SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency() to handle framerate over 1000 FPS properly. (#996)
-- Examples: SDL: Using scancode exclusively instead of a confusing mixture of scancodes and keycodes.
-- Examples: SDL: Visual Studio: Added .vcxproj file. Using %SDL2_DIR% in the default .vcxproj and build files instead of %SDL_DIR%, the earlier being more standard.
-- Examples: Vulkan: Visual Studio: Added .vcxproj file.
-- Examples: Apple: Fixed filenames in OSX xcode project. Various other Mac friendly fixes. [@gerryhernandez etc.]
-- Examples: Visual Studio: Disabled extraneous function-level check in Release build.
-- Internals: Lots of refactoring!
-- Various minor fixes, tweaks, optimizations, comments.
-
------------------------------------------------------------------------
-
-VERSION 1.53 (Released 2017-12-25)
-Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.53
-
-Breaking Changes:
-
-- Renamed the emblematic `ShowTestWindow()` function to `ShowDemoWindow()`. Kept redirection function (will obsolete).
-- Renamed `GetItemsLineHeightWithSpacing()` to `GetFrameHeightWithSpacing()` for consistency. Kept redirection function (will obsolete).
-- Renamed `ImGuiTreeNodeFlags_AllowOverlapMode` flag to `ImGuiTreeNodeFlags_AllowItemOverlap`. Kept redirection enum (will obsolete).
-- Obsoleted `IsRootWindowFocused()` in favor of using `IsWindowFocused(ImGuiFocusedFlags_RootWindow)`. Kept redirection function (will obsolete). (#1382)
-- Obsoleted `IsRootWindowOrAnyChildFocused()` in favor of using `IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows)`. Kept redirection function (will obsolete). (#1382)
-- Obsoleted `IsRootWindowOrAnyChildHovered()` in favor of using `IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows)`. Kept redirection function (will obsolete). (#1382)
-- Obsoleted `SetNextWindowContentWidth() in favor of using `SetNextWindowContentSize()`. Kept redirection function (will obsolete).
-- Renamed `ImGuiTextBuffer::append()` helper to `appendf()`, and `appendv()` to `appendfv()` for consistency. If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed.
-- ImDrawList: Removed 'bool anti_aliased = true' final parameter of `ImDrawList::AddPolyline()` and `ImDrawList::AddConvexPolyFilled()`. Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame.
-- Style, ImDrawList: Renamed `style.AntiAliasedShapes` to `style.AntiAliasedFill` for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags.
-- Style, Begin: Removed `ImGuiWindowFlags_ShowBorders` window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. `style.FrameBorderSize`, `style.WindowBorderSize`). Use `ImGui::ShowStyleEditor()` to look them up.
- Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time.
- It is recommended that you use the `StyleColorsClassic()`, `StyleColorsDark()`, `StyleColorsLight()` functions. Also see `ShowStyleSelector()`.
-- Style: Removed `ImGuiCol_ComboBg` in favor of combo boxes using `ImGuiCol_PopupBg` for consistency. Combo are normal popups.
-- Style: Renamed `ImGuiCol_ChildWindowBg` to `ImGuiCol_ChildBg`.
-- Style: Renamed `style.ChildWindowRounding` to `style.ChildRounding`, `ImGuiStyleVar_ChildWindowRounding` to `ImGuiStyleVar_ChildRounding`.
-- Removed obsolete redirection functions: SetScrollPosHere() - marked obsolete in v1.42, July 2015.
-- Removed obsolete redirection functions: GetWindowFont(), GetWindowFontSize() - marked obsolete in v1.48, March 2016.
-
-Other Changes:
-
-- Added `io.OptCursorBlink` option to allow disabling cursor blinking. (#1427)
-- Added `GetOverlayDrawList()` helper to quickly get access to a ImDrawList that will be rendered in front of every windows.
-- Added `GetFrameHeight()` helper which returns `(FontSize + style.FramePadding.y * 2)`.
-- Drag and Drop: Added Beta API to easily use drag and drop patterns between imgui widgets.
- - Setup a source on a widget with `BeginDragDropSource()`, `SetDragDropPayload()`, `EndDragDropSource()` functions.
- - Receive data with `BeginDragDropTarget()`, `AcceptDragDropPayload()`, `EndDragDropTarget()`.
- - See ImGuiDragDropFlags for various options.
- - The ColorEdit4() and ColorButton() widgets now support Drag and Drop.
- - The API is tagged as Beta as it still may be subject to small changes.
-- Drag and Drop: When drag and drop is active, tree nodes and collapsing header can be opened by hovering on them for 0.7 seconds.
-- Renamed io.OSXBehaviors to io.OptMacOSXBehaviors. Should not affect users as the compile-time default is usually enough. (#473, #650)
-- Style: Added StyleColorsDark() style. (#707) [@dougbinks]
-- Style: Added StyleColorsLight() style. Best used with frame borders + thicker font than the default font. (#707)
-- Style: Added style.PopupRounding setting. (#1112)
-- Style: Added style.FrameBorderSize, style.WindowBorderSize. Removed ImGuiWindowFlags_ShowBorders window flag! Borders are now fully set up in the ImGuiStyle structure. Use ImGui::ShowStyleEditor() to look them up. (#707, fix #819, #1031)
-- Style: Various small changes to the classic style (most noticeably, buttons are now using blue shades). (#707)
-- Style: Renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg.
-- Style: Renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding.
-- Style: Removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency. (#707)
-- Style: Made the ScaleAllSizes() helper rounds down every values so they are aligned on integers.
-- Focus: Added SetItemDefaultFocus(), which in the current (master) branch behave the same as doing `if (IsWindowAppearing()) SetScrollHere()`.
- In the navigation branch this will also set the default focus. Prefer using this when creating combo boxes with `BeginCombo()` so your code will be forward-compatible with gamepad/keyboard navigation features. (#787)
-- Combo: Popup grows horizontally to accomodate for contents that is larger then the parent combo button.
-- Combo: Added BeginCombo()/EndCombo() API which allows use to submit content of any form and manage your selection state without relying on indices.
-- Combo: Added ImGuiComboFlags_PopupAlignLeft flag to BeginCombo() to prioritize keeping the popup on the left side (for small-button-looking combos).
-- Combo: Added ImGuiComboFlags_HeightSmall, ImGuiComboFlags_HeightLarge, ImGuiComboFlags_HeightLargest to easily provide desired popup height.
-- Combo: You can use SetNextWindowSizeConstraints() before BeginCombo() to specify specific popup width/height constraints.
-- Combo: Offset popup position by border size so that a double border isn't so visible. (#707)
-- Combo: Recycling windows by using a stack number instead of a unique id, wasting less memory (like menus do).
-- InputText: Added ImGuiInputTextFlags_NoUndoRedo flag. (#1506, #1508) [@ibachar]
-- Window: Fixed auto-resize allocating too much space for scrollbar when SizeContents is bigger than maximum window size (fixes c0547d3). (#1417)
-- Window: Child windows with MenuBar use regular WindowPadding.y so layout look consistent as child or as a regular window.
-- Window: Begin(): Fixed appending into a child window with a second Begin() from a different window stack querying the wrong window for the window->Collapsed test.
-- Window: Calling IsItemActive(), IsItemHovered() etc. after a call to Begin() provides item data for the title bar, so you can easily test if the title bar is being hovered, etc. (#823)
-- Window: Made it possible to use SetNextWindowPos() on a child window.
-- Window: Fixed a one frame glitch. When an appearing window claimed the focus themselves, the title bar wouldn't use the focused color for one frame.
-- Window: Added ImGuiWindowFlags_ResizeFromAnySide flag to resize from any borders or from the lower-left corner of a window. This requires your backend to honor GetMouseCursor() requests for full usability. (#822)
-- Window: Sizing fixes when useing SetNextWindowSize() on individual axises.
-- Window: Made mouse wheel scrolling accomodate better to windows that are smaller than the scroll step.
-- Window: SetNextWindowContentSize() adjust for the size of decorations (title bar/menu bar), but _not_ for borders are we consistently make borders not affect layout.
- If you need a non-child window of an exact size with border enabled but zero window padding, you'll need to accodomate for the border size yourself.
-- Window: Using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. (#1380, #1502)
-- Window: Active Modal window always set the WantCaptureKeyboard flag. (#744)
-- Window: Moving window doesn't use accumulating MouseDelta so straying out of imgui boundaries keeps moved imgui window at the same cursor-relative position.
-- IsWindowFocused(): Added ImGuiFocusedFlags_ChildWindows flag to include child windows in the focused test. (#1382).
-- IsWindowFocused(): Added ImGuiFocusedFlags_RootWindow flag to start focused test from the root (top-most) window. Obsolete IsRootWindowFocused(). (#1382)
-- IsWindowHovered(): Added ImGuiHoveredFlags_ChildWindows flag to include child windows in the hovered test. (#1382).
-- IsWindowHovered(): Added ImGuiHoveredFlags_RootWindow flag to start hovered test from the root (top-most) window. The combination of both flags obsoletes IsRootWindowOrAnyChildHovered(). (#1382)
-- IsWindowHovered(): Fixed return value when an item is active to use the same logic as IsItemHovered(). (#1382, #1404)
-- IsWindowHovered(): Always return true when current window is being moved. (#1382)
-- Scrollbar: Fixed issues with vertical scrollbar flickering/appearing, typically when manually resizing and using a pattern of filling available height (e.g. full sized BeginChild).
-- Scrollbar: Minor graphical fix for when scrollbar don't have enough visible space to display the full grab.
-- Scrolling: Fixed padding and scrolling asymetry where lower/right sides of a window wouldn't use WindowPadding properly + causing minor scrolling glitches.
-- Tree: TreePush with zero arguments was ambiguous. Resolved by making it call TreePush(const void*). [@JasonWilkins]
-- Tree: Renamed ImGuiTreeNodeFlags_AllowOverlapMode to ImGuiTreeNodeFlags_AllowItemOverlap. (#600, #1330)
-- MenuBar: Fixed minor rendering issues on the right size when resizing a window very small and using rounded window corners.
-- MenuBar: better software clipping to handle small windows, in particular child window don't have minimum constraints so we need to render clipped menus better.
-- BeginMenu(): Tweaked the Arrow/Triangle displayed on child menu items.
-- Columns: Clipping columns borders on Y axis on CPU because some Linux GPU drivers appears to be unhappy with triangle spanning large regions. (#125)
-- Columns: Added ImGuiColumnsFlags_GrowParentContentsSize to internal API to restore old content sizes behavior (may be obsolete). (#1444, #125)
-- Columns: Columns width is no longer lost when dragging a column to the right side of the window, until releasing the mouse button you have a chance to save them. (#1499, #125). [@ggtucker]
-- Columns: Fixed dragging when using a same of columns multiple times in the frame. (#125)
-- Indent(), Unindent(): Allow passing negative values.
-- ColorEdit4(): Made IsItemActive() return true when picker popup is active. (#1489)
-- ColorEdit4(): Tweaked tooltip so that the color button aligns more correctly with text.
-- ColorEdit4(): Support drag and drop. Color buttons can be used as drag sources, and ColorEdit widgets as drag targets. (#143)
-- ColorPicker4(): Fixed continously returning true when holding mouse button on the sat/value/alpha locations. We only return true on value change. (#1489)
-- NewFrame(): using literal strings in the most-frequently firing IM_ASSERT expressions to increase the odd of programmers seeing them (especially those who don't use a debugger).
-- NewFrame() now asserts if neither Render or EndFrame have been called. Exposed EndFrame(). Made it legal to call EndFrame() more than one. (#1423)
-- ImGuiStorage: Added BuildSortByKey() helper to rebuild storage from stratch.
-- ImFont: Added GetDebugName() helper.
-- ImFontAtlas: Added missing Thai punctuation in the GetGlyphRangesThai() ranges. (#1396) [@nProtect]
-- ImDrawList: Removed 'bool anti_aliased = true' final parameter of ImDrawList::AddPolyline() and ImDrawList::AddConvexPolyFilled(). Anti-aliasing is controlled via the regular style.AntiAliased flags.
-- ImDrawList: Added ImDrawList::AddImageRounded() helper. (#845) [@thedmd]
-- ImDrawList: Refactored to make ImDrawList independant of ImGui. Removed static variable in PathArcToFast() which caused linking issues to some.
-- ImDrawList: Exposed ImDrawCornerFlags, replaced occurences of ~0 with an explicit ImDrawCornerFlags_All. NB: Inversed BotLeft (prev 1<<3, now 1<<2) and BotRight (prev 1<<2, now 1<<3).
-- ImVector: Added ImVector::push_front() helper.
-- ImVector: Added ImVector::contains() helper.
-- ImVector: insert() uses grow_capacity() instead of using grow policy inconsistent with push_back().
-- Internals: Remove requirement to define IMGUI_DEFINE_PLACEMENT_NEW to use the IM_PLACEMENT_NEW macro. (#1103)
-- Internals: ButtonBehavior: Fixed ImGuiButtonFlags_NoHoldingActiveID flag from incorrectly setting the ActiveIdClickOffset field.
- This had no known effect within imgui code but could have affected custom drag and drop patterns. And it is more correct this way! (#1418)
-- Internals: ButtonBehavior: Fixed ImGuiButtonFlags_AllowOverlapMode to avoid temporarily activating widgets on click before they have been correctly double-hovered. (#319, #600)
-- Internals: Added SplitterBehavior() helper. (#319)
-- Internals: Added IM_NEW(), IM_DELETE() helpers. (#484, #504, #1517)
-- Internals: Basic refactor of the settings API which now allows external elements to be loaded/saved.
-- Demo: Added ShowFontSelector() showing loaded fonts.
-- Demo: Added ShowStyleSelector() to select among default styles. (#707)
-- Demo: Renamed the emblematic ShowTestWindow() function to ShowDemoWindow().
-- Demo: Style Editor: Added a "Simplified settings" sections with checkboxes for border size and frame rounding. (#707, #1019)
-- Demo: Style Editor: Added combo box to select stock styles and select current font when multiple are loaded. (#707)
-- Demo: Style Editor: Using local storage so Save/Revert button makes more sense without code passing its storage. Aadded horizontal scroll bar. Fixed Save/Revert button to be always accessible. (#1211)
-- Demo: Console: Fixed context menu issue. (#1404)
-- Demo: Console: Fixed incorrect positioning which was hidden by a minor scroll issue (this would affect people who copied the Console code as is).
-- Demo: Constrained Resize: Added more test cases. (#1417)
-- Demo: Custom Rendering: Fixed clipping rectangle extruding out of parent window.
-- Demo: Layout: Removed unnecessary and misleading BeginChild/EndChild calls.
-- Demo: The "Color Picker with Palette" demo supports drag and drop. (#143)
-- Demo: Display better mouse cursor info for debugging backends.
-- Demo: Stopped using rand() function in demo code.
-- Examples: Added a handful of extra comments (about fonts, third-party libraries used in the examples, etc.).
-- Examples: DirectX9: Handle loss of D3D9 device (D3DERR_DEVICELOST). (#1464)
-- Examples: Added null_example/ which is helpful for quick testing on multiple compilers/settings without relying on graphics library.
-- Fix for using alloca() in "Clang with Microsoft Codechain" mode.
-- Various fixes, optimizations, comments.
-
------------------------------------------------------------------------
-
-VERSION 1.52 (2017-10-27)
-Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.52
-
-Breaking Changes:
-
-- IO: `io.MousePos` needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing, instead of ImVec2(-1,-1) as previously) This is needed so we can clear `io.MouseDelta` field when the mouse is made available again.
-- Renamed `AlignFirstTextHeightToWidgets()` to `AlignTextToFramePadding()`. Kept inline redirection function (will obsolete).
-- Obsoleted the legacy 5 parameters version of Begin(). Please avoid using it. If you need a transparent window background, uses `PushStyleColor()`. The old size parameter there was also misleading and equivalent to calling `SetNextWindowSize(size, ImGuiCond_FirstTimeEver)`. Kept inline redirection function (will obsolete).
-- Obsoleted `IsItemHoveredRect()`, `IsMouseHoveringWindow()` in favor of using the newly introduced flags of `IsItemHovered()` and `IsWindowHovered()`. Kept inline redirection function (will obsolete). (#1382)
-- Removed `IsItemRectHovered()`, `IsWindowRectHovered()` recently introduced in 1.51 which were merely the more consistent/correct names for the above functions which are now obsolete anyway. (#1382)
-- Changed `IsWindowHovered()` default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it. (#1382)
-- Renamed imconfig.h's `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS` to `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS` for consistency.
-
-Other Changes:
-
-- ProgressBar: fixed rendering when straddling rounded area. (#1296)
-- SliderFloat, DragFloat: Using scientific notation e.g. "%.1e" in the displayed format string doesn't mistakenly trigger rounding of the value. [@MomentsInGraphics]
-- Combo, InputFloat, InputInt: Made the small button on the right side align properly with the equivalent colored button of ColorEdit4().
-- IO: Tweaked logic for `io.WantCaptureMouse` so it now outputs false when e.g. hovering over void while an InputText() is active. (#621) [@pdoane]
-- IO: Fixed `io.WantTextInput` from mistakenly outputting true when an activated Drag or Slider was previously turned into an InputText(). (#1317)
-- Misc: Added flags to `IsItemHovered()`, `IsWindowHovered()` to access advanced hovering-test behavior. Generally useful for popups and drag'n drop behaviors: (relates to ~#439, #1013, #143, #925)
- - `ImGuiHoveredFlags_AllowWhenBlockedByPopup`
- - `ImGuiHoveredFlags_AllowWhenBlockedByActiveItem`
- - `ImGuiHoveredFlags_AllowWhenOverlapped`
- - `ImGuiHoveredFlags_RectOnly`
-- Input: Added `IsMousePosValid()` helper.
-- Input: Added `GetKeyPressedAmount()` to easily measure press count when the repeat rate is faster than the frame rate.
-- Input/Focus: Disabled TAB and Shift+TAB when CTRL key is held.
-- Checkbox: Now rendering a tick mark instead of a full square.
-- ColorEdit4: Added "Copy as..." option in context menu. (#346)
-- ColorPicker: Improved ColorPicker hue wheel color interpolation. (#1313) [@thevaber]
-- ColorButton: Reduced bordering artefact that would be particularly visible with an opaque Col_FrameBg and FrameRounding enabled.
-- ColorButton: Fixed rendering color button with a checkerboard if the transparency comes from the global style.Alpha and not from the actual source color.
-- TreeNode: Added `ImGuiTreeNodeFlags_FramePadding` flag to conveniently create a tree node with full padding at the beginning of a line, without having to call `AlignTextToFramePadding()`.
-- Trees: Fixed calling `SetNextTreeNodeOpen()` on a collapsed window leaking to the first tree node item of the next frame.
-- Layout: Horizontal layout is automatically enforced in a menu bar, so you can use non-MenuItem elements without calling SameLine().
-- Separator: Output a vertical separator when used inside a menu bar (or in general when horizontal layout is active, but that isn't exposed yet!).
-- Windows: Added `IsWindowAppearing()` helper (helpful e.g. as a condition before initializing some of your own things.).
-- Windows: Fixed title bar color of top-most window under a modal window.
-- Windows: Fixed not being able to move a window by clicking on one of its child window. (#1337, #635)
-- Windows: Fixed `Begin()` auto-fit calculation code that predict the presence of a scrollbar so it works better when window size constraints are used.
-- Windows: Fixed calling `Begin()` more than once per frame setting `window_just_activated_by_user` which in turn would set enable the Appearing condition for that frame.
-- Windows: The implicit "Debug" window now uses a "Debug##Default" identifier instead of "Debug" to allow user creating a window called "Debug" without losing their custom flags.
-- Windows: Made the `ImGuiWindowFlags_NoMove` flag properly inherited from parent to child. In a setup with ParentWindow (no flag) -> Child (NoMove) -> SubChild (no flag), the user won't be able to move the parent window by clicking on SubChild. (#1381)
-- Popups: Popups can be closed with a right-click anywhere, without altering focus under the popup. (~#439)
-- Popups: `BeginPopupContextItem()`, `BeginPopupContextWindow()` are now setup to allow reopening a context menu by right-clicking again. (~#439)
-- Popups: `BeginPopupContextItem()` now supports a NULL string identifier and uses the last item ID if available.
-- Popups: Added `OpenPopupOnItemClick()` helper which mimic `BeginPopupContextItem()` but doesn't do the BeginPopup().
-- MenuItem: Only activating on mouse release. [@Urmeli0815] (was already fixed in nav branch).
-- MenuItem: Made tick mark thicker (thick mark?).
-- MenuItem: Tweaks to be usable inside a menu bar (nb: it looks like a regular menu and thus is misleading, prefer using Button() and regular widgets in menu bar if you need to). (#1387)
-- ImDrawList: Fixed a rare draw call merging bug which could lead to undisplayed triangles. (#1172, #1368)
-- ImDrawList: Fixed a rare bug in `ChannelsMerge()` when all contents has been clipped, leading to an extraneous draw call being created. (#1172, #1368)
-- ImFont: Added `AddGlyph()` building helper for use by custom atlas builders.
-- ImFontAtlas: Added support for CustomRect API to submit custom rectangles to be packed into the atlas. You can map them as font glyphs, or use them for custom purposes.
- After the atlas is built you can query the position of your rectangles in the texture and then copy your data there. You can use this features to create e.g. full color font-mapped icons.
-- ImFontAtlas: Fixed fall-back handling when merging fonts, if a glyph was missing from the second font input it could have used a glyph from the first one. (#1349) [@inolen]
-- ImFontAtlas: Fixed memory leak on build failure case when stbtt_InitFont failed (generally due to incorrect or supported font type). (#1391) (@Moka42)
-- ImFontConfig: Added `RasterizerMultiply` option to alter the brightness of individual fonts at rasterization time, which may help increasing readability for some.
-- ImFontConfig: Added `RasterizerFlags` to pass options to custom rasterizer (e.g. the [imgui_freetype](https://github.com/ocornut/imgui_club/tree/master/imgui_freetype) rasterizer in imgui_club has such options).
-- ImVector: added resize() variant with initialization value.
-- Misc: Changed the internal name formatting of child windows identifier to use slashes (instead of dots) as separator, more readable.
-- Misc: Fixed compilation with `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` defined.
-- Misc: Marked all format+va_list functions with format attribute so GCC/Clang can warn about misuses.
-- Misc: Fixed compilation on NetBSD due to missing alloca.h (#1319) [@RyuKojiro]
-- Misc: Improved warnings compilation for newer versions of Clang. (#1324) (@waywardmonkeys)
-- Misc: Added `io.WantMoveMouse flags` (from Nav branch) and honored in Examples applications. Currently unused but trying to spread Examples applications code that supports it.
-- Misc: Added `IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS` support in imconfig.h to allow user reimplementing the `ImFormatString()` functions e.g. to use stb_printf(). (#1038)
-- Misc: [Windows] Fixed default Win32 `SetClipboardText()` handler leaving the Win32 clipboard handler unclosed on failure. [@pdoane]
-- Style: Added `ImGuiStyle::ScaleAllSizes(float)` helper to make it easier to have application transition e.g. from low to high DPI with a matching style.
-- Metrics: Draw window bounding boxes when hovering Pos/Size; List all draw layers; Trimming empty commands like Render() does.
-- Examples: OpenGL3: Save and restore sampler state. (#1145) [@nlguillemot]
-- Examples: OpenGL2, OpenGL3: Save and restore polygon mode. (#1307) [@JJscott]
-- Examples: DirectX11: Allow creating device with feature level 10 since we don't really need much for that example. (#1333)
-- Examples: DirectX9/10/12: Using the Win32 SetCapture/ReleaseCapture API to read mouse coordinates when they are out of bounds. (#1375) [@Gargaj, @ocornut]
-- Tools: Fixed binary_to_compressed_c tool to return 0 when successful. (#1350) [@benvanik]
-- Internals: Exposed more helpers and unfinished features in imgui_internal.h. (use at your own risk!).
-- Internals: A bunch of internal refactoring, hopefully haven't broken anything! Merged a bunch of internal changes from the upcoming Navigation branch.
-- Various tweaks, fixes and documentation changes.
-
-Beta Navigation Branch:
-(Lots of work has been done toward merging the Beta Gamepad/Keyboard Navigation branch (#787) in master.)
-(Please note that this branch is always kept up to date with master. If you are using the navigation branch, some of the changes include:)
-- Nav: Added `#define IMGUI_HAS_NAV` in imgui.h to ease sharing code between both branches. (#787)
-- Nav: MainMenuBar now releases focus when user gets out of the menu layer. (#787)
-- Nav: When applying focus to a window with only menus, the menu layer is automatically activated. (#787)
-- Nav: Added `ImGuiNavInput_KeyMenu` (~Alt key) aside from ImGuiNavInput_PadMenu input as it is one differentiator of pad vs keyboard that was detrimental to the keyboard experience. Although isn't officially supported, it makes the current experience better. (#787)
-- Nav: Move requests now wrap vertically inside Menus and Popups. (#787)
-- Nav: Allow to collapse tree nodes with NavLeft and open them with NavRight. (#787, #1079).
-- Nav: It's now possible to navigate sibling of a menu-bar while navigating inside one of their child. If a Left<>Right navigation request fails to find a match we forward the request to the root menu. (#787, #126)
-- Nav: Fixed `SetItemDefaultFocus` from stealing default focus when we are initializing default focus for a menu bar layer. (#787)
-- Nav: Support for fall-back horizontal scrolling with PadLeft/PadRight (nb: fall-back scrolling is only used to navigate windows that have no interactive items). (#787)
-- Nav: Fixed tool-tip from being selectable in the window selection list. (#787)
-- Nav: `CollapsingHeader(bool*)` variant: fixed for `IsItemHovered()` not working properly in the nav branch. (#600, #787)
-- Nav: InputText: Fixed using Up/Down history callback feature when Nav is enabled. (#787)
-- Nav: InputTextMultiline: Fixed navigation/selection. Disabled selecting all when activating a multi-line text editor. (#787)
-- Nav: More consistently drawing a (thin) navigation rectangle hover filled frames such as tree nodes, collapsing header, menus. (#787)
-- Nav: Various internal refactoring.
-
------------------------------------------------------------------------
-
-VERSION 1.51 (2017-08-24)
-Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.51
-
-Breaking Changes:
-
-Work on dear imgui has been gradually resuming. It means that fixes and new features should be tackled at a faster rate than last year. However, in order to move forward with the library and get rid of some cruft, I have taken the liberty to be a little bit more aggressive than usual with API breaking changes. Read the details below and search for those names in your code! In the grand scheme of things, those changes are small and should not affect everyone, but this is technically our most aggressive release so far in term of API breakage. If you want to be extra forward-facing, you can enable `#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in your imconfig.h to disable the obsolete names/redirection.
-
-- Renamed `IsItemHoveredRect()` to `IsItemRectHovered()`. Kept inline redirection function (will obsolete).
-- Renamed `IsMouseHoveringWindow()` to `IsWindowRectHovered()` for consistency. Kept inline redirection function (will obsolete).
-- Renamed `IsMouseHoveringAnyWindow()` to `IsAnyWindowHovered()` for consistency. Kept inline redirection function (will obsolete).
-- Renamed `ImGuiCol_Columns***` enums to `ImGuiCol_Separator***`. Kept redirection enums (will obsolete).
-- Renamed `ImGuiSetCond***` types and enums to `ImGuiCond***`. Kept redirection enums (will obsolete).
-- Renamed `GetStyleColName()` to `GetStyleColorName()` for consistency. Unlikely to be used by end-user!
-- Added `PushStyleColor(ImGuiCol idx, ImU32 col)` overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicily to fix.
-- Marked the weird `IMGUI_ONCE_UPON_A_FRAME` helper macro as obsolete. Prefer using the more explicit `ImGuiOnceUponAFrame`.
-- Changed `ColorEdit4(const char* label, float col[4], bool show_alpha = true)` signature to `ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)`, where flags 0x01 is a safe no-op (hello dodgy backward compatibility!). The new `ColorEdit4`/`ColorPicker4` functions have lots of available flags! Check and run the demo window, under "Color/Picker Widgets", to understand the various new options.
-- Changed signature of `ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)` to `ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0))`. This function was rarely used and was very dodgy (no explicit ID!).
-- Changed `BeginPopupContextWindow(bool also_over_items=true, const char* str_id=NULL, int mouse_button=1)` signature to `(const char* str_id=NULL, int mouse_button=1, bool also_over_items=true)`. This is perhaps the most aggressive change in this update, but note that the majority of users relied on default parameters completely, so this will affect only a fraction of users of this already rarely used function.
-- Removed `IsPosHoveringAnyWindow()`, which was partly broken and misleading. In the vast majority of cases, people using that function wanted to use `io.WantCaptureMouse` flag. Replaced with IM_ASSERT + comment redirecting user to `io.WantCaptureMouse`. (#1237)
-- Removed the old `ValueColor()` helpers, they are equivalent to calling `Text(label)` + `SameLine()` + `ColorButton()`.
-- Removed `ColorEditMode()` and `ImGuiColorEditMode` type in favor of `ImGuiColorEditFlags` and parameters to the various Color*() functions. The `SetColorEditOptions()` function allows to initialize default but the user can still change them with right-click context menu. Commenting out your old call to `ColorEditMode()` may just be fine!
-
-Other Changes:
-
-- Added flags to `ColorEdit3()`, `ColorEdit4()`. The color edit widget now has a context-menu and access to the color picker. (#346)
-- Added flags to `ColorButton()`. (#346)
-- Added `ColorPicker3()`, `ColorPicker4()`. The API along with those of the updated `ColorEdit4()` was designed so you may use them in various situation and hopefully compose your own picker if required. There are a bunch of available flags, check the Demo window and comment for `ImGuiColorEditFlags_`. Some of the options it supports are: two color picker types (hue bar + sat/val rectangle, hue wheel + rotating sat/val triangle), display as u8 or float, lifting 0.0..1.0 constraints (currently rgba only), context menus, alpha bar, background checkerboard options, preview tooltip, basic revert. For simple use, calling the existing `ColorEdit4()` function as you did before will be enough, as you can now open the color picker from there. (#346) [@r-lyeh, @nem0, @thennequin, @dariomanesku and @ocornut]
-- Added `SetColorEditOptions()` to set default color options (e.g. if you want HSV over RGBA, float over u8, select a default picker mode etc. at startup time without a user intervention. Note that the user can still change options with the context menu unless disabled with `ImGuiColorFlags_NoOptions` or explicitly enforcing a display type/picker mode etc.).
-- Added user-facing `IsPopupOpen()` function. (#891) [@mkeeter]
-- Added `GetColorU32(u32)` variant that perform the style alpha multiply without a floating-point round trip, and helps makes code more consistent when using ImDrawList APIs.
-- Added `PushStyleColor(ImGuiCol idx, ImU32 col)` overload.
-- Added `GetStyleColorVec4(ImGuiCol idx)` which is equivalent to accessing `ImGui::GetStyle().Colors[idx]` (aka return the raw style color without alpha alteration).
-- ImFontAtlas: Added `GlyphRangesBuilder` helper class, which makes it easier to build custom glyph ranges from your app/game localization data, or add into existing glyph ranges.
-- ImFontAtlas: Added `TexGlyphPadding` option. (#1282) [@jadwallis]
-- ImFontAtlas: Made it possible to override size of AddFontDefault() (even if it isn't really recommended!).
-- ImDrawList: Added `GetClipRectMin()`, `GetClipRectMax()` helpers.
-- Fixed Ini saving crash if the ImGuiWindowFlags_NoSavedSettings gets removed from a window after its creation (unlikely!). (#1000)
-- Fixed `PushID()`/`PopID()` from marking parent window as Accessed (which needlessly woke up the root "Debug" window when used outside of a regular window). (#747)
-- Fixed an assert when calling `CloseCurrentPopup()` twice in a row. [@nem0]
-- Window size can be loaded from .ini data even if ImGuiWindowFlags_NoResize flag is set. (#1048, #1056)
-- Columns: Added `SetColumnWidth()`. (#913) [@ggtucker]
-- Columns: Dragging a column preserve its width by default. (#913) [@ggtucker]
-- Columns: Fixed first column appearing wider than others. (#1266)
-- Columns: Fixed allocating space on the right-most side with the assumption of a vertical scrollbar. The space is only allocated when needed. (#125, #913, #893, #1138)
-- Columns: Fixed the right-most column from registering its content width to the parent window, which led to various issues when using auto-resizing window or e.g. horizonal scrolling. (#519, #125, #913)
-- Columns: Refactored some of the columns code internally toward a better API (not yet exposed) + minor optimizations. (#913) [@ggtucker, @ocornut]
-- Popups: Most popups windows can be moved by the user after appearing (if they don't have explicit positions provided by caller, or e.g. sub-menu popup). The previous restriction was totally arbitrary. (#1252)
-- Tooltip: `SetTooltip()` is expanded immediately into a window, honoring current font / styling setting. Add internal mechanism to override tooltips. (#862)
-- PlotHistogram: bars are drawn based on zero-line, so negative values are going under. (#828)
-- Scrolling: Fixed return values of `GetScrollMaxX()`, `GetScrollMaxY()` when both scrollbars were enabled. Tweak demo to display more data. (#1271) [@degracode]
-- Scrolling: Fixes for Vertical Scrollbar not automatically getting enabled if enabled Horizontal Scrollbar straddle the vertical limit. (#1271, #246)
-- Scrolling: `SetScrollHere()`, `SetScrollFromPosY()`: Fixed Y scroll aiming when Horizontal Scrollbar is enabled. (#665).
-- [Windows] Clipboard: Fixed not closing win32 clipboard on early open failure path. (#1264)
-- Removed an unnecessary dependency on int64_t which failed on some older compilers.
-- Demo: Rearranged everything under Widgets in a more consistent way.
-- Demo: Columns: Added Horizontal Scrolling demo. Tweaked another Columns demo. (#519, #125, #913)
-- Examples: OpenGL: Various makefiles for MINGW, Linux. (#1209, #1229, #1209) [@fr500, @acda]
-- Examples: Enabled vsync by default in example applications, so it doesn't confuse people that the sample run at 2000+ fps and waste an entire CPU. (#1213, #1151).
-- Various other small fixes, tweaks, comments, optimizations.
-
------------------------------------------------------------------------
-
-VERSION 1.50 (2017-06-02)
-Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.50
-
-Breaking Changes:
-
- - Added a void* user_data parameter to Clipboard function handlers. (#875)
- - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
- - Renamed ImDrawList::PathFill() - rarely used directly - to ImDrawList::PathFillConvex() for clarity and consistency.
- - Removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset.
- - Style: style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
- - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild().
-
-Other Changes:
-
-- InputText(): Added support for CTRL+Backspace (delete word).
-- InputText(): OSX uses Super+Arrows for home/end. Add Shortcut+Backspace support. (#650) [@michaelbartnett]
-- InputText(): Got rid of individual OSX-specific options in ImGuiIO, added a single io.OSXBehaviors flag. (#473, #650)
-- InputText(): Fixed pressing home key on last character when it isn't a trailing \n (#588, #815)
-- InputText(): Fixed state corruption/crash bug in stb_textedit.h redo logic when exhausting undo/redo char buffer. (#715. #681)
-- InputTextMultiline(): Fixed Ctrl+DownArrow moving scrolling out of bounds.
-- InputTextMultiline(): Scrollbar fix for when input and latched internal buffers differs in a way that affects vertical scrollbar existence. (#725)
-- ImFormatString(): Fixed an overflow handling bug with implementation of vsnprintf() that do not return -1. (#793)
-- BeginChild(const char*) now applies stack id to provided label, consistent with other widgets. (#894, #713)
-- SameLine() with explicit X position is relative to left of group/columns. (ref #746, #125, #630)
-- SliderInt(), SliderFloat() supports reverse direction (where v_min > v_max). (#854)
-- SliderInt(), SliderFloat() better support for when v_min==v_max. (#919)
-- SliderInt(), SliderFloat() enforces writing back value when interacting, to be consistent with other widgets. (#919)
-- SliderInt, SliderFloat(): Fixed edge case where style.GrabMinSize being bigger than slider width can lead to a division by zero. (#919)
-- Added IsRectVisible() variation with explicit start-end positions. (#768) [@thedmd]
-- Fixed TextUnformatted() clipping bug in the large-text path when horizontal scroll has been applied. (#692, #246)
-- Fixed minor text clipping issue in window title when using font straying above usual line. (#699)
-- Fixed SetCursorScreenPos() fixed not adjusting CursorMaxPos as well.
-- Fixed scrolling offset when using SetScrollY(), SetScrollFromPosY(), SetScrollHere() with menu bar.
-- Fixed using IsItemActive() after EndGroup() or any widget using groups. (#840, #479)
-- Fixed IsItemActive() lagging by one frame on initial widget activation. (#840)
-- Fixed Separator() zero-height bounding box resulting in clipping when laying exactly on top line of clipping rectangle (#860)
-- Fixed PlotLines() PlotHistogram() calling with values_count == 0.
-- Fixed clicking on a window's void while staying still overzealously marking .ini settings as dirty. (#923)
-- Fixed assert triggering when a window has zero rendering but has a callback. (#810)
-- Scrollbar: Fixed rendering when sizes are negative to reduce glitches (which can happen with certain style settings and zero WindowMinSize).
-- EndGroup(): Made IsItemHovered() work when an item was activated within the group. (#849)
-- BulletText(): Fixed stopping to display formatted string after the '##' mark.
-- Closing the focused window restore focus to the first active root window in descending z-order .(part of #727)
-- Word-wrapping: Fixed a bug where we never wrapped after a 1 character word. [@sronsse]
-- Word-wrapping: Fixed TextWrapped() overriding wrap position if one is already set. (#690)
-- Word-wrapping: Fixed incorrect testing for negative wrap coordinates, they are perfectly legal. (#706)
-- ImGuiListClipper: fixed automatic-height calc path dumbly having user display element 0 twice. (#661, #716)
-- ImGuiListClipper: Fix to behave within column. (#661, #662, #716)
-- ImDrawList: Renamed ImDrawList::PathFill() to ImDrawList::PathFillConvex() for clarity. (BREAKING API)
-- Columns: End() avoid calling Columns(1) if no columns set is open, not sure why it wasn't the case already (pros: faster, cons: exercise less code).
-- ColorButton(): Fix ColorButton showing wrong hex value for alpha. (#1068) [@codecat]
-- ColorEdit4(): better preserve inputting value out of 0..255 range, display then clamped in Hexadecimal form.
-- Shutdown() clear out some remaining pointers for sanity. (#836)
-- Added IMGUI_USE_BGRA_PACKED_COLOR option in imconfig.h (#767, #844) [@thedmd]
-- Style: Removed the inconsistent shadow under RenderCollapseTriangle() (~#707)
-- Style: Added ButtonTextAlign, ImGuiStyleVar_ButtonTextAlign. (#842)
-- ImFont: Allowing to use up to 0xFFFE glyphs in same font (increased from previous 0x8000).
-- ImFont: Added GetGlyphRangesThai() helper. [@nProtect]
-- ImFont: CalcWordWrapPositionA() fixed font scaling with fallback character.
-- ImFont: Calculate and store the approximate texture surface to get an idea of how costly each source font is.
-- ImFontConfig: Added GlyphOffset to explicitely offset glyphs at font build time, useful for merged fonts. Removed MergeGlyphCenterV. (BREAKING API)
-- Clarified asserts in CheckStacksSize() when there is a stack mismatch.
-- Context: Support for #define-ing GImGui and IMGUI_SET_CURRENT_CONTEXT_FUNC to enable custom thread-based hackery (#586)
-- Updated stb_truetype.h to 1.14 (added OTF support, removed warnings). (#883, #976)
-- Updated stb_rect_pack.h to 0.10 (removed warnings). (#883)
-- Added ImGuiMouseCursor_None enum value for convenient usage by app/binding.
-- Clipboard: Added a void* user_data parameter to Clipboard function handlers. (#875) (BREAKING API)
-- Internals: Refactor internal text alignment options to use ImVec2, removed ImGuiAlign. (#842, #222)
-- Internals: Renamed ImLoadFileToMemory to ImFileLoadToMemory to be consistent with ImFileOpen + fix mismatching .h name. (#917)
-- Windows: Fixed Windows default clipboard handler leaving its buffer unfreed on application's exit. (#714)
-- Windows: No default IME handler when compiling for Windows using GCC. (#738)
-- Windows: Now using _wfopen() instead of fopen() to allow passing in paths/filenames with UTF-8 characters. (#917)
-- Tools: binary_to_compressed_c: Avoid ?? trigraphs sequences in string outputs which break some older compilers. (#839)
-- Demo: Added an extra 3-way columns demo.
-- Demo: ShowStyleEditor: show font character map / grid in more details.
-- Demo: Console: Fixed a completion bug when multiple candidates are equals and match until the end.
-- Demo: Fixed 1-byte off overflow in the ShowStyleEditor() combo usage. (#783) [@bear24rw]
-- Examples: Accessing ImVector fields directly, feel less stl-ey. (#810)
-- Examples: OpenGL*: Saving/restoring existing scissor rectangle for completeness. (#807)
-- Examples: OpenGL*: Saving/restoring active texture number (the value modified by glActiveTexture). (#1087, #1088, #1116)
-- Examples: OpenGL*: Saving/restoring separate color/alpha blend functions correctly. (#1120) [@greggman]
-- Examples: OpenGL2: Uploading font texture as RGBA32 to increase compatibility with users shaders for beginners. (#824)
-- Examples: Vulkan: Countless fixes and improvements. (#785, #804, #910, #1017, #1039, #1041, #1042, #1043, #1080) [@martty, @Loftilus, @ParticlePeter, @SaschaWillems]
-- Examples: DirectX9/10/10: Only call SetCursor(NULL) is io.MouseDrawCursor is set. (#585, #909)
-- Examples: DirectX9: Explicitely setting viewport to match that other examples are doing. (#937)
-- Examples: GLFW+OpenGL3: Fixed Shutdown() calling GL functions with NULL parameters if NewFrame was never called. (#800)
-- Examples: GLFW+OpenGL2: Renaming opengl_example/ to opengl2_example/ for clarity.
-- Examples: SDL+OpenGL: explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
-- Examples: SDL2: Added build .bat files for Win32.
-- Added various links to language/engine bindings.
-- Various other minor fixes, tweaks, comments, optimizations.
-
------------------------------------------------------------------------
-
-VERSION 1.49 (2016-05-09)
-Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.49
-
-Breaking Changes:
-
-- Renamed `SetNextTreeNodeOpened()` to `SetNextTreeNodeOpen()` for consistency, no redirection.
-- Removed confusing set of `GetInternalState()`, `GetInternalStateSize()`, `SetInternalState()` functions. Now using `CreateContext()`, `DestroyContext()`, `GetCurrentContext()`, `SetCurrentContext()`. If you were using multiple contexts the change should be obvious and trivial.
-- Obsoleted old signature of `CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false)`, as extra parameters were badly designed and rarely used. Most uses were using 1 parameter and shouldn't affect you. You can replace the "default_open = true" flag in new API with `CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen)`.
-- Changed `ImDrawList::PushClipRect(ImVec4 rect)` to `ImDraw::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false)`. Note that higher-level `ImGui::PushClipRect()` is preferable because it will clip at logic/widget level, whereas `ImDrawList::PushClipRect()` only affect your renderer.
-- Title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore (see #655). If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you. However if your TitleBg/TitleBgActive alpha was <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar.
- This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color. (Or If this is confusing, just pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color.)
-
- ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col)
- {
- float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w));
- float k = title_bg_col.w / new_a;
- return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a);
- }
-
-Other changes:
-
-- New version of ImGuiListClipper helper calculates item height automatically. See comments and demo code. (#662, #661, #660)
-- Added SetNextWindowSizeConstraints() to enable basic min/max and programmatic size constraints on window. Added demo. (#668)
-- Added PushClipRect()/PopClipRect() (previously part of imgui_internal.h). Changed ImDrawList::PushClipRect() prototype. (#610)
-- Added IsRootWindowOrAnyChildHovered() helper. (#615)
-- Added TreeNodeEx() functions. (#581, #600, #190)
-- Added ImGuiTreeNodeFlags_Selected flag to display treenode as "selected". (#581, #190)
-- Added ImGuiTreeNodeFlags_AllowOverlapMode flag. (#600)
-- Added ImGuiTreeNodeFlags_NoTreePushOnOpen flag (#590).
-- Added ImGuiTreeNodeFlags_NoAutoOpenOnLog flag (previously private).
-- Added ImGuiTreeNodeFlags_DefaultOpen flag (previously private).
-- Added ImGuiTreeNodeFlags_OpenOnDoubleClick flag.
-- Added ImGuiTreeNodeFlags_OpenOnArrow flag.
-- Added ImGuiTreeNodeFlags_Leaf flag, always opened, no arrow, for convenience. For simple use case prefer using TreeAdvanceToLabelPos()+Text().
-- Added ImGuiTreeNodeFlags_Bullet flag, to add a bullet to Leaf node or replace Arrow with a bullet.
-- Added TreeAdvanceToLabelPos(), GetTreeNodeToLabelSpacing() helpers. (#581, #324)
-- Added CreateContext()/DestroyContext()/GetCurrentContext()/SetCurrentContext(). Obsoleted nearly identical GetInternalState()/SetInternalState() functions. (#586, #269)
-- Added NewLine() to undo a SameLine() and as a shy reminder that horizontal layout support hasn't been implemented yet.
-- Added IsItemClicked() helper. (#581)
-- Added CollapsingHeader() variant with close button. (#600)
-- Fixed MenuBar missing lower border when borders are enabled.
-- InputText(): Fixed clipping of cursor rendering in case it gets out of the box (which can be forced w/ ImGuiInputTextFlags_NoHorizontalScroll. (#601)
-- Style: Changed default IndentSpacing from 22 to 21. (#581, #324)
-- Style: Fixed TitleBg/TitleBgActive color being rendered above WindowBg color, which was inconsistent and causing visual artefact. (#655)
- This broke the meaning of TitleBg and TitleBgActive. Only affect values where Alpha<1.0f. Fixed default theme. Read comments in "API BREAKING CHANGES" section to convert.
-- Relative rendering of order of Child windows creation is preserved, to allow more control with overlapping childs. (#595)
-- Fixed GetWindowContentRegionMax() being off by ScrollbarSize amount when explicit SizeContents is set.
-- Indent(), Unindent(): optional non-default indenting width. (#324, #581)
-- Bullet(), BulletText(): Slightly bigger. Less polygons.
-- ButtonBehavior(): fixed subtle old bug when a repeating button would also return true on mouse release (barely noticeable unless RepeatRate is set to be very slow). (#656)
-- BeginMenu(): a menu that becomes disabled while open gets closed down, facilitate user's code. (#126)
-- BeginGroup(): fixed using within Columns set. (#630)
-- Fixed a lag in reading the currently hovered window when dragging a window. (#635)
-- Obsoleted 4 parameters version of CollapsingHeader(). Refactored code into TreeNodeBehavior. (#600, #579)
-- Scrollbar: minor fix for top-right rounding of scrollbar background when window has menubar but no title bar.
-- MenuItem(): checkmark render in disabled color when menu item is disabled.
-- Fixed clipping rectangle floating point representation to ensure renderer-side float point operations yield correct results in typical DirectX/GL settings. (#582, 597)
-- Fixed GetFrontMostModalRootWindow(), fixing missing fade-out when a combo pop was used stacked over a modal window. (#604)
-- ImDrawList: Added AddQuad(), AddQuadFilled() helpers.
-- ImDrawList: AddText() refactor, moving some code to ImFont, reserving less unused vertices when large vertical clipping occurs.
-- ImFont: Added RenderChar() helper.
-- ImFont: Added AddRemapChar() helper. (#609)
-- ImFontConfig: Clarified persistence requirement of GlyphRanges array. (#651)
-- ImGuiStorage: Added bool helper functions for completeness.
-- AddFontFromMemoryCompressedTTF(): Fix font config propagation. (#587)
-- Renamed majority of use of the word "opened" to "open" for clarity. Renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(). (#625, #579)
-- Examples: OpenGL3: Saving/restoring glActiveTexture() state. (#602)
-- Examples: DirectX9: save/restore all device state.
-- Examples: DirectX9: Removed dependency on d3dx9.h, d3dx9.lib, dxguid.lib so it can be used in a DirectXMath.h only environment. (#611)
-- Examples: DirectX10/X11: Apply depth-stencil state (no use of depth buffer). (#640, #636)
-- Examples: DirectX11/X11: Added comments on removing dependency on D3DCompiler. (#638)
-- Examples: SDL: Initialize video+timer subsystem only.
-- Examples: Apple/iOS: lowered xcode project deployment target from 10.7 to 10.11. (#598, #575)
-
------------------------------------------------------------------------
-
-VERSION 1.48 (2016-04-09)
-Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.48
-
-Breaking Changes:
-
-- Consistently honoring exact width passed to PushItemWidth() (when positive), previously it would add extra FramePadding.x*2 over that width. Some hand-tuned layout may be affected slightly. (#346)
-- Style: removed `style.WindowFillAlphaDefault` which was confusing and redundant, baked alpha into `ImGuiCol_WindowBg` color. If you had a custom WindowBg color but didn't change WindowFillAlphaDefault, multiply WindowBg alpha component by 0.7. Renamed `ImGuiCol_TooltipBg` to `ImGuiCol_PopupBG`, applies to other types of popups. `bg_alpha` parameter of 5-parameters version of Begin() is an override. (#337)
-- InputText(): Added BufTextLen field in ImGuiTextEditCallbackData. Requesting user to update it if the buffer is modified in the callback. Added a temporary length-check assert to minimize panic for the 3 people using the callback. (#541)
-- Renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete). (#340)
-
-Other Changes:
-
-- Consistently honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. Some hand-tuned layout may be affected slightly. (#346)
-- Fixed clipping of child windows within parent not taking account of child outer clipping boundaries (including scrollbar, etc.). (#506)
-- TextUnformatted(): Fixed rare crash bug with large blurb of text (2k+) not finished with a '\n' and fully above the clipping Y line. (#535)
-- IO: Added 'KeySuper' field to hold Cmd keyboard modifiers for OS X. Updated all examples accordingly. (#473)
-- Added ImGuiWindowFlags_ForceVerticalScrollbar, ImGuiWindowFlags_ForceHorizontalScrollbar flags. (#476)
-- Added IM_COL32 macros to generate a U32 packed color, convenient for direct use of ImDrawList api. (#346)
-- Added GetFontTexUvWhitePixel() helper, convenient for direct use of ImDrawList api.
-- Selectable(): Added ImGuiSelectableFlags_AllowDoubleClick flag to allow user reacting on double-click. (@zapolnov) (#516)
-- Begin(): made the close button explicitly set the boolean to false instead of toggling it. (#499)
-- BeginChild()/EndChild(): fixed incorrect layout to allow widgets submitted after an auto-fitted child window. (#540)
-- BeginChild(): Added ImGuiWindowFlags_AlwaysUseWindowPadding flag to ensure non-bordered child window uses window padding. (#462)
-- Fixed InputTextMultiLine(), ListBox(), BeginChildFrame(), ProgressBar(): outer frame not honoring bordering. (#462, #503)
-- Fixed Image(), ImageButtion() rendering a rectangle 1 px too large on each axis. (#457)
-- SetItemAllowOverlap(): Promoted from imgui_internal.h to public imgui.h api. (#517)
-- Combo(): Right-most button stays highlighted when popup is open.
-- Combo(): Display popup above if there's isn't enough space below / or select largest side. (#505)
-- DragFloat(), SliderFloat(), InputFloat(): fixed cases of erroneously returning true repeatedly after a text input modification (e.g. "0.0" --> "0.000" would keep returning true). (#564)
-- DragFloat(): Always apply value when mouse is held/widget active, so that an always-reseting variable (e.g. non saved local) can be passed.
-- InputText(): OS X friendly behaviors: Word movement uses Alt key; Shortcuts uses Cmd key; Double-clicking text select a single word; Jumping to next word sets cursor to end of current word instead of beginning of current word. (@zhiayang), (#473)
-- InputText(): Added BufTextLen in ImGuiTextEditCallbackData. Requesting user to maintain it if buffer is modified. Zero-ing structure properly before use. (#541)
-- CheckboxFlags(): Added support for testing/setting multiple flags at the same time. (@DMartinek) (#555)
-- TreeNode(), CollapsingHeader() fixed not being able to use "##" sequence in a formatted label.
-- ColorEdit4(): Empty label doesn't add InnerSpacing.x, matching behavior of other widgets. (#346)
-- ColorEdit4(): Removed unnecessary calls to scanf() when idle in hexadecimal edit mode.
-- BeginPopupContextItem(), BeginPopupContextWindow(): added early out optimization.
-- CaptureKeyboardFromApp() / CaptureMouseFromApp(): added argument to allow clearing the capture flag. (#533)
-- ImDrawList: Fixed index-overflow check broken by AddText() casting current index back to ImDrawIdx. (#514)
-- ImDrawList: Fixed incorrect removal of trailing draw command if it is a callback command.
-- ImDrawList: Allow windows with only a callback only to be functional. (#524)
-- ImDrawList: Fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis. (#457)
-- ImDrawList: Fixed ImDrawList::AddCircle() to fit precisely within bounding box like AddCircleFilled() and AddRectFilled(). (#457)
-- ImDrawList: AddCircle(), AddRect() takes optional thickness parameter.
-- ImDrawList: Added AddTriangle().
-- ImDrawList: Added PrimQuadUV() helper to ease custom rendering of textured quads (require primitive reserve).
-- ImDrawList: Allow AddText(ImFont\* font, float font_size, ...) variant to take NULL/0.0f as default.
-- ImFontAtlas: heuristic increase default texture width up for large number of glyphs. (#491)
-- ImTextBuffer: Fixed empty() helper which was utterly broken.
-- Metrics: allow to inspect individual triangles in drawcalls.
-- Demo: added more draw primitives in the Custom Rendering example. (#457)
-- Demo: extra comments and example for PushItemWidth(-1) patterns.
-- Demo: InputText password demo filters out blanks. (#515)
-- Demo: Fixed malloc/free mismatch and leak when destructing demo console, if it has been used. (@fungos) (#536)
-- Demo: plot code doesn't use ImVector to avoid heap allocation and be more friendly to custom allocator users. (#538)
-- Fixed compilation on DragonFly BSD (@mneumann) (#563)
-- Examples: Vulkan: Added a Vulkan example (@Loftilus) (#549)
-- Examples: DX10, DX11: Saving/restoring most device state so dropping render function in your codebase shouldn't have DX device side-effects. (#570)
-- Examples: DX10, DX11: Fixed ImGui_ImplDX??_NewFrame() from recreating device objects if render isn't called (g_pVB not set).
-- Examples: OpenGL3: Fix BindVertexArray/BindBuffer order. (@nlguillemot) (#527)
-- Examples: OpenGL: skip rendering and calling glViewport() if we have zero-fixed buffer. (#486)
-- Examples: SDL2+OpenGL3: Fix context creation options. Made ImGui_ImplSdlGL3_NewFrame() signature match GL2 one. (#468, #463)
-- Examples: SDL2+OpenGL2/3: Fix for high-dpi displays. (@nickgravelyn)
-- Various extra comments and clarification in the code.
-- Various other fixes and optimisations.
-
------------------------------------------------------------------------
-
-For older version, see https://github.com/ocornut/imgui/releases
-
diff --git a/third_party/imgui/LICENSE.txt b/third_party/imgui/LICENSE.txt
index 21b6ee7e2a..d876399591 100644
--- a/third_party/imgui/LICENSE.txt
+++ b/third_party/imgui/LICENSE.txt
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2014-2018 Omar Cornut
+Copyright (c) 2014-2020 Omar Cornut
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/third_party/imgui/README.md b/third_party/imgui/README.md
deleted file mode 100644
index 1190405ac4..0000000000
--- a/third_party/imgui/README.md
+++ /dev/null
@@ -1,327 +0,0 @@
-dear imgui,
-=====
-[](https://travis-ci.org/ocornut/imgui)
-[](https://scan.coverity.com/projects/4720)
-
-_(This library is free but needs your support to sustain its development. There are many desirable features and maintenance ahead If you are an individual using dear imgui, please consider donating via Patreon or PayPal. If your company is using dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development). I can invoice for technical support, custom development etc. E-mail: omarcornut at gmail.)_
-
-Monthly donations via Patreon:
-
[](http://www.patreon.com/imgui)
-
-One-off donations via PayPal:
-
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-
-Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).**
-
-Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.
-
-Dear ImGui is particularly suited to integration in games engine (for tooling), realtime 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.
-
-Dear ImGui is self-contained within a few files that you can easily copy and compile into your application/engine:
-- imgui.cpp
-- imgui.h
-- imgui_demo.cpp
-- imgui_draw.cpp
-- imgui_internal.h
-- imconfig.h (empty by default, user-editable)
-- stb_rect_pack.h
-- stb_textedit.h
-- stb_truetype.h
-
-No specific build process is required. You can add the .cpp files to your project or #include them from an existing file.
-
-### Usage
-
-Your code passes mouse/keyboard/gamepad inputs and settings to Dear ImGui (see example applications for more details). After Dear ImGui is setup, you can use it from \_anywhere\_ in your program loop:
-
-Code:
-```cpp
-ImGui::Text("Hello, world %d", 123);
-if (ImGui::Button("Save"))
-{
- // do stuff
-}
-ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
-ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
-```
-Result:
-

-
_(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px / Rounding: 5)_
-
-Code:
-```cpp
-// Create a window called "My First Tool", with a menu bar.
-ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar);
-if (ImGui::BeginMenuBar())
-{
- if (ImGui::BeginMenu("File"))
- {
- if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ }
- if (ImGui::MenuItem("Save", "Ctrl+S")) { /* Do stuff */ }
- if (ImGui::MenuItem("Close", "Ctrl+W")) { my_tool_active = false; }
- ImGui::EndMenu();
- }
- ImGui::EndMenuBar();
-}
-
-// Edit a color (stored as ~4 floats)
-ImGui::ColorEdit4("Color", my_color);
-
-// Plot some values
-const float my_values[] = { 0.2f, 0.1f, 1.0f, 0.5f, 0.9f, 2.2f };
-ImGui::PlotLines("Frame Times", my_values, IM_ARRAYSIZE(my_values));
-
-// Display contents in a scrolling region
-ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff");
-ImGui::BeginChild("Scrolling");
-for (int n = 0; n < 50; n++)
- ImGui::Text("%04d: Some text", n);
-ImGui::EndChild();
-ImGui::End();
-```
-Result:
-

-
-### How it works
-
-Check out the References section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize state duplication, state synchronization and state storage from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
-
-Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate dear imgui with your existing codebase.
-
-_A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._
-
-Dear ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc.
-
-Demo Binaries
--------------
-
-You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
-- [imgui-demo-binaries-20180207.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20180207.zip) (Windows binaries, Dear ImGui 1.60 WIP built 2018/01/07, 5 executables)
-
-The demo applications are unfortunately not yet DPI aware so expect some blurryness on a 4K screen. For DPI awareness you can load/reload your font at different scale, and scale your Style with `style.ScaleAllSizes()`.
-
-Bindings
---------
-
-Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading one texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles. The [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder is populated with applications doing just that. If you are an experienced programmer and at ease with those concepts, it should take you less than an hour to integrate Dear ImGui in your custom engine, but make sure to spend time reading the FAQ, the comments and other documentation!
-
-_NB: those third-party bindings may be more or less maintained, more or less close to the original API (as people who create language bindings sometimes haven't used the C++ API themselves.. for the good reason that they aren't C++ users). Dear ImGui was designed with C++ in mind and some of the subtleties may be lost in translation with other languages. If your language supports it, I would suggest replicating the function overloading and default parameters used in the original, else the API may be harder to use. In doubt, please check the original C++ version first!_
-
-Languages: (third-party bindings)
-- C: [cimgui](https://github.com/Extrawurst/cimgui)
-- C#/.Net: [ImGui.NET](https://github.com/mellinoe/ImGui.NET)
-- ChaiScript: [imgui-chaiscript](https://github.com/JuJuBoSc/imgui-chaiscript)
-- D: [DerelictImgui](https://github.com/Extrawurst/DerelictImgui)
-- Go: [go-imgui](https://github.com/Armored-Dragon/go-imgui)
-- Haxe/hxcpp: [linc_imgui](https://github.com/Aidan63/linc_imgui)
-- JavaScript: [imgui-js](https://github.com/flyover/imgui-js)
-- Lua: [imgui_lua_bindings](https://github.com/patrickriordan/imgui_lua_bindings)
-- Odin: [odin-dear_imgui](https://github.com/ThisDrunkDane/odin-dear_imgui)
-- Pascal: [imgui-pas](https://github.com/dpethes/imgui-pas)
-- Python [CyImGui](https://github.com/chromy/cyimgui)
-- Python [pyimgui](https://github.com/swistakm/pyimgui)
-- Rust: [imgui-rs](https://github.com/Gekkio/imgui-rs)
-
-Frameworks:
-- DirectX 9, DirectX 10, DirectX 11, DirectX 12: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- OpenGL 2/3 (with GLFW or SDL): [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Vulkan (with GLFW): [examples/](https://github.com/ocornut/imgui/tree/master/examples)
-- Allegro 5, iOS, 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: FreeGlut + OpenGL2: [#801](https://github.com/ocornut/imgui/pull/801)
-- Unmerged PR: Native Win32 and OSX: [#281](https://github.com/ocornut/imgui/pull/281)
-- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
-- Cinder: [Cinder-ImGui](https://github.com/simongeilfus/Cinder-ImGui)
-- Cocos2d-x: [imguix](https://github.com/c0i/imguix), [issue #551](https://github.com/ocornut/imgui/issues/551)
-- Flexium/SFML: [FlexGUI](https://github.com/DXsmiley/FlexGUI)
-- GML/GameMakerStudio2: [ImGuiGML](https://marketplace.yoyogames.com/assets/6221/imguigml)
-- Irrlicht: [IrrIMGUI](https://github.com/ZahlGraf/IrrIMGUI)
-- Ogre: [ogreimgui](https://bitbucket.org/LMCrashy/ogreimgui/src)
-- OpenFrameworks: [ofxImGui](https://github.com/jvcleave/ofxImGui)
-- OpenSceneGraph/OSG: [gist](https://gist.github.com/fulezi/d2442ca7626bf270226014501357042c)
-- LÖVE: [love-imgui](https://github.com/slages/love-imgui)
-- NanoRT: [syoyo/imgui](https://github.com/syoyo/imgui/tree/nanort)
-- Qt3d: [imgui-qt3d](https://github.com/alpqr/imgui-qt3d)
-- Unreal Engine 4: [segross/UnrealImGui](https://github.com/segross/UnrealImGui) or [sronsse/UnrealEngine_ImGui](https://github.com/sronsse/UnrealEngine_ImGui)
-- SFML: [imgui-sfml](https://github.com/EliasD/imgui-sfml) or [imgui-backends](https://github.com/Mischa-Alff/imgui-backends)
-
-For other bindings: see [this page](https://github.com/ocornut/imgui/wiki/Links/).
-Please contact me with the Issues tracker or Twitter to fix/update this list.
-
-Roadmap
--------
-Some of the goals for 2018 are:
-- Finish work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))
-- Finish work on viewports and multiple OS windows management. (see [#1542](https://github.com/ocornut/imgui/issues/1542))
-- Finish work on docking, tabs. (see [#351](https://github.com/ocornut/imgui/issues/351#issuecomment-346865709))
-- Make Columns better. (they are currently pretty terrible!)
-- Make the examples look better, improve styles, improve font support, make the examples hi-DPI aware.
-
-Gallery
--------
-
-User screenshots:
-
[Gallery Part 1](https://github.com/ocornut/imgui/issues/123) (Feb 2015 to Feb 2016)
-
[Gallery Part 2](https://github.com/ocornut/imgui/issues/539) (Feb 2016 to Aug 2016)
-
[Gallery Part 3](https://github.com/ocornut/imgui/issues/772) (Aug 2016 to Jan 2017)
-
[Gallery Part 4](https://github.com/ocornut/imgui/issues/973) (Jan 2017 to Aug 2017)
-
[Gallery Part 5](https://github.com/ocornut/imgui/issues/1269) (Aug 2017 onward)
-
Also see the [Mega screenshots](https://github.com/ocornut/imgui/issues/1273) for an idea of the available features.
-
-Various tools
-[](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png)
-
-[](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v160/editor_white.png)
-
-
-
-[](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/profiler.png)
-
-Dear ImGui can load TTF/OTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
-Code:
-```cpp
-ImGuiIO& io = ImGui::GetIO();
-io.Fonts->AddFontFromFileTTF("NotoSansCJKjp-Medium.otf", 20.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
-```
-```cpp
-ImGui::Text(u8"こんにちは!テスト %d", 123);
-if (ImGui::Button(u8"ロード"))
-{
- // do stuff
-}
-ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
-ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
-```
-Result:
-

-
_(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_
-
-References
-----------
-
-The Immediate Mode GUI paradigm may at first appear unusual to some users. This is mainly because "Retained Mode" GUIs have been so widespread and predominant. The following links can give you a better understanding about how Immediate Mode GUIs works.
-- [Johannes 'johno' Norneby's article](http://www.johno.se/book/imgui.html).
-- [A presentation by Rickard Gustafsson and Johannes Algelind](http://www.cse.chalmers.se/edu/year/2011/course/TDA361/Advanced%20Computer%20Graphics/IMGUI.pdf).
-- [Jari Komppa's tutorial on building an ImGui library](http://iki.fi/sol/imgui/).
-- [Casey Muratori's original video that popularized the concept](https://mollyrocket.com/861).
-- [Nicolas Guillemot's CppCon'16 flashtalk about Dear ImGui](https://www.youtube.com/watch?v=LSRJ1jZq90k).
-- [Thierry Excoffier's Zero Memory Widget](http://perso.univ-lyon1.fr/thierry.excoffier/ZMW/).
-
-See the [Links page](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to different languages and frameworks.
-
-Frequently Asked Question (FAQ)
--------------------------------
-
-Where is the documentation?
-
-- The documentation is at the top of imgui.cpp + effectively imgui.h.
-- Example code is in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function. It covers most features of ImGui so you can read the code and call the function itself to see its output.
-- Standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder.
-- We obviously needs better documentation! Consider contributing or becoming a [Patron](http://www.patreon.com/imgui) to promote this effort.
-
-Which version should I get?
-
-I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported.
-
-Who uses Dear ImGui?
-
-See the [Software using dear imgui page](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) for an (incomplete) list of games/software which are publicly known to use dear imgui. Please add yours if you can!
-
-Why the odd dual naming, "dear imgui" vs "ImGui"?
-
-The library started its life and is best known as "ImGui" only due to the fact that I didn't give it a proper name when I released it. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations. It seemed confusing and unfair to hog the name. To reduce the ambiguity without affecting existing codebases, I have decided on an alternate, longer name "dear imgui" that people can use to refer to this specific library in ambiguous situations.
-
-How can I help?
-
How can I display an image? What is ImTextureID, how does it works?
-
How can I have multiple widgets with the same label, or without any label? (Yes). A primer on labels and ID stack.
-
How can I tell when Dear ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?
-
How can I load a different font than the default?
-
How can I easily use icons in my application?
-
How can I load multiple fonts?
-
How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
-
How can I preserve my Dear ImGui context across reloading a DLL? (loss of the global/static variables)
-
How can I use the drawing facilities without an Dear ImGui window? (using ImDrawList API)
-
I integrated Dear ImGui in my engine and the text or lines are blurry..
-
I integrated Dear ImGui in my engine and some elements are disappearing when I move windows around..
-
-See the FAQ in imgui.cpp for answers.
-
-How do you use Dear ImGui on a platform that may not have a mouse or keyboard?
-
-You can control Dear ImGui with a gamepad, see the explanation in imgui.cpp about how to use the navigation feature (short version: map your gamepad inputs into the `io.NavInputs[]` array and set `io.NavFlags |= ImGuiNavFlags_EnableGamepad`).
-
-You can share your computer mouse seamlessy with your console/tablet/phone using [Synergy](http://synergy-project.org). This is the prefered solution for developer productivity. In particular, their [micro-synergy-client](https://github.com/symless/micro-synergy-client) repo there is _uSynergy.c_ sources for a small embeddable that you can use on any platform to connect to your host PC. You may also use a third party solution such as [Remote ImGui](https://github.com/JordiRos/remoteimgui).
-
-For touch inputs, you can increase the hit box of widgets (via the _style.TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse or gamepad to allow optimising for screen real-estate and precision.
-
-Can you create elaborate/serious tools with Dear ImGui?
-
-Yes. People have written game editors, data browsers, debuggers, profilers and all sort of non-trivial tools with the library. In my experience the simplicity of the API is very empowering. Your UI runs close to your live data. Make the tools always-on and everybody in the team will be inclined to create new tools (as opposed to more "offline" UI toolkits where only a fraction of your team effectively creates tools). The list of sponsors below is also an indicator that serious game teams have been using the library.
-
-Dear ImGui is very programmer centric and the immediate-mode GUI paradigm might requires you to readjust some habits before you can realize its full potential. Dear ImGui is about making things that are simple, efficient and powerful.
-
-Can you reskin the look of Dear ImGui?
-
-You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as Dear ImGui is designed and optimised to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. Below is a screenshot from [LumixEngine](https://github.com/nem0/LumixEngine) with custom colors + a docking/tabs extension (both of which you can find in the Issues section and will eventually be merged):
-
-
-
-Why using C++ (as opposed to C)?
-
-Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost-insanity/quagmire. Dear ImGui does NOT require C++11 so it can be used with most old C++ compilers. Dear ImGui doesn't use any C++ header file. Language-wise, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience.
-
-There is an reasonably maintained [c-api for ImGui](https://github.com/Extrawurst/cimgui) by Stephan Dilly designed for binding in other languages. I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Links](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to other languages.
-
-Support dear imgui
-------------------
-
-How can I help financing further development of Dear ImGui?
-
-Your contributions are keeping the library alive. If you are an individual using dear imgui, please consider donating to enable me to spend more time improving the library.
-
-Monthly donations via Patreon:
-
[](http://www.patreon.com/imgui)
-
-One-off donations via PayPal:
-
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
-
-If your company uses dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development). I can invoice for private support, custom development etc. E-mail: omarcornut at gmail. Thanks!
-
-Credits
--------
-
-Developed by [Omar Cornut](http://www.miracleworld.net) and every direct or indirect contributors to the GitHub. The early version of this library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com).
-
-I first discovered imgui principles at [Q-Games](http://www.q-games.com) where Atman had dropped his own simple imgui implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating on it.
-
-Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license).
-
-Embeds [stb_textedit.h, stb_truetype.h, stb_rectpack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
-
-Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. And everybody posting feedback, questions and patches on the GitHub.
-
-Ongoing dear imgui development is financially supported on [**Patreon**](http://www.patreon.com/imgui) and by private sponsors.
-
-Double-chocolate sponsors:
-- Blizzard
-- Media Molecule
-- Mobigame
-- Insomniac Games
-- Aras Pranckevičius
-- Lizardcube
-- Greggman
-- DotEmu
-
-Salty caramel supporters:
-- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Recognition Robotics, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko, Mercury Labs, Singularity Demo Group, Mischa Alff, Sebastien Ronsse, Lionel Landwerlin.
-
-Caramel supporters:
-- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Kit framework, Josh Faust, Martin Donlon, Quinton, Felix, Andrew Belt, Codecat, Cort Stratton, Claudio Canepa, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Roger Clark, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Miloš Tošić, Jonas Bernemann, Johan Andersson, Nathan Hartman, Michael Labbe, Tomasz Golebiowski, Louis Schnellbach, Felipe Alfonso, Jimmy Andrews, Bojan Endrovski, Robin Berg Pettersen, Rachel Crawford, Edsel Malasig, Andrew Johnson.
-
-And other supporters; thanks!
-(Please contact me or PR if you would like to be added or removed from this list)
-
-License
--------
-
-Dear ImGui is licensed under the MIT License, see LICENSE for more information.
diff --git a/third_party/imgui/TODO.txt b/third_party/imgui/TODO.txt
deleted file mode 100644
index 939393ba6d..0000000000
--- a/third_party/imgui/TODO.txt
+++ /dev/null
@@ -1,270 +0,0 @@
-dear imgui
-ISSUES & TODO LIST
-
-Issue numbers (#) refer to github issues listed at https://github.com/ocornut/imgui/issues/XXXX
-The list below consist mostly of ideas noted down before they are requested/discussed by users (at which point they usually exist on the github issue tracker).
-It's mostly a bunch of personal notes, probably incomplete. Feel free to query if you have any questions.
-
- - doc/test: add a proper documentation+regression testing system (#435)
- - doc/test: checklist app to verify binding/integration of imgui (test inputs, rendering, callback, etc.).
- - doc/tips: tips of the day: website? applet in imgui_club?
- - project: folder or separate repository with maintained helpers (e.g. imgui_memory_editor.h, imgui_stl.h, maybe imgui_dock would be there?)
-
- - window: calling SetNextWindowSize() every frame with <= 0 doesn't do anything, may be useful to allow (particularly when used for a single axis). (#690)
- - window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list. perhaps a lightweight explicit cleanup pass.
- - window: auto-fit feedback loop when user relies on any dynamic layout (window width multiplier, column) appears weird to end-user. clarify.
- - window: allow resizing of child windows (possibly given min/max for each axis?.)
- - window: background options for child windows, border option (disable rounding).
- - window: resizing from any sides? done. > need backends to honor mouse cursors properly. (#822)
- - window: resize from borders: support some form of outer padding to make it easier to grab borders. (#822)
- - window: begin with *p_open == false should return false.
- - window: get size/pos helpers given names (see discussion in #249)
- - window: a collapsed window can be stuck behind the main menu bar?
- - window: when window is very small, prioritize resize button over close button.
- - window: detect extra End() call that pop the "Debug" window out and assert at End() call site instead of at end of frame.
- - window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd.
- - window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
- - window: expose contents size. (#1045)
- - window: GetWindowSize() returns (0,0) when not calculated? (#1045)
- - window: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate.
-!- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
- - scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro)
-
- - drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
- - drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
- - drawlist: primtiives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api
- - drawlist: make it easier to toggle AA per primitive, so we can use e.g. non-AA fill + AA borders more naturally
- - drawlist: non-AA strokes have gaps between points (#593, #288), especially RenderCheckmark().
- - drawlist: would be good to be able to deep copy a draw list (ImVector= op?).
- - drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation.
-
- - main: considering adding an Init() function? some constructs are awkward in the implementation because of the lack of them.
- - main: find a way to preserve relative orders of multiple reappearing windows (so an app toggling between "modes" e.g. fullscreen vs all tools) won't lose relative ordering.
- - main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
- - main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
- - main: rename the main "Debug" window to avoid ID collision with user who may want to use "Debug" with specific flags.
-
- - widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc. (#395)
- - widgets: clean up widgets internal toward exposing everything and stabilizing imgui_internals.h.
- - widgets: add visauls for Disabled/ReadOnly mode and expose publicly (#211)
- - widgets: add always-allow-overlap mode.
- - widgets: alignment options in style (e.g. center Selectable, Right-Align within Button, etc.) #1260
- - widgets: activate by identifier (trigger button, focus given id)
-
- - input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now and super fragile.
- - input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
- - input text: expose CursorPos in char filter event (#816)
- - input text: access public fields via a non-callback API e.g. InputTextGetState("xxx") that may return NULL if not active.
- - input text: flag to disable live update of the user buffer (also applies to float/int text input) (#701)
- - input text: way to dynamically grow the buffer without forcing the user to initially allocate for worse case, e.g. more natural std::string (follow up on #200)
- - input text: hover tooltip could show unclamped text
- - input text: option to Tab after an Enter validation.
- - input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
- - input text: easier ways to update buffer (from source char*) while owned. preserve some sort of cursor position for multi-line text.
- - input text: add discard flag (e.g. ImGuiInputTextFlags_DiscardActiveBuffer) or make it easier to clear active focus for text replacement during edition (#725)
- - input text: display bug when clicking a drag/slider after an input text in a different window has all-selected text (order dependant). actually a very old bug but no one appears to have noticed it.
- - input text multi-line: don't directly call AddText() which does an unnecessary vertex reserve for character count prior to clipping. and/or more line-based clipping to AddText(). and/or reorganize TextUnformatted/RenderText for more efficiency for large text (e.g TextUnformatted could clip and log separately, etc).
- - input text multi-line: support for cut/paste without selection (cut/paste the current line)
- - input text multi-line: line numbers? status bar? (follow up on #200)
- - input text multi-line: behave better when user changes input buffer while editing is active (even though it is illegal behavior). namely, the change of buffer can create a scrollbar glitch (#725)
- - input text multi-line: better horizontal scrolling support (#383, #1224)
- - input text: allow centering/positioning text so that ctrl+clicking Drag or Slider keeps the textual value at the same pixel position.
- - input number: optional range min/max for Input*() functions
- - input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled)
- - input number: use mouse wheel to step up/down
- - input number: applying arithmetics ops (+,-,*,/) messes up with text edit undo stack.
-
- - layout: helper or a way to express ImGui::SameLine(ImGui::GetCursorStartPos().x + ImGui::CalcItemWidth() + ImGui::GetStyle().ItemInnerSpacing.x); in a simpler manner.
- - layout: generalization of the above: a concept equivalent to word processor ruler tab stop ~ mini columns (position in X, no clipping implied) (vaguely relate to #267, #395, also what is used internally for menu items)
- - layout: horizontal layout helper (#97)
- - layout: horizontal flow until no space left (#404)
- - layout: more generic alignment state (left/right/centered) for single items?
- - layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding.
- - layout: BeginGroup() needs a border option. (~#1496)
- - layout: vertical alignement of mixed height items (e.g. buttons) within a same line (#1284)
-
- - columns: sizing policy (e.g. for each column: fixed size, %, fill, distribute default size among fills) (#513, #125)
- - columns: add a conditional parameter to SetColumnOffset() (#513, #125)
- - columns: headers. reorderable. (#513, #125)
- - columns: optional sorting modifiers (up/down), sort list so sorting can be done multi-critera. notify user when sort order changed.
- - columns: option to alternate background colors on odd/even scanlines.
- - columns: allow columns to recurse.
- - columns: allow a same columns set to be interrupted by e.g. CollapsingHeader and resume with columns in sync when moving them.
- - columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (#125)
- - columns: flag to add horizontal separator above/below?
- - columns/layout: setup minimum line height (equivalent of automatically calling AlignFirstTextHeightToWidgets)
-
-!- color: the color conversion helpers/types are a mess and needs sorting out.
- - color: (api breaking) ImGui::ColorConvertXXX functions should be loose ImColorConvertXX to match imgui_internals.h
- - coloredit: it is still somehow awkward to copy colors around (unless going through Hex mode).
-
- - plot: full featured plot/graph api w/ scrolling, zooming etc. all bell & whistle. why not!
- - plot: PlotLines() should use the polygon-stroke facilities, less verticles (currently issues with averaging normals)
- - plot: make it easier for user to draw extra stuff into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots)
- - plot: "smooth" automatic scale over time, user give an input 0.0(full user scale) 1.0(full derived from value)
- - plot: option/feature: draw the zero line
- - plot: option/feature: draw grid, vertical markers
- - plot: option/feature: draw unit
- - plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID)
-
- - clipper: ability to force display 1 item in the list would be convenient (for patterns where we need to set active id etc.)
- - clipper: ability to disable the clipping through a simple flag/bool.
- - clipper: ability to run without knowing full count in advance.
-
- - splitter/separator: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
-
- - dock: docking extension
- - dock: dock out from a collapsing header? would work nicely but need emitting window to keep submitting the code.
-
- - tabs: re-ordering, close buttons, context menu, persistent order (#261, #351)
-
- - ext: stl-ish friendly extension (imgui_stl.h) that has wrapped for std::string, std::vector etc.
-
- - button: provide a button that looks framed.
- - image/image button: misalignment on padded/bordered button?
- - image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that?
- - image button: not taking an explicit id is odd.
- - slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
- - slider: initial absolute click is imprecise. change to relative movement slider (same as scrollbar).
- - slider: add dragging-based widgets to edit values with mouse (on 2 axises), saving screen real-estate.
- - slider: tint background based on value (e.g. v_min -> v_max, or use 0.0f either side of the sign)
- - slider: precision dragging
- - slider: step option (#1183)
- - knob: rotating knob widget (#942)
- - slider & drag: int data passing through a float
- - drag float: up/down axis
- - drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits)
-
- - combo: use clipper: make it easier to disable clipper with a single flag.
- - combo: option for BeginCombo to not return true when unchanged (#1182)
- - combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203)
- - listbox: multiple selection.
- - listbox: unselect option (#1208)
- - listbox: make it easier/more natural to implement range-select (need some sort of info/ref about the last clicked/focused item that user can translate to an index?) (wip stash)
- - listbox: user may want to initial scroll to focus on the one selected value?
- - listbox: expose hovered item for a basic ListBox
- - listbox: keyboard navigation.
- - listbox: scrolling should track modified selection.
-
-!- popups/menus: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331, #402)
- - popups: reopening context menu at new position should be the behavior by default? (equivalent to internal OpenPopupEx() with reopen_existing=true) (~#1497)
- - popups: if the popup functions took explicit ImGuiID it would allow the user to manage the scope of those ID. (#331)
- - popups: clicking outside (to close popup) and holding shouldn't drag window below.
- - popups: add variant using global identifier similar to Begin/End (#402)
- - popups: border options. richer api like BeginChild() perhaps? (#197)
- - tooltip: tooltip that doesn't fit in entire screen seems to lose their "last preferred direction" and may teleport when moving mouse.
- - tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
- - tooltip: allow tooltips with timers? or general timer policy? (instaneous vs timed)
-
- - menus: calling BeginMenu() twice with a same name doesn't append as Begin() does for regular windows (#1207)
- - menus: menu bars inside modals windows are acting weird.
- - statusbar: add a per-window status bar helper similar to what menubar does.
- - shortcuts: local-style shortcut api, e.g. parse "&Save"
- - shortcuts,menus: global-style shortcut api e.g. "Save (CTRL+S)" -> explicit flag for recursing into closed menu
- - shortcuts: programmatically access shortcuts "Focus("&Save"))
- - menus: menubars: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
- - menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer.
-
- - text: selectable text (for copy) as a generic feature (ItemFlags?)
- - text: proper alignment options in imgui_internal.h
- - text wrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (#249)
- - text: it's currently impossible to have a window title with "##". perhaps an official workaround would be nice. \ style inhibitor? non-visible ascii code to insert between #?
- - text link/url button: underlined. should api expose an ID or use text contents as ID? which colors enum to use?
-
- - tree node / optimization: avoid formatting when clipped.
- - tree node: tree-node/header right-most side doesn't take account of horizontal scrolling.
- - tree node: add treenode/treepush int variants? not there because (void*) cast from int warns on some platforms/settings?
- - tree node: try to apply scrolling at time of TreePop() if node was just opened and end of node is past scrolling limits?
- - tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
- - tree node: tweak color scheme to distinguish headers from selected tree node (#581)
- - tree node: leaf/non-leaf highlight mismatch.
-
-!- settings: expose enough to save/load .ini from RAM instead of fopen
- - settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
- - settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437)
- - stb: add defines to disable stb implementations
-
-!- style: better default styles. (#707)
- - style: border types: out-screen, in-screen, etc. (#447)
- - style/optimization: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding.
- - style: add window shadow (fading away from the window. Paint-style calculation of vertices alpha after drawlist would be easier)
- - style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps to other settings? avoid implementing duplicate helpers such as SmallCheckbox(), etc.
- - style: try to make PushStyleVar() more robust to incorrect parameters (to be more friendly to edit & continues situation).
- - style: global scale setting.
- - style: WindowPadding needs to be EVEN as the 0.5 multiplier used on this value probably have a subtle effect on clip rectangle
- - style: have a more global HSV setter (e.g. alter hue on all elements). consider replacing active/hovered by offset in HSV space? (#438, #707, #1223)
- - style: gradients fill (#1223) ~ 2 bg colors for each fill? tricky with rounded shapes and using textures for corners.
- - style editor: color child window height expressed in multiple of line height.
-
- - log: LogButtons() options for specifying depth and/or hiding depth slider
- - log: have more control over the log scope (e.g. stop logging when leaving current tree node scope)
- - log: be able to log anything (e.g. right-click on a window/tree-node, shows context menu? log into tty/file/clipboard)
- - log: let user copy any window content to clipboard easily (CTRL+C on windows? while moving it? context menu?). code is commented because it fails with multiple Begin/End pairs.
-
- - filters: set a current filter that tree node can automatically query to hide themselves
- - filters: handle wildcards (with implicit leading/trailing *), regexps
- - filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb)
-
- - drag and drop: add demo. (#143, #479)
- - drag and drop: test with reordering nodes (in a list, or a tree node). (#143)
- - drag and drop: test integrating with os drag and drop.
- - node/graph editor (#306)
- - pie menus patterns (#434)
- - markup: simple markup language for color change? (#902)
-
- - font: better vertical centering (based e.g on height of lowercase 'x'?). currently Roboto-Medium size 16 px isn't currently centered.
- - font: free the Alpha buffer if user only requested RGBA.
-!- font: better CalcTextSizeA() API, at least for simple use cases. current one is horrible (perhaps have simple vs extended versions).
- - font: enforce monospace through ImFontConfig (for icons?) + create dual ImFont output from same input, reusing rasterized data but with different glyphs/AdvanceX
- - font: finish CustomRectRegister() to allow mapping unicode codepoint to custom texture data
- - font: PushFontSize API (#1018)
- - font/atlas: incremental updates
- - font/atlas: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier.
- - font/atlas: allow user to submit its own primitive to be rectpacked, and allow to map them on a Unicode point.
- - font: MemoryTTF taking ownership confusing/not obvious, maybe default should be opposite?
- - font/text: vertical and/or rotated text renderer (#705) - vertical is easier clipping wise
- - font: imgui_freetype.h alternative renderer (#618)
- - font: optimization: for monospace font (like the default one) we can trim IndexXAdvance as long as trailing value is == FallbackXAdvance (need to make sure TAB is still correct).
- - font: add support for kerning, probably optional. A) perhaps default to (32..128)^2 matrix ~ 9K entries = 36KB, then hash for non-ascii?. B) or sparse lookup into per-char list?
- - font: add a simpler CalcTextSizeA() api? current one ok but not welcome if user needs to call it directly (without going through ImGui::CalcTextSize)
- - font: fix AddRemapChar() to work before font has been built.
- - font: (api breaking) removed "TTF" from symbol names. also because it now supports OTF.
-
- - nav: integrate navigation branch into master. (#787)
- - nav: allow input system to be be more tolerant of io.DeltaTime=0.0f
- - nav: Left within a tree node block as a fallback.
- - nav: Esc on a flattened child
- - nav: menus: allow pressing Menu to leave a sub-menu.
- - nav: integrate/design keyboard controls.
- - nav: simulate right-click or context activation? (SHIFT+F10)
- - nav: tabs should go through most/all widgets (in submission order?).
- - nav: when CTRL-Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering.
- - nav: cannot access menubar of a flattened child window with Alt/menu key (not a very common use case..).
- - nav: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys.
- - nav: when activating a button that changes label (without a static ID) or disappear, can we somehow automatically recover into a nearest highlight item?
- - focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
- - focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
- - focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787)
-
- - inputs: we need an explicit flag about whether the imgui window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors.
- - inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71)
- - inputs: support track pad style scrolling & slider edit.
-
- - misc: idle refresh: expose cursor blink animation timer for backend to be able to lower framerate.
- - misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?)
- - misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL)
- - misc: fix for compilation settings where stdcall isn't the default (e.g. vectorcall) (#1230)
- - remote: make a system like RemoteImGui first-class citizen/project (#75)
-
- - demo: add vertical separator demo
- - demo: add virtual scrolling example?
- - examples: directx9: save/restore device state more thoroughly.
- - examples: window minimize, maximize (#583)
- - examples: provide a zero-framerate/idle example.
- - examples: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // the problem is that DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
- - optimization: replace vsnprintf with stb_printf? or enable the defines/infrastructure to allow it (#1038)
- - optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
- - optimization: add a flag to disable most of rendering, for the case where the user expect to skip it (#335)
- - optimization: use another hash function than crc32, e.g. FNV1a
- - optimization/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)?
- - optimization: turn some the various stack vectors into statically-sized arrays
diff --git a/third_party/imgui/docs/CHANGELOG.txt b/third_party/imgui/docs/CHANGELOG.txt
new file mode 100644
index 0000000000..4d757e0bb0
--- /dev/null
+++ b/third_party/imgui/docs/CHANGELOG.txt
@@ -0,0 +1,2492 @@
+dear imgui
+CHANGELOG
+
+This document holds the user-facing changelog that we also use in release notes.
+We generally fold multiple commits pertaining to the same topic as a single entry.
+Changes to the examples/bindings are included within the individual .cpp files in the examples/ folder.
+
+RELEASE NOTES: https://github.com/ocornut/imgui/releases
+REPORT ISSUES, ASK QUESTIONS: https://github.com/ocornut/imgui/issues
+COMMITS HISTORY: https://github.com/ocornut/imgui/commits/master
+FAQ https://www.dearimgui.org/faq/
+WIKI https://github.com/ocornut/imgui/wiki
+
+WHEN TO UPDATE?
+
+- Keeping your copy of Dear ImGui updated regularly is recommended.
+- It is generally safe to sync to the latest commit in master or docking branches
+ The library is fairly stable and regressions tends to be fixed fast when reported.
+
+HOW TO UPDATE?
+
+- Overwrite every file except imconfig.h (if you have modified it).
+- You may also locally branch to modify imconfig.h and merge latest into your branch.
+- Read the `Breaking Changes` section (in imgui.cpp or here in the Changelog).
+- If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it.
+- If you are dropping this repository in your codebase, please leave the demo and text files in there, they will be useful.
+- You may diff your previous Changelog with the one you just copied and read that diff.
+- You may enable `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in imconfig.h to forcefully disable legacy names and symbols.
+ Doing it every once in a while is a good way to make sure you are not using obsolete symbols. Dear ImGui is in active development,
+ and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
+- Please report any issue!
+
+
+-----------------------------------------------------------------------
+ VERSION 1.77 (Released 2020-06-29)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.77
+
+Breaking Changes:
+
+- Removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular() function. Please
+ note that this is a Beta api and will likely be reworked in order to support multi-DPI accross
+ multiple monitors.
+- Renamed OpenPopupOnItemClick() to OpenPopupContextItem(). Kept inline redirection function (will obsolete).
+- Removed BeginPopupContextWindow(const char*, int mouse_button, bool also_over_items) in favor
+ of BeginPopupContextWindow(const char*, ImGuiPopupFlags flags) with ImGuiPopupFlags_NoOverItems.
+ Kept inline redirection function (will obsolete).
+- Removed obsoleted CalcItemRectClosestPoint() entry point (has been asserting since December 2017).
+
+Other Changes:
+
+- TreeNode: Fixed bug where BeginDragDropSource() failed when the _OpenOnDoubleClick flag is
+ enabled (bug introduced in 1.76, but pre-1.76 it would also fail unless the _OpenOnArrow
+ flag was also set, and _OpenOnArrow is frequently set along with _OpenOnDoubleClick).
+- TreeNode: Fixed bug where dragging a payload over a TreeNode() with either _OpenOnDoubleClick
+ or _OpenOnArrow would open the node. (#143)
+- Windows: Fix unintended feedback loops when resizing windows close to main viewport edges. [@rokups]
+- Tabs: Added style.TabMinWidthForUnselectedCloseButton settings:
+ - Set to 0.0f (default) to always make a close button appear on hover (same as Chrome, VS).
+ - Set to FLT_MAX to only display a close button when selected (merely hovering is not enough).
+ - Set to an intermediary value to toggle behavior based on width (same as Firefox).
+- Tabs: Added a ImGuiTabItemFlags_NoTooltip flag to disable the tooltip for individual tab item
+ (vs ImGuiTabBarFlags_NoTooltip for entire tab bar). [@Xipiryon]
+- Popups: All functions capable of opening popups (OpenPopup*, BeginPopupContext*) now take a new
+ ImGuiPopupFlags sets of flags instead of a mouse button index. The API is automatically backward
+ compatible as ImGuiPopupFlags is guaranteed to hold mouse button index in the lower bits.
+- Popups: Added ImGuiPopupFlags_NoOpenOverExistingPopup for OpenPopup*/BeginPopupContext* functions
+ to first test for the presence of another popup at the same level.
+- Popups: Added ImGuiPopupFlags_NoOpenOverItems for BeginPopupContextWindow() - similar to testing
+ for !IsAnyItemHovered() prior to doing an OpenPopup().
+- Popups: Added ImGuiPopupFlags_AnyPopupId and ImGuiPopupFlags_AnyPopupLevel flags for IsPopupOpen(),
+ allowing to check if any popup is open at the current level, if a given popup is open at any popup
+ level, if any popup is open at all.
+- Popups: Fix an edge case where programatically closing a popup while clicking on its empty space
+ would attempt to focus it and close other popups. (#2880)
+- Popups: Fix BeginPopupContextVoid() when clicking over the area made unavailable by a modal. (#1636)
+- Popups: Clarified some of the comments and function prototypes.
+- Modals: BeginPopupModal() doesn't set the ImGuiWindowFlags_NoSavedSettings flag anymore, and will
+ not always be auto-centered. Note that modals are more similar to regular windows than they are to
+ popups, so api and behavior may evolve further toward embracing this. (#915, #3091)
+ Enforce centering using e.g. SetNextWindowPos(io.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f,0.5f)).
+- Metrics: Added a "Settings" section with some details about persistent ini settings.
+- Nav, Menus: Fix vertical wrap-around in menus or popups created with multiple appending calls to
+ BeginMenu()/EndMenu() or BeginPopup(0/EndPopup(). (#3223, #1207) [@rokups]
+- Drag and Drop: Fixed unintended fallback "..." tooltip display during drag operation when
+ drag source uses _SourceNoPreviewTooltip flags. (#3160) [@rokups]
+- Columns: Lower overhead on column switches and switching to background channel.
+ Benefits Columns but was primarily made with Tables in mind!
+- Fonts: Fix GetGlyphRangesKorean() end-range to end at 0xD7A3 (instead of 0xD79D). (#348, #3217) [@marukrap]
+- ImDrawList: Fixed an issue where draw command merging or primitive unreserve while crossing the
+ VtxOffset boundary would lead to draw commands with wrong VtxOffset. (#3129, #3163, #3232, #2591)
+ [@thedmd, @Shironekoben, @sergeyn, @ocornut]
+- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where changing channels with different
+ TextureId, VtxOffset would incorrectly apply new settings to draw channels. (#3129, #3163)
+ [@ocornut, @thedmd, @Shironekoben]
+- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where starting a split when current
+ VtxOffset was not zero would lead to draw commands with wrong VtxOffset. (#2591)
+- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where starting a split right after
+ a callback draw command would incorrectly override the callback draw command.
+- ImDrawList: Fixed minor bug introduced in 1.75 where AddCircle() with 12 segments would
+ generate an extra unrequired vertex. [@ShironekoBen]
+- Misc, Freetype: Fix for rare case where FT_Get_Char_Index() succeeds but FT_Load_Glyph() fails.
+- Docs: Improved and moved font documentation to docs/FONTS.md so it can be readable on the web.
+ Updated various links/wiki accordingly. Added FAQ entry about DPI. (#2861) [@ButternCream, @ocornut]
+- CI: Added CI test to verify we're never accidentally dragging libstdc++ (on some compiler setups,
+ static constructors for non-pod data seems to drag in libstdc++ due to thread-safety concerns).
+ Fixed a static constructor which led to this dependency on some compiler setups.
+- Backends: Win32: Support for #define NOGDI, won't try to call GetDeviceCaps(). (#3137, #2327)
+- Backends: Win32: Fix _WIN32_WINNT < 0x0600 (MinGW defaults to 0x502 == Windows 2003). (#3183)
+- Backends: SDL: Report a zero display-size when window is minimized, consistent with other backends,
+ making more render/clipping code use an early out path.
+- Backends: OpenGL: Fixed handling of GL 4.5+ glClipControl(GL_UPPER_LEFT) by inverting the
+ projection matrix top and bottom values. (#3143, #3146) [@u3shit]
+- Backends: OpenGL: On OSX, if unspecified by app, made default GLSL version 150. (#3199) [@albertvaka]
+- Backends: OpenGL: Fixed loader auto-detection to not interfere with ES2/ES3 defines. (#3246) [@funchal]
+- Backends: Vulkan: Fixed error in if initial frame has no vertices. (#3177)
+- Backends: Vulkan: Fixed edge case where render callbacks wouldn't be called if the ImDrawData
+ structure didn't have any vertices. (#2697) [@kudaba]
+- Backends: OSX: Added workaround to avoid fast mouse clicks. (#3261, #1992, #2525) [@nburrus]
+- Examples: GLFW+Vulkan, SDL+Vulkan: Fix for handling of minimized windows. (#3259)
+- Examples: Apple: Fixed example_apple_metal and example_apple_opengl2 using imgui_impl_osx.mm
+ not forwarding right and center mouse clicks. (#3260) [@nburrus]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.76 (Released 2020-04-12)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.76
+
+Other Changes:
+
+- Drag and Drop, Nav: Disabling navigation arrow keys when drag and drop is active. In the docking
+ branch pressing arrow keys while dragging a window from a tab could trigger an assert. (#3025)
+- BeginMenu: Using same ID multiple times appends content to a menu. (#1207) [@rokups]
+- BeginMenu: Fixed a bug where SetNextWindowXXX data before a BeginMenu() would not be cleared
+ when the menu is not open. (#3030)
+- InputText: Fixed password fields displaying ASCII spaces as blanks instead of using the '*'
+ glyph. (#2149, #515)
+- Selectable: Fixed honoring style.SelectableTextAlign with unspecified size. (#2347, #2601)
+- Selectable: Allow using ImGuiSelectableFlags_SpanAllColumns in other columns than first. (#125)
+- TreeNode: Made clicking on arrow with _OpenOnArrow toggle the open state on the Mouse Down
+ event rather than the Mouse Down+Up sequence (this is rather standard behavior).
+- ColorButton: Added ImGuiColorEditFlags_NoBorder flag to remove the border normally enforced
+ by default for standalone ColorButton.
+- Nav: Fixed interactions with ImGuiListClipper, so e.g. Home/End result would not clip the
+ landing item on the landing frame. (#787)
+- Nav: Fixed currently focused item from ever being clipped by ItemAdd(). (#787)
+- Scrolling: Fixed scrolling centering API leading to non-integer scrolling values and initial
+ cursor position. This would often get fixed after the fix item submission, but using the
+ ImGuiListClipper as the first thing after Begin() could largely break size calculations. (#3073)
+- Added optional support for Unicode plane 1-16 (#2538, #2541, #2815) [@cloudwu, @samhocevar]
+ - Compile-time enable with '#define IMGUI_USE_WCHAR32' in imconfig.h.
+ - More onsistent handling of unsupported code points (0xFFFD).
+ - Surrogate pairs are supported when submitting UTF-16 data via io.AddInputCharacterUTF16(),
+ allowing for more complete CJK input.
+ - sizeof(ImWchar) goes from 2 to 4. IM_UNICODE_CODEPOINT_MAX goes from 0xFFFF to 0x10FFFF.
+ - Various structures such as ImFont, ImFontGlyphRangesBuilder will use more memory, this
+ is currently not particularly efficient.
+- Columns: undid the change in 1.75 were Columns()/BeginColumns() were preemptively limited
+ to 64 columns with an assert. (#3037, #125)
+- Window: Fixed a bug with child window inheriting ItemFlags from their parent when the child
+ window also manipulate the ItemFlags stack. (#3024) [@Stanbroek]
+- Font: Fixed non-ASCII space occasionally creating unnecessary empty looking polygons.
+- Misc: Added an explicit compile-time test for non-scoped IM_ASSERT() macros to redirect users
+ to a solution rather than encourage people to add braces in the codebase.
+- Misc: Added additional checks in EndFrame() to verify that io.KeyXXX values have not been
+ tampered with between NewFrame() and EndFrame().
+- Misc: Made default clipboard handlers for Win32 and OSX use a buffer inside the main context
+ instead of a static buffer, so it can be freed properly on Shutdown. (#3110)
+- Misc, Freetype: Fixed support for IMGUI_STB_RECT_PACK_FILENAME compile time directive
+ in imgui_freetype.cpp (matching support in the regular code path). (#3062) [@DonKult]
+- Metrics: Made Tools section more prominent. Showing wire-frame mesh directly hovering the ImDrawCmd
+ instead of requiring to open it. Added options to disable bounding box and mesh display.
+ Added notes on inactive/gc-ed windows.
+- Demo: Added black and white and color gradients to Demo>Examples>Custom Rendering.
+- CI: Added more tests on the continuous-integration server: extra warnings for Clang/GCC, building
+ SDL+Metal example, building imgui_freetype.cpp, more compile-time imconfig.h settings: disabling
+ obsolete functions, enabling 32-bit ImDrawIdx, enabling 32-bit ImWchar, disabling demo. [@rokups]
+- Backends: OpenGL3: Fixed version check mistakenly testing for GL 4.0+ instead of 3.2+ to enable
+ ImGuiBackendFlags_RendererHasVtxOffset, leaving 3.2 contexts without it. (#3119, #2866) [@wolfpld]
+- Backends: OpenGL3: Added include support for older glbinding 2.x loader. (#3061) [@DonKult]
+- Backends: Win32: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(),
+ ImGui_ImplWin32_GetDpiScaleForMonitor() helpers functions (backported from the docking branch).
+ Those functions makes it easier for example apps to support hi-dpi features without setting up
+ a manifest.
+- Backends: Win32: Calling AddInputCharacterUTF16() from WM_CHAR message handler in order to support
+ high-plane surrogate pairs. (#2815) [@cloudwu, @samhocevar]
+- Backends: SDL: Added ImGui_ImplSDL2_InitForMetal() for API consistency (even though the function
+ currently does nothing).
+- Backends: SDL: Fixed mapping for ImGuiKey_KeyPadEnter. (#3031) [@Davido71]
+- Examples: Win32+DX12: Fixed resizing main window, enabled debug layer. (#3087, #3115) [@sergeyn]
+- Examples: SDL+DX11: Fixed resizing main window. (#3057) [@joeslay]
+- Examples: Added SDL+Metal example application. (#3017) [@coding-jackalope]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.75 (Released 2020-02-10)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.75
+
+Breaking Changes:
+
+- Removed redirecting functions/enums names that were marked obsolete in 1.53 (December 2017):
+ - ShowTestWindow() -> use ShowDemoWindow()
+ - IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow)
+ - IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows)
+ - SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f)
+ - GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing()
+ - ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg
+ - ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding
+ - ImGuiTreeNodeFlags_AllowOverlapMode -> use ImGuiTreeNodeFlags_AllowItemOverlap
+ - IMGUI_DISABLE_TEST_WINDOWS -> use IMGUI_DISABLE_DEMO_WINDOWS
+ If you were still using the old names, while you are cleaning up, considering enabling
+ IMGUI_DISABLE_OBSOLETE_FUNCTIONS in imconfig.h even temporarily to have a pass at finding
+ and removing up old API calls, if any remaining.
+- Removed implicit default parameter to IsMouseDragging(int button = 0) to be consistent
+ with other mouse functions (none of the other functions have it).
+- Obsoleted calling ImDrawList::PrimReserve() with a negative count (which was vaguely
+ documented and rarely if ever used). Instead we added an explicit PrimUnreserve() API
+ which can be implemented faster. Also clarified pre-existing constraints which weren't
+ documented (can only unreserve from the last reserve call). If you suspect you ever
+ used that feature before (very unlikely, but grep for call to PrimReserve in your code),
+ you can #define IMGUI_DEBUG_PARANOID in imconfig.h to catch existing calls. [@ShironekoBen]
+- ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius.
+- Limiting Columns()/BeginColumns() api to 64 columns with an assert. While the current code
+ technically supports it, future code may not so we're putting the restriction ahead.
+ [Undid that change in 1.76]
+- imgui_internal.h: changed ImRect() default constructor initializes all fields to 0.0f instead
+ of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by
+ adding points into it without explicit initialization, you may need to fix your initial value.
+
+Other Changes:
+
+- Inputs: Added ImGuiMouseButton enum for convenience (e.g. ImGuiMouseButton_Right=1).
+ We forever guarantee that the existing value will not changes so existing code is free to use 0/1/2.
+- Nav: Fixed a bug where the initial CTRL-Tab press while in a child window sometimes selected
+ the current root window instead of always selecting the previous root window. (#787)
+- ColorEdit: Fix label alignment when using ImGuiColorEditFlags_NoInputs. (#2955) [@rokups]
+- ColorEdit: In HSV display of a RGB stored value, attempt to locally preserve Saturation
+ when Value==0.0 (similar to changes done in 1.73 for Hue). Removed Hue editing lock since
+ those improvements in 1.73 makes them unnecessary. (#2722, #2770). [@rokups]
+- ColorEdit: "Copy As" context-menu tool shows hex values with a '#' prefix instead of '0x'.
+- ColorEdit: "Copy As" content-menu tool shows hex values both with/without alpha when available.
+- InputText: Fix corruption or crash when executing undo after clearing input with ESC, as a
+ byproduct we are allowing to later undo the revert with a CTRL+Z. (#3008).
+- InputText: Fix using a combination of _CallbackResize (e.g. for std::string binding), along with the
+ _EnterReturnsTrue flag along with the rarely used property of using an InputText without persisting
+ user-side storage. Previously if you had e.g. a local unsaved std::string and reading result back
+ from the widget, the user string object wouldn't be resized when Enter key was pressed. (#3009)
+- MenuBar: Fix minor clipping issue where occasionally a menu text can overlap the right-most border.
+- Window: Fix SetNextWindowBgAlpha(1.0f) failing to override alpha component. (#3007) [@Albog]
+- Window: When testing for the presence of the ImGuiWindowFlags_NoBringToFrontOnFocus flag we
+ test both the focused/clicked window (which could be a child window) and the root window.
+- ImDrawList: AddCircle(), AddCircleFilled() API can now auto-tessellate when provided a segment
+ count of zero. Alter tessellation quality with 'style.CircleSegmentMaxError'. [@ShironekoBen]
+- ImDrawList: Add AddNgon(), AddNgonFilled() API with a guarantee on the explicit segment count.
+ In the current branch they are essentially the same as AddCircle(), AddCircleFilled() but as
+ we will rework the circle rendering functions to use textures and automatic segment count
+ selection, those new api can fill a gap. [@ShironekoBen]
+- Columns: ImDrawList::Channels* functions now work inside columns. Added extra comments to
+ suggest using user-owned ImDrawListSplitter instead of ImDrawList functions. [@rokups]
+- Misc: Added ImGuiMouseCursor_NotAllowed enum so it can be used by more shared widgets. [@rokups]
+- Misc: Added IMGUI_DISABLE compile-time definition to make all headers and sources empty.
+- Misc: Disable format checks when using stb_printf, to allow using extra formats.
+ Made IMGUI_USE_STB_SPRINTF a properly documented imconfig.h flag. (#2954) [@loicmolinari]
+- Misc: Added misc/single_file/imgui_single_file.h, We use this to validate compiling all *.cpp
+ files in a same compilation unit. Actual users of that technique (also called "Unity builds")
+ can generally provide this themselves, so we don't really recommend you use this. [@rokups]
+- CI: Added PVS-Studio static analysis on the continuous-integration server. [@rokups]
+- Backends: GLFW, SDL, Win32, OSX, Allegro: Added support for ImGuiMouseCursor_NotAllowed. [@rokups]
+- Backends: GLFW: Added support for the missing mouse cursors newly added in GLFW 3.4+. [@rokups]
+- Backends: SDL: Wayland: use SDL_GetMouseState (because there is no global mouse state available
+ on Wayland). (#2800, #2802) [@NeroBurner]
+- Backends: GLFW, SDL: report Windows key (io.KeySuper) as always released. Neither GLFW nor SDL can
+ correctly report the key release in every cases (e.g. when using Win+V) causing problems with some
+ widgets. The next release of GLFW (3.4+) will have a fix for it. However since it is both difficult
+ and discouraged to make use of this key for Windows application anyway, we just hide it. (#2976)
+- Backends: Win32: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD to disable all
+ XInput using code, and IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT to disable linking with XInput,
+ the later may be problematic if compiling with recent Windows SDK and you want your app to run
+ on Windows 7. You can instead try linking with Xinput9_1_0.lib instead. (#2716)
+- Backends: Glut: Improved FreeGLUT support for MinGW. (#3004) [@podsvirov]
+- Backends: Emscripten: Avoid forcefully setting IMGUI_DISABLE_FILE_FUNCTIONS. (#3005) [@podsvirov]
+- Examples: OpenGL: Explicitly adding -DIMGUI_IMPL_OPENGL_LOADER_GL3W to Makefile to match linking
+ settings (otherwise if another loader such as Glew is accessible, the OpenGL3 backend might
+ automatically use it). (#2919, #2798)
+- Examples: OpenGL: Added support for glbinding OpenGL loader. (#2870) [@rokups]
+- Examples: Emscripten: Demonstrating embedding fonts in Makefile and code. (#2953) [@Oipo]
+- Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed
+ even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.74 (Released 2019-11-25)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.74
+
+Breaking Changes:
+
+- Removed redirecting functions/enums names that were marked obsolete in 1.52 (October 2017):
+ - Begin() [old 5 args version] -> use Begin() [3 args], use SetNextWindowSize() SetNextWindowBgAlpha() if needed
+ - IsRootWindowOrAnyChildHovered() -> use IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows)
+ - AlignFirstTextHeightToWidgets() -> use AlignTextToFramePadding()
+ - SetNextWindowPosCenter() -> use SetNextWindowPos() with a pivot of (0.5f, 0.5f)
+ - ImFont::Glyph -> use ImFontGlyph
+ If you were still using the old names, read "API Breaking Changes" section of imgui.cpp to find out
+ the new names or equivalent features, or see how they were implemented until 1.73.
+- Inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used
+ by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function.
+ If you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can
+ add +io.KeyRepeatDelay to it to compensate for the fix.
+ The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0).
+ Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay).
+ Fixed the code and altered default io.KeyRepeatRate,Delay from 0.250,0.050 to 0.300,0.050 to compensate.
+ If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you.
+- Misc: Renamed IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS to IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS. (#1038)
+- Misc: Renamed IMGUI_DISABLE_MATH_FUNCTIONS to IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS.
+- Fonts: ImFontAtlas::AddCustomRectRegular() now requires an ID larger than 0x110000 (instead of 0x10000) to
+ conform with supporting Unicode planes 1-16 in a future update. ID below 0x110000 will now assert.
+- Backends: DX12: Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function.
+ The value is unused in master branch but will be used by the multi-viewport feature. (#2851) [@obfuscate]
+
+Other Changes:
+
+- InputText, Nav: Fixed Home/End key broken when activating Keyboard Navigation. (#787)
+- InputText: Filter out ASCII 127 (DEL) emitted by low-level OSX layer, as we are using the Key value. (#2578)
+- Layout: Fixed a couple of subtle bounding box vertical positioning issues relating to the handling of text
+ baseline alignment. The issue would generally manifest when laying out multiple items on a same line,
+ with varying heights and text baseline offsets.
+ Some specific examples, e.g. a button with regular frame padding followed by another item with a
+ multi-line label and no frame padding, such as: multi-line text, small button, tree node item, etc.
+ The second item was correctly offset to match text baseline, and would interact/display correctly,
+ but it wouldn't push the contents area boundary low enough.
+- Scrollbar: Fixed an issue where scrollbars wouldn't display on the frame following a frame where
+ all child window contents would be culled.
+- ColorPicker: Fixed SV triangle gradient to block (broken in 1.73). (#2864, #2711). [@lewa-j]
+- TreeNode: Fixed combination of ImGuiTreeNodeFlags_SpanFullWidth and ImGuiTreeNodeFlags_OpenOnArrow
+ incorrectly locating the arrow hit position to the left of the frame. (#2451, #2438, #1897)
+- TreeNode: The collapsing arrow accepts click even if modifier keys are being held, facilitating
+ interactions with custom multi-selections patterns. (#2886, #1896, #1861)
+- TreeNode: Added IsItemToggledOpen() to explicitly query if item was just open/closed, facilitating
+ interactions with custom multi-selections patterns. (#1896, #1861)
+- DragScalar, SliderScalar, InputScalar: Added p_ prefix to parameter that are pointers to the data
+ to clarify how they are used, and more comments redirecting to the demo code. (#2844)
+- Error handling: Assert if user mistakenly calls End() instead of EndChild() on a child window. (#1651)
+- Misc: Optimized storage of window settings data (reducing allocation count).
+- Misc: Windows: Do not use _wfopen() if IMGUI_DISABLE_WIN32_FUNCTIONS is defined. (#2815)
+- Misc: Windows: Disabled win32 function by default when building with UWP. (#2892, #2895)
+- Misc: Using static_assert() when using C++11, instead of our own construct (avoid zealous Clang warnings).
+- Misc: Added IMGUI_DISABLE_FILE_FUNCTIONS/IMGUI_DISABLE_DEFAULT_FILE_FUNCTION to nullify or disable
+ default implementation of ImFileXXX functions linking with fopen/fclose/fread/fwrite. (#2734)
+- Docs: Improved and moved FAQ to docs/FAQ.md so it can be readable on the web. [@ButternCream, @ocornut]
+- Docs: Moved misc/fonts/README.txt to docs/FONTS.txt.
+- Docs: Added permanent redirect from https://www.dearimgui.org/faq to FAQ page.
+- Demo: Added simple item reordering demo in Widgets -> Drag and Drop section. (#2823, #143) [@rokups]
+- Metrics: Show wire-frame mesh and approximate surface area when hovering ImDrawCmd. [@ShironekoBen]
+- Metrics: Expose basic details of each window key/value state storage.
+- Examples: DX12: Using IDXGIDebug1::ReportLiveObjects() when DX12_ENABLE_DEBUG_LAYER is enabled.
+- Examples: Emscripten: Removed BINARYEN_TRAP_MODE=clamp from Makefile which was removed in Emscripten 1.39.0
+ but required prior to 1.39.0, making life easier for absolutely no-one. (#2877, #2878) [@podsvirov]
+- Backends: OpenGL2: Explicitly backup, setup and restore GL_TEXTURE_ENV to increase compatibility with
+ legacy OpenGL applications. (#3000)
+- Backends: OpenGL3: Fix building with pre-3.2 GL loaders which do not expose glDrawElementsBaseVertex(),
+ using runtime GL version to decide if we set ImGuiBackendFlags_RendererHasVtxOffset. (#2866, #2852) [@dpilawa]
+- Backends: OSX: Fix using Backspace key. (#2578, #2817, #2818) [@DiligentGraphics]
+- Backends: GLFW: Previously installed user callbacks are now restored on shutdown. (#2836) [@malte-v]
+- CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example
+ applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.73 (Released 2019-09-24)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.73
+
+Other Changes:
+
+- Nav, Scrolling: Added support for Home/End key. (#787)
+- ColorEdit: Disable Hue edit when Saturation==0 instead of letting Hue values jump around.
+- ColorEdit, ColorPicker: In HSV display of a RGB stored value, attempt to locally preserve Hue
+ when Saturation==0, which reduces accidentally lossy interactions. (#2722, #2770) [@rokups]
+- ColorPicker: Made rendering aware of global style alpha of the picker can be faded out. (#2711)
+ Note that some elements won't accurately fade down with the same intensity, and the color wheel
+ when enabled will have small overlap glitches with (style.Alpha < 1.0).
+- TabBar: Fixed single-tab not shrinking their width down.
+- TabBar: Fixed clicking on a tab larger than tab-bar width creating a bouncing feedback loop.
+- TabBar: Feed desired width (sum of unclipped tabs width) into layout system to allow for auto-resize. (#2768)
+ (before 1.71 tab bars fed the sum of current width which created feedback loops in certain situations).
+- TabBar: Improved shrinking for large number of tabs to avoid leaving extraneous space on the right side.
+ Individuals tabs are given integer-rounded width and remainder is spread between tabs left-to-right.
+- Columns, Separator: Fixed a bug where non-visible separators within columns would alter the next row position
+ differently than visible ones.
+- SliderScalar: Improved assert when using U32 or U64 types with a large v_max value. (#2765) [@loicmouton]
+- DragInt, DragFloat, DragScalar: Using (v_min > v_max) allows locking any edits to the value.
+- DragScalar: Fixed dragging of unsigned values on ARM cpu (float to uint cast is undefined). (#2780) [@dBagrat]
+- TreeNode: Added ImGuiTreeNodeFlags_SpanAvailWidth flag. (#2451, #2438, #1897) [@Melix19, @PathogenDavid]
+ This extends the hit-box to the right-most edge, even if the node is not framed.
+ (Note: this is not the default in order to allow adding other items on the same line. In the future we will
+ aim toward refactoring the hit-system to be front-to-back, allowing more natural overlapping of items,
+ and then we will be able to make this the default.)
+- TreeNode: Added ImGuiTreeNodeFlags_SpanFullWidth flag. This extends the hit-box to both the left-most and
+ right-most edge of the working area, bypassing indentation.
+- CollapsingHeader: Added support for ImGuiTreeNodeFlags_Bullet and ImGuiTreeNodeFlags_Leaf on framed nodes,
+ mostly for consistency. (#2159, #2160) [@goran-w]
+- Selectable: Added ImGuiSelectableFlags_AllowItemOverlap flag in public api (was previously internal only).
+- Style: Allow style.WindowMenuButtonPosition to be set to ImGuiDir_None to hide the collapse button. (#2634, #2639)
+- Font: Better ellipsis ("...") drawing implementation. Instead of drawing three pixel-ey dots (which was glaringly
+ unfitting with many types of fonts) we first attempt to find a standard ellipsis glyphs within the loaded set.
+ Otherwise we render ellipsis using '.' from the font from where we trim excessive spacing to make it as narrow
+ as possible. (#2775) [@rokups]
+- ImDrawList: Clarified the name of many parameters so reading the code is a little easier. (#2740)
+- ImDrawListSplitter: Fixed merging channels if the last submitted draw command used a different texture. (#2506)
+- Using offsetof() when available in C++11. Avoids Clang sanitizer complaining about old-style macros. (#94)
+- ImVector: Added find(), find_erase(), find_erase_unsorted() helpers.
+- Added a mechanism to compact/free the larger allocations of unused windows (buffers are compacted when
+ a window is unused for 60 seconds, as per io.ConfigWindowsMemoryCompactTimer = 60.0f). Note that memory
+ usage has never been reported as a problem, so this is merely a touch of overzealous luxury. (#2636)
+- Documentation: Various tweaks and improvements to the README page. [@ker0chan]
+- Backends: OpenGL3: Tweaked initialization code allow application calling ImGui_ImplOpenGL3_CreateFontsTexture()
+ before ImGui_ImplOpenGL3_NewFrame(), which sometimes can be convenient.
+- Backends: OpenGL3: Attempt to automatically detect default GL loader by using __has_include. (#2798) [@o-micron]
+- Backends: DX11: Fixed GSGetShader() call not passing an initialized instance count, which would
+ generally make the DX11 debug layer complain (bug added in 1.72).
+- Backends: Vulkan: Added support for specifying multisample count. Set 'ImGui_ImplVulkan_InitInfo::MSAASamples' to
+ one of the VkSampleCountFlagBits values to use, default is non-multisampled as before. (#2705, #2706) [@vilya]
+- Examples: OSX: Fix example_apple_opengl2/main.mm not forwarding mouse clicks and drags correctly. (#1961, #2710)
+ [@intonarumori, @ElectricMagic]
+- Misc: Updated stb_rect_pack.h from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic,
+ fix handling of rectangles too large to fit inside texture). (#2762) [@tido64]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.72b (Released 2019-07-31)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.72b
+
+Other Changes:
+
+- Nav, Scrolling: Fixed programmatic scroll leading to a slightly incorrect scroll offset when
+ the window has decorations or a menu-bar (broken in 1.71). This was mostly noticeable when
+ a keyboard/gamepad movement led to scrolling the view, or using e.g. SetScrollHereY() function.
+- Nav: Made hovering non-MenuItem Selectable not re-assign the source item for keyboard navigation.
+- Nav: Fixed an issue with NavFlattened window flag (beta) where widgets not entirely fitting
+ in child window (often selectables because of their protruding sides) would be not considered
+ as entry points to to navigate toward the child window. (#787)
+
+
+-----------------------------------------------------------------------
+ VERSION 1.72 (Released 2019-07-27)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.72
+
+Breaking Changes:
+
+- Removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017):
+ - ImGuiCol_Column*, ImGuiSetCond_* enums.
+ - IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow() functions.
+ - IMGUI_ONCE_UPON_A_FRAME macro.
+ If you were still using the old names, read "API Breaking Changes" section of imgui.cpp to find out
+ the new names or equivalent features.
+- Renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete).
+- Removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()).
+ Kept redirection function (will obsolete). (#581, #324)
+
+Other Changes:
+
+- Scrolling: Made mouse-wheel scrolling lock the underlying window until the mouse is moved again or
+ until a short delay expires (~2 seconds). This allow uninterrupted scroll even if child windows are
+ passing under the mouse cursor. (#2604)
+- Scrolling: Made it possible for mouse wheel and navigation-triggered scrolling to override a call to
+ SetScrollX()/SetScrollY(), making it possible to use a simpler stateless pattern for auto-scrolling:
+ // (Submit items..)
+ if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) // If scrolling at the already at the bottom..
+ ImGui::SetScrollHereY(1.0f); // ..make last item fully visible
+- Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco]
+- Scrolling: Mouse wheel scrolling while hovering a child window is automatically forwarded to parent window
+ if ScrollMax is zero on the scrolling axis.
+ Also still the case if ImGuiWindowFlags_NoScrollWithMouse is set (not new), but previously the forwarding
+ would be disabled if ImGuiWindowFlags_NoScrollbar was set on the child window, which is not the case
+ any more. Forwarding can still be disabled by setting ImGuiWindowFlags_NoInputs. (amend #1502, #1380).
+- Window: Fixed InnerClipRect right-most coordinates using wrong padding setting (introduced in 1.71).
+- Window: Fixed old SetWindowFontScale() api value from not being inherited by child window. Added
+ comments about the right way to scale your UI (load a font at the right side, rebuild atlas, scale style).
+- Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small.
+- Combo: Hide arrow when there's not enough space even for the square button.
+- InputText: Testing for newly added ImGuiKey_KeyPadEnter key. (#2677, #2005) [@amc522]
+- TabBar: Fixed unfocused tab bar separator color (was using ImGuiCol_Tab, should use ImGuiCol_TabUnfocusedActive).
+- Columns: Fixed a regression from 1.71 where the right-side of the contents rectangle within each column
+ would wrongly use a WindowPadding.x instead of ItemSpacing.x like it always did. (#125, #2666)
+- Columns: Made the right-most edge reaches up to the clipping rectangle (removing half of WindowPadding.x
+ worth of asymmetrical/extraneous padding, note that there's another half that conservatively has to offset
+ the right-most column, otherwise it's clipping width won't match the other columns). (#125, #2666)
+- Columns: Improved honoring alignment with various values of ItemSpacing.x and WindowPadding.x. (#125, #2666)
+- Columns: Made GetColumnOffset() and GetColumnWidth() behave when there's no column set, consistently with
+ other column functions. (#2683)
+- InputTextMultiline: Fixed vertical scrolling tracking glitch.
+- Word-wrapping: Fixed overzealous word-wrapping when glyph edge lands exactly on the limit. Because
+ of this, auto-fitting exactly unwrapped text would make it wrap. (fixes initial 1.15 commit, 78645a7d).
+- Style: Attenuated default opacity of ImGuiCol_Separator in Classic and Light styles.
+- Style: Added style.ColorButtonPosition (left/right, defaults to ImGuiDir_Right) to move the color button
+ of ColorEdit3/ColorEdit4 functions to either side of the inputs.
+- IO: Added ImGuiKey_KeyPadEnter and support in various back-ends (previously back-ends would need to
+ specifically redirect key-pad keys to their regular counterpart). This is a temporary attenuating measure
+ until we actually refactor and add whole sets of keys into the ImGuiKey enum. (#2677, #2005) [@amc522]
+- Misc: Made Button(), ColorButton() not trigger an "edited" event leading to IsItemDeactivatedAfterEdit()
+ returning true. This also effectively make ColorEdit4() not incorrect trigger IsItemDeactivatedAfterEdit()
+ when clicking the color button to open the picker popup. (#1875)
+- Misc: Added IMGUI_DISABLE_METRICS_WINDOW imconfig.h setting to explicitly compile out ShowMetricsWindow().
+- Debug, Metrics: Added "Tools->Item Picker" tool which allow clicking on a widget to break in the debugger
+ within the item code. The tool calls IM_DEBUG_BREAK() which can be redefined in imconfig.h if needed.
+- ImDrawList: Fixed CloneOutput() helper crashing. (#1860) [@gviot]
+- ImDrawList::ChannelsSplit(), ImDrawListSplitter: Fixed an issue with merging draw commands between
+ channel 0 and 1. (#2624)
+- ImDrawListSplitter: Fixed memory leak when using low-level split api (was not affecting ImDrawList api,
+ also this type was added in 1.71 and not advertised as a public-facing feature).
+- Fonts: binary_to_compressed_c.cpp: Display an error message if failing to open/read the input font file.
+- Demo: Log, Console: Using a simpler stateless pattern for auto-scrolling.
+- Demo: Widgets: Showing how to use the format parameter of Slider/Drag functions to display the name
+ of an enum value instead of the underlying integer value.
+- Demo: Renamed the "Help" menu to "Tools" (more accurate).
+- Backends: DX10/DX11: Backup, clear and restore Geometry Shader is any is bound when calling renderer.
+- Backends: DX11: Clear Hull Shader, Domain Shader, Compute Shader before rendering. Not backing/restoring them.
+- Backends: OSX: Disabled default native Mac clipboard copy/paste implementation in core library (added in 1.71),
+ because it needs application to be linked with '-framework ApplicationServices'. It can be explicitly
+ enabled back by using '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h. Re-added
+ equivalent using NSPasteboard api in the imgui_impl_osx.mm experimental back-end. (#2546)
+- Backends: SDL2: Added dummy ImGui_ImplSDL2_InitForD3D() function to make D3D support more visible.
+ (#2482, #2632) [@josiahmanson]
+- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.71 (Released 2019-06-12)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.71
+
+Breaking Changes:
+
+- IO: changed AddInputCharacter(unsigned short c) signature to AddInputCharacter(unsigned int c).
+- Renamed SetNextTreeNodeOpen() to SetNextItemOpen(). Kept inline redirection function (will obsolete).
+- Window: rendering of child windows outer decorations (e.g. bg color, border, scrollbars) is now
+ performed as part of their parent window, avoiding the creation of an extraneous draw commands.
+ If you have overlapping child windows with decorations, and relied on their relative z-order to be
+ mapped to submission their order, this will affect your rendering. The optimization is disabled
+ if the parent window has no visual output because it appears to be the most common situation leading
+ to the creation of overlapping child windows. Please reach out if you are affected by this change!
+
+Other Changes:
+
+- Window: clarified behavior of SetNextWindowContentSize(). Content size is defined as the size available
+ after removal of WindowPadding on each sides. So SetNextWindowContentSize(ImVec2(100,100)) + auto-resize
+ will always allow submitting a 100x100 item without creating a scrollbar, regarding of WindowPadding.
+ The exact meaning of ContentSize for decorated windows was previously ill-defined.
+- Window: Fixed auto-resize with AlwaysVerticalScrollbar or AlwaysHorizontalScrollbar flags.
+- Window: Fixed one case where auto-resize by double-clicking the resize grip would make either scrollbar
+ appear for a single frame after the resize.
+- Separator: Revert 1.70 "Declare its thickness (1.0f) to the layout" change. It's not incorrect
+ but it breaks existing some layout patterns. Will return back to it when we expose Separator flags.
+- Fixed InputScalar, InputScalarN, SliderScalarN, DragScalarN with non-visible label from inserting
+ style.ItemInnerSpacing.x worth of trailing spacing.
+- Fixed InputFloatX, SliderFloatX, DragFloatX functions erroneously reporting IsItemEdited() multiple
+ times when the text input doesn't match the formatted output value (e.g. input "1" shows "1.000").
+ It wasn't much of a problem because we typically use the return value instead of IsItemEdited() here.
+- Fixed uses of IsItemDeactivated(), IsItemDeactivatedAfterEdit() on multi-components widgets and
+ after EndGroup(). (#2550, #1875)
+- Fixed crash when appending with BeginMainMenuBar() more than once and no other window are showing. (#2567)
+- ColorEdit: Fixed the color picker popup only displaying inputs as HSV instead of showing multiple
+ options. (#2587, broken in 1.69 by #2384).
+- CollapsingHeader: Better clipping when a close button is enabled and it overlaps the label. (#600)
+- Scrollbar: Minor bounding box adjustment to cope with various border size.
+- Scrollbar, Style: Changed default style.ScrollbarSize from 16 to 14.
+- Combo: Fixed rounding not applying with the ImGuiComboFlags_NoArrowButton flag. (#2607) [@DucaRii]
+- Nav: Fixed gamepad/keyboard moving of window affecting contents size incorrectly, sometimes leading
+ to scrollbars appearing during the movement.
+- Nav: Fixed rare crash when e.g. releasing Alt-key while focusing a window with a menu at the same
+ frame as clearing the focus. This was in most noticeable in back-ends such as Glfw and SDL which
+ emits key release events when focusing another viewport, leading to Alt+clicking on void on another
+ viewport triggering the issue. (#2609)
+- TreeNode, CollapsingHeader: Fixed highlight frame not covering horizontal area fully when using
+ horizontal scrolling. (#2211, #2579)
+- TabBar: Fixed BeginTabBar() within a window with horizontal scrolling from creating a feedback
+ loop with the horizontal contents size.
+- Columns: Fixed Columns() within a window with horizontal scrolling from not covering the full
+ horizontal area (previously only worked with an explicit contents size). (#125)
+- Columns: Fixed Separator from creating an extraneous draw command. (#125)
+- Columns: Fixed Selectable with SpanAllColumns flag from creating an extraneous draw command. (#125)
+- Style: Added style.WindowMenuButtonPosition (left/right, defaults to ImGuiDir_Left) to move the
+ collapsing/docking button to the other side of the title bar.
+- Style: Made window close button cross slightly smaller.
+- Log/Capture: Fixed BeginTabItem() label not being included in a text log/capture.
+- ImDrawList: Added ImDrawCmd::VtxOffset value to support large meshes (64k+ vertices) using 16-bit indices.
+ The renderer back-end needs to set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' to enable
+ this, and honor the ImDrawCmd::VtxOffset field. Otherwise the value will always be zero. (#2591)
+ This has the advantage of preserving smaller index buffers and allowing to execute on hardware that do not
+ support 32-bit indices. Most examples back-ends have been modified to support the VtxOffset field.
+- ImDrawList: Added ImDrawCmd::IdxOffset value, equivalent to summing element count for each draw command.
+ This is provided for convenience and consistency with VtxOffset. (#2591)
+- ImDrawCallback: Allow to override the signature of ImDrawCallback by #define-ing it. This is meant to
+ facilitate custom rendering back-ends passing local render-specific data to the draw callback.
+- ImFontAtlas: FreeType: Added RasterizerFlags::Monochrome flag to disable font anti-aliasing. Combine
+ with RasterizerFlags::MonoHinting for best results. (#2545) [@HolyBlackCat]
+- ImFontGlyphRangesBuilder: Fixed unnecessarily over-sized buffer, which incidentally was also not
+ fully cleared. Fixed edge-case overflow when adding character 0xFFFF. (#2568). [@NIKE3500]
+- Demo: Added full "Dear ImGui" prefix to the title of "Dear ImGui Demo" and "Dear ImGui Metrics" windows.
+- Backends: Add native Mac clipboard copy/paste default implementation in core library to match what we are
+ dealing with Win32, and to facilitate integration in custom engines. (#2546) [@andrewwillmott]
+- Backends: OSX: imgui_impl_osx: Added mouse cursor support. (#2585, #1873) [@actboy168]
+- Examples/Backends: DirectX9/10/11/12, Metal, Vulkan, OpenGL3 (Desktop GL only): Added support for large meshes
+ (64k+ vertices) with 16-bit indices, enable 'ImGuiBackendFlags_RendererHasVtxOffset' in those back-ends. (#2591)
+- Examples/Backends: Don't filter characters under 0x10000 before calling io.AddInputCharacter(),
+ the filtering is done in io.AddInputCharacter() itself. This is in prevision for fuller Unicode
+ support. (#2538, #2541)
+
+
+-----------------------------------------------------------------------
+ VERSION 1.70 (Released 2019-05-06)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.70
+
+Breaking Changes:
+
+- ImDrawList: Improved algorithm for mitre joints on thick lines, preserving correct thickness
+ up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines,
+ they will appear a little thicker now. (#2518) [@rmitton]
+- Obsoleted GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead.
+ Kept inline redirection function.
+- Examples: Vulkan: Added MinImageCount/ImageCount fields in ImGui_ImplVulkan_InitInfo, required
+ during initialization to specify the number of in-flight image requested by swap chains.
+ (was previously a hard #define IMGUI_VK_QUEUED_FRAMES 2). (#2071, #1677) [@nathanvoglsam]
+- Examples: Vulkan: Tidying up the demo/internals helpers (most engine/app should not rely
+ on them but it is possible you have!).
+
+Other Changes:
+
+- ImDrawList: Added ImDrawCallback_ResetRenderState, a special ImDrawList::AddCallback() value
+ to request the renderer back-end to reset its render state. (#2037, #1639, #2452)
+ Examples: Added support for ImDrawCallback_ResetRenderState in all renderer back-ends. Each
+ renderer code setting up initial render state has been moved to a function so it could be
+ called at the start of rendering and when a ResetRenderState is requested. [@ocornut, @bear24rw]
+- InputText: Fixed selection background rendering one frame after the cursor movement when
+ first transitioning from no-selection to has-selection. (Bug in 1.69) (#2436) [@Nazg-Gul]
+- InputText: Work-around for buggy standard libraries where isprint('\t') returns true. (#2467, #1336)
+- InputText: Fixed ImGuiInputTextFlags_AllowTabInput leading to two tabs characters being inserted
+ if the back-end provided both Key and Character input. (#2467, #1336)
+- Layout: Added SetNextItemWidth() helper to avoid using PushItemWidth/PopItemWidth() for single items.
+ Note that SetNextItemWidth() currently only affect the same subset of items as PushItemWidth(),
+ generally referred to as the large framed+labeled items. Because the new SetNextItemWidth()
+ function is explicit we may later extend its effect to more items.
+- Layout: Fixed PushItemWidth(-width) for right-side alignment laying out some items (button, listbox, etc.)
+ with negative sizes if the 'width' argument was smaller than the available width at the time of item
+ submission.
+- Window: Fixed window with the AlwaysAutoResize flag unnecessarily extending their hovering boundaries
+ by a few pixels (this is used to facilitate resizing from borders when available for a given window).
+ One of the noticeable minor side effect was that navigating menus would have had a tendency to disable
+ highlight from parent menu items earlier than necessary while approaching the child menu.
+- Window: Close button is horizontally aligned with style.FramePadding.x.
+- Window: Fixed contents region being off by WindowBorderSize amount on the right when scrollbar is active.
+- Window: Fixed SetNextWindowSizeConstraints() with non-rounded positions making windows drift. (#2067, #2530)
+- Popups: Closing a popup restores the focused/nav window in place at the time of the popup opening,
+ instead of restoring the window that was in the window stack at the time of the OpenPopup call. (#2517)
+ Among other things, this allows opening a popup while no window are focused, and pressing Escape to
+ clear the focus again.
+- Popups: Fixed right-click from closing all popups instead of aiming at the hovered popup level
+ (regression in 1.67).
+- Selectable: With ImGuiSelectableFlags_AllowDoubleClick doesn't return true on the mouse button release
+ following the double-click. Only first mouse release + second mouse down (double-click) returns true.
+ Likewise for internal ButtonBehavior() with both _PressedOnClickRelease | _PressedOnDoubleClick. (#2503)
+- GetMouseDragDelta(): also returns the delta on the mouse button released frame. (#2419)
+- GetMouseDragDelta(): verify that mouse positions are valid otherwise returns zero.
+- Inputs: Also add support for horizontal scroll with Shift+Mouse Wheel. (#2424, #1463) [@LucaRood]
+- PlotLines, PlotHistogram: Ignore NaN values when calculating min/max bounds. (#2485)
+- Columns: Fixed boundary of clipping being off by 1 pixel within the left column. (#125)
+- Separator: Declare its thickness (1.0f) to the layout, making items around separator more symmetrical.
+- Combo, Slider, Scrollbar: Improve rendering in situation when there's only a few pixels available (<3 pixels).
+- Nav: Fixed Drag/Slider functions going into text input mode when keyboard CTRL is held while pressing NavActivate.
+- Drag and Drop: Fixed drag source with ImGuiDragDropFlags_SourceAllowNullID and null ID from receiving click
+ regardless of being covered by another window (it didn't honor correct hovering rules). (#2521)
+- ImDrawList: Improved algorithm for mitre joints on thick lines, preserving correct thickness up to 90 degrees
+ angles, also faster to output. (#2518) [@rmitton]
+- Misc: Added IM_MALLOC/IM_FREE macros mimicking IM_NEW/IM_DELETE so user doesn't need to revert
+ to using the ImGui::MemAlloc()/MemFree() calls directly.
+- Misc: Made IMGUI_CHECKVERSION() macro also check for matching size of ImDrawIdx.
+- Metrics: Added "Show windows rectangles" tool to visualize the different rectangles.
+- Demo: Improved trees in columns demo.
+- Examples: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized
+ GL function loaders early, and help users understand what they are missing. (#2421)
+- Examples: SDL: Added support for SDL_GameController gamepads (enable with ImGuiConfigFlags_NavEnableGamepad). (#2509) [@DJLink]
+- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble, @redblobgames]
+- Examples: Metal: Added Glfw+Metal example. (#2527) [@bear24rw]
+- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop.
+- Examples: Vulkan: Fixed in-flight buffers issues when using multi-viewports. (#2461, #2348, #2378, #2097)
+- 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: Vulkan: Added ImGui_ImplVulkan_SetMinImageCount() to change min image count at runtime. (#2071) [@nathanvoglsam]
+- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454)
+- Examples: DirectX10/11/12, Allegro, Marmalade: Render functions early out when display size is zero (minimized). (#2496)
+- 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)
+- Examples: Visual Studio: Updated default platform toolset+sdk in vcproj files from v100+sdk7 (vs2010)
+ to v110+sdk8 (vs2012). This is mostly so we can remove reliance on DXSDK_DIR for the DX10/DX11 example,
+ which if existing and when switching to recent SDK ends up conflicting and creating warnings.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.69 (Released 2019-03-13)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.69
+
+Breaking Changes:
+
+- Renamed ColorEdit/ColorPicker's ImGuiColorEditFlags_RGB/_HSV/_HEX flags to respectively
+ ImGuiColorEditFlags_DisplayRGB/_DisplayHSV/_DisplayHex. This is because the addition of
+ new flag ImGuiColorEditFlags_InputHSV makes the earlier one ambiguous.
+ Kept redirection enum values (will obsolete). (#2384) [@haldean]
+- Renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete). (#2391)
+
+Other Changes:
+
+- Added GetBackgroundDrawList() helper to quickly get access to a ImDrawList that will be rendered
+ behind every other windows. (#2391, #545)
+- DragScalar, InputScalar, SliderScalar: Added support for u8/s8/u16/s16 data types (ImGuiDataType_S8, etc.)
+ We are reusing function instances of larger types to reduce code size. (#643, #320, #708, #1011)
+- Added InputTextWithHint() to display a description/hint in the text box when no text
+ has been entered. (#2400) [@Organic-Code, @ocornut]
+- Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigating to the menu layer.
+- Nav: Fixed Ctrl+Tab keeping active InputText() of a previous window active after the switch. (#2380)
+- Fixed IsItemDeactivated()/IsItemDeactivatedAfterEdit() from not correctly returning true
+ when tabbing out of a focusable widget (Input/Slider/Drag) in most situations. (#2215, #1875)
+- InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when
+ style.FramePadding.x is abnormally larger than style.FramePadding.y. Since the buttons are
+ meant to be square (to align with e.g. color button) we always use FramePadding.y. (#2367)
+- InputInt, InputScalar: +/- buttons now respects the natural type limits instead of
+ overflowing or underflowing the value.
+- InputText: Fixed an edge case crash that would happen if another widget sharing the same ID
+ is being swapped with an InputText that has yet to be activated.
+- InputText: Fixed various display corruption related to swapping the underlying buffer while
+ a input widget is active (both for writable and read-only paths). Often they would manifest
+ when manipulating the scrollbar of a multi-line input text.
+- ColorEdit, ColorPicker, ColorButton: Added ImGuiColorEditFlags_InputHSV to manipulate color
+ values encoded as HSV (in order to avoid HSV<>RGB round trips and associated singularities).
+ (#2383, #2384) [@haldean]
+- ColorPicker: Fixed a bug/assertion when displaying a color picker in a collapsed window
+ while dragging its title bar. (#2389)
+- ColorEdit: Fixed tooltip not honoring the ImGuiColorEditFlags_NoAlpha contract of never
+ reading the 4th float in the array (value was read and discarded). (#2384) [@haldean]
+- MenuItem, Selectable: Fixed disabled widget interfering with navigation (fix c2db7f63 in 1.67).
+- TabBar: Fixed a crash when using many BeginTabBar() recursively (didn't affect docking). (#2371)
+- TabBar: Added extra mis-usage error recovery. Past the assert, common mis-usage don't lead to
+ hard crashes any more, facilitating integration with scripting languages. (#1651)
+- TabBar: Fixed ImGuiTabItemFlags_SetSelected being ignored if the tab is not visible (with
+ scrolling policy enabled) or if is currently appearing.
+- TabBar: Fixed Tab tooltip code making drag and drop tooltip disappear during the frame where
+ the drag payload activate a tab.
+- TabBar: Reworked scrolling policy (when ImGuiTabBarFlags_FittingPolicyScroll is set) to
+ teleport the view when aiming at a tab far away the visible section, and otherwise accelerate
+ the scrolling speed to cap the scrolling time to 0.3 seconds.
+- Text: Fixed large Text/TextUnformatted calls not feeding their size into layout when starting
+ below the lower point of the current clipping rectangle. This bug has been there since v1.0!
+ It was hardly noticeable but would affect the scrolling range, which in turn would affect
+ some scrolling request functions when called during the appearing frame of a window.
+- Plot: Fixed divide-by-zero in PlotLines() when passing a count of 1. (#2387) [@Lectem]
+- Log/Capture: Fixed LogXXX functions emitting extraneous leading carriage return.
+- Log/Capture: Fixed an issue when empty string on a new line would not emit a carriage return.
+- Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute
+ tree depth instead of a relative one.
+- Log/Capture: Fixed CollapsingHeader trailing ascii representation being "#" instead of "##".
+- ImFont: Added GetGlyphRangesVietnamese() helper. (#2403)
+- Misc: Asserting in NewFrame() if style.WindowMinSize is zero or smaller than (1.0f,1.0f).
+- Demo: Using GetBackgroundDrawList() and GetForegroundDrawList() in "Custom Rendering" demo.
+- Demo: InputText: Demonstrating use of ImGuiInputTextFlags_CallbackResize. (#2006, #1443, #1008).
+- Examples: GLFW, SDL: Preserve DisplayFramebufferScale when main viewport is minimized.
+ (This is particularly useful for the viewport branch because we are not supporting per-viewport
+ frame-buffer scale. It fixes windows not refreshing when main viewport is minimized.) (#2416)
+- Examples: OpenGL: Fix to be able to run on ES 2.0 / WebGL 1.0. [@rmitton, @gabrielcuvillier]
+- Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN
+ even if the OpenGL headers/loader happens to define the value. (#2366, #2186)
+- Examples: Allegro: Added support for touch events (emulating mouse). (#2219) [@dos1]
+- Examples: DirectX9: Minor changes to match the other DirectX examples more closely. (#2394)
+
+
+-----------------------------------------------------------------------
+ VERSION 1.68 (Released 2019-02-19)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.68
+
+Breaking Changes:
+
+- Removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
+- Made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame).
+ If for some reason your time step calculation gives you a zero value, replace it with a dummy small value!
+
+Other Changes:
+
+- Added .editorconfig file for text editors to standardize using spaces. (#2038) [@kudaba]
+- ImDrawData: Added FramebufferScale field (currently a copy of the value from io.DisplayFramebufferScale).
+ This is to allow render functions being written without pulling any data from ImGuiIO, allowing incoming
+ multi-viewport feature to behave on Retina display and with multiple displays.
+ If you are not using a custom binding, please update your render function code ahead of time,
+ and use draw_data->FramebufferScale instead of io.DisplayFramebufferScale. (#2306, #1676)
+- Added IsItemActivated() as an extension to the IsItemDeactivated/IsItemDeactivatedAfterEdit functions
+ which are useful to implement variety of undo patterns. (#820, #956, #1875)
+- InputText: Fixed a bug where ESCAPE would not restore the initial value in all situations. (#2321) [@relick]
+- InputText: Fixed a bug where ESCAPE would be first captured by the Keyboard Navigation code. (#2321, #787)
+- InputText: Fixed redo buffer exhaustion handling (rare) which could corrupt the undo character buffer. (#2333)
+ The way the redo/undo buffers work would have made it generally unnoticeable to the user.
+- Fixed range-version of PushID() and GetID() not honoring the ### operator to restart from the seed value.
+- Fixed CloseCurrentPopup() on a child-menu of a modal incorrectly closing the modal. (#2308)
+- Tabs: Added ImGuiTabBarFlags_TabListPopupButton flag to show a popup button on manual tab bars. (#261, #351)
+- Tabs: Removed ImGuiTabBarFlags_NoTabListPopupButton which was available in 1.67 but actually had zero use.
+- Tabs: Fixed a minor clipping glitch when changing style's FramePadding from frame to frame.
+- Tabs: Fixed border (when enabled) so it is aligned correctly mid-pixel and appears as bright as other borders.
+- Style, Selectable: Added ImGuiStyle::SelectableTextAlign and ImGuiStyleVar_SelectableTextAlign. (#2347) [@haldean]
+- Menus: Tweaked horizontal overlap between parent and child menu (to help convey relative depth)
+ from using style.ItemSpacing.x to style.ItemInnerSpacing.x, the later being expected to be smaller. (#1086)
+- RadioButton: Fixed label horizontal alignment to precisely match Checkbox().
+- Window: When resizing from an edge, the border is more visible and better follow the rounded corners.
+- Window: Fixed initial width of collapsed windows not taking account of contents width (broken in 1.67). (#2336, #176)
+- Scrollbar: Fade out and disable interaction when too small, in order to facilitate using the resize grab on very
+ small window, as well as reducing visual noise/overlap.
+- ListBox: Better optimized when clipped / non-visible.
+- InputTextMultiline: Better optimized when clipped / non-visible.
+- Font: Fixed high-level ImGui::CalcTextSize() used by most widgets from erroneously subtracting 1.0f*scale to
+ calculated text width. Among noticeable side-effects, it would make sequences of repeated Text/SameLine calls
+ not align the same as a single call, and create mismatch between high-level size calculation and those performed
+ with the lower-level ImDrawList api. (#792) [@SlNPacifist]
+- Font: Fixed building atlas when specifying duplicate/overlapping ranges within a same font. (#2353, #2233)
+- ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle"
+ with a small number of segments (e.g. an hexagon). (#2287) [@baktery]
+- ImGuiTextBuffer: Added append() function (unformatted).
+- ImFontAtlas: Added 0x2000-0x206F general punctuation range to default ChineseFull/ChineseSimplifiedCommon ranges. (#2093)
+- ImFontAtlas: FreeType: Added support for imgui allocators + custom FreeType only SetAllocatorFunctions. (#2285) [@Vuhdo]
+- ImFontAtlas: FreeType: Fixed using imgui_freetype.cpp in unity builds. (#2302)
+- Demo: Fixed "Log" demo not initializing properly, leading to the first line not showing before a Clear. (#2318) [@bluescan]
+- Demo: Added "Auto-scroll" option in Log/Console demos. (#2300) [@nicolasnoble, @ocornut]
+- Examples: Metal, OpenGL2, OpenGL3, Vulkan: Fixed offsetting of clipping rectangle with ImDrawData::DisplayPos != (0,0)
+ when the display frame-buffer scale scale is not (1,1). While this doesn't make a difference when using master branch,
+ this is effectively fixing support for multi-viewport with Mac Retina Displays on those examples. (#2306) [@rasky, @ocornut]
+ Also using ImDrawData::FramebufferScale instead of io.DisplayFramebufferScale.
+- Examples: Clarified the use the ImDrawData::DisplayPos to offset clipping rectangles.
+- Examples: Win32: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created
+ in a different thread or parent. (#1951, #2087, #2156, #2232) [many people]
+- Examples: SDL: Using the SDL_WINDOW_ALLOW_HIGHDPI flag. (#2306, #1676) [@rasky]
+- Examples: Win32: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is enabled).
+- Examples: Win32: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. (#2264)
+- Examples: DirectX9: Explicitly disable fog (D3DRS_FOGENABLE) before drawing in case user state has it set. (#2288, #2230)
+- Examples: OpenGL2: Added #define GL_SILENCE_DEPRECATION to cope with newer XCode warnings.
+- Examples: OpenGL3: Using GLSL 4.10 shaders for any GLSL version over 410 (e.g. 430, 450). (#2329) [@BrutPitt]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.67 (Released 2019-01-14)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.67
+
+Breaking Changes:
+
+- Made it illegal to call Begin("") with an empty string. This somehow half-worked before but had various undesirable
+ side-effect because the window would have ID zero. In particular it is causing problems in viewport/docking branches.
+- Renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges and removed its [Beta] mark.
+ The addition of new configuration options in the Docking branch is pushing for a little reorganization of those names.
+- Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
+
+Other Changes:
+- Added BETA api for Tab Bar/Tabs widgets: (#261, #351)
+ - Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem(), SetTabItemClosed() API.
+ - Added ImGuiTabBarFlags flags for BeginTabBar().
+ - Added ImGuiTabItemFlags flags for BeginTabItem().
+ - Style: Added ImGuiCol_Tab, ImGuiCol_TabHovered, ImGuiCol_TabActive, ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive colors.
+ - Demo: Added Layout->Tabs demo code.
+ - Demo: Added "Documents" example app showcasing possible use for tabs.
+ This feature was merged from the Docking branch in order to allow the use of regular tabs in your code.
+ (It does not provide the docking/splitting/merging of windows available in the Docking branch)
+- Added ImGuiWindowFlags_UnsavedDocument window flag to append '*' to title without altering the ID, as a convenience
+ to avoid using the ### operator. In the Docking branch this also has an effect on tab closing behavior.
+- Window, Focus, Popup: Fixed an issue where closing a popup by clicking another window with the _NoMove flag would refocus
+ the parent window of the popup instead of the newly clicked window.
+- Window: Contents size is preserved while a window collapsed. Fix auto-resizing window losing their size for one frame when uncollapsed.
+- Window: Contents size is preserved while a window contents is hidden (unless it is hidden for resizing purpose).
+- Window: Resizing windows from edge is now enabled by default (io.ConfigWindowsResizeFromEdges=true). Note that
+ it only works _if_ the back-end sets ImGuiBackendFlags_HasMouseCursors, which the standard back-ends do.
+- Window: Added io.ConfigWindowsMoveFromTitleBarOnly option. This is ignored by window with no title bars (often popups).
+ This affects clamping window within the visible area: with this option enabled title bars need to be visible. (#899)
+- Window: Fixed using SetNextWindowPos() on a child window (which wasn't really documented) position the cursor as expected
+ in the parent window, so there is no mismatch between the layout in parent and the position of the child window.
+- InputFloat: When using ImGuiInputTextFlags_ReadOnly the step buttons are disabled. (#2257)
+- DragFloat: Fixed broken mouse direction change with power!=1.0. (#2174, #2206) [@Joshhua5]
+- Nav: Fixed an keyboard issue where holding Activate/Space for longer than two frames on a button would unnecessary
+ keep the focus on the parent window, which could steal it from newly appearing windows. (#787)
+- Nav: Fixed animated window titles from being updated when displayed in the CTRL+Tab list. (#787)
+- Error recovery: Extraneous/undesired calls to End() are now being caught by an assert in the End() function closer
+ to the user call site (instead of being reported in EndFrame). Past the assert, they don't lead to crashes any more. (#1651)
+ Missing calls to End(), past the assert, should not lead to crashes or to the fallback Debug window appearing on screen.
+ Those changes makes it easier to integrate dear imgui with a scripting language allowing, given asserts are redirected
+ into e.g. an error log and stopping the script execution.
+- ImFontAtlas: Stb and FreeType: Atlas width is now properly based on total surface rather than glyph count (unless overridden with TexDesiredWidth).
+- ImFontAtlas: Stb and FreeType: Fixed atlas builder so missing glyphs won't influence the atlas texture width. (#2233)
+- ImFontAtlas: Stb and FreeType: Fixed atlas builder so duplicate glyphs (when merging fonts) won't be included in the rasterized atlas.
+- ImFontAtlas: FreeType: Fixed abnormally high atlas height.
+- ImFontAtlas: FreeType: Fixed support for any values of TexGlyphPadding (not just only 1).
+- ImDrawList: Optimized some of the functions for performance of debug builds where non-inline function call cost are non-negligible.
+ (Our test UI scene on VS2015 Debug Win64 with /RTC1 went ~5.9 ms -> ~4.9 ms. In Release same scene stays at ~0.3 ms.)
+- IO: Added BackendPlatformUserData, BackendRendererUserData, BackendLanguageUserData void* for storage use by back-ends.
+- IO: Renamed InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead!
+- IO: AddInputCharacter() goes into a queue which can receive as many characters as needed during the frame. This is useful
+ for automation to not have an upper limit on typing speed. Will later transition key/mouse to use the event queue later.
+- Style: Tweaked default value of style.DisplayWindowPadding from (20,20) to (19,19) so the default style as a value
+ which is the same as the title bar height.
+- Demo: "Simple Layout" and "Style Editor" are now using tabs.
+- Demo: Added a few more things under "Child windows" (changing ImGuiCol_ChildBg, positioning child, using IsItemHovered after a child).
+- Examples: DirectX10/11/12: Made imgui_impl_dx10/dx11/dx12.cpp link d3dcompiler.lib from the .cpp file to ease integration.
+- Examples: Allegro 5: Properly destroy globals on shutdown to allow for restart. (#2262) [@DomRe]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.66b (Released 2018-12-01)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.66b
+
+Other Changes:
+
+- Fixed a text rendering/clipping bug introduced in 1.66 (on 2018-10-12, commit ede3a3b9) that affect single ImDrawList::AddText()
+ calls with single strings larger than 10k. Text/TextUnformatted() calls were not affected, but e.g. InputText() was. [@pdoane]
+- When the focused window become inactive don't restore focus to a window with the ImGuiWindowFlags_NoInputs flag. (#2213) [@zzzyap]
+- Separator: Fixed Separator() outputting an extraneous empty line when captured into clipboard/text/file.
+- Demo: Added ShowAboutWindow() call, previously was only accessible from the demo window.
+- Demo: ShowAboutWindow() now display various Build/Config Information (compiler, os, etc.) that can easily be copied into bug reports.
+- Fixed build issue with osxcross and macOS. (#2218) [@dos1]
+- Examples: Setting up 'io.BackendPlatformName'/'io.BackendRendererName' fields to the current back-end can be displayed in the About window.
+- Examples: SDL: changed the signature of ImGui_ImplSDL2_ProcessEvent() to use a const SDL_Event*. (#2187)
+
+
+-----------------------------------------------------------------------
+ VERSION 1.66 (Released 2018-11-22)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.66
+
+Breaking Changes:
+
+- Renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete).
+- Renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files. (#2035, #2096)
+
+Other Changes:
+
+- Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to
+ accidental alteration of window position. We now round the provided size. (#2067)
+- Fixed calling DestroyContext() always saving .ini data with the current context instead
+ of the supplied context pointer. (#2066)
+- Nav, Focus: Fixed ImGuiWindowFlags_NoBringToFrontOnFocus windows not being restoring focus
+ properly after the main menu bar or last focused window is deactivated.
+- Nav: Fixed an assert in certain circumstance (mostly when using popups) when mouse positions stop being valid. (#2168)
+- Nav: Fixed explicit directional input not re-highlighting current nav item if there is a single item in the window
+ and highlight has been previously disabled by the mouse. (#787)
+- DragFloat: Fixed a situation where dragging with value rounding enabled or with a power curve
+ erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075).
+- DragFloat: Disabled using power curve when one edge is FLT_MAX (broken in 1.61). (#2024)
+- DragFloat: Disabled setting a default drag speed when one edge is FLT_MAX. (#2024)
+- SliderAngle: Added optional format argument to alter precision or localize the string. (#2150) [@podsvirov]
+- Window: Resizing from edges (with io.ConfigResizeWindowsFromEdges Beta flag) extends the hit region
+ of root floating windows outside the window, making it easier to resize windows. Resize grips are also
+ extended accordingly so there are no discontinuity when hovering between borders and corners. (#1495, #822)
+- Window: Added ImGuiWindowFlags_NoBackground flag to avoid rendering window background. This is mostly to allow
+ the creation of new flag combinations, as we could already use SetNextWindowBgAlpha(0.0f). (#1660) [@biojppm, @ocornut]
+- Window: Added ImGuiWindowFlags_NoDecoration helper flag which is essentially NoTitleBar+NoResize+NoScrollbar+NoCollapse.
+- Window: Added ImGuiWindowFlags_NoMouseInputs which is basically the old ImGuiWindowFlags_NoInputs (essentially
+ we have renamed ImGuiWindowFlags_NoInputs to ImGuiWindowFlags_NoMouseInputs). Made the new ImGuiWindowFlags_NoInputs
+ encompass both NoMouseInputs+NoNav, which is consistent with its description. (#1660, #787)
+- Window, Inputs: Fixed resizing from edges when io.MousePos is not pixel-rounded by rounding mouse position input. (#2110)
+- BeginChild(): Fixed BeginChild(const char*, ...) variation erroneously not applying the ID stack
+ to the provided string to uniquely identify the child window. This was undoing an intentional change
+ introduced in 1.50 and broken in 1.60. (#1698, #894, #713).
+- TextUnformatted(): Fixed a case where large-text path would read bytes past the text_end marker depending
+ on the position of new lines in the buffer (it wasn't affecting the output but still not the right thing to do!)
+- ListBox(): Fixed frame sizing when items_count==1 unnecessarily showing a scrollbar. (#2173) [@luk1337, @ocornut]
+- ListBox(): Tweaked frame sizing so list boxes will look more consistent when FramePadding is far from ItemSpacing.
+- RenderText(): Some optimization for very large text buffers, useful for non-optimized builds.
+- BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f.
+- ArrowButton(): Fixed arrow shape being horizontally misaligned by (FramePadding.y-FramePadding.x) if they are different.
+- Demo: Split the contents of ShowDemoWindow() into smaller functions as it appears to speed up link time with VS. (#2152)
+- Drag and Drop: Added GetDragDropPayload() to peek directly into the payload (if any) from anywhere. (#143)
+- ImGuiTextBuffer: Avoid heap allocation when empty.
+- ImDrawList: Fixed AddConvexPolyFilled() undefined behavior when passing points_count smaller than 3,
+ in particular, points_count==0 could lead to a memory stomp if the draw list was previously empty.
+- Examples: DirectX10, DirectX11: Removed seemingly unnecessary calls to invalidate and recreate device objects
+ in the WM_SIZE handler. (#2088) [@ice1000]
+- Examples: GLFW: User previously installed GLFW callbacks are now saved and chain-called by the default callbacks. (#1759)
+- Examples: OpenGL3: Added support for GL 4.5's glClipControl(GL_UPPER_LEFT). (#2186)
+- Examples: OpenGL3+GLFW: Fixed error condition when using the GLAD loader. (#2157) [@blackball]
+- Examples: OpenGL3+GLFW/SDL: Made main.cpp compile with IMGUI_IMPL_OPENGL_LOADER_CUSTOM (may be missing init). (#2178) [@doug-moen]
+- Examples: SDL2+Vulkan: Fixed application shutdown which could deadlock on Linux + Xorg. (#2181) [@eRabbit0]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.65 (Released 2018-09-06)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.65
+
+Breaking Changes:
+
+- Renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and
+ stb_rect_pack.h to imstb_rectpack.h. If you were conveniently using the imgui copy of those
+ STB headers in your project, you will have to update your include paths. (#1718, #2036)
+ The reason for this change is to avoid conflicts for projects that may also be importing
+ their own copy of the STB libraries. Note that imgui's copy of stb_textedit.h is modified.
+- Renamed io.ConfigCursorBlink to io.ConfigInputTextCursorBlink. (#1427)
+
+Other Changes:
+
+- This is a minor release following the 1.64 refactor, with a little more shuffling of code.
+- Clarified and improved the source code sectioning in all files (easier to search or browse sections).
+- Nav: Removed the [Beta] tag from various descriptions of the gamepad/keyboard navigation system.
+ Although it is not perfect and will keep being improved, it is fairly functional and used by many. (#787)
+- Fixed a build issue with non-Cygwin GCC under Windows.
+- Demo: Added a "Configuration" block to make io.ConfigFlags/io.BackendFlags more prominent.
+- Examples: OpenGL3+SDL2: Fixed error condition when using the GLAD loader. (#2059, #2002) [@jiri]
+
+
+-----------------------------------------------------------------------
+ VERSION 1.64 (Released 2018-08-31)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.64
+
+Changes:
+
+- Moved README, CHANGELOG and TODO files to the docs/ folder.
+ If you are updating dear imgui by copying files, take the chance to delete the old files.
+- Added imgui_widgets.cpp file, extracted and moved widgets code out of imgui.cpp into imgui_widgets.cpp.
+ Re-ordered some of the code remaining in imgui.cpp.
+ NONE OF THE FUNCTIONS HAVE CHANGED. THE CODE IS SEMANTICALLY 100% IDENTICAL, BUT _EVERY_ FUNCTIONS HAS BEEN MOVED.
+ Because of this, any local modifications to imgui.cpp will likely conflict when you update.
+ If you have any modifications to imgui.cpp, it is suggested that you first update to 1.63, then
+ isolate your patches. You can peak at imgui_widgets.cpp from 1.64 to get a sense of what is included in it,
+ then separate your changes into several patches that can more easily be applied to 1.64 on a per-file basis.
+ What I found worked nicely for me, was to open the diff of the old patches in an interactive merge/diff tool,
+ search for the corresponding function in the new code and apply the chunks manually.
+- As a reminder, if you have any change to imgui.cpp it is a good habit to discuss them on the github,
+ so a solution applicable on the Master branch can be found. If your company has changes that you cannot
+ disclose you may also contact me privately.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.63 (Released 2018-08-29)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.63
+
+Breaking Changes:
+
+- Style: Renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features.
+ Kept redirection enum (will obsolete).
+- Changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecision over time.
+- Removed per-window ImGuiWindowFlags_ResizeFromAnySide Beta flag in favor `io.ConfigResizeWindowsFromEdges=true` to
+ enable the feature globally. (#1495)
+ The feature is not currently enabled by default because it is not satisfying enough, but will eventually be.
+- InputText: Renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData
+ for consistency. Kept redirection types (will obsolete).
+- InputText: Removed ImGuiTextEditCallbackData::ReadOnly because it is a duplication of (::Flags & ImGuiInputTextFlags_ReadOnly).
+- Renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API.
+ Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent).
+- Renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to
+ io.ConfigMacOSXBehaviors for consistency. (#1427, #473)
+- Removed obsolete redirection functions: CollapsingHeader() variation with 2 bools - marked obsolete in v1.49, May 2016.
+
+Other Changes:
+
+- ArrowButton: Fixed to honor PushButtonRepeat() setting (and internals' ImGuiItemFlags_ButtonRepeat).
+- ArrowButton: Setup current line text baseline so that ArrowButton() + SameLine() + Text() are aligned properly.
+- Nav: Added a CTRL+TAB window list and changed the highlight system accordingly. The change is motivated by upcoming
+ Docking features. (#787)
+- Nav: Made CTRL+TAB skip menus + skip the current navigation window if is has the ImGuiWindow_NoNavFocus set. (#787)
+ While it was previously possible, you won't be able to CTRL-TAB out and immediately back in a window with the
+ ImGuiWindow_NoNavFocus flag.
+- Window: Allow menu and popups windows from ignoring the style.WindowMinSize values so short menus/popups are not padded. (#1909)
+- Window: Added global io.ConfigResizeWindowsFromEdges option to enable resizing windows from their edges and from
+ the lower-left corner. (#1495)
+- Window: Collapse button shows hovering highlight + clicking and dragging on it allows to drag the window as well.
+- Added IsItemEdited() to query if the last item modified its value (or was pressed). This is equivalent to the bool
+ returned by most widgets.
+ It is useful in some situation e.g. using InputText() with ImGuiInputTextFlags_EnterReturnsTrue. (#2034)
+- InputText: Added support for buffer size/capacity changes via the ImGuiInputTextFlags_CallbackResize flag. (#2006, #1443, #1008).
+- InputText: Fixed not tracking the cursor horizontally when modifying the text buffer through a callback.
+- InputText: Fixed minor off-by-one issue when submitting a buffer size smaller than the initial zero-terminated buffer contents.
+- InputText: Fixed a few pathological crash cases on single-line InputText widget with multiple millions characters worth of contents.
+ Because the current text drawing function reserve for a worst-case amount of vertices and how we handle horizontal clipping,
+ we currently just avoid displaying those single-line widgets when they are over a threshold of 2 millions characters,
+ until a better solution is found.
+- Drag and Drop: Fixed an incorrect assert when dropping a source that is submitted after the target (bug introduced with 1.62 changes
+ related to the addition of IsItemDeactivated()). (#1875, #143)
+- Drag and Drop: Fixed ImGuiDragDropFlags_SourceNoDisableHover to affect hovering state prior to calling IsItemHovered() + fixed description. (#143)
+- Drag and Drop: Calling BeginTooltip() between a BeginDragSource()/EndDragSource() or BeginDropTarget()/EndDropTarget() uses adjusted tooltip
+ settings matching the one created when calling BeginDragSource() without the ImGuiDragDropFlags_SourceNoPreviewTooltip flag. (#143)
+- Drag and Drop: Payload stays available and under the mouse if the source stops being submitted, however the tooltip is replaced by "...". (#1725)
+- Drag and Drop: Added ImGuiDragDropFlags_SourceAutoExpirePayload flag to force payload to expire if the source stops being submitted. (#1725, #143).
+- IsItemHovered(): Added ImGuiHoveredFlags_AllowWhenDisabled flag to query hovered status on disabled items. (#1940, #211)
+- Selectable: Added ImGuiSelectableFlags_Disabled flag in the public API. (#211)
+- ColorEdit4: Fixed a bug when text input or drag and drop leading to unsaturated HSV values would erroneously alter the resulting color. (#2050)
+- Misc: Added optional misc/stl/imgui_stl.h wrapper to use with STL types (e.g. InputText with std::string). (#2006, #1443, #1008)
+ [*EDIT* renamed to misc/std/imgui_stdlib.h in 1.66]
+- Misc: Added IMGUI_VERSION_NUM for easy compile-time testing. (#2025)
+- Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut]
+- Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors.
+- Made assertion more clear when trying to call Begin() outside of the NewFrame()..EndFrame() scope. (#1987)
+- Fixed assertion when transitioning from an active ID to another within a group, affecting ColorPicker (broken in 1.62). (#2023, #820, #956, #1875).
+- Fixed PushID() from keeping alive the new ID Stack top value (if a previously active widget shared the ID it would be erroneously kept alive).
+- Fixed horizontal mouse wheel not forwarding the request to the parent window if ImGuiWindowFlags_NoScrollWithMouse is set. (#1463, #1380, #1502)
+- Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276)
+- ImDrawList: Improved handling for worst-case vertices reservation policy when large amount of text (e.g. 1+ million character strings)
+ are being submitted in a single call. It would typically have crashed InputTextMultiline(). (#200)
+- OS/Windows: Fixed missing ImmReleaseContext() call in the default Win32 IME handler. (#1932) [@vby]
+- Metrics: Changed io.MetricsActiveWindows to reflect the number of active windows (!= from visible windows), which is useful
+ for lazy/idle render mechanisms as new windows are typically not visible for one frame.
+- Metrics: Added io.MetricsRenderWindow to reflect the number of visible windows.
+- Metrics: Added io.MetricsActiveAllocations, moving away from the cross-context global counters than we previously used. (#1565, #1599, #586)
+- Demo: Added basic Drag and Drop demo. (#143)
+- Demo: Modified the Console example to use InsertChars() in the input text callback instead of poking directly into the buffer.
+ Although this won't make a difference in the example itself, using InsertChars() will honor the resizing callback properly. (#2006, #1443, #1008).
+- Demo: Clarified the use of IsItemHovered()/IsItemActive() right after being in the "Active, Focused, Hovered & Focused Tests" section.
+- Examples: Tweaked the main.cpp of each example.
+- Examples: Metal: Added Metal rendering backend. (#1929, #1873) [@warrenm]
+- Examples: OSX: Added early raw OSX platform backend. (#1873) [@pagghiu, @itamago, @ocornut]
+- Examples: Added mac OSX & iOS + Metal example in example_apple_metal/. (#1929, #1873) [@warrenm]
+- Examples: Added mac OSX + OpenGL2 example in example_apple_opengl2/. (#1873)
+- Examples: OpenGL3: Added shaders more versions of GLSL. (#1938, #1941, #1900, #1513, #1466, etc.)
+- Examples: OpenGL3: Tweaked the imgui_impl_opengl3.cpp to work as-is with Emscripten + WebGL 2.0. (#1941). [@o-micron]
+- Examples: OpenGL3: Made the example app default to GL 3.0 + GLSL 130 (instead of GL 3.2 + GLSL 150) unless on Mac.
+- Examples: OpenGL3: Added error output when shaders fail to compile/link.
+- Examples: OpenGL3: Added support for glew and glad OpenGL loaders out of the box. (#2001, #2002) [@jdumas]
+- Examples: OpenGL2: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications. (#1996)
+- Examples: DirectX10, DirectX11: Fixed unreleased resources in Init and Shutdown functions. (#1944)
+- Examples: DirectX11: Querying for IDXGIFactory instead of IDXGIFactory1 to increase compatibility. (#1989) [@matt77hias]
+- Examples: Vulkan: Fixed handling of VkSurfaceCapabilitiesKHR::maxImageCount = 0 case. Tweaked present mode selections.
+- Examples: Win32, Glfw, SDL: Added support for the ImGuiMouseCursor_Hand cursor.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.62 (Released 2018-06-22)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.62
+
+Breaking Changes:
+
+- TreeNodeEx(): The helper ImGuiTreeNodeFlags_CollapsingHeader flag now include ImGuiTreeNodeFlags_NoTreePushOnOpen.
+ The flag was already set by CollapsingHeader().
+ The only difference is if you were using TreeNodeEx() manually with ImGuiTreeNodeFlags_CollapsingHeader and without
+ ImGuiTreeNodeFlags_NoTreePushOnOpen. In this case you can remove the ImGuiTreeNodeFlags_NoTreePushOnOpen flag from
+ your call (ImGuiTreeNodeFlags_CollapsingHeader & ~ImGuiTreeNodeFlags_NoTreePushOnOpen). (#1864)
+ This also apply if you were using internal's TreeNodeBehavior() with the ImGuiTreeNodeFlags_CollapsingHeader flag directly.
+- ImFontAtlas: Renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish new smaller variants and
+ discourage using the full set. (#1859)
+
+Other Changes:
+
+- Examples back-ends have been refactored to separate the platform code (e.g. Win32, Glfw, SDL2) from the renderer code (e.g. DirectX11, OpenGL3, Vulkan).
+ The "Platform" bindings are in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, etc.
+ The "Renderer" bindings are in charge of: creating the main font texture, rendering imgui draw data.
+ before: imgui_impl_dx11.cpp --> after: imgui_impl_win32.cpp + imgui_impl_dx11.cpp
+ before: imgui_impl_dx12.cpp --> after: imgui_impl_win32.cpp + imgui_impl_dx12.cpp
+ before: imgui_impl_glfw_gl3.cpp --> after: imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
+ before: imgui_impl_glfw_vulkan.cpp --> after: imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
+ before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl2.cpp
+ before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp etc.
+ - The idea is what we can now easily combine and maintain back-ends and reduce code redundancy. Individual files are
+ smaller and more reusable. Integration of imgui into a new/custom engine may also be easier as there is less overlap
+ between "windowing / inputs" and "rendering" code, so you may study or grab one half of the code and not the other.
+ - This change was motivated by the fact that adding support for the upcoming multi-viewport feature requires more work
+ from the Platform and Renderer back-ends, and the amount of redundancy across files was becoming too difficult to
+ maintain. If you use default back-ends, you'll benefit from an easy update path to support multi-viewports later
+ (for future ImGui 1.7x).
+ - This is not strictly a breaking change if you keep your old bindings, but when you'll want to fully update your bindings,
+ expect to have to reshuffle a few things.
+ - Each example still has its own main.cpp which you may refer you to understand how to initialize and glue everything together.
+ - Some frameworks (such as the Allegro, Marmalade) handle both the "platform" and "rendering" part, and your custom engine may as well.
+ - Read examples/README.txt for details.
+- Added IsItemDeactivated() to query if the last item was active previously and isn't anymore. Useful for Undo/Redo patterns. (#820, #956, #1875)
+- Added IsItemDeactivatedAfterChange() [*EDIT* renamed to IsItemDeactivatedAfterEdit() in 1.63] if the last item was active previously,
+ is not anymore, and during its active state modified a value. Note that you may still get false positive (e.g. drag value and while
+ holding return on the same value). (#820, #956, #1875)
+- Nav: Added support for PageUp/PageDown (explorer-style: first aim at bottom/top most item, when scroll a page worth of contents). (#787)
+- Nav: To keep the navigated item in view we also attempt to scroll the parent window as well as the current window. (#787)
+- ColorEdit3, ColorEdit4, ColorButton: Added ImGuiColorEditFlags_NoDragDrop flag to disable ColorEditX as drag target and ColorButton as drag source. (#1826)
+- BeginDragDropSource(): Offset tooltip position so it is off the mouse cursor, but also closer to it than regular tooltips,
+ and not clamped by viewport. (#1739)
+- BeginDragDropTarget(): Added ImGuiDragDropFlags_AcceptNoPreviewTooltip flag to request hiding the drag source tooltip
+ from the target site. (#143)
+- BeginCombo(), BeginMainMenuBar(), BeginChildFrame(): Temporary style modification are restored at the end of BeginXXX
+ instead of EndXXX, to not affect tooltips and child windows.
+- Popup: Improved handling of (erroneously) repeating calls to OpenPopup() to not close the popup's child popups. (#1497, #1533, #1865).
+- InputTextMultiline(): Fixed double navigation highlight when scrollbar is active. (#787)
+- InputText(): Fixed Undo corruption after pasting large amount of text (Redo will still fail when undo buffers are exhausted,
+ but text won't be corrupted).
+- SliderFloat(): When using keyboard/gamepad and a zero precision format string (e.g. "%.0f"), always step in integer units. (#1866)
+- ImFontConfig: Added GlyphMinAdvanceX/GlyphMaxAdvanceX settings useful to make a font appears monospaced, particularly useful
+ for icon fonts. (#1869)
+- ImFontAtlas: Added GetGlyphRangesChineseSimplifiedCommon() helper that returns a list of ~2500 most common Simplified Chinese
+ characters. (#1859) [@JX-Master, @ocornut]
+- Examples: OSX: Added imgui_impl_osx.mm binding to be used along with e.g. imgui_impl_opengl2.cpp. (#281, #1870) [@pagghiu, @itamago, @ocornut]
+- Examples: GLFW: Made it possible to Shutdown/Init the backend again (by reseting the time storage properly). (#1827) [@ice1000]
+- Examples: Win32: Fixed handling of mouse wheel messages to support sub-unit scrolling messages (typically sent by track-pads). (#1874) [@zx64]
+- Examples: SDL+Vulkan: Added SDL+Vulkan example.
+- Examples: Allegro5: Added support for ImGuiConfigFlags_NoMouseCursorChange flag. Added clipboard support.
+- Examples: Allegro5: Unindexing buffers ourselves as Allegro indexed drawing primitives are buggy in the DirectX9 back-end
+ (will be fixed in Allegro 5.2.5+).
+- Examples: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from ImGui_ImplDX12_NewFrame() to ImGui_ImplDX12_RenderDrawData() which makes a lots more sense. (#301)
+- Examples: Vulkan: Reordered parameters ImGui_ImplVulkan_RenderDrawData() to be consistent with other bindings,
+ a good occasion since we refactored the code.
+- Examples: FreeGLUT: Added FreeGLUT bindings. Added FreeGLUT+OpenGL2 example. (#801)
+- Examples: The functions in imgui_impl_xxx.cpp are prefixed with IMGUI_IMPL_API (which defaults to IMGUI_API) to facilitate
+ some uses. (#1888)
+- Examples: Fixed bindings to use ImGuiMouseCursor_COUNT instead of old name ImGuiMouseCursor_Count_ so they can compile
+ with IMGUI_DISABLE_OBSOLETE_FUNCTIONS. (#1887)
+- Misc: Updated stb_textedit from 1.09 + patches to 1.12 + minor patches.
+- Internals: PushItemFlag() flags are inherited by BeginChild().
+
+
+-----------------------------------------------------------------------
+ VERSION 1.61 (Released 2018-05-14)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.61
+
+Breaking Changes:
+
+- DragInt(): The default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally
+ any more. If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
+ To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d,
+ giving time to users to upgrade their code.
+ If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your
+ codebase for e.g. "DragInt.*%f" to you find them.
+- InputFloat(): Obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more
+ flexible "const char* format", consistent with other functions. Kept redirection functions (will obsolete).
+- Misc: IM_DELETE() helper function added in 1.60 doesn't set the input pointer to NULL, more consistent with standard
+ expectation and allows passing r-values.
+
+Other Changes:
+
+- Added DragScalar, DragScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#643, #320, #708, #1011)
+- Added InputScalar, InputScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#643, #320, #708, #1011)
+- Added SliderScalar, SliderScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#643, #320, #708, #1011)
+- Window: Fixed pop-ups/tooltips/menus not honoring style.DisplaySafeAreaPadding as well as it should have (part of menus
+ displayed outside the safe area, etc.).
+- Window: Fixed windows using the ImGuiWindowFlags_NoSavedSettings flag from not using the same default position as other windows. (#1760)
+- Window: Relaxed the internal stack size checker to allow Push/Begin/Pop/.../End patterns to be used with PushStyleColor, PushStyleVar, PushFont without causing a false positive assert. (#1767)
+- Window: Fixed the default proportional item width lagging by one frame on resize.
+- Columns: Fixed a bug introduced in 1.51 where columns would affect the contents size of their container, often creating
+ feedback loops when ImGuiWindowFlags_AlwaysAutoResize was used. (#1760)
+- Settings: Fixed saving an empty .ini file if CreateContext/DestroyContext are called without a single call to NewFrame(). (#1741)
+- Settings: Added LoadIniSettingsFromDisk(), LoadIniSettingsFromMemory(), SaveIniSettingsToDisk(), SaveIniSettingsToMemory()
+ to manually load/save .ini settings. (#923, #993)
+- Settings: Added io.WantSaveIniSettings flag, which is set to notify the application that e.g. SaveIniSettingsToMemory()
+ should be called. (#923, #993)
+- Scrolling: Fixed a case where using SetScrollHere(1.0f) at the bottom of a window on the same frame the window height
+ has been growing would have the scroll clamped using the previous height. (#1804)
+- MenuBar: Made BeginMainMenuBar() honor style.DisplaySafeAreaPadding so the text can be made visible on TV settings that
+ don't display all pixels. (#1439) [@dougbinks]
+- InputText: On Mac OS X, filter out characters when the CMD modifier is held. (#1747) [@sivu]
+- InputText: On Mac OS X, support CMD+SHIFT+Z for Redo. CMD+Y is also supported as major apps seems to default to support both. (#1765) [@lfnoise]
+- InputText: Fixed returning true when edition is cancelled with ESC and the current buffer matches the initial value.
+- InputFloat,InputFloat2,InputFloat3,InputFloat4: Added variations taking a more flexible and consistent optional
+ "const char* format" parameter instead of "int decimal_precision". This allow using custom formats to display values
+ in scientific notation, and is generally more consistent with other API.
+ Obsoleted functions using the optional "int decimal_precision" parameter. (#648, #712)
+- DragFloat, DragInt: Cancel mouse tweak when current value is initially past the min/max boundaries and mouse is pushing
+ in the same direction (keyboard/gamepad version already did this).
+- DragFloat, DragInt: Honor natural type limits (e.g. INT_MAX, FLT_MAX) instead of wrapping around. (#708, #320)
+- DragFloat, SliderFloat: Fixes to allow input of scientific notation numbers when using CTRL+Click to input the value. (~#648, #1011)
+- DragFloat, SliderFloat: Rounding-on-write uses the provided format string instead of parsing the precision from the string,
+ which allows for finer uses of %e %g etc. (#648, #642)
+- DragFloat: Improved computation when using the power curve. Improved lost of input precision with very small steps.
+ Added an assert than power-curve requires a min/max range. (~#642)
+- DragFloat: The 'power' parameter is only honored if the min/max parameter are also setup.
+- DragInt, SliderInt: Fixed handling of large integers (we previously passed data around internally as float, which reduced
+ the range of valid integers).
+- ColorEdit: Fixed not being able to pass the ImGuiColorEditFlags_NoAlpha or ImGuiColorEditFlags_HDR flags to SetColorEditOptions().
+- Nav: Fixed hovering a Selectable() with the mouse so that it update the navigation cursor (as it happened in the pre-1.60 navigation branch). (#787)
+- Style: Changed default style.DisplaySafeAreaPadding values from (4,4) to (3,3) so it is smaller than FramePadding and has no effect on main menu bar on a computer. (#1439)
+- Fonts: When building font atlas, glyphs that are missing in the fonts are not using the glyph slot to render a dummy/default glyph. Saves space and allow merging fonts with
+ overlapping font ranges such as FontAwesome5 which split out the Brands separately from the Solid fonts. (#1703, #1671)
+- Misc: Added IMGUI_CHECKVERSION() macro to compare version string and data structure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769)
+- Misc: Added IMGUI_DISABLE_MATH_FUNCTIONS in imconfig.h to make it easier to redefine wrappers for std/crt math functions.
+- Misc: Fix to allow compiling in unity builds where stb_rectpack/stb_truetype may be already included in the same compilation unit.
+- Demo: Simple Overlay: Added a context menu item to enable freely moving the window.
+- Demo: Added demo for DragScalar(), InputScalar(), SliderScalar(). (#643)
+- Examples: Calling IMGUI_CHECKVERSION() in the main.cpp of every example application.
+- Examples: Allegro 5: Added support for 32-bit indices setup via defining ImDrawIdx, to avoid an unnecessary conversion (Allegro 5 doesn't support 16-bit indices).
+- Examples: Allegro 5: Renamed bindings from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
+- Examples: DirectX 9: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. (#1790, #1687) [@sr-tream]
+- Examples: SDL: Fixed clipboard paste memory leak in the SDL binding code. (#1803) [@eliasdaler]
+- Various minor fixes, tweaks, refactoring, comments.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.60 (Released 2018-04-07)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.60
+
+The gamepad/keyboard navigation branch (which has been in the work since July 2016) has been merged.
+Gamepad/keyboard navigation is still marked as Beta and has to be enabled explicitly.
+Various internal refactoring have also been done, as part of the navigation work and as part of the upcoming viewport/docking work.
+
+Breaking Changes:
+
+- Obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render().
+ e.g. with example backends, call ImDrawData* draw_data = ImGui::GetDrawData(); ImGui_ImplXXXX_RenderDrawData(draw_data).
+- Reorganized context handling to be more explicit: (#1599)
+ - YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
+ - removed Shutdown() function, as DestroyContext() serve this purpose. If you are using an old backend from the examples/ folder, remove the line that calls Shutdown().
+ - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance.
+ - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
+ - removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts.
+- Renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
+- Fonts: Moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths.
+- Fonts: changed ImFont::DisplayOffset.y to defaults to 0 instead of +1. Fixed vertical rounding of Ascent/Descent to match TrueType renderer.
+ If you were adding or subtracting (not assigning) to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. (#1619)
+- BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
+- Obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
+- Obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete).
+- Renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, not used by core, and honored by some binding ahead of merging the Nav branch).
+- Removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered style colors as the closing cross uses regular button colors now.
+- Renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData.
+- Removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it should be easy to replicate on your side (you can find the code in 1.53).
+- [EDITED] Window: BeginChild() with an explicit name doesn't include the hash within the internal window name. (#1698)
+ This change was erroneously introduced, undoing the change done for #894, #713, and not documented properly in the original
+ 1.60 release Changelog. It was fixed on 2018-09-28 (1.66) and I wrote this paragraph the same day.
+
+Other Changes:
+
+- Doc: Added a Changelog file in the repository to ease comparing versions (it goes back to dear imgui 1.48), until now it was only on GitHub.
+- Navigation: merged in the gamepad/keyboard navigation (about a million changes!). (#787, #323)
+ The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable.
+- To use Gamepad Navigation:
+ - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable.
+ - Backend: Set io.BackendFlags |= ImGuiBackendFlags_HasGamepad + fill the io.NavInputs[] fields before calling NewFrame(). Read imgui.cpp for more details.
+ - See https://github.com/ocornut/imgui/issues/1599 for recommended gamepad mapping or download PNG/PSD at http://goo.gl/9LgVZW
+ - See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. Read imgui.cpp for more details.
+- To use Keyboard Navigation:
+ - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
+ - Basic controls: arrows to navigate, Alt to enter menus, Space to activate item, Enter to edit text, Escape to cancel/close, Ctrl-Tab to focus windows, etc.
+ - When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag will be set.
+ For more advanced uses, you may want to read from io.NavActive or io.NavVisible. Read imgui.cpp for more details.
+- Navigation: SetItemDefaultFocus() sets the navigation position in addition to scrolling. (#787)
+- Navigation: Added IsItemFocused(), added IsAnyItemFocused(). (#787)
+- Navigation: Added window flags: ImGuiWindowFlags_NoNav (== ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus).
+- Navigation: Style: Added ImGuiCol_NavHighlight, ImGuiCol_NavWindowingHighlight colors. (#787)
+- Navigation: TreeNode: Added ImGuiTreeNodeFlags_NavLeftJumpsBackHere flag to allow Nav Left direction to jump back to parent tree node from any of its child. (#1079)
+- Navigation: IO: Added io.ConfigFlags (input), io.NavActive (output), io.NavVisible (output). (#787)
+- Context: Removed the default global context and font atlas instances, which caused various problems to users of multiple contexts and DLL users. (#1565, #1599)
+ YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. Existing apps will assert/crash without it.
+- Context: Added SetAllocatorFunctions() to rewire memory allocators (as a replacement to previous parameters to CreateContext()). Allocators are shared by all contexts and imgui helpers. (#1565, #586, #992, #1007, #1558)
+- Context: You may pass a ImFontAtlas to CreateContext() to specify a font atlas to share. Shared font atlas are not owned by the context and not destroyed along with it. (#1599)
+- Context: Added IMGUI_DISABLE_DEFAULT_ALLOCATORS to disable linking with malloc/free. (#1565, #586, #992, #1007, #1558)
+- IO: Added io.ConfigFlags for user application to store settings for imgui and for the backend:
+ - ImGuiConfigFlags_NavEnableKeyboard: Enable keyboard navigation.
+ - ImGuiConfigFlags_NavEnableGamepad: Enable gamepad navigation (provided ImGuiBackendFlags_HasGamepad is also set by backend).
+ - ImGuiConfigFlags_NavEnableSetMousePos: Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward.
+ - ImGuiConfigFlags_NoMouseCursorChange: Instruct backend to not alter mouse cursor shape and visibility (by default the example backend use mouse cursor API of the platform when available)
+ - ImGuiConfigFlags_NoMouse: Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information passed by the backend.
+ - ImGuiConfigFlags_IsSRGB, ImGuiConfigFlags_IsTouchScreen: Flags for general application use.
+- IO: Added io.BackendFlags for backend to store its capabilities (currently: _HasGamepad, _HasMouseCursors, _HasSetMousePos). This will be used more in the next version.
+- IO: Added ImGuiKey_Insert, ImGuiKey_Space keys. Setup in all example bindings. (#1541)
+- IO: Added Horizontal Mouse Wheel support for horizontal scrolling. (#1463) [@tseeker]
+- IO: Added IsAnyMouseDown() helper which is helpful for bindings to handle mouse capturing.
+- Window: Clicking on a window with the ImGuiWIndowFlags_NoMove flags takes an ActiveId so we can't hover something else when dragging afterwards. (#1381, #1337)
+- Window: IsWindowHovered(): Added ImGuiHoveredFlags_AnyWindow, ImGuiFocusedFlags_AnyWindow flags (See Breaking Changes). Added to demo. (#1382)
+- Window: Added SetNextWindowBgAlpha() helper. Particularly helpful since the legacy 5-parameters version of Begin() has been marked as obsolete in 1.53. (#1567)
+- Window: Fixed SetNextWindowContentSize() with 0.0f on Y axis (or SetNextWindowContentWidth()) overwriting the contents size. Got broken on Dec 10 (1.53). (#1363)
+- ArrowButton: Added ArrowButton() given a cardinal direction (e.g. ImGuiDir_Left).
+- InputText: Added alternative clipboard shortcuts: Shift+Delete (cut), CTRL+Insert (copy), Shift+Insert (paste). (#1541)
+- InputText: Fixed losing Cursor X position when clicking outside on an item that's submitted after the InputText(). It was only noticeable when restoring focus programmatically. (#1418, #1554)
+- InputText: Added ImGuiInputTextFlags_CharsScientific flag to also allow 'e'/'E' for input of values using scientific notation. Automatically used by InputFloat.
+- Style: Default style is now StyleColorsDark(), instead of the old StyleColorsClassic(). (#707)
+- Style: Enable window border by default. (#707)
+- Style: Exposed ImGuiStyleVar_WindowTitleAlign, ImGuiStyleVar_ScrollbarSize, ImGuiStyleVar_ScrollbarRounding, ImGuiStyleVar_GrabRounding + added an assert to reduce accidental breakage. (#1181)
+- Style: Added style.MouseCursorScale help when using the software mouse cursor facility. (#939).
+- Style: Close button nows display a cross before hovering. Fixed cross positioning being a little off. Uses button colors for highlight when hovering. (#707)
+- Popup: OpenPopup() Always reopen existing pop-ups. (Removed imgui_internal.h's OpenPopupEx() which was used for this.) (#1497, #1533).
+- Popup: BeginPopupContextItem(), BeginPopupContextWindow(), BeginPopupContextVoid(), OpenPopupOnItemClick() all react on mouse release instead of mouse press. (~#439)
+- Popup: Better handling of user mistakenly calling OpenPopup() every frame (with reopen_existing option). The error will now be more visible and easier to understand. (#1497)
+- Popup: BeginPopup(): Exposed extra_flags parameter that are passed through to Begin(). (#1533)
+- Popup: BeginPopupModal: fixed the conditional test for SetNextWindowPos() which was polling the wrong window, which in practice made the test succeed all the time.
+- Tooltip: BeginTooltip() sets ImGuiWindowFlags_NoInputs flag.
+- Scrollbar: Fixed ScrollbarY enable test after ScrollbarX has been enabled being a little off (small regression from Nov 2017). (#1574)
+- Scrollbar: Fixed ScrollbarX enable test subtracting WindowPadding.x (this has been there since the addition of horizontal scroll bar!).
+- Columns: Clear offsets data when columns count changed. (#1525)
+- Columns: Fixed a memory leak of ImGuiColumnsSet's Columns vector. (#1529) [@unprompted]
+- Columns: Fixed resizing a window very small breaking some columns positioning (broken in 1.53).
+- Columns: The available column extent takes consideration of the right-most clipped pixel, so the right-most column may look a little wider but will contain the same amount of visible contents.
+- MenuBar: Fixed menu bar pushing a clipping rect outside of its allocated bound (usually unnoticeable).
+- TreeNode: nodes with the ImGuiTreeNodeFlags_Leaf flag correctly disable highlight when DragDrop is active. (#143, #581)
+- Drag and Drop: Increased payload type string to 32 characters instead of 8. (#143)
+- Drag and Drop: TreeNode as drop target displays rectangle over full frame. (#1597, #143)
+- DragFloat: Fix/workaround for backends which do not preserve a valid mouse position when dragged out of bounds. (#1559)
+- InputFloat: Allow inputing value using scientific notation e.g. "1e+10".
+- InputDouble: Added InputDouble() function. We use a format string instead of a decimal_precision parameter to also for "%e" and variants. (#1011)
+- Slider, Combo: Use ImGuiCol_FrameBgHovered color when hovered. (#1456) [@stfx]
+- Combo: BeginCombo(): Added ImGuiComboFlags_NoArrowButton to disable the arrow button and only display the wide value preview box.
+- Combo: BeginCombo(): Added ImGuiComboFlags_NoPreview to disable the preview and only display a square arrow button.
+- Combo: Arrow button isn't displayed over frame background so its blended color matches other buttons. Left side of the button isn't rounded.
+- PlotLines: plot a flat line if scale_min==scale_max. (#1621)
+- Fonts: Changed DisplayOffset.y to defaults to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer.
+ If you were adding or subtracting (not assigning) to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. (#1619)
+- Fonts: Updated stb_truetype from 1.14 to stb_truetype 1.19. (w/ include fix from some platforms #1622)
+- Fonts: Added optional FreeType rasterizer in misc/freetype. Moved from imgui_club repo. (#618) [@Vuhdo, @mikesart, @ocornut]
+- Fonts: Moved extra_fonts/ to misc/fonts/.
+- ImFontAtlas: Fixed cfg.MergeMode not reusing existing glyphs if available (always overwrote).
+- ImFontAtlas: Handle stb_truetype stbtt_InitFont() and stbtt_PackBegin() possible failures more gracefully, GetTexDataAsRGBA32() won't crash during conversion. (#1527)
+- ImFontAtlas: Moved mouse cursor data out of ImGuiContext, fix drawing them with multiple contexts. Also remove the last remaining undesirable dependency on ImGui in imgui_draw.cpp. (#939)
+- ImFontAtlas: Added ImFontAtlasFlags_NoPowerOfTwoHeight flag to disable padding font height to nearest power of two. (#1613)
+- ImFontAtlas: Added ImFontAtlasFlags_NoMouseCursors flag to disable baking software mouse cursors, mostly to save texture memory on very low end hardware. (#1613)
+- ImDrawList: Fixed AddRect() with anti-aliasing disabled (lower-right corner pixel was often missing, rounding looks a little better.) (#1646)
+- ImDrawList: Added CloneOutput() helper to facilitate the cloning of ImDrawData or ImDrawList for multi-threaded rendering.
+- Misc: Functions passed to libc qsort are explicitly marked cdecl to support compiling with vectorcall as the default calling convention. (#1230, #1611) [@RandyGaul]
+- Misc: ImVec2: added [] operator. This is becoming desirable for some code working of either axes independently. Better adding it sooner than later.
+- Misc: NewFrame(): Added an assert to detect incorrect filling of the io.KeyMap[] array earlier. (#1555)
+- Misc: Added IM_OFFSETOF() helper in imgui.h (previously was in imgui_internal.h)
+- Misc: Added IM_NEW(), IM_DELETE() helpers in imgui.h (previously were in imgui_internal.h)
+- Misc: Added obsolete redirection function GetItemsLineHeightWithSpacing() (which redirects to GetFrameHeightWithSpacing()), as intended and stated in docs of 1.53.
+- Misc: Added misc/natvis/imgui.natvis for visual studio debugger users to easily visualize imgui internal types. Added to examples projects.
+- Misc: Added IMGUI_USER_CONFIG to define a custom configuration filename. (#255, #1573, #1144, #41)
+- Misc: Added IMGUI_STB_TRUETYPE_FILENAME and IMGUI_STB_RECT_PACK_FILENAME compile time directives to use another version of the stb_ files.
+- Misc: Updated stb_rect_pack from 0.10 to 0.11 (minor changes).
+ (Those flags are not used by ImGui itself, they only exists to make it easy for the engine/backend to pass information to the application in a standard manner.)
+- Metrics: Added display of Columns state.
+- Demo: Improved Selectable() examples. (#1528)
+- Demo: Tweaked the Child demos, added a menu bar to the second child to test some navigation functions.
+- Demo: Console: Using ImGuiCol_Text to be more friendly to color changes.
+- Demo: Using IM_COL32() instead of ImColor() in ImDrawList centric contexts. Trying to phase out use of the ImColor helper whenever possible.
+- Examples: Files in examples/ now include their own changelog so it is easier to occasionally update your bindings if needed.
+- Examples: Using Dark theme by default. (#707). Tweaked demo code.
+- Examples: Added support for horizontal mouse wheel for API that allows it. (#1463) [@tseeker]
+- Examples: All examples now setup the io.BackendFlags to signify they can honor mouse cursors, gamepad, etc.
+- Examples: DirectX10: Fixed erroneous call to io.Fonts->ClearInputData() + ClearTexData() that was left in DX10 example but removed in 1.47 (Nov 2015) in every other backends. (#1733)
+- Examples: DirectX12: Added DirectX 12 example. (#301) [@jdm3]
+- Examples: OpenGL3+GLFW,SDL: Changed GLSL shader version from 330 to 150. (#1466, #1504)
+- Examples: OpenGL3+GLFW,SDL: Added a way to override the GLSL version string in the Init function. (#1466, #1504).
+- Examples: OpenGL3+GLFW,SDL: Creating VAO in the render function so it can be more easily used by multiple shared OpenGL contexts. (#1217)
+- Examples: OpenGL3+GLFW: Using 3.2 context instead of 3.3. (#1466)
+- Examples: OpenGL: Setting up glPixelStorei() explicitly before uploading texture.
+- Examples: OpenGL: Calls to glPolygonMode() are casting parameters as GLEnum to not fail with more strict bindings. (#1628) [@ilia-glushchenko]
+- Examples: Win32 (DirectX9,10,11,12): Added support for mouse cursor shapes. (#1495)
+- Examples: Win32 (DirectX9,10,11,12: Support for windows using the CS_DBLCLKS class flag by handling the double-click messages (WM_LBUTTONDBLCLK etc.). (#1538, #754) [@ndandoulakis]
+- Examples: Win32 (DirectX9,10,11,12): Made the Win32 proc handlers not assert if there is no active context yet, to be more flexible with creation order. (#1565)
+- Examples: GLFW: Added support for mouse cursor shapes (the diagonal resize cursors are unfortunately not supported by GLFW at the moment. (#1495)
+- Examples: GLFW: Don't attempt to change the mouse cursor input mode if it is set to GLFW_CURSOR_DISABLED by the application. (#1202) [@PhilCK]
+- Examples: SDL: Added support for mouse cursor shapes. (#1626) [@olls]
+- Examples: SDL: Using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging (SDL 2.0.4+ only, otherwise using SDL_WINDOW_INPUT_FOCUS instead of previously SDL_WINDOW_MOUSE_FOCUS). (#1559)
+- Examples: SDL: Enabled vsync by default so people don't come at us when the examples are running at 2000 FPS and burning a CPU core.
+- Examples: SDL: Using SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency() to handle frame-rate over 1000 FPS properly. (#996)
+- Examples: SDL: Using scan-code exclusively instead of a confusing mixture of scan-codes and key-codes.
+- Examples: SDL: Visual Studio: Added .vcxproj file. Using %SDL2_DIR% in the default .vcxproj and build files instead of %SDL_DIR%, the earlier being more standard.
+- Examples: Vulkan: Visual Studio: Added .vcxproj file.
+- Examples: Apple: Fixed filenames in OSX xcode project. Various other Mac friendly fixes. [@gerryhernandez etc.]
+- Examples: Visual Studio: Disabled extraneous function-level check in Release build.
+- Various fixes, tweaks, internal refactoring, optimizations, comments.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.53 (Released 2017-12-25)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.53
+
+Breaking Changes:
+
+- Renamed the emblematic `ShowTestWindow()` function to `ShowDemoWindow()`. Kept redirection function (will obsolete).
+- Renamed `GetItemsLineHeightWithSpacing()` to `GetFrameHeightWithSpacing()` for consistency. Kept redirection function (will obsolete).
+- Renamed `ImGuiTreeNodeFlags_AllowOverlapMode` flag to `ImGuiTreeNodeFlags_AllowItemOverlap`. Kept redirection enum (will obsolete).
+- Obsoleted `IsRootWindowFocused()` in favor of using `IsWindowFocused(ImGuiFocusedFlags_RootWindow)`. Kept redirection function (will obsolete). (#1382)
+- Obsoleted `IsRootWindowOrAnyChildFocused()` in favor of using `IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows)`. Kept redirection function (will obsolete). (#1382)
+- Obsoleted `IsRootWindowOrAnyChildHovered()` in favor of using `IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows)`. Kept redirection function (will obsolete). (#1382)
+- Obsoleted `SetNextWindowContentWidth() in favor of using `SetNextWindowContentSize()`. Kept redirection function (will obsolete).
+- Renamed `ImGuiTextBuffer::append()` helper to `appendf()`, and `appendv()` to `appendfv()` for consistency. If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed.
+- ImDrawList: Removed 'bool anti_aliased = true' final parameter of `ImDrawList::AddPolyline()` and `ImDrawList::AddConvexPolyFilled()`. Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame.
+- Style, ImDrawList: Renamed `style.AntiAliasedShapes` to `style.AntiAliasedFill` for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags.
+- Style, Begin: Removed `ImGuiWindowFlags_ShowBorders` window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. `style.FrameBorderSize`, `style.WindowBorderSize`, `style.PopupBorderSize`).
+ Use `ImGui::ShowStyleEditor()` to look them up.
+ Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time.
+ It is recommended that you use the `StyleColorsClassic()`, `StyleColorsDark()`, `StyleColorsLight()` functions. Also see `ShowStyleSelector()`.
+- Style: Removed `ImGuiCol_ComboBg` in favor of combo boxes using `ImGuiCol_PopupBg` for consistency. Combo are normal pop-ups.
+- Style: Renamed `ImGuiCol_ChildWindowBg` to `ImGuiCol_ChildBg`.
+- Style: Renamed `style.ChildWindowRounding` to `style.ChildRounding`, `ImGuiStyleVar_ChildWindowRounding` to `ImGuiStyleVar_ChildRounding`.
+- Removed obsolete redirection functions: SetScrollPosHere() - marked obsolete in v1.42, July 2015.
+- Removed obsolete redirection functions: GetWindowFont(), GetWindowFontSize() - marked obsolete in v1.48, March 2016.
+
+Other Changes:
+
+- Added `io.OptCursorBlink` option to allow disabling cursor blinking. (#1427) [renamed to io.ConfigCursorBlink in 1.63]
+- Added `GetOverlayDrawList()` helper to quickly get access to a ImDrawList that will be rendered in front of every windows.
+- Added `GetFrameHeight()` helper which returns `(FontSize + style.FramePadding.y * 2)`.
+- Drag and Drop: Added Beta API to easily use drag and drop patterns between imgui widgets.
+ - Setup a source on a widget with `BeginDragDropSource()`, `SetDragDropPayload()`, `EndDragDropSource()` functions.
+ - Receive data with `BeginDragDropTarget()`, `AcceptDragDropPayload()`, `EndDragDropTarget()`.
+ - See ImGuiDragDropFlags for various options.
+ - The ColorEdit4() and ColorButton() widgets now support Drag and Drop.
+ - The API is tagged as Beta as it still may be subject to small changes.
+- Drag and Drop: When drag and drop is active, tree nodes and collapsing header can be opened by hovering on them for 0.7 seconds.
+- Renamed io.OSXBehaviors to io.OptMacOSXBehaviors. Should not affect users as the compile-time default is usually enough. (#473, #650)
+- Style: Added StyleColorsDark() style. (#707) [@dougbinks]
+- Style: Added StyleColorsLight() style. Best used with frame borders + thicker font than the default font. (#707)
+- Style: Added style.PopupRounding setting. (#1112)
+- Style: Added style.FrameBorderSize, style.WindowBorderSize, style.PopupBorderSize. Removed ImGuiWindowFlags_ShowBorders window flag!
+ Borders are now fully set up in the ImGuiStyle structure. Use ImGui::ShowStyleEditor() to look them up. (#707, fix #819, #1031)
+- Style: Various small changes to the classic style (most noticeably, buttons are now using blue shades). (#707)
+- Style: Renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg.
+- Style: Renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding.
+- Style: Removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency. (#707)
+- Style: Made the ScaleAllSizes() helper rounds down every values so they are aligned on integers.
+- Focus: Added SetItemDefaultFocus(), which in the current (master) branch behave the same as doing `if (IsWindowAppearing()) SetScrollHere()`.
+ In the navigation branch this will also set the default focus. Prefer using this when creating combo boxes with `BeginCombo()` so your code will be forward-compatible with gamepad/keyboard navigation features. (#787)
+- Combo: Pop-up grows horizontally to accommodate for contents that is larger then the parent combo button.
+- Combo: Added BeginCombo()/EndCombo() API which allows use to submit content of any form and manage your selection state without relying on indices.
+- Combo: Added ImGuiComboFlags_PopupAlignLeft flag to BeginCombo() to prioritize keeping the pop-up on the left side (for small-button-looking combos).
+- Combo: Added ImGuiComboFlags_HeightSmall, ImGuiComboFlags_HeightLarge, ImGuiComboFlags_HeightLargest to easily provide desired pop-up height.
+- Combo: You can use SetNextWindowSizeConstraints() before BeginCombo() to specify specific pop-up width/height constraints.
+- Combo: Offset popup position by border size so that a double border isn't so visible. (#707)
+- Combo: Recycling windows by using a stack number instead of a unique id, wasting less memory (like menus do).
+- InputText: Added ImGuiInputTextFlags_NoUndoRedo flag. (#1506, #1508) [@ibachar]
+- Window: Fixed auto-resize allocating too much space for scrollbar when SizeContents is bigger than maximum window size (fixes c0547d3). (#1417)
+- Window: Child windows with MenuBar use regular WindowPadding.y so layout look consistent as child or as a regular window.
+- Window: Begin(): Fixed appending into a child window with a second Begin() from a different window stack querying the wrong window for the window->Collapsed test.
+- Window: Calling IsItemActive(), IsItemHovered() etc. after a call to Begin() provides item data for the title bar, so you can easily test if the title bar is being hovered, etc. (#823)
+- Window: Made it possible to use SetNextWindowPos() on a child window.
+- Window: Fixed a one frame glitch. When an appearing window claimed the focus themselves, the title bar wouldn't use the focused color for one frame.
+- Window: Added ImGuiWindowFlags_ResizeFromAnySide flag to resize from any borders or from the lower-left corner of a window. This requires your backend to honor GetMouseCursor() requests for full usability. (#822)
+- Window: Sizing fixes when using SetNextWindowSize() on individual axises.
+- Window: Hide new window for one frame until they calculate their size. Also fixes SetNextWindowPos() given a non-zero pivot. (#1694)
+- Window: Made mouse wheel scrolling accommodate better to windows that are smaller than the scroll step.
+- Window: SetNextWindowContentSize() adjust for the size of decorations (title bar/menu bar), but _not_ for borders are we consistently make borders not affect layout.
+ If you need a non-child window of an exact size with border enabled but zero window padding, you'll need to accommodate for the border size yourself.
+- Window: Using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. (#1380, #1502)
+- Window: Active Modal window always set the WantCaptureKeyboard flag. (#744)
+- Window: Moving window doesn't use accumulating MouseDelta so straying out of imgui boundaries keeps moved imgui window at the same cursor-relative position.
+- IsWindowFocused(): Added ImGuiFocusedFlags_ChildWindows flag to include child windows in the focused test. (#1382).
+- IsWindowFocused(): Added ImGuiFocusedFlags_RootWindow flag to start focused test from the root (top-most) window. Obsolete IsRootWindowFocused(). (#1382)
+- IsWindowHovered(): Added ImGuiHoveredFlags_ChildWindows flag to include child windows in the hovered test. (#1382).
+- IsWindowHovered(): Added ImGuiHoveredFlags_RootWindow flag to start hovered test from the root (top-most) window. The combination of both flags obsoletes IsRootWindowOrAnyChildHovered(). (#1382)
+- IsWindowHovered(): Fixed return value when an item is active to use the same logic as IsItemHovered(). (#1382, #1404)
+- IsWindowHovered(): Always return true when current window is being moved. (#1382)
+- Scrollbar: Fixed issues with vertical scrollbar flickering/appearing, typically when manually resizing and using a pattern of filling available height (e.g. full sized BeginChild).
+- Scrollbar: Minor graphical fix for when scrollbar don't have enough visible space to display the full grab.
+- Scrolling: Fixed padding and scrolling asymmetry where lower/right sides of a window wouldn't use WindowPadding properly + causing minor scrolling glitches.
+- Tree: TreePush with zero arguments was ambiguous. Resolved by making it call TreePush(const void*). [@JasonWilkins]
+- Tree: Renamed ImGuiTreeNodeFlags_AllowOverlapMode to ImGuiTreeNodeFlags_AllowItemOverlap. (#600, #1330)
+- MenuBar: Fixed minor rendering issues on the right size when resizing a window very small and using rounded window corners.
+- MenuBar: better software clipping to handle small windows, in particular child window don't have minimum constraints so we need to render clipped menus better.
+- BeginMenu(): Tweaked the Arrow/Triangle displayed on child menu items.
+- Columns: Clipping columns borders on Y axis on CPU because some Linux GPU drivers appears to be unhappy with triangle spanning large regions. (#125)
+- Columns: Added ImGuiColumnsFlags_GrowParentContentsSize to internal API to restore old content sizes behavior (may be obsolete). (#1444, #125)
+- Columns: Columns width is no longer lost when dragging a column to the right side of the window, until releasing the mouse button you have a chance to save them. (#1499, #125). [@ggtucker]
+- Columns: Fixed dragging when using a same of columns multiple times in the frame. (#125)
+- Indent(), Unindent(): Allow passing negative values.
+- ColorEdit4(): Made IsItemActive() return true when picker pop-up is active. (#1489)
+- ColorEdit4(): Tweaked tooltip so that the color button aligns more correctly with text.
+- ColorEdit4(): Support drag and drop. Color buttons can be used as drag sources, and ColorEdit widgets as drag targets. (#143)
+- ColorPicker4(): Fixed continuously returning true when holding mouse button on the sat/value/alpha locations. We only return true on value change. (#1489)
+- NewFrame(): using literal strings in the most-frequently firing IM_ASSERT expressions to increase the odd of programmers seeing them (especially those who don't use a debugger).
+- NewFrame() now asserts if neither Render or EndFrame have been called. Exposed EndFrame(). Made it legal to call EndFrame() more than one. (#1423)
+- ImGuiStorage: Added BuildSortByKey() helper to rebuild storage from scratch.
+- ImFont: Added GetDebugName() helper.
+- ImFontAtlas: Added missing Thai punctuation in the GetGlyphRangesThai() ranges. (#1396) [@nProtect]
+- ImDrawList: Removed 'bool anti_aliased = true' final parameter of ImDrawList::AddPolyline() and ImDrawList::AddConvexPolyFilled(). Anti-aliasing is controlled via the regular style.AntiAliased flags.
+- ImDrawList: Added ImDrawList::AddImageRounded() helper. (#845) [@thedmd]
+- ImDrawList: Refactored to make ImDrawList independent of ImGui. Removed static variable in PathArcToFast() which caused linking issues to some.
+- ImDrawList: Exposed ImDrawCornerFlags, replaced occurrences of ~0 with an explicit ImDrawCornerFlags_All. NB: Inversed BotLeft (prev 1<<3, now 1<<2) and BotRight (prev 1<<2, now 1<<3).
+- ImVector: Added ImVector::push_front() helper.
+- ImVector: Added ImVector::contains() helper.
+- ImVector: insert() uses grow_capacity() instead of using grow policy inconsistent with push_back().
+- Internals: Remove requirement to define IMGUI_DEFINE_PLACEMENT_NEW to use the IM_PLACEMENT_NEW macro. (#1103)
+- Internals: ButtonBehavior: Fixed ImGuiButtonFlags_NoHoldingActiveID flag from incorrectly setting the ActiveIdClickOffset field.
+ This had no known effect within imgui code but could have affected custom drag and drop patterns. And it is more correct this way! (#1418)
+- Internals: ButtonBehavior: Fixed ImGuiButtonFlags_AllowOverlapMode to avoid temporarily activating widgets on click before they have been correctly double-hovered. (#319, #600)
+- Internals: Added SplitterBehavior() helper. (#319)
+- Internals: Added IM_NEW(), IM_DELETE() helpers. (#484, #504, #1517)
+- Internals: Basic refactor of the settings API which now allows external elements to be loaded/saved.
+- Demo: Added ShowFontSelector() showing loaded fonts.
+- Demo: Added ShowStyleSelector() to select among default styles. (#707)
+- Demo: Renamed the emblematic ShowTestWindow() function to ShowDemoWindow().
+- Demo: Style Editor: Added a "Simplified settings" sections with check-boxes for border size and frame rounding. (#707, #1019)
+- Demo: Style Editor: Added combo box to select stock styles and select current font when multiple are loaded. (#707)
+- Demo: Style Editor: Using local storage so Save/Revert button makes more sense without code passing its storage. Added horizontal scroll bar. Fixed Save/Revert button to be always accessible. (#1211)
+- Demo: Console: Fixed context menu issue. (#1404)
+- Demo: Console: Fixed incorrect positioning which was hidden by a minor scroll issue (this would affect people who copied the Console code as is).
+- Demo: Constrained Resize: Added more test cases. (#1417)
+- Demo: Custom Rendering: Fixed clipping rectangle extruding out of parent window.
+- Demo: Layout: Removed unnecessary and misleading BeginChild/EndChild calls.
+- Demo: The "Color Picker with Palette" demo supports drag and drop. (#143)
+- Demo: Display better mouse cursor info for debugging backends.
+- Demo: Stopped using rand() function in demo code.
+- Examples: Added a handful of extra comments (about fonts, third-party libraries used in the examples, etc.).
+- Examples: DirectX9: Handle loss of D3D9 device (D3DERR_DEVICELOST). (#1464)
+- Examples: Added null_example/ which is helpful for quick testing on multiple compilers/settings without relying on graphics library.
+- Fix for using alloca() in "Clang with Microsoft Codechain" mode.
+- Various fixes, optimizations, comments.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.52 (2017-10-27)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.52
+
+Breaking Changes:
+
+- IO: `io.MousePos` needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing, instead of ImVec2(-1,-1) as previously) This is needed so we can clear `io.MouseDelta` field when the mouse is made available again.
+- Renamed `AlignFirstTextHeightToWidgets()` to `AlignTextToFramePadding()`. Kept inline redirection function (will obsolete).
+- Obsoleted the legacy 5 parameters version of Begin(). Please avoid using it. If you need a transparent window background, uses `PushStyleColor()`. The old size parameter there was also misleading and equivalent to calling `SetNextWindowSize(size, ImGuiCond_FirstTimeEver)`. Kept inline redirection function (will obsolete).
+- Obsoleted `IsItemHoveredRect()`, `IsMouseHoveringWindow()` in favor of using the newly introduced flags of `IsItemHovered()` and `IsWindowHovered()`. Kept inline redirection function (will obsolete). (#1382)
+- Obsoleted 'SetNextWindowPosCenter()' in favor of using 1SetNextWindowPos()` with a pivot value which allows to do the same and more. Keep inline redirection function.
+- Removed `IsItemRectHovered()`, `IsWindowRectHovered()` recently introduced in 1.51 which were merely the more consistent/correct names for the above functions which are now obsolete anyway. (#1382)
+- Changed `IsWindowHovered()` default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it. (#1382)
+- Renamed imconfig.h's `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS` to `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS` for consistency.
+- Renamed ImFont::Glyph to ImFontGlyph. Kept redirection typedef (will obsolete).
+
+Other Changes:
+
+- ProgressBar: fixed rendering when straddling rounded area. (#1296)
+- SliderFloat, DragFloat: Using scientific notation e.g. "%.1e" in the displayed format string doesn't mistakenly trigger rounding of the value. [@MomentsInGraphics]
+- Combo, InputFloat, InputInt: Made the small button on the right side align properly with the equivalent colored button of ColorEdit4().
+- IO: Tweaked logic for `io.WantCaptureMouse` so it now outputs false when e.g. hovering over void while an InputText() is active. (#621) [@pdoane]
+- IO: Fixed `io.WantTextInput` from mistakenly outputting true when an activated Drag or Slider was previously turned into an InputText(). (#1317)
+- Misc: Added flags to `IsItemHovered()`, `IsWindowHovered()` to access advanced hovering-test behavior. Generally useful for pop-ups and drag and drop behaviors: (relates to ~#439, #1013, #143, #925)
+ - `ImGuiHoveredFlags_AllowWhenBlockedByPopup`
+ - `ImGuiHoveredFlags_AllowWhenBlockedByActiveItem`
+ - `ImGuiHoveredFlags_AllowWhenOverlapped`
+ - `ImGuiHoveredFlags_RectOnly`
+- Input: Added `IsMousePosValid()` helper.
+- Input: Added `GetKeyPressedAmount()` to easily measure press count when the repeat rate is faster than the frame rate.
+- Input/Focus: Disabled TAB and Shift+TAB when CTRL key is held.
+- CheckBox: Now rendering a tick mark instead of a full square.
+- ColorEdit4: Added "Copy as..." option in context menu. (#346)
+- ColorPicker: Improved ColorPicker hue wheel color interpolation. (#1313) [@thevaber]
+- ColorButton: Reduced bordering artifact that would be particularly visible with an opaque Col_FrameBg and FrameRounding enabled.
+- ColorButton: Fixed rendering color button with a checkerboard if the transparency comes from the global style.Alpha and not from the actual source color.
+- TreeNode: Added `ImGuiTreeNodeFlags_FramePadding` flag to conveniently create a tree node with full padding at the beginning of a line, without having to call `AlignTextToFramePadding()`.
+- Trees: Fixed calling `SetNextTreeNodeOpen()` on a collapsed window leaking to the first tree node item of the next frame.
+- Layout: Horizontal layout is automatically enforced in a menu bar, so you can use non-MenuItem elements without calling SameLine().
+- Separator: Output a vertical separator when used inside a menu bar (or in general when horizontal layout is active, but that isn't exposed yet!).
+- Window: Added `IsWindowAppearing()` helper (helpful e.g. as a condition before initializing some of your own things.).
+- Window: Added pivot parameter to `SetNextWindowPos()`, making it possible to center or right align a window. Obsoleted `SetNextWindowPosCenter()`.
+- Window: Fixed title bar color of top-most window under a modal window.
+- Window: Fixed not being able to move a window by clicking on one of its child window. (#1337, #635)
+- Window: Fixed `Begin()` auto-fit calculation code that predict the presence of a scrollbar so it works better when window size constraints are used.
+- Window: Fixed calling `Begin()` more than once per frame setting `window_just_activated_by_user` which in turn would set enable the Appearing condition for that frame.
+- Window: The implicit "Debug" window now uses a "Debug##Default" identifier instead of "Debug" to allow user creating a window called "Debug" without losing their custom flags.
+- Window: Made the `ImGuiWindowFlags_NoMove` flag properly inherited from parent to child. In a setup with ParentWindow (no flag) -> Child (NoMove) -> SubChild (no flag), the user won't be able to move the parent window by clicking on SubChild. (#1381)
+- Popups: Pop-ups can be closed with a right-click anywhere, without altering focus under the pop-up. (~#439)
+- Popups: `BeginPopupContextItem()`, `BeginPopupContextWindow()` are now setup to allow reopening a context menu by right-clicking again. (~#439)
+- Popups: `BeginPopupContextItem()` now supports a NULL string identifier and uses the last item ID if available.
+- Popups: Added `OpenPopupOnItemClick()` helper which mimic `BeginPopupContextItem()` but doesn't do the BeginPopup().
+- MenuItem: Only activating on mouse release. [@Urmeli0815] (was already fixed in nav branch).
+- MenuItem: Made tick mark thicker (thick mark?).
+- MenuItem: Tweaks to be usable inside a menu bar (nb: it looks like a regular menu and thus is misleading, prefer using Button() and regular widgets in menu bar if you need to). (#1387)
+- ImDrawList: Fixed a rare draw call merging bug which could lead to undisplayed triangles. (#1172, #1368)
+- ImDrawList: Fixed a rare bug in `ChannelsMerge()` when all contents has been clipped, leading to an extraneous draw call being created. (#1172, #1368)
+- ImFont: Added `AddGlyph()` building helper for use by custom atlas builders.
+- ImFontAtlas: Added support for CustomRect API to submit custom rectangles to be packed into the atlas. You can map them as font glyphs, or use them for custom purposes.
+ After the atlas is built you can query the position of your rectangles in the texture and then copy your data there. You can use this features to create e.g. full color font-mapped icons.
+- ImFontAtlas: Fixed fall-back handling when merging fonts, if a glyph was missing from the second font input it could have used a glyph from the first one. (#1349) [@inolen]
+- ImFontAtlas: Fixed memory leak on build failure case when stbtt_InitFont failed (generally due to incorrect or supported font type). (#1391) (@Moka42)
+- ImFontConfig: Added `RasterizerMultiply` option to alter the brightness of individual fonts at rasterization time, which may help increasing readability for some.
+- ImFontConfig: Added `RasterizerFlags` to pass options to custom rasterizer (e.g. the [imgui_freetype](https://github.com/ocornut/imgui_club/tree/master/imgui_freetype) rasterizer in imgui_club has such options).
+- ImVector: added resize() variant with initialization value.
+- Misc: Changed the internal name formatting of child windows identifier to use slashes (instead of dots) as separator, more readable.
+- Misc: Fixed compilation with `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` defined.
+- Misc: Marked all format+va_list functions with format attribute so GCC/Clang can warn about misuses.
+- Misc: Fixed compilation on NetBSD due to missing alloca.h (#1319) [@RyuKojiro]
+- Misc: Improved warnings compilation for newer versions of Clang. (#1324) (@waywardmonkeys)
+- Misc: Added `io.WantMoveMouse flags` (from Nav branch) and honored in Examples applications. Currently unused but trying to spread Examples applications code that supports it.
+- Misc: Added `IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS` support in imconfig.h to allow user reimplementing the `ImFormatString()` functions e.g. to use stb_printf(). (#1038)
+- Misc: [Windows] Fixed default Win32 `SetClipboardText()` handler leaving the Win32 clipboard handler unclosed on failure. [@pdoane]
+- Style: Added `ImGuiStyle::ScaleAllSizes(float)` helper to make it easier to have application transition e.g. from low to high DPI with a matching style.
+- Metrics: Draw window bounding boxes when hovering Pos/Size; List all draw layers; Trimming empty commands like Render() does.
+- Examples: OpenGL3: Save and restore sampler state. (#1145) [@nlguillemot]
+- Examples: OpenGL2, OpenGL3: Save and restore polygon mode. (#1307) [@JJscott]
+- Examples: DirectX11: Allow creating device with feature level 10 since we don't really need much for that example. (#1333)
+- Examples: DirectX9/10/12: Using the Win32 SetCapture/ReleaseCapture API to read mouse coordinates when they are out of bounds. (#1375) [@Gargaj, @ocornut]
+- Tools: Fixed binary_to_compressed_c tool to return 0 when successful. (#1350) [@benvanik]
+- Internals: Exposed more helpers and unfinished features in imgui_internal.h. (use at your own risk!).
+- Internals: A bunch of internal refactoring, hopefully haven't broken anything! Merged a bunch of internal changes from the upcoming Navigation branch.
+- Various tweaks, fixes and documentation changes.
+
+Beta Navigation Branch:
+(Lots of work has been done toward merging the Beta Gamepad/Keyboard Navigation branch (#787) in master.)
+(Please note that this branch is always kept up to date with master. If you are using the navigation branch, some of the changes include:)
+- Nav: Added `#define IMGUI_HAS_NAV` in imgui.h to ease sharing code between both branches. (#787)
+- Nav: MainMenuBar now releases focus when user gets out of the menu layer. (#787)
+- Nav: When applying focus to a window with only menus, the menu layer is automatically activated. (#787)
+- Nav: Added `ImGuiNavInput_KeyMenu` (~Alt key) aside from ImGuiNavInput_PadMenu input as it is one differentiator of pad vs keyboard that was detrimental to the keyboard experience. Although isn't officially supported, it makes the current experience better. (#787)
+- Nav: Move requests now wrap vertically inside Menus and Pop-ups. (#787)
+- Nav: Allow to collapse tree nodes with NavLeft and open them with NavRight. (#787, #1079).
+- Nav: It's now possible to navigate sibling of a menu-bar while navigating inside one of their child. If a Left<>Right navigation request fails to find a match we forward the request to the root menu. (#787, #126)
+- Nav: Fixed `SetItemDefaultFocus` from stealing default focus when we are initializing default focus for a menu bar layer. (#787)
+- Nav: Support for fall-back horizontal scrolling with PadLeft/PadRight (nb: fall-back scrolling is only used to navigate windows that have no interactive items). (#787)
+- Nav: Fixed tool-tip from being selectable in the window selection list. (#787)
+- Nav: `CollapsingHeader(bool*)` variant: fixed for `IsItemHovered()` not working properly in the nav branch. (#600, #787)
+- Nav: InputText: Fixed using Up/Down history callback feature when Nav is enabled. (#787)
+- Nav: InputTextMultiline: Fixed navigation/selection. Disabled selecting all when activating a multi-line text editor. (#787)
+- Nav: More consistently drawing a (thin) navigation rectangle hover filled frames such as tree nodes, collapsing header, menus. (#787)
+- Nav: Various internal refactoring.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.51 (2017-08-24)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.51
+
+Breaking Changes:
+
+Work on dear imgui has been gradually resuming. It means that fixes and new features should be tackled at a faster rate than last year. However, in order to move forward with the library and get rid of some cruft, I have taken the liberty to be a little bit more aggressive than usual with API breaking changes. Read the details below and search for those names in your code! In the grand scheme of things, those changes are small and should not affect everyone, but this is technically our most aggressive release so far in term of API breakage. If you want to be extra forward-facing, you can enable `#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in your imconfig.h to disable the obsolete names/redirection.
+
+- Renamed `IsItemHoveredRect()` to `IsItemRectHovered()`. Kept inline redirection function (will obsolete).
+- Renamed `IsMouseHoveringWindow()` to `IsWindowRectHovered()` for consistency. Kept inline redirection function (will obsolete).
+- Renamed `IsMouseHoveringAnyWindow()` to `IsAnyWindowHovered()` for consistency. Kept inline redirection function (will obsolete).
+- Renamed `ImGuiCol_Columns***` enums to `ImGuiCol_Separator***`. Kept redirection enums (will obsolete).
+- Renamed `ImGuiSetCond***` types and enums to `ImGuiCond***`. Kept redirection enums (will obsolete).
+- Renamed `GetStyleColName()` to `GetStyleColorName()` for consistency. Unlikely to be used by end-user!
+- Added `PushStyleColor(ImGuiCol idx, ImU32 col)` overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicitly to fix.
+- Marked the weird `IMGUI_ONCE_UPON_A_FRAME` helper macro as obsolete. Prefer using the more explicit `ImGuiOnceUponAFrame`.
+- Changed `ColorEdit4(const char* label, float col[4], bool show_alpha = true)` signature to `ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)`, where flags 0x01 is a safe no-op (hello dodgy backward compatibility!). The new `ColorEdit4`/`ColorPicker4` functions have lots of available flags! Check and run the demo window, under "Color/Picker Widgets", to understand the various new options.
+- Changed signature of `ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)` to `ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0))`. This function was rarely used and was very dodgy (no explicit ID!).
+- Changed `BeginPopupContextWindow(bool also_over_items=true, const char* str_id=NULL, int mouse_button=1)` signature to `(const char* str_id=NULL, int mouse_button=1, bool also_over_items=true)`. This is perhaps the most aggressive change in this update, but note that the majority of users relied on default parameters completely, so this will affect only a fraction of users of this already rarely used function.
+- Removed `IsPosHoveringAnyWindow()`, which was partly broken and misleading. In the vast majority of cases, people using that function wanted to use `io.WantCaptureMouse` flag. Replaced with IM_ASSERT + comment redirecting user to `io.WantCaptureMouse`. (#1237)
+- Removed the old `ValueColor()` helpers, they are equivalent to calling `Text(label)` + `SameLine()` + `ColorButton()`.
+- Removed `ColorEditMode()` and `ImGuiColorEditMode` type in favor of `ImGuiColorEditFlags` and parameters to the various Color*() functions. The `SetColorEditOptions()` function allows to initialize default but the user can still change them with right-click context menu. Commenting out your old call to `ColorEditMode()` may just be fine!
+
+Other Changes:
+
+- Added flags to `ColorEdit3()`, `ColorEdit4()`. The color edit widget now has a context-menu and access to the color picker. (#346)
+- Added flags to `ColorButton()`. (#346)
+- Added `ColorPicker3()`, `ColorPicker4()`. The API along with those of the updated `ColorEdit4()` was designed so you may use them in various situation and hopefully compose your own picker if required. There are a bunch of available flags, check the Demo window and comment for `ImGuiColorEditFlags_`. Some of the options it supports are: two color picker types (hue bar + sat/val rectangle, hue wheel + rotating sat/val triangle), display as u8 or float, lifting 0.0..1.0 constraints (currently rgba only), context menus, alpha bar, background checkerboard options, preview tooltip, basic revert. For simple use, calling the existing `ColorEdit4()` function as you did before will be enough, as you can now open the color picker from there. (#346) [@r-lyeh, @nem0, @thennequin, @dariomanesku and @ocornut]
+- Added `SetColorEditOptions()` to set default color options (e.g. if you want HSV over RGBA, float over u8, select a default picker mode etc. at startup time without a user intervention. Note that the user can still change options with the context menu unless disabled with `ImGuiColorFlags_NoOptions` or explicitly enforcing a display type/picker mode etc.).
+- Added user-facing `IsPopupOpen()` function. (#891) [@mkeeter]
+- Added `GetColorU32(u32)` variant that perform the style alpha multiply without a floating-point round trip, and helps makes code more consistent when using ImDrawList APIs.
+- Added `PushStyleColor(ImGuiCol idx, ImU32 col)` overload.
+- Added `GetStyleColorVec4(ImGuiCol idx)` which is equivalent to accessing `ImGui::GetStyle().Colors[idx]` (aka return the raw style color without alpha alteration).
+- ImFontAtlas: Added `GlyphRangesBuilder` helper class, which makes it easier to build custom glyph ranges from your app/game localization data, or add into existing glyph ranges.
+- ImFontAtlas: Added `TexGlyphPadding` option. (#1282) [@jadwallis]
+- ImFontAtlas: Made it possible to override size of AddFontDefault() (even if it isn't really recommended!).
+- ImDrawList: Added `GetClipRectMin()`, `GetClipRectMax()` helpers.
+- Fixed Ini saving crash if the ImGuiWindowFlags_NoSavedSettings gets removed from a window after its creation (unlikely!). (#1000)
+- Fixed `PushID()`/`PopID()` from marking parent window as Accessed (which needlessly woke up the root "Debug" window when used outside of a regular window). (#747)
+- Fixed an assert when calling `CloseCurrentPopup()` twice in a row. [@nem0]
+- Window size can be loaded from .ini data even if ImGuiWindowFlags_NoResize flag is set. (#1048, #1056)
+- Columns: Added `SetColumnWidth()`. (#913) [@ggtucker]
+- Columns: Dragging a column preserve its width by default. (#913) [@ggtucker]
+- Columns: Fixed first column appearing wider than others. (#1266)
+- Columns: Fixed allocating space on the right-most side with the assumption of a vertical scrollbar. The space is only allocated when needed. (#125, #913, #893, #1138)
+- Columns: Fixed the right-most column from registering its content width to the parent window, which led to various issues when using auto-resizing window or e.g. horizontal scrolling. (#519, #125, #913)
+- Columns: Refactored some of the columns code internally toward a better API (not yet exposed) + minor optimizations. (#913) [@ggtucker, @ocornut]
+- Popups: Most pop-ups windows can be moved by the user after appearing (if they don't have explicit positions provided by caller, or e.g. sub-menu pop-up). The previous restriction was totally arbitrary. (#1252)
+- Tooltip: `SetTooltip()` is expanded immediately into a window, honoring current font / styling setting. Add internal mechanism to override tooltips. (#862)
+- PlotHistogram: bars are drawn based on zero-line, so negative values are going under. (#828)
+- Scrolling: Fixed return values of `GetScrollMaxX()`, `GetScrollMaxY()` when both scrollbars were enabled. Tweak demo to display more data. (#1271) [@degracode]
+- Scrolling: Fixes for Vertical Scrollbar not automatically getting enabled if enabled Horizontal Scrollbar straddle the vertical limit. (#1271, #246)
+- Scrolling: `SetScrollHere()`, `SetScrollFromPosY()`: Fixed Y scroll aiming when Horizontal Scrollbar is enabled. (#665).
+- [Windows] Clipboard: Fixed not closing Win32 clipboard on early open failure path. (#1264)
+- Removed an unnecessary dependency on int64_t which failed on some older compilers.
+- Demo: Rearranged everything under Widgets in a more consistent way.
+- Demo: Columns: Added Horizontal Scrolling demo. Tweaked another Columns demo. (#519, #125, #913)
+- Examples: OpenGL: Various makefiles for MINGW, Linux. (#1209, #1229, #1209) [@fr500, @acda]
+- Examples: Enabled vsync by default in example applications, so it doesn't confuse people that the sample run at 2000+ fps and waste an entire CPU. (#1213, #1151).
+- Various other small fixes, tweaks, comments, optimizations.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.50 (2017-06-02)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.50
+
+Breaking Changes:
+
+- Added a void* user_data parameter to Clipboard function handlers. (#875)
+- SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
+- Renamed ImDrawList::PathFill() - rarely used directly - to ImDrawList::PathFillConvex() for clarity and consistency.
+- Removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset.
+- Style: style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
+- BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild().
+
+Other Changes:
+
+- InputText(): Added support for CTRL+Backspace (delete word).
+- InputText(): OSX uses Super+Arrows for home/end. Add Shortcut+Backspace support. (#650) [@michaelbartnett]
+- InputText(): Got rid of individual OSX-specific options in ImGuiIO, added a single io.OSXBehaviors flag. (#473, #650)
+- InputText(): Fixed pressing home key on last character when it isn't a trailing \n (#588, #815)
+- InputText(): Fixed state corruption/crash bug in stb_textedit.h redo logic when exhausting undo/redo char buffer. (#715. #681)
+- InputTextMultiline(): Fixed CTRL+DownArrow moving scrolling out of bounds.
+- InputTextMultiline(): Scrollbar fix for when input and latched internal buffers differs in a way that affects vertical scrollbar existence. (#725)
+- ImFormatString(): Fixed an overflow handling bug with implementation of vsnprintf() that do not return -1. (#793)
+- BeginChild(const char*) now applies stack id to provided label, consistent with other widgets. (#894, #713)
+- SameLine() with explicit X position is relative to left of group/columns. (ref #746, #125, #630)
+- SliderInt(), SliderFloat() supports reverse direction (where v_min > v_max). (#854)
+- SliderInt(), SliderFloat() better support for when v_min==v_max. (#919)
+- SliderInt(), SliderFloat() enforces writing back value when interacting, to be consistent with other widgets. (#919)
+- SliderInt, SliderFloat(): Fixed edge case where style.GrabMinSize being bigger than slider width can lead to a division by zero. (#919)
+- Added IsRectVisible() variation with explicit start-end positions. (#768) [@thedmd]
+- Fixed TextUnformatted() clipping bug in the large-text path when horizontal scroll has been applied. (#692, #246)
+- Fixed minor text clipping issue in window title when using font straying above usual line. (#699)
+- Fixed SetCursorScreenPos() fixed not adjusting CursorMaxPos as well.
+- Fixed scrolling offset when using SetScrollY(), SetScrollFromPosY(), SetScrollHere() with menu bar.
+- Fixed using IsItemActive() after EndGroup() or any widget using groups. (#840, #479)
+- Fixed IsItemActive() lagging by one frame on initial widget activation. (#840)
+- Fixed Separator() zero-height bounding box resulting in clipping when laying exactly on top line of clipping rectangle (#860)
+- Fixed PlotLines() PlotHistogram() calling with values_count == 0.
+- Fixed clicking on a window's void while staying still overzealously marking .ini settings as dirty. (#923)
+- Fixed assert triggering when a window has zero rendering but has a callback. (#810)
+- Scrollbar: Fixed rendering when sizes are negative to reduce glitches (which can happen with certain style settings and zero WindowMinSize).
+- EndGroup(): Made IsItemHovered() work when an item was activated within the group. (#849)
+- BulletText(): Fixed stopping to display formatted string after the '##' mark.
+- Closing the focused window restore focus to the first active root window in descending z-order .(part of #727)
+- Word-wrapping: Fixed a bug where we never wrapped after a 1 character word. [@sronsse]
+- Word-wrapping: Fixed TextWrapped() overriding wrap position if one is already set. (#690)
+- Word-wrapping: Fixed incorrect testing for negative wrap coordinates, they are perfectly legal. (#706)
+- ImGuiListClipper: Fixed automatic-height calc path dumbly having user display element 0 twice. (#661, #716)
+- ImGuiListClipper: Fix to behave within column. (#661, #662, #716)
+- ImDrawList: Renamed ImDrawList::PathFill() to ImDrawList::PathFillConvex() for clarity. (BREAKING API)
+- Columns: End() avoid calling Columns(1) if no columns set is open, not sure why it wasn't the case already (pros: faster, cons: exercise less code).
+- ColorButton(): Fix ColorButton showing wrong hex value for alpha. (#1068) [@codecat]
+- ColorEdit4(): better preserve inputting value out of 0..255 range, display then clamped in Hexadecimal form.
+- Shutdown() clear out some remaining pointers for sanity. (#836)
+- Added IMGUI_USE_BGRA_PACKED_COLOR option in imconfig.h (#767, #844) [@thedmd]
+- Style: Removed the inconsistent shadow under RenderCollapseTriangle() (~#707)
+- Style: Added ButtonTextAlign, ImGuiStyleVar_ButtonTextAlign. (#842)
+- ImFont: Allowing to use up to 0xFFFE glyphs in same font (increased from previous 0x8000).
+- ImFont: Added GetGlyphRangesThai() helper. [@nProtect]
+- ImFont: CalcWordWrapPositionA() fixed font scaling with fallback character.
+- ImFont: Calculate and store the approximate texture surface to get an idea of how costly each source font is.
+- ImFontConfig: Added GlyphOffset to explicitly offset glyphs at font build time, useful for merged fonts. Removed MergeGlyphCenterV. (BREAKING API)
+- Clarified asserts in CheckStacksSize() when there is a stack mismatch.
+- Context: Support for #define-ing GImGui and IMGUI_SET_CURRENT_CONTEXT_FUNC to enable custom thread-based hackery (#586)
+- Updated stb_truetype.h to 1.14 (added OTF support, removed warnings). (#883, #976)
+- Updated stb_rect_pack.h to 0.10 (removed warnings). (#883)
+- Added ImGuiMouseCursor_None enum value for convenient usage by app/binding.
+- Clipboard: Added a void* user_data parameter to Clipboard function handlers. (#875) (BREAKING API)
+- Internals: Refactor internal text alignment options to use ImVec2, removed ImGuiAlign. (#842, #222)
+- Internals: Renamed ImLoadFileToMemory to ImFileLoadToMemory to be consistent with ImFileOpen + fix mismatching .h name. (#917)
+- OS/Windows: Fixed Windows default clipboard handler leaving its buffer unfreed on application's exit. (#714)
+- OS/Windows: No default IME handler when compiling for Windows using GCC. (#738)
+- OS/Windows: Now using _wfopen() instead of fopen() to allow passing in paths/filenames with UTF-8 characters. (#917)
+- Tools: binary_to_compressed_c: Avoid ?? trigraphs sequences in string outputs which break some older compilers. (#839)
+- Demo: Added an extra 3-way columns demo.
+- Demo: ShowStyleEditor: show font character map / grid in more details.
+- Demo: Console: Fixed a completion bug when multiple candidates are equals and match until the end.
+- Demo: Fixed 1-byte off overflow in the ShowStyleEditor() combo usage. (#783) [@bear24rw]
+- Examples: Accessing ImVector fields directly, feel less stl-ey. (#810)
+- Examples: OpenGL*: Saving/restoring existing scissor rectangle for completeness. (#807)
+- Examples: OpenGL*: Saving/restoring active texture number (the value modified by glActiveTexture). (#1087, #1088, #1116)
+- Examples: OpenGL*: Saving/restoring separate color/alpha blend functions correctly. (#1120) [@greggman]
+- Examples: OpenGL2: Uploading font texture as RGBA32 to increase compatibility with users shaders for beginners. (#824)
+- Examples: Vulkan: Countless fixes and improvements. (#785, #804, #910, #1017, #1039, #1041, #1042, #1043, #1080) [@martty, @Loftilus, @ParticlePeter, @SaschaWillems]
+- Examples: DirectX9/10/10: Only call SetCursor(NULL) is io.MouseDrawCursor is set. (#585, #909)
+- Examples: DirectX9: Explicitly setting viewport to match that other examples are doing. (#937)
+- Examples: GLFW+OpenGL3: Fixed Shutdown() calling GL functions with NULL parameters if NewFrame was never called. (#800)
+- Examples: GLFW+OpenGL2: Renaming opengl_example/ to opengl2_example/ for clarity.
+- Examples: SDL+OpenGL: explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
+- Examples: SDL2: Added build .bat files for Win32.
+- Added various links to language/engine bindings.
+- Various other minor fixes, tweaks, comments, optimizations.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.49 (2016-05-09)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.49
+
+Breaking Changes:
+
+- Renamed `SetNextTreeNodeOpened()` to `SetNextTreeNodeOpen()` for consistency, no redirection.
+- Removed confusing set of `GetInternalState()`, `GetInternalStateSize()`, `SetInternalState()` functions. Now using `CreateContext()`, `DestroyContext()`, `GetCurrentContext()`, `SetCurrentContext()`. If you were using multiple contexts the change should be obvious and trivial.
+- Obsoleted old signature of `CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false)`, as extra parameters were badly designed and rarely used. Most uses were using 1 parameter and shouldn't affect you. You can replace the "default_open = true" flag in new API with `CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen)`.
+- Changed `ImDrawList::PushClipRect(ImVec4 rect)` to `ImDraw::PushClipRect(ImVec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false)`. Note that higher-level `ImGui::PushClipRect()` is preferable because it will clip at logic/widget level, whereas `ImDrawList::PushClipRect()` only affect your renderer.
+- Title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore (see #655). If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you. However if your TitleBg/TitleBgActive alpha was <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar.
+ This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color. (Or If this is confusing, just pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color.)
+
+ ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col)
+ {
+ float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w));
+ float k = title_bg_col.w / new_a;
+ return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a);
+ }
+
+Other changes:
+
+- New version of ImGuiListClipper helper calculates item height automatically. See comments and demo code. (#662, #661, #660)
+- Added SetNextWindowSizeConstraints() to enable basic min/max and programmatic size constraints on window. Added demo. (#668)
+- Added PushClipRect()/PopClipRect() (previously part of imgui_internal.h). Changed ImDrawList::PushClipRect() prototype. (#610)
+- Added IsRootWindowOrAnyChildHovered() helper. (#615)
+- Added TreeNodeEx() functions. (#581, #600, #190)
+- Added ImGuiTreeNodeFlags_Selected flag to display TreeNode as "selected". (#581, #190)
+- Added ImGuiTreeNodeFlags_AllowOverlapMode flag. (#600)
+- Added ImGuiTreeNodeFlags_NoTreePushOnOpen flag (#590).
+- Added ImGuiTreeNodeFlags_NoAutoOpenOnLog flag (previously private).
+- Added ImGuiTreeNodeFlags_DefaultOpen flag (previously private).
+- Added ImGuiTreeNodeFlags_OpenOnDoubleClick flag.
+- Added ImGuiTreeNodeFlags_OpenOnArrow flag.
+- Added ImGuiTreeNodeFlags_Leaf flag, always opened, no arrow, for convenience. For simple use case prefer using TreeAdvanceToLabelPos()+Text().
+- Added ImGuiTreeNodeFlags_Bullet flag, to add a bullet to Leaf node or replace Arrow with a bullet.
+- Added TreeAdvanceToLabelPos(), GetTreeNodeToLabelSpacing() helpers. (#581, #324)
+- Added CreateContext()/DestroyContext()/GetCurrentContext()/SetCurrentContext(). Obsoleted nearly identical GetInternalState()/SetInternalState() functions. (#586, #269)
+- Added NewLine() to undo a SameLine() and as a shy reminder that horizontal layout support hasn't been implemented yet.
+- Added IsItemClicked() helper. (#581)
+- Added CollapsingHeader() variant with close button. (#600)
+- Fixed MenuBar missing lower border when borders are enabled.
+- InputText(): Fixed clipping of cursor rendering in case it gets out of the box (which can be forced w/ ImGuiInputTextFlags_NoHorizontalScroll. (#601)
+- Style: Changed default IndentSpacing from 22 to 21. (#581, #324)
+- Style: Fixed TitleBg/TitleBgActive color being rendered above WindowBg color, which was inconsistent and causing visual artifact. (#655)
+ This broke the meaning of TitleBg and TitleBgActive. Only affect values where Alpha<1.0f. Fixed default theme. Read comments in "API BREAKING CHANGES" section to convert.
+- Relative rendering of order of Child windows creation is preserved, to allow more control with overlapping children. (#595)
+- Fixed GetWindowContentRegionMax() being off by ScrollbarSize amount when explicit SizeContents is set.
+- Indent(), Unindent(): optional non-default indenting width. (#324, #581)
+- Bullet(), BulletText(): Slightly bigger. Less polygons.
+- ButtonBehavior(): fixed subtle old bug when a repeating button would also return true on mouse release (barely noticeable unless RepeatRate is set to be very slow). (#656)
+- BeginMenu(): a menu that becomes disabled while open gets closed down, facilitate user's code. (#126)
+- BeginGroup(): fixed using within Columns set. (#630)
+- Fixed a lag in reading the currently hovered window when dragging a window. (#635)
+- Obsoleted 4 parameters version of CollapsingHeader(). Refactored code into TreeNodeBehavior. (#600, #579)
+- Scrollbar: minor fix for top-right rounding of scrollbar background when window has menu bar but no title bar.
+- MenuItem(): the check mark renders in disabled color when menu item is disabled.
+- Fixed clipping rectangle floating point representation to ensure renderer-side float point operations yield correct results in typical DirectX/GL settings. (#582, 597)
+- Fixed GetFrontMostModalRootWindow(), fixing missing fade-out when a combo pop was used stacked over a modal window. (#604)
+- ImDrawList: Added AddQuad(), AddQuadFilled() helpers.
+- ImDrawList: AddText() refactor, moving some code to ImFont, reserving less unused vertices when large vertical clipping occurs.
+- ImFont: Added RenderChar() helper.
+- ImFont: Added AddRemapChar() helper. (#609)
+- ImFontConfig: Clarified persistence requirement of GlyphRanges array. (#651)
+- ImGuiStorage: Added bool helper functions for completeness.
+- AddFontFromMemoryCompressedTTF(): Fix ImFontConfig propagation. (#587)
+- Renamed majority of use of the word "opened" to "open" for clarity. Renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(). (#625, #579)
+- Examples: OpenGL3: Saving/restoring glActiveTexture() state. (#602)
+- Examples: DirectX9: save/restore all device state.
+- Examples: DirectX9: Removed dependency on d3dx9.h, d3dx9.lib, dxguid.lib so it can be used in a DirectXMath.h only environment. (#611)
+- Examples: DirectX10/X11: Apply depth-stencil state (no use of depth buffer). (#640, #636)
+- Examples: DirectX11/X11: Added comments on removing dependency on D3DCompiler. (#638)
+- Examples: SDL: Initialize video+timer subsystem only.
+- Examples: Apple/iOS: lowered XCode project deployment target from 10.7 to 10.11. (#598, #575)
+
+
+-----------------------------------------------------------------------
+ VERSION 1.48 (2016-04-09)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.48
+
+Breaking Changes:
+
+- Consistently honoring exact width passed to PushItemWidth() (when positive), previously it would add extra FramePadding.x*2 over that width. Some hand-tuned layout may be affected slightly. (#346)
+- Style: removed `style.WindowFillAlphaDefault` which was confusing and redundant, baked alpha into `ImGuiCol_WindowBg` color. If you had a custom WindowBg color but didn't change WindowFillAlphaDefault, multiply WindowBg alpha component by 0.7. Renamed `ImGuiCol_TooltipBg` to `ImGuiCol_PopupBG`, applies to other types of pop-ups. `bg_alpha` parameter of 5-parameters version of Begin() is an override. (#337)
+- InputText(): Added BufTextLen field in ImGuiTextEditCallbackData. Requesting user to update it if the buffer is modified in the callback. Added a temporary length-check assert to minimize panic for the 3 people using the callback. (#541)
+- Renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete). (#340)
+
+Other Changes:
+
+- Consistently honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. Some hand-tuned layout may be affected slightly. (#346)
+- Fixed clipping of child windows within parent not taking account of child outer clipping boundaries (including scrollbar, etc.). (#506)
+- TextUnformatted(): Fixed rare crash bug with large blurb of text (2k+) not finished with a '\n' and fully above the clipping Y line. (#535)
+- IO: Added 'KeySuper' field to hold CMD keyboard modifiers for OS X. Updated all examples accordingly. (#473)
+- Added ImGuiWindowFlags_ForceVerticalScrollbar, ImGuiWindowFlags_ForceHorizontalScrollbar flags. (#476)
+- Added IM_COL32 macros to generate a U32 packed color, convenient for direct use of ImDrawList api. (#346)
+- Added GetFontTexUvWhitePixel() helper, convenient for direct use of ImDrawList api.
+- Selectable(): Added ImGuiSelectableFlags_AllowDoubleClick flag to allow user reacting on double-click. (@zapolnov) (#516)
+- Begin(): made the close button explicitly set the boolean to false instead of toggling it. (#499)
+- BeginChild()/EndChild(): fixed incorrect layout to allow widgets submitted after an auto-fitted child window. (#540)
+- BeginChild(): Added ImGuiWindowFlags_AlwaysUseWindowPadding flag to ensure non-bordered child window uses window padding. (#462)
+- Fixed InputTextMultiLine(), ListBox(), BeginChildFrame(), ProgressBar(): outer frame not honoring bordering. (#462, #503)
+- Fixed Image(), ImageButtion() rendering a rectangle 1 px too large on each axis. (#457)
+- SetItemAllowOverlap(): Promoted from imgui_internal.h to public imgui.h api. (#517)
+- Combo(): Right-most button stays highlighted when pop-up is open.
+- Combo(): Display pop-up above if there's isn't enough space below / or select largest side. (#505)
+- DragFloat(), SliderFloat(), InputFloat(): fixed cases of erroneously returning true repeatedly after a text input modification (e.g. "0.0" --> "0.000" would keep returning true). (#564)
+- DragFloat(): Always apply value when mouse is held/widget active, so that an always-reseting variable (e.g. non saved local) can be passed.
+- InputText(): OS X friendly behaviors: Word movement uses ALT key; Shortcuts uses CMD key; Double-clicking text select a single word; Jumping to next word sets cursor to end of current word instead of beginning of current word. (@zhiayang), (#473)
+- InputText(): Added BufTextLen in ImGuiTextEditCallbackData. Requesting user to maintain it if buffer is modified. Zero-ing structure properly before use. (#541)
+- CheckboxFlags(): Added support for testing/setting multiple flags at the same time. (@DMartinek) (#555)
+- TreeNode(), CollapsingHeader() fixed not being able to use "##" sequence in a formatted label.
+- ColorEdit4(): Empty label doesn't add InnerSpacing.x, matching behavior of other widgets. (#346)
+- ColorEdit4(): Removed unnecessary calls to scanf() when idle in hexadecimal edit mode.
+- BeginPopupContextItem(), BeginPopupContextWindow(): added early out optimization.
+- CaptureKeyboardFromApp() / CaptureMouseFromApp(): added argument to allow clearing the capture flag. (#533)
+- ImDrawList: Fixed index-overflow check broken by AddText() casting current index back to ImDrawIdx. (#514)
+- ImDrawList: Fixed incorrect removal of trailing draw command if it is a callback command.
+- ImDrawList: Allow windows with only a callback only to be functional. (#524)
+- ImDrawList: Fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis. (#457)
+- ImDrawList: Fixed ImDrawList::AddCircle() to fit precisely within bounding box like AddCircleFilled() and AddRectFilled(). (#457)
+- ImDrawList: AddCircle(), AddRect() takes optional thickness parameter.
+- ImDrawList: Added AddTriangle().
+- ImDrawList: Added PrimQuadUV() helper to ease custom rendering of textured quads (require primitive reserve).
+- ImDrawList: Allow AddText(ImFont\* font, float font_size, ...) variant to take NULL/0.0f as default.
+- ImFontAtlas: heuristic increase default texture width up for large number of glyphs. (#491)
+- ImTextBuffer: Fixed empty() helper which was utterly broken.
+- Metrics: allow to inspect individual triangles in draw calls.
+- Demo: added more draw primitives in the Custom Rendering example. (#457)
+- Demo: extra comments and example for PushItemWidth(-1) patterns.
+- Demo: InputText password demo filters out blanks. (#515)
+- Demo: Fixed malloc/free mismatch and leak when destructing demo console, if it has been used. (@fungos) (#536)
+- Demo: plot code doesn't use ImVector to avoid heap allocation and be more friendly to custom allocator users. (#538)
+- Fixed compilation on DragonFly BSD (@mneumann) (#563)
+- Examples: Vulkan: Added a Vulkan example (@Loftilus) (#549)
+- Examples: DX10, DX11: Saving/restoring most device state so dropping render function in your codebase shouldn't have DX device side-effects. (#570)
+- Examples: DX10, DX11: Fixed ImGui_ImplDX??_NewFrame() from recreating device objects if render isn't called (g_pVB not set).
+- Examples: OpenGL3: Fix BindVertexArray/BindBuffer order. (@nlguillemot) (#527)
+- Examples: OpenGL: skip rendering and calling glViewport() if we have zero-fixed buffer. (#486)
+- Examples: SDL2+OpenGL3: Fix context creation options. Made ImGui_ImplSdlGL3_NewFrame() signature match GL2 one. (#468, #463)
+- Examples: SDL2+OpenGL2/3: Fix for high-dpi displays. (@nickgravelyn)
+- Various extra comments and clarification in the code.
+- Various other fixes and optimizations.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.47 (2015-12-25)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.47
+
+Changes:
+
+- Rebranding "ImGui" -> "dear imgui" as an optional first name to reduce ambiguity with IMGUI term. (#21)
+- Added ProgressBar(). (#333)
+- InputText(): Added ImGuiInputTextFlags_Password mode: hide display, disable logging/copying to clipboard. (#237, #363, #374)
+- Added GetColorU32() helper to retrieve color given enum with global alpha and extra applied.
+- Added ImGuiIO::ClearInputCharacters() superfluous helper.
+- Fixed ImDrawList draw command merging bug where using PopClipRect() along with PushTextureID()/PopTextureID() functions
+ would occasionally restore an incorrect clipping rectangle.
+- Fixed ImDrawList draw command merging so PushTextureID(XXX)/PopTextureID()/PushTextureID(XXX) sequence are now properly merged.
+- Fixed large popups positioning issues when their contents on either axis is larger than DisplaySize,
+ and WindowPadding < DisplaySafeAreaPadding.
+- Fixed border rendering in various situations when using non-pixel aligned glyphs.
+- Fixed border rendering of windows to always contain the border within the window.
+- Fixed Shutdown() leaking font atlas data if NewFrame() was never called. (#396, #303)
+- Fixed int>void\* warnings for 64-bit architectures with fancy warnings enabled.
+- Renamed the dubious Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete.
+- InputText(): Fixed and better handling of using keyboard while mouse button if being held and dragging. (#429)
+- InputText(): Replace OS IME (Input Method Editor) cursor on top-left when we are not text editing.
+- TreeNode(), CollapsingHeader(), Bullet(), BulletText(): various sizing and layout fixes to better support laying out
+ multiple item with different height on same line. (#414, #282)
+- Begin(): Initial window creation with ImGuiWindowFlags_NoBringToFrontOnFocus flag pushes it at the front of global window list.
+- BeginPopupContextWindow() and BeginPopupContextVoid() reopen window on subsequent click. (#439)
+- ColorEdit4(): Fixed broken tooltip on hovering the color button. (actually fixes #373, #380)
+- ImageButton(): uses FrameRounding up to a maximum of available framing size. (#394)
+- Columns: Fixed bug with indentation within columns, also making code a bit shorter/faster. (#414, #125)
+- Columns: Columns set with no implicit id include the columns count within the id to reduce collisions. (#125)
+- Columns: Removed one unnecessary allocation when columns are not used by a window. (#125)
+- ImFontAtlas: Tweaked GetGlyphRangesJapanese() so it is easier to modify.
+- ImFontAtlas: Updated stb_rect_pack.h to 0.08.
+- Metrics: Fixed computing ImDrawCmd bounding box when the draw buffer have been unindexed.
+- Demo: Added a simple "Property Editor" demo applet. (#125, #414)
+- Demo: Fixed assertion in "Custom Rendering" demo when holding both mouse buttons. (#393)
+- Demo: Lots of extra comments, fixes.
+- Demo: Tweaks to Style Editor.
+- Examples: Not clearing input data/tex data in atlas (will be required for dynamic atlas anyway).
+- Examples: Added /Zi (output debug information) to Win32 batch files.
+- Examples: Various fixes for resizing window and recreating graphic context.
+- Examples: OpenGL2/3: Save/restore viewport as part of default render function. (#392, #441).
+- Examples; OpenGL3: Fixed gl3w.c for Linux when compiled with a C++ compiler. (#411)
+- Examples: DirectX: Removed assumption about Unicode build in example main.cpp. (#399)
+- Examples: DirectX10: Added DirectX10 example. (#424)
+- Examples: DirectX11: Downgraded requirement from shader model 5.0 to 4.0. (#420)
+- Examples: DirectX11: Removed Debug flag from graphics context. (#415)
+- Examples: Added SDL+OpenGL3 example. (#356)
+
+
+-----------------------------------------------------------------------
+ VERSION 1.46 (2015-10-18)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.46
+
+Changes:
+
+- Begin*(): added ImGuiWindowFlags_NoFocusOnAppearing flag. (#314)
+- Begin*(): added ImGuiWindowFlags_NoBringToFrontOnFocus flag.
+- Added GetDrawData() alternative to setting a Render function pointer in ImGuiIO structure.
+- Added SetClipboardText(), GetClipboardText() helper shortcuts that user code can call directly without reading
+ from the ImGuiIO structure (to match MemAlloc/MemFree)
+- Fixed handling of malformed UTF-8 at the end of a non-zero terminated string range.
+- Fixed mouse click detection when passing DeltaTime 0.0. (#338)
+- Fixed IsKeyReleased() and IsMouseReleased() returning true on the first frame.
+- Fixed using SetNextWindow\* functions on Modal windows with a ImGuiSetCond_Appearing condition. (#377)
+- IsMouseHoveringRect(): Added 'bool clip' parameter to disable clipping provided rectangle. (#316)
+- InputText(): added ImGuiInputTextFlags_ReadOnly flag. (#211)
+- InputText(): lose cursor/undo-stack when reactivating focus is buffer has changed size.
+- InputText(): fixed ignoring text inputs when ALT or ALTGR are pressed. (#334)
+- InputText(): fixed mouse-dragging not tracking the cursor when text doesn't fit. (#339)
+- InputText(): fixed cursor pixel-perfect alignment when horizontally scrolling.
+- InputText(): fixed crash when passing a buf_size==0 (which can be of use for read-only selectable text boxes). (#360)
+- InputFloat() fixed explicit precision modifier, both display and input were broken.
+- PlotHistogram(): improved rendering of histogram with a lot of values.
+- Dummy(): creates an item so functions such as IsItemHovered() can be used.
+- BeginChildFrame() helper: added the extra_flags parameter.
+- Scrollbar: fixed rounding of background + child window consistenly have ChildWindowBg color under ScrollbarBg fill. (#355).
+- Scrollbar: background color less translucent in default style so it works better when changing background color.
+- Scrollbar: fixed minor rendering offset when borders are enabled. (#365)
+- ImDrawList: fixed 1 leak per ImDrawList using the ChannelsSplit() API (via Columns). (#318)
+- ImDrawList: fixed rectangle rendering glitches with width/height <= 1/2 and rounding enabled.
+- ImDrawList: AddImage() uv parameters default to (0,0) and (1,1).
+- ImFontAtlas: Added TexDesiredWidth and tweaked default cheapo best-width choice. (#327)
+- ImFontAtlas: Added GetGlyphRangesKorean() helper to retrieve unicode ranges for Korean. (#348)
+- ImGuiTextFilter::Draw() helper return bool and build when filter is modified.
+- ImGuiTextBuffer: added c_str() helper.
+- ColorEdit4(): fixed hovering the color button always showing 1.0 alpha. (#373)
+- ColorConvertFloat4ToU32() round the floats instead of truncating them.
+- Window: Fixed window lower-right clipping limit so it plays more friendly with both OpenGL and DirectX coordinates.
+- Internal: Extracted a EndFrame() function out of Render() but kept it internal/private + clarified some asserts. (#335)
+- Internal: Added missing IMGUI_API definitions in imgui_internal.h (#326)
+- Internal: ImLoadFileToMemory() return void\* instead of taking void*\* + allow optional int\* file_size.
+- Demo: Horizontal scrollbar demo allows to enable simultanaeous scrollbars on both axises.
+- Tools: binary_to_compressed_c.cpp: added -nocompress option.
+- Examples: Added example for the Marmalade platform.
+- Examples: Added batch files to build Windows examples with VS.
+- Examples: OpenGL3: Saving/restoring more GL state correctly. (#347)
+- Examples: OpenGL2/3: Added msys2/mingw64 target to Makefiles.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.45 (2015-09-01)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.45
+
+Breaking Changes:
+
+- With the addition of better horizontal scrolling primitives I had to make some consistency fixes.
+ `GetCursorPos()` `SetCursorPos()` `GetContentRegionMax()` `GetWindowContentRegionMin()` `GetWindowContentRegionMax()`
+ are now incorporating the scrolling amount. They were incorrectly not incorporating this amount previously.
+ It PROBABLY shouldn't break anything, but that depends on how you used them. Namely:
+ - If you always used SetCursorPos() with values relative to GetCursorPos() there shouldn't be a problem.
+ However if you used absolute coordinates, note that SetCursorPosY(100.0f) will put you at +100 from the initial Y position (which may be scrolled out of the view), NOT at +100 from the window top border. Since there wasn't any official scrolling value on X axis (past just manually moving the cursor) this can only affect you if you used to set absolute coordinates on the Y axis which is hopefully rare/unlikely, and trivial to fix.
+ - The value of GetWindowContentRegionMax() isn't necessarily close to GetWindowWidth() if horizontally scrolling.
+ Previously they were roughly interchangeable (roughly because the content region exclude window padding).
+
+Other Changes:
+
+- Added Horizontal Scrollbar via ImGuiWindowFlags_HorizontalScroll (#246).
+- Added GetScrollX(), GetScrollX(), GetScrollMaxX() apis (#246).
+- Added SetNextWindowContentSize(), SetNextWindowContentWidth() to explicitly set the content size of a window, which
+ define the range of scrollbar. When set explicitly it also define the base value from which widget width are derived.
+- Added IO.WantTextInput telling when ImGui is expecting text input, so that e.g. OS on-screen keyboard can be enabled.
+- Added printf attribute to printf-like text formatting functions (Clang/GCC).
+- Added GetMousePosOnOpeningCurrentPopup() helper.
+- Added GetContentRegionAvailWidth() helper.
+- Malformed UTF-8 data don't terminate string, output 0xFFFD instead (#307).
+- ImDrawList: Added AddBezierCurve(), PathBezierCurveTo() API for cubic bezier curves (#311).
+- ImDrawList: Allow to override ImDrawIdx type (#292).
+- ImDrawList: Added an assert on overflowing index value (#292).
+- ImDrawList: Fixed issues with channels split/merge. Now functional without manually adding a draw cmd. Added comments.
+- ImDrawData: Added ScaleClipRects() helper useful when rendering scaled. (#287).
+- Fixed Bullet() inconsistent layout behaviour when clipped.
+- Fixed IsWindowHovered() not taking account of window hoverability (may be disabled because of a popup).
+- Fixed InvisibleButton() not honoring negative size consistently with other widgets that do so.
+- Fixed OpenPopup() accessing current window, effectively opening "Debug" when called from an empty window stack.
+- TreeNode(): Fixed IsItemHovered() result being inconsistent with interaction visuals (#282).
+- TreeNode(): Fixed mouse interaction padding past the node label being accounted for in layout (#282).
+- BeginChild(): Passing a ImGuiWindowFlags_NoMove inhibits moving parent window from this child.
+- BeginChild() fixed missing rounding for child sizes which leaked into layout and have items misaligned.
+- Begin(): Removed default name = "Debug" parameter. We already have a "Debug" window pushed to the stack in the first place so it's not really a useful default.
+- Begin(): Minor fixes with windows main clipping rectangle (e.g. child window with border).
+- Begin(): Window flags are only read on the first call of the frame. Subsequent calls ignore flags, which allows appending to a window without worryin about flags.
+- InputText(): ignore character input when ctrl/alt are held. (Normally those text input are ignored by most wrappers.) (#279).
+- Demo: Fixed incorrectly formed string passed to Combo (#298).
+- Demo: Added simple Log demo.
+- Demo: Added horizontal scrolling example + enabled in console, log and child examples (#246).
+- Style: made scrollbars rounded by default. Because nice. Minor menu bar background alpha tweak. (#246)
+- Metrics: display indices along with triangles count (#299) and some internal state.
+- ImGuiTextFilter::PassFilter() supports string range. Added [] helper to ImGuiTextBuffer.
+- ImGuiTextFilter::Draw() default parameter width=0.0f for no override, allow override with negative values.
+- Examples: OpenGL2/OpenGL3: fix for retina displays. Default font current lack crispness.
+- Examples: OpenGL2/OpenGL3: save/restore more GL state correctly.
+- Examples: DirectX9/DirectX11: resizing buffers dynamically (#299).
+- Examples: DirectX9/DirectX11: added missing middle mouse button to Windows event handler.
+- Examples: DirectX11: fix for Visual Studio 2015 presumably shipping with an updated version of DX11.
+- Examples: iOS: fixed missing files in project.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.44 (2015-08-08)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.44
+
+Breaking Changes:
+
+- imgui.cpp has been split intro extra files: imgui_demo.cpp, imgui_draw.cpp, imgui_internal.h.
+ Add the two extra .cpp to your project or #include them from another .cpp file. (#219)
+
+Other Changes:
+
+- Internal data structure and several useful functions are now exposed in imgui_internal.h. This should make it easier
+ and more natural to extend ImGui. However please note that none of the content in imgui_internal.h is guaranteed
+ for forward-compatibility and code using those types/functions may occasionally break. (#219)
+- All sample code is in imgui_demo.cpp. Please keep this file in your project and consider allowing your code to call
+ the ShowTestWindow() function as de-facto guide to ImGui features. It will be stripped out by the linker when unused.
+- Added GetContentRegionAvail() helper (basically GetContentRegionMax() - GetCursorPos()).
+- Added ImGuiWindowFlags_NoInputs for totally input-passthru window.
+- Button(): honor negative size consistently with other widgets that do so (width -100 to align the button 100 pixels
+ before the right-most position of the contents region).
+- InputTextMultiline(): honor negative size consistently with other widgets that do so.
+- Combo() clamp popup to lower edge of visible area.
+- InputInt(): value doesn't pass through an int>float>int casting chain, fix handling lost of precision with "large" integer.
+- InputInt() allow hexadecimal input (awkwardly via ImGuiInputTextFlags_CharsHexadecimal but we will allow format
+ string in InputInt* later).
+- Checkbox(), RadioButton(): fixed scaling of checkbox and radio button for the filling of "active" visual.
+- Columns: never assume horizontal space for scrollbar if NoScrollbar flag is explicitly set.
+- Slider: fixed using FramePadding between frame and grab visual. Scaling that spacing would look odd.
+- Fixed lower-right resize grip hit box not scaling along with its rendered size (#287)
+- ImDrawList: Fixed angles in ImDrawList::PathArcTo(), PathArcToFast() (v1.43) being off by an extra PI for no reason.
+- ImDrawList: Added ImDrawList::AddText() shorthand helper.
+- ImDrawList: Add missing support for anti-aliased thick-lines (#133, also ref #288)
+- ImFontAtlas: Added AddFontFromMemoryCompressedBase85TTF() to load base85 encoded font string. Default font encoded
+ as base85 saves ~100 lines / 26 KB of source code. Added base85 output to the binary_to_compressed_c tool.
+- Build fix for MinGW (#276).
+- Examples: OpenGL3: Fixed running on script core profiles for OSX (#277).
+- Examples: OpenGL3: Simplified code using glBufferData for vertices as well (#277, #278)
+- Examples: DirectX11: Clear font texture view to ensure Release() doesn't get called twice (#290).
+- Updated to stb_truetype 1.07 (back to vanilla version as our minor changes are now in master & fix unlikely assert
+ with odd fonts (#280)
+
+
+-----------------------------------------------------------------------
+ VERSION 1.43 (2015-07-17)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.43
+
+Breaking Changes:
+
+- This is a rather important release and we unfortunately had to break the rendering API.
+ ImGui now requires you to render indexed vertices instead of non-indexed ones. The fix should be very easy.
+ Sorry for that! This change is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost.
+ Each ImDrawList now contains both a vertex buffer and an index buffer. For each command, render ElemCount/3 triangles
+ using indices from the index buffer.
+- If you are using a vanilla copy of one of the imgui_impl_XXXX.cpp provided in the example, you just need to update
+ your copy and you can ignore the rest.
+- The signature of the io.RenderDrawListsFn handler has changed
+ From: ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
+ To: ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data)
+ With: argument 'cmd_lists' -> 'draw_data->CmdLists'
+ argument 'cmd_lists_count' -> 'draw_data->CmdListsCount'
+ ImDrawList 'commands' -> 'CmdBuffer'
+ ImDrawList 'vtx_buffer' -> 'VtxBuffer'
+ ImDrawList n/a -> 'IdxBuffer' (new)
+ ImDrawCmd 'vtx_count' -> 'ElemCount'
+ ImDrawCmd 'clip_rect' -> 'ClipRect'
+ ImDrawCmd 'user_callback' -> 'UserCallback'
+ ImDrawCmd 'texture_id' -> 'TextureId'
+- If you REALLY cannot render indexed primitives, you can call the draw_data->DeIndexAllBuffers() method to de-index
+ the buffers. This is slow and a waste of CPU/GPU. Prefer using indexed rendering!
+ Refer to code in the examples/ folder or ask on the GitHub if you are unsure of how to upgrade. Please upgrade!
+
+Other Changes:
+
+- Added anti-aliasing on lines and shapes based on primitives by @MikkoMononen (#133).
+ Between the use of indexed-rendering and the fact that the entire rendering codebase has been optimized and massaged
+ enough, with anti-aliasing enabled ImGui 1.43 is now running FASTER than 1.41.
+ Made some extra effort in making the code run faster in your typical Debug build.
+- Anti-aliasing can be disabled in the ImGuiStyle structure via the AntiAliasedLines/AntiAliasedShapes fields for further gains.
+- ImDrawList: Added AddPolyline(), AddConvexPolyFilled() with optional anti-aliasing.
+- ImDrawList: Added stateful path building and stroking API. PathLineTo(), PathArcTo(), PathRect(), PathFill(), PathStroke()
+ with optional anti-aliasing.
+- ImDrawList: Added AddRectFilledMultiColor() helper.
+- ImDrawList: Added multi-channel rendering so out of order elements can be rendered in separate channels and then merged
+ back together (used by columns).
+- ImDrawList: Fixed merging draw commands when equal clip rectangles are in the two first commands.
+- ImDrawList: Fixed window draw lists not destructed properly on Shutdown().
+- ImDrawData: Added DeIndexAllBuffers() helper.
+- Added lots of new font options ImFontAtlas::AddFont() and the new ImFontConfig structure.
+ - Added support for oversampling (ImFontConfig: OversampleH, OversampleV) and sub-pixel positioning (ImFontConfig: PixelSnapH).
+ Oversampling allows sub-pixel positioning but can also be used as a way to get some leeway with scaling fonts without re-rasterizing.
+ - Added GlyphExtraSpacing option to add extra horizontal spacing between characters (#242).
+ - Added MergeMode option to merge glyphs from different font inputs into a same font (#182, #232).
+ - Added FontDataOwnedByAtlas option to keep ownership from the TTF data buffer and request the atlas to make a copy (#220).
+- Updated to stb_truetype 1.06 (+ minor mods) with better font rasterization.
+- InputText: Added ImGuiInputTextFlags_NoHorizontalScroll flag.
+- InputText: Added ImGuiInputTextFlags_AlwaysInsertMode flag.
+- InputText: Added HasSelection() helper in ImGuiTextEditCallbackData as a clarification.
+- InputText: Fix for using END key on a multi-line text editor (#275)
+- Columns: Dispatch render of each column in a sub-draw list and merge on closure, saving a lot of draw calls! (#125)
+- Popups: Fixed Combo boxes inside menus. (#272)
+- Style: Added GrabRounding setting to make the sliders etc. grabs rounded.
+- Changed SameLine() parameters from int to float.
+- Fixed incorrect assert triggering when code stole ActiveID from user moving a window by calling e.g. SetKeyboardFocusHere().
+- Fixed CollapsingHeader() label rendering outside its frame in columns context where ClipRect max isn't aligned with the
+ right-side of the header.
+- Metrics window: calculate bounding box of actual vertices when hovering a draw list.
+- Examples: Showing more information in the Fonts section.
+- Examples: Added a gratuitous About window.
+- Examples: Updated all examples code (OpenGL/DX9/DX11/SDL/Allegro/iOS) to use indexed rendering.
+- Examples: Fixed the SDL2 example to support Unicode text input (#274).
+
+
+-----------------------------------------------------------------------
+ VERSION 1.42 (2015-07-08)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.42
+
+Breaking Changes:
+
+- Renamed SetScrollPosHere() to SetScrollHere(). Kept inline redirection function (will obsolete).
+- Renamed GetScrollPosY() to GetScrollY(). Necessary to reduce confusion and make scrolling API consistent,
+ because positions (e.g. cursor position) are not equivalent to scrolling amount.
+- Removed obsolete GetDefaultFontData() function that would assert anyway.
+ If you are updating from <1.30 you'll get a compile error instead of an assertion. (obsoleted 2015/01/11)
+
+Other Changes:
+
+- Added SDL2 example application (courtesy of @CedricGuillemet)
+- Added iOS example application (courtesy of @joeld42)
+- Added Allegro 5 example application (courtesy of @bggd)
+- Added TitleBgActive color in style so focused window is made visible. (#253)
+- Added CaptureKeyboardFromApp() / CaptureMouseFromApp() to manually enforce inputs capturing.
+- Added DragFloatRange2() DragIntRange2() helpers. (#76)
+- Added a Y centering ratio to SetScrollFromCursorPos() which can be used to aim the top or bottom of the window. (#150)
+- Added SetScrollY(), SetScrollFromPos(), GetCursorStartPos() for manual scrolling manipulations. (#150).
+- Added GetKeyIndex() helper for converting from ImGuiKey_\* enum to user's keycodes. Basically pulls from io.KeysMap[].
+- Added missing ImGuiKey_PageUp, ImGuiKey_PageDown so more UI code can be written without referring to implementation-side keycodes.
+- MenuItem() can be activated on release. (#245)
+- Allowing NewFrame() with DeltaTime==0.0f to not assert.
+- Fixed IsMouseDragging(). (#260)
+- Fixed PlotLines(), PlotHistogram() using incorrect hovering test so they would show their tooltip even when there is
+ a popup between mouse and the graph.
+- Fixed window padding being reported incorrectly for child windows with borders when parent have no borders.
+- Fixed a bug with TextUnformatted() clipping of long text blob when clipping y1 line sits on the first line of text. (#257)
+- Fixed text baseline alignment of small button (no padding) after regular buttons.
+- Fixed ListBoxHeader() not honoring negative sizes the same way as BeginChild() or BeginChildFrame(). (#263)
+- Fixed warnings for more pedantic compiler settings (#258).
+- ImVector<> cannot be re-defined anymore, cannot be replaced with std::vector<>. Allowed us to clean up and optimize
+ lots of code. Yeah! (#262)
+- ImDrawList: store pointer to their owner name for easier auditing/debugging.
+- Examples: added scroll tracking example with SetScrollFromCursorPos().
+- Examples: metrics windows render clip rectangle when hovering over a draw call.
+- Lots of small optimization (particularly to run faster on unoptimized builds) and tidying up.
+- Added font links in extra_fonts/ + instructions for using compressed fonts in C array.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.41 (2015-06-26)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.41
+
+Breaking Changes:
+
+- Changed ImageButton() default bg_col parameter from (0,0,0,1) (black) to (0,0,0,0) (transparent).
+ Only makes a difference when texture have transparency.
+- Changed Selectable() API from (label, selected, size) to (label, selected, flags, size).
+ Size override should be used very rarely so hopefully it doesn't affect many people. Sorry!
+
+Other Changes:
+
+- Added InputTextMultiline() multi-line text editor, vertical scrolling, selection, optimized enough to handle rather
+ big chunks of text in stateless context (thousands of lines are ok), option for allowing Tab to be input, option
+ for validating with Return or Ctrl+Return (#200).
+- Added modal window API, BeginPopupModal(), follows the popup api scheme. Modal windows can be closed by clicking
+ outside. By default the rest of the screen is dimmed (using ImGuiCol_ModalWindowDarkening). Modal windows can be stacked.
+- Added GetGlyphRangesCyrillic() helper (#237).
+- Added SetNextWindowPosCenter() to center a window prior to knowing its size. (#249)
+- Added IsWindowHovered() helper.
+- Added IsMouseReleased(), IsKeyReleased() helpers to allow to user to avoid tracking them. (#248)
+- Allow Set*WindowSize() calls to be used with popups.
+- Window: AutoFit can be triggered on each axis separately via SetNextWindowSize(), etc.
+- Window: fixed scrolling with mouse wheel while window was collapsed.
+- Window: fixed mouse wheel scroll issues.
+- DragFloat(), SliderFloat(): Fixed rounding of negative numbers which sometime made the negative lower bound unreachable.
+- InputText(): lifted character count limit.
+- InputText(): fixes in case of using per-window font scaling.
+- Selectable(), MenuItem(): do not use frame rounding for hovering/selection.
+- Selectable(): Added flag ImGuiSelectableFlags_DontClosePopups.
+- Selectable(): Added flag ImGuiSelectableFlags_SpanAllColumns (#125).
+- Combo(): Fixed issue with activating a Combo() not taking active id (#241).
+- ColorButton(), ColorEdit4(): fix to ensure that the colored square stays square when non-default padding settings are used.
+- BeginChildFrame(): returns bool like BeginChild() for clipping.
+- SetScrollPosHere(): takes account of item height + more accurate centering + fixed precision issue.
+- ImFont: ignoring '\r'.
+- ImFont: added GetCharAdvance() helper. Exposed font Ascent and font Descent.
+- ImFont: additional rendering optimizations.
+- Metrics windows display storage size.
+
+
+-----------------------------------------------------------------------
+ VERSION 1.40 (2015-05-31)
+-----------------------------------------------------------------------
+
+Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.40
+
+Breaking Changes:
+
+- The BeginPopup() API (introduced in 1.37) had to be changed to allow for stacked popups and menus.
+ Use OpenPopup() to toggle the opened state and BeginPopup() to append.**
+- The third parameter of Button(), 'repeat_if_held' has been removed. While it's been very rarely used,
+ some code will possibly break if you didn't rely on the default parameter.
+ Use PushButtonRepeat()/PopButtonRepeat() to configure repeat.
+- Renamed IsRectClipped() to !IsRectVisible() for consistency (opposite return value!). Kept inline redirection function (will obsolete)
+- Renamed GetWindowCollapsed() to IsWindowCollapsed() for consistency. Kept inline indirection function (will obsolete).
+
+Other Changes:
+
+- Menus: Added a menu system! Menus are typically populated with menu items and sub-menus, but you can add any sort of
+ widgets in them (buttons, text inputs, sliders, etc.). (#126)
+- Menus: Added MenuItem() to append a menu item. Optional shortcut display, acts a button & toggle with checked/unchecked state,
+ disabled mode. Menu items can be used in any window.
+- Menus: Added BeginMenu() to append a sub-menu. Note that you generally want to add sub-menu inside a popup or a menu-bar.
+ They will work inside a normal window but it will be a bit unusual.
+- Menus: Added BeginMenuBar() to append to window menu-bar (set ImGuiWindowFlags_MenuBar to enable).
+- Menus: Added BeginMainMenuBar() helper to append to a fullscreen main menu-bar.
+- Popups: Support for stacked popups. Each popup level inhibit inputs to lower levels. The menus system is based on this. (#126).
+- Popups: Added BeginPopupContextItem(), BeginPopupContextWindow(), BeginPopupContextVoid() to create a popup window on mouse-click.
+- Popups: Popups have borders by default (#197), attenuated border alpha in default theme.
+- Popups & Tooltip: Fit within display. Handling various positioning/sizing/scrolling edge cases. Better hysteresis when moving
+ in corners. Tooltip always tries to stay away from mouse-cursor.
+- Added ImGuiStorage::GetVoidPtrRef() for manipulating stored void*.
+- Added IsKeyDown() IsMouseDown() as convenience and for consistency with existing functions (instead of reading them from IO structures).
+- Added Dummy() helper to advance layout by a given size. Unlike InvisibleButton() this doesn't catch any click.
+- Added configurable io.KeyRepeatDelay, io.KeyRepeatRate keyboard and mouse repeat rate.
+- Added PushButtonRepeat() / PopButtonRepeat() to enable hold-button-to-repeat press on any button.
+- Removed the third 'repeat' parameter of Button().
+- Added IsAnyItemHovered() helper.
+- Added GetItemsLineHeightWithSpacing() helper.
+- Added ImGuiListClipper helper for clipping large list of evenly sized items, to avoid using CalcListClipping() directly.
+- Separator: within group start on group horizontal offset. (#205)
+- InputText: Fixed incorrect edit state after text buffer is appended to by user via the callback. (#206)
+- InputText: CTRL+letter-key shortcuts (e.g. CTRL+C/V/X) makes sure only CTRL is pressed. (#214)
+- InputText: Fixed cursor generating a zero-width wire-frame rectangle turning into a division by zero (would go unnoticed
+ unless you trapped exceptions).
+- InputFloatN/InputIntN: Flags parameter added to match scalar versions. (#218)
+- Selectable: Horizontal filling not declared to ItemSize() so Selectable(),SameLine() works and we can better auto-fit the window.
+- Selectable: Handling text baseline alignment for line that aren't of text height.
+- Combo: Empty label doesn't add ItemInnerSpacing alignment, matching other widgets.
+- EndGroup: Carries the text base offset from the last line of the group (sort of incorrect but better than nothing,
+ should use the first line of the group, will implement in the future).
+- Columns: distinguish columns-set ID from other widgets as a convenience, added asserts and sailors.
+- ListBox: ListBox() function only use public API to encourage creating custom versions. ListBoxHeader() can return false.
+- ListBox: Uses ImGuiListClipper and assume items of matching height, so large lists can be handled.
+- Plot: overlay label clipped within frame when not fitting.
+- Window: Added ImGuiSetCond_Appearing to test the hidden->visible transition in SetWindow***/SetNextWindow*** functions.
+- Window: Auto-fitting cancel out one worth of vertical spacing for vertical symmetry (like what group and tooltip do).
+- Window: Default item width for auto-resizing windows expressed as a factor of font height, scales better with different font.
+- Window: Fixed auto-fit calculation mismatch of whether a scrollbar will be added by maximum height clamping. Also honor NoScrollBar in the case of height clamping, not adding extra horizontal space.
+- Window: Hovering require to hover same child window. Reverted 860cf57 (December 3). Might break something if you have
+ child overlapping items in parent window.
+- Window: Fixed appending multiple times to an existing child via multiple BeginChild/EndChild calls to same child name.
+ Allows a simple form of out-of-order appending.
+- Window: Fixed auto-filling child window using WindowMinSize at their minimum size, irrelevant.
+- Metrics: Added io.MetricsActiveWindows counter. (#213.
+- Metrics: Added io.MetricsAllocs counter (number of active memory allocations).
+- Metrics: ShowMetricsWindow() shows popups stack, allocations.
+- Style: Added style.DisplayWindowPadding to prevent windows from reaching edges of display (similar to style.DisplaySafeAreaPadding which is still in effect and also affect popups/tooltips).
+- Style: Removed style.AutoFitPadding, using style.WindowPadding makes more sense (the default values were already the same).
+- Style: Added style.ScrollbarRounding. (#212)
+- Style: Added ImGuiCol_TextDisabled for disabled text. Added TextDisabled() helper.
+- Style: Added style.WindowTitleAlign alignment options, to e.g. center title on windows. (#222)
+- ImVector: tweak growth strategy, matches vector from VS2010.
+- ImFontAtlas: Added ClearFonts(), making the different clear funcs more explicit. (#224)
+- ImFontAtlas: Fixed appending new fonts without clearing existing fonts. Clearing input data left to application. (#224)
+- ImDrawList: Merge draw command better, cases of multiple Begin/End gets merged properly.
+- Store common stacked settings contiguously in memory to avoid heap allocation for unused features, and reduce cache misses.
+- Shutdown() tests for g.IO.Fonts not being NULL to ease use of multiple ImGui contexts. (#207)
+- Added IMGUI_DISABLE_OBSOLETE_FUNCTIONS define to disable the functions that are meant to be removed.
+- Examples: Added ? marks with tooltips next to various widgets. Added more comments in the demo window.
+- Examples: Added Menu-bar example.
+- Examples: Added Simple Layout example.
+- Examples: AutoResize demo doesn't use TextWrapped().
+- Examples: Console example uses standard malloc/free, makes more sense as a copy & pastable example.
+- Examples: DirectX9/11: Fixed key mapping for down arrow.
+- Examples: DirectX9/11: hide OS cursor if ImGui is drawing it. (#155)
+- Examples: DirectX11: explicitly set rasterizer state.
+- Examples: OpenGL3: Add conditional compilation of forward compat as required by glfw on OSX. (#229)
+- Fixed build with Visual Studio 2008 (possibly earlier versions as well).
+- Other fixes, comments, tweaks.
+
+
+-----------------------------------------------------------------------
+
+For older version, see https://github.com/ocornut/imgui/releases
+
diff --git a/third_party/imgui/docs/FAQ.md b/third_party/imgui/docs/FAQ.md
new file mode 100644
index 0000000000..adce4d4063
--- /dev/null
+++ b/third_party/imgui/docs/FAQ.md
@@ -0,0 +1,653 @@
+# FAQ (Frequenty Asked Questions)
+
+You may link to this document using short form:
+ https://www.dearimgui.org/faq
+or its real address:
+ https://github.com/ocornut/imgui/blob/master/docs/FAQ.md
+or view this file with any Markdown viewer.
+
+
+## Index
+
+| **Q&A: Basics** |
+:---------------------------------------------------------- |
+| [Where is the documentation?](#q-where-is-the-documentation) |
+| [What is this library called?](#q-what-is-this-library-called) |
+| [Which version should I get?](#q-which-version-should-i-get) |
+| **Q&A: Integration** |
+| **[How to get started?](#q-how-to-get-started)** |
+| **[How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?](#q-how-can-i-tell-whether-to-dispatch-mousekeyboard-to-dear-imgui-or-to-my-application)** |
+| [How can I enable keyboard or gamepad controls?](#q-how-can-i-enable-keyboard-or-gamepad-controls) |
+| [How can I use this on a machine without mouse, keyboard or screen? (input share, remote display)](#q-how-can-i-use-this-on-a-machine-without-mouse-keyboard-or-screen-input-share-remote-display) |
+| [I integrated Dear ImGui in my engine and little squares are showing instead of text..](#q-i-integrated-dear-imgui-in-my-engine-and-little-squares-are-showing-instead-of-text) |
+| [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) |
+| [I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries..](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-displaying-outside-their-expected-windows-boundaries) |
+| **Q&A: Usage** |
+| **[How can I have widgets with an empty label?
How can I have multiple widgets with the same label?
Why are multiple widgets reacting when I interact with one?](#q-how-can-i-have-widgets-with-an-empty-label)** |
+| [How can I display an image? What is ImTextureID, how does it work?](#q-how-can-i-display-an-image-what-is-imtextureid-how-does-it-work)|
+| [How can I use my own math types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-math-types-instead-of-imvec2imvec4) |
+| [How can I interact with standard C++ types (such as std::string and std::vector)?](#q-how-can-i-interact-with-standard-c-types-such-as-stdstring-and-stdvector) |
+| [How can I display custom shapes? (using low-level ImDrawList API)](#q-how-can-i-display-custom-shapes-using-low-level-imdrawlist-api) |
+| **Q&A: Fonts, Text** |
+| [How should I handle DPI in my application?](#q-how-should-i-handle-dpi-in-my-application) |
+| [How can I load a different font than the default?](#q-how-can-i-load-a-different-font-than-the-default) |
+| [How can I easily use icons in my application?](#q-how-can-i-easily-use-icons-in-my-application) |
+| [How can I load multiple fonts?](#q-how-can-i-load-multiple-fonts) |
+| [How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?](#q-how-can-i-display-and-input-non-latin-characters-such-as-chinese-japanese-korean-cyrillic) |
+| **Q&A: Concerns** |
+| [Who uses Dear ImGui?](#q-who-uses-dear-imgui) |
+| [Can you create elaborate/serious tools with Dear ImGui?](#q-can-you-create-elaborateserious-tools-with-dear-imgui) |
+| [Can you reskin the look of Dear ImGui?](#q-can-you-reskin-the-look-of-dear-imgui) |
+| [Why using C++ (as opposed to C)?](#q-why-using-c-as-opposed-to-c) |
+| **Q&A: Community** |
+| [How can I help?](#q-how-can-i-help) |
+
+
+# Q&A: Basics
+
+### Q: Where is the documentation?
+
+**This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.**
+- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder to explain how to integrate Dear ImGui with your own engine/application. You can run those applications and explore them.
+- See demo code in [imgui_demo.cpp](https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp) and particularly the `ImGui::ShowDemoWindow()` function. The demo covers most features of Dear ImGui, so you can read the code and see its output.
+- See documentation and comments at the top of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) + general API comments in [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h).
+- The [Wiki](https://github.com/ocornut/imgui/wiki) has many resources and links.
+- The [Glossary](https://github.com/ocornut/imgui/wiki/Glossary) page may be useful.
+- The [Issues](https://github.com/ocornut/imgui/issues) section can be searched for past questions and issues.
+- Your programming IDE is your friend, find the type or function declaration to find comments associated to it.
+- The `ImGui::ShowMetricsWindow()` function exposes lots of internal information and tools. Although it is primary designed as a debugging tool, having access to that information tends to help understands concepts.
+
+##### [Return to Index](#index)
+
+---
+
+### Q. What is this library called?
+
+**This library is called Dear ImGui**. Please refer to it as Dear ImGui (not ImGui, not IMGUI).
+
+(The library misleadingly started its life in 2014 as "ImGui" due to the fact that I didn't give it a proper name when when I released 1.0, and had no particular expectation that it would take off. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations e.g. Unity uses it own implementation of the IMGUI paradigm. To reduce the ambiguity without affecting existing code bases, I have decided in December 2015 a fully qualified name "Dear ImGui" for this library.
+
+##### [Return to Index](#index)
+
+---
+
+### Q: Which version should I get?
+I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported.
+
+You may use the [docking](https://github.com/ocornut/imgui/tree/docking) branch which includes:
+- [Docking features](https://github.com/ocornut/imgui/issues/2109)
+- [Multi-viewport features](https://github.com/ocornut/imgui/issues/1542)
+
+Many projects are using this branch and it is kept in sync with master regularly.
+
+You may merge in the [tables](https://github.com/ocornut/imgui/tree/tables) branch which includes:
+- [Table features](https://github.com/ocornut/imgui/issues/2957)
+
+##### [Return to Index](#index)
+
+----
+
+# Q&A: Integration
+
+### Q: How to get started?
+
+Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp).
+Read [examples/README.txt](https://github.com/ocornut/imgui/tree/master/examples/README.txt).
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?
+
+You can read the `io.WantCaptureMouse`, `io.WantCaptureKeyboard` and `io.WantTextInput` flags from the ImGuiIO structure.
+
+e.g. `if (ImGui::GetIO().WantCaptureMouse) { ... }`
+
+- When `io.WantCaptureMouse` is set, imgui wants to use your mouse state, and you may want to discard/hide the inputs from the rest of your application.
+- When `io.WantCaptureKeyboard` is set, imgui wants to use your keyboard state, and you may want to discard/hide the inputs from the rest of your application.
+- When `io.WantTextInput` is set to may want to notify your OS to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS).
+
+**Note:** You should always pass your mouse/keyboard inputs to Dear ImGui, even when the io.WantCaptureXXX flag are set false.
+ This is because imgui needs to detect that you clicked in the void to unfocus its own windows.
+
+**Note:** The `io.WantCaptureMouse` is more correct that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handle mouse dragging correctly (both dragging that started over your application or over a Dear ImGui window) and handle e.g. popup and modal windows blocking inputs.
+
+**Note:** Those flags are updated by `ImGui::NewFrame()`. However it is generally more correct and easier that you poll flags from the previous frame, then submit your inputs, then call `NewFrame()`. If you attempt to do the opposite (which is generally harder) you are likely going to submit your inputs after `NewFrame()`, and therefore too late.
+
+**Note:** If you are using a touch device, you may find use for an early call to `UpdateHoveredWindowAndCaptureFlags()` to correctly dispatch your initial touch. We will work on better out-of-the-box touch support in the future.
+
+**Note:** Text input widget releases focus on the "KeyDown" event of the Return key, so the subsequent "KeyUp" event that your application receive will typically have `io.WantCaptureKeyboard == false`. Depending on your application logic it may or not be inconvenient to receive that KeyUp event. You might want to track which key-downs were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I enable keyboard or gamepad controls?
+- The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected!
+- Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable.
+- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting back-end).
+- See [Control Sheets for Gamepads](http://www.dearimgui.org/controls_sheets) (reference PNG/PSD for for PS4, XB1, Switch gamepads).
+- See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details.
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I use this on a machine without mouse, keyboard or screen? (input share, remote display)
+- You can share your computer mouse seamlessly with your console/tablet/phone using solutions such as [Synergy](https://symless.com/synergy)
+This is the preferred solution for developer productivity.
+In particular, the [micro-synergy-client repository](https://github.com/symless/micro-synergy-client) has simple
+and portable source code (uSynergy.c/.h) for a small embeddable client that you can use on any platform to connect
+to your host computer, based on the Synergy 1.x protocol. Make sure you download the Synergy 1 server on your computer.
+Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-like protocols.
+- Game console users: consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback.
+- You may also use a third party solution such as [Remote ImGui](https://github.com/JordiRos/remoteimgui) or [imgui-ws](https://github.com/ggerganov/imgui-ws) which sends the vertices to render over the local network, allowing you to use Dear ImGui even on a screen-less machine. See [Wiki](https://github.com/ocornut/imgui/wiki) index for most details.
+- For touch inputs, you can increase the hit box of widgets (via the `style.TouchPadding` setting) to accommodate for the lack of precision of touch inputs, but it is recommended you use a mouse or gamepad to allow optimizing for screen real-estate and precision.
+
+##### [Return to Index](#index)
+
+---
+
+### Q: I integrated Dear ImGui in my engine and little squares are showing instead of text..
+This usually means that: your font texture wasn't uploaded into GPU, or your shader or other rendering state are not reading from the right texture (e.g. texture wasn't bound).
+If this happens using the standard back-ends it is probably that the texture failed to upload, which could happens if for some reason your texture is too big. Also see [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md).
+
+##### [Return to Index](#index)
+
+---
+
+### Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
+### Q: I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries..
+You are probably mishandling the clipping rectangles in your render function.
+Each draw command needs the triangle rendered using the clipping rectangle provided in the ImDrawCmd structure (`ImDrawCmd->CllipRect`).
+Rectangles provided by Dear ImGui are defined as
+`(x1=left,y1=top,x2=right,y2=bottom)`
+and **NOT** as
+`(x1,y1,width,height)`
+Refer to rendering back-ends in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder for references of how to handle the `ClipRect` field.
+
+##### [Return to Index](#index)
+
+---
+
+# Q&A: Usage
+
+### Q: How can I have widgets with an empty label?
+### Q: How can I have multiple widgets with the same label?
+### Q: Why are multiple widgets reacting when I interact with one?
+
+A primer on labels and the ID Stack...
+
+Dear ImGui internally need to uniquely identify UI elements.
+Elements that are typically not clickable (such as calls to the Text functions) don't need an ID.
+Interactive widgets (such as calls to Button buttons) need a unique ID.
+Unique ID are used internally to track active widgets and occasionally associate state to widgets.
+Unique ID are implicitly built from the hash of multiple elements that identify the "path" to the UI element.
+
+- Unique ID are often derived from a string label and at minimum scoped within their host window:
+```c
+Begin("MyWindow");
+Button("OK"); // Label = "OK", ID = hash of ("MyWindow", "OK")
+Button("Cancel"); // Label = "Cancel", ID = hash of ("MyWindow", "Cancel")
+End();
+```
+- Other elements such as tree nodes, etc. also pushes to the ID stack:
+```c
+Begin("MyWindow");
+if (TreeNode("MyTreeNode"))
+{
+ Button("OK"); // Label = "OK", ID = hash of ("MyWindow", "MyTreeNode", "OK")
+ TreePop();
+}
+End();
+```
+- Two items labeled "OK" in different windows or different tree locations won't collide:
+```
+Begin("MyFirstWindow");
+Button("OK"); // Label = "OK", ID = hash of ("MyFirstWindow", "OK")
+End();
+Begin("MyOtherWindow");
+Button("OK"); // Label = "OK", ID = hash of ("MyOtherWindow", "OK")
+End();
+```
+
+We used "..." above to signify whatever was already pushed to the ID stack previously:
+
+- If you have a same ID twice in the same location, you'll have a conflict:
+```c
+Button("OK");
+Button("OK"); // ID collision! Interacting with either button will trigger the first one.
+```
+Fear not! this is easy to solve and there are many ways to solve it!
+
+- Solving ID conflict in a simple/local context:
+When passing a label you can optionally specify extra ID information within string itself.
+Use "##" to pass a complement to the ID that won't be visible to the end-user.
+This helps solving the simple collision cases when you know e.g. at compilation time which items
+are going to be created:
+```c
+Begin("MyWindow");
+Button("Play"); // Label = "Play", ID = hash of ("MyWindow", "Play")
+Button("Play##foo1"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo1") // Different from above
+Button("Play##foo2"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo2") // Different from above
+End();
+```
+- If you want to completely hide the label, but still need an ID:
+```c
+Checkbox("##On", &b); // Label = "", ID = hash of (..., "##On") // No visible label, just a checkbox!
+```
+- Occasionally/rarely you might want change a label while preserving a constant ID. This allows
+you to animate labels. For example you may want to include varying information in a window title bar,
+but windows are uniquely identified by their ID. Use "###" to pass a label that isn't part of ID:
+```c
+Button("Hello###ID"); // Label = "Hello", ID = hash of (..., "###ID")
+Button("World###ID"); // Label = "World", ID = hash of (..., "###ID") // Same as above, even if the label looks different
+
+sprintf(buf, "My game (%f FPS)###MyGame", fps);
+Begin(buf); // Variable title, ID = hash of "MyGame"
+```
+- Solving ID conflict in a more general manner:
+Use PushID() / PopID() to create scopes and manipulate the ID stack, as to avoid ID conflicts
+within the same window. This is the most convenient way of distinguishing ID when iterating and
+creating many UI elements programmatically.
+You can push a pointer, a string or an integer value into the ID stack.
+Remember that ID are formed from the concatenation of _everything_ pushed into the ID stack.
+At each level of the stack we store the seed used for items at this level of the ID stack.
+```c
+Begin("Window");
+for (int i = 0; i < 100; i++)
+{
+ PushID(i); // Push i to the id tack
+ Button("Click"); // Label = "Click", ID = hash of ("Window", i, "Click")
+ PopID();
+}
+for (int i = 0; i < 100; i++)
+{
+ MyObject* obj = Objects[i];
+ PushID(obj);
+ Button("Click"); // Label = "Click", ID = hash of ("Window", obj pointer, "Click")
+ PopID();
+}
+for (int i = 0; i < 100; i++)
+{
+ MyObject* obj = Objects[i];
+ PushID(obj->Name);
+ Button("Click"); // Label = "Click", ID = hash of ("Window", obj->Name, "Click")
+ PopID();
+}
+End();
+```
+- You can stack multiple prefixes into the ID stack:
+```c
+Button("Click"); // Label = "Click", ID = hash of (..., "Click")
+PushID("node");
+ Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
+ PushID(my_ptr);
+ Button("Click"); // Label = "Click", ID = hash of (..., "node", my_ptr, "Click")
+ PopID();
+PopID();
+```
+- Tree nodes implicitly creates a scope for you by calling PushID().
+```c
+Button("Click"); // Label = "Click", ID = hash of (..., "Click")
+if (TreeNode("node")) // <-- this function call will do a PushID() for you (unless instructed not to, with a special flag)
+{
+ Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
+ TreePop();
+}
+```
+
+When working with trees, ID are used to preserve the open/close state of each tree node.
+Depending on your use cases you may want to use strings, indices or pointers as ID.
+- e.g. when following a single pointer that may change over time, using a static string as ID
+will preserve your node open/closed state when the targeted object change.
+- e.g. when displaying a list of objects, using indices or pointers as ID will preserve the
+node open/closed state differently. See what makes more sense in your situation!
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I display an image? What is ImTextureID, how does it work?
+
+Short explanation:
+- Refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki).
+- You may use functions such as `ImGui::Image()`, `ImGui::ImageButton()` or lower-level `ImDrawList::AddImage()` to emit draw calls that will use your own textures.
+- Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as ImTextureID (void*) value.
+- Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason).
+
+**Please read documentations or tutorials on your graphics API to understand how to display textures on the screen before moving onward.**
+
+Long explanation:
+- Dear ImGui's job is to create "meshes", defined in a renderer-agnostic format made of draw commands and vertices. At the end of the frame those meshes (ImDrawList) will be displayed by your rendering function. They are made up of textured polygons and the code to render them is generally fairly short (a few dozen lines). In the examples/ folder we provide functions for popular graphics API (OpenGL, DirectX, etc.).
+- Each rendering function decides on a data type to represent "textures". The concept of what is a "texture" is entirely tied to your underlying engine/graphics API.
+ We carry the information to identify a "texture" in the ImTextureID type.
+ImTextureID is nothing more that a void*, aka 4/8 bytes worth of data: just enough to store 1 pointer or 1 integer of your choice.
+Dear ImGui doesn't know or understand what you are storing in ImTextureID, it merely pass ImTextureID values until they reach your rendering function.
+- In the [examples/](https://github.com/ocornut/imgui/tree/master/examples) bindings, for each graphics API binding we decided on a type that is likely to be a good representation for specifying an image from the end-user perspective. This is what the _examples_ rendering functions are using:
+```
+OpenGL:
+- ImTextureID = GLuint
+- See ImGui_ImplOpenGL3_RenderDrawData() function in imgui_impl_opengl3.cpp
+```
+```
+DirectX9:
+- ImTextureID = LPDIRECT3DTEXTURE9
+- See ImGui_ImplDX9_RenderDrawData() function in imgui_impl_dx9.cpp
+```
+```
+DirectX11:
+- ImTextureID = ID3D11ShaderResourceView*
+- See ImGui_ImplDX11_RenderDrawData() function in imgui_impl_dx11.cpp
+```
+```
+DirectX12:
+- ImTextureID = D3D12_GPU_DESCRIPTOR_HANDLE
+- See ImGui_ImplDX12_RenderDrawData() function in imgui_impl_dx12.cpp
+```
+For example, in the OpenGL example binding we store raw OpenGL texture identifier (GLuint) inside ImTextureID.
+Whereas in the DirectX11 example binding we store a pointer to ID3D11ShaderResourceView inside ImTextureID, which is a higher-level structure tying together both the texture and information about its format and how to read it.
+
+- If you have a custom engine built over e.g. OpenGL, instead of passing GLuint around you may decide to use a high-level data type to carry information about the texture as well as how to display it (shaders, etc.). The decision of what to use as ImTextureID can always be made better knowing how your codebase is designed. If your engine has high-level data types for "textures" and "material" then you may want to use them.
+If you are starting with OpenGL or DirectX or Vulkan and haven't built much of a rendering engine over them, keeping the default ImTextureID representation suggested by the example bindings is probably the best choice.
+(Advanced users may also decide to keep a low-level type in ImTextureID, and use ImDrawList callback and pass information to their renderer)
+
+User code may do:
+```cpp
+// Cast our texture type to ImTextureID / void*
+MyTexture* texture = g_CoffeeTableTexture;
+ImGui::Image((void*)texture, ImVec2(texture->Width, texture->Height));
+```
+The renderer function called after ImGui::Render() will receive that same value that the user code passed:
+```cpp
+// Cast ImTextureID / void* stored in the draw command as our texture type
+MyTexture* texture = (MyTexture*)pcmd->TextureId;
+MyEngineBindTexture2D(texture);
+```
+Once you understand this design you will understand that loading image files and turning them into displayable textures is not within the scope of Dear ImGui.
+This is by design and is actually a good thing, because it means your code has full control over your data types and how you display them.
+If you want to display an image file (e.g. PNG file) into the screen, please refer to documentation and tutorials for the graphics API you are using.
+
+Refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki) to find simplified examples for loading textures with OpenGL, DirectX9 and DirectX11.
+
+C/C++ tip: a void* is pointer-sized storage. You may safely store any pointer or integer into it by casting your value to ImTextureID / void*, and vice-versa.
+Because both end-points (user code and rendering function) are under your control, you know exactly what is stored inside the ImTextureID / void*.
+Examples:
+```cpp
+GLuint my_tex = XXX;
+void* my_void_ptr;
+my_void_ptr = (void*)(intptr_t)my_tex; // cast a GLuint into a void* (we don't take its address! we literally store the value inside the pointer)
+my_tex = (GLuint)(intptr_t)my_void_ptr; // cast a void* into a GLuint
+
+ID3D11ShaderResourceView* my_dx11_srv = XXX;
+void* my_void_ptr;
+my_void_ptr = (void*)my_dx11_srv; // cast a ID3D11ShaderResourceView* into an opaque void*
+my_dx11_srv = (ID3D11ShaderResourceView*)my_void_ptr; // cast a void* into a ID3D11ShaderResourceView*
+```
+Finally, you may call `ImGui::ShowMetricsWindow()` to explore/visualize/understand how the ImDrawList are generated.
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I use my own math types instead of ImVec2/ImVec4?
+
+You can edit [imconfig.h](https://github.com/ocornut/imgui/blob/master/imconfig.h) and setup the `IM_VEC2_CLASS_EXTRA`/`IM_VEC4_CLASS_EXTRA` macros to add implicit type conversions.
+This way you'll be able to use your own types everywhere, e.g. passing `MyVector2` or `glm::vec2` to ImGui functions instead of `ImVec2`.
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I interact with standard C++ types (such as std::string and std::vector)?
+- Being highly portable (bindings for several languages, frameworks, programming style, obscure or older platforms/compilers), and aiming for compatibility & performance suitable for every modern real-time game engines, dear imgui does not use any of std C++ types. We use raw types (e.g. char* instead of std::string) because they adapt to more use cases.
+- To use ImGui::InputText() with a std::string or any resizable string class, see [misc/cpp/imgui_stdlib.h](https://github.com/ocornut/imgui/blob/master/misc/cpp/imgui_stdlib.h).
+- To use combo boxes and list boxes with `std::vector` or any other data structure: the `BeginCombo()/EndCombo()` API
+lets you iterate and submit items yourself, so does the `ListBoxHeader()/ListBoxFooter()` API.
+Prefer using them over the old and awkward `Combo()/ListBox()` api.
+- Generally for most high-level types you should be able to access the underlying data type.
+You may write your own one-liner wrappers to facilitate user code (tip: add new functions in ImGui:: namespace from your code).
+- Dear ImGui applications often need to make intensive use of strings. It is expected that many of the strings you will pass
+to the API are raw literals (free in C/C++) or allocated in a manner that won't incur a large cost on your application.
+Please bear in mind that using `std::string` on applications with large amount of UI may incur unsatisfactory performances.
+Modern implementations of `std::string` often include small-string optimization (which is often a local buffer) but those
+are not configurable and not the same across implementations.
+- If you are finding your UI traversal cost to be too large, make sure your string usage is not leading to excessive amount
+of heap allocations. Consider using literals, statically sized buffers and your own helper functions. A common pattern
+is that you will need to build lots of strings on the fly, and their maximum length can be easily be scoped ahead.
+One possible implementation of a helper to facilitate printf-style building of strings: https://github.com/ocornut/Str
+This is a small helper where you can instance strings with configurable local buffers length. Many game engines will
+provide similar or better string helpers.
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I display custom shapes? (using low-level ImDrawList API)
+
+- You can use the low-level `ImDrawList` api to render shapes within a window.
+
+```
+ImGui::Begin("My shapes");
+
+ImDrawList* draw_list = ImGui::GetWindowDrawList();
+
+// Get the current ImGui cursor position
+ImVec2 p = ImGui::GetCursorScreenPos();
+
+// Draw a red circle
+draw_list->AddCircleFilled(ImVec2(p.x + 50, p.y + 50), 30.0f, IM_COL32(255, 0, 0, 255), 16);
+
+// Draw a 3 pixel thick yellow line
+draw_list->AddLine(ImVec2(p.x, p.y), ImVec2(p.x + 100.0f, p.y + 100.0f), IM_COL32(255, 255, 0, 255), 3.0f);
+
+// Advance the ImGui cursor to claim space in the window (otherwise the window will appears small and needs to be resized)
+ImGui::Dummy(ImVec2(200, 200));
+
+ImGui::End();
+```
+
+
+- Refer to "Demo > Examples > Custom Rendering" in the demo window and read the code of `ShowExampleAppCustomRendering()` in `imgui_demo.cpp` from more examples.
+- To generate colors: you can use the macro `IM_COL32(255,255,255,255)` to generate them at compile time, or use `ImGui::GetColorU32(IM_COL32(255,255,255,255))` or `ImGui::GetColorU32(ImVec4(1.0f,1.0f,1.0f,1.0f))` to generate a color that is multiplied by the current value of `style.Alpha`.
+- Math operators: if you have setup `IM_VEC2_CLASS_EXTRA` in `imconfig.h` to bind your own math types, you can use your own math types and their natural operators instead of ImVec2. ImVec2 by default doesn't export any math operators in the public API. You may use `#define IMGUI_DEFINE_MATH_OPERATORS` `#include "imgui_internal.h"` to use the internally defined math operators, but instead prefer using your own math library and set it up in `imconfig.h`.
+- You can use `ImGui::GetBackgroundDrawList()` or `ImGui::GetForegroundDrawList()` to access draw lists which will be displayed behind and over every other dear imgui windows (one bg/fg drawlist per viewport). This is very convenient if you need to quickly display something on the screen that is not associated to a dear imgui window.
+- You can also create your own dummy window and draw inside it. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags (The `ImGuiWindowFlags_NoDecoration` flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse). Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
+- You can create your own ImDrawList instance. You'll need to initialize them with `ImGui::GetDrawListSharedData()`, or create your own instancing ImDrawListSharedData, and then call your renderer function with your own ImDrawList or ImDrawData data.
+
+##### [Return to Index](#index)
+
+---
+
+# Q&A: Fonts, Text
+
+### Q: How should I handle DPI in my application?
+
+The short answer is: obtain the desired DPI scale, load a suitable font resized with that scale (always round down font size to nearest integer), and scale your Style structure accordingly using `style.ScaleAllSizes()`.
+
+Your application may want to detect DPI change and reload the font and reset style being frames.
+
+Your ui code should avoid using hardcoded constants for size and positioning. Prefer to express values as multiple of reference values such as `ImGui::GetFontSize()` or `ImGui::GetFrameHeight()`. So e.g. instead of seeing a hardcoded height of 500 for a given item/window, you may want to use `30*ImGui::GetFontSize()` instead.
+
+Down the line Dear ImGui will provide a variety of standardized reference values to facilitate using this.
+
+Applications in the `examples/` folder are not DPI aware partly because they are unable to load a custom font from the file-system (may change that in the future).
+
+The reason DPI is not auto-magically solved in stock examples is that we don't yet have a satisfying solution for the "multi-dpi" problem (using the `docking` branch: when multiple viewport windows are over multiple monitors using different DPI scale). The current way to handle this on the application side is:
+- Create and maintain one font atlas per active DPI scale (e.g. by iterating `platform_io.Monitors[]` before `NewFrame()`).
+- Hook `platform_io.OnChangedViewport()` to detect when a `Begin()` call makes a Dear ImGui window change monitor (and therefore DPI).
+- In the hook: swap atlas, swap style with correctly sized one, remap the current font from one atlas to the other (may need to maintain a remapping table of your fonts at variying DPI scale).
+
+This approach is relatively easy and functional but come with two issues:
+- It's not possibly to reliably size or position a window ahead of `Begin()` without knowing on which monitor it'll land.
+- Style override may be lost during the `Begin()` call crossing monitor boundaries. You may need to do some custom scaling mumbo-jumbo if you want your `OnChangedViewport()` handler to preserve style overrides.
+
+Please note that if you are not using multi-viewports with multi-monitors using different DPI scale, you can ignore all of this and use the simpler technique recommended at the top.
+
+### Q: How can I load a different font than the default?
+Use the font atlas to load the TTF/OTF file you want:
+
+```cpp
+ImGuiIO& io = ImGui::GetIO();
+io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
+io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
+```
+
+Default is ProggyClean.ttf, monospace, rendered at size 13, embedded in dear imgui's source code.
+
+(Tip: monospace fonts are convenient because they allow to facilitate horizontal alignment directly at the string level.)
+
+(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file for more details about font loading.)
+
+New programmers: remember that in C/C++ and most programming languages if you want to use a
+backslash \ within a string literal, you need to write it double backslash "\\":
+
+```cpp
+io.Fonts->AddFontFromFileTTF("MyFolder\MyFont.ttf", size); // WRONG (you are escaping the M here!)
+io.Fonts->AddFontFromFileTTF("MyFolder\\MyFont.ttf", size; // CORRECT
+io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
+```
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I easily use icons in my application?
+The most convenient and practical way is to merge an icon font such as FontAwesome inside you
+main font. Then you can refer to icons within your strings.
+You may want to see `ImFontConfig::GlyphMinAdvanceX` to make your icon look monospace to facilitate alignment.
+(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file for more details about icons font loading.)
+With some extra effort, you may use colorful icon by registering custom rectangle space inside the font atlas,
+and copying your own graphics data into it. See docs/FONTS.md about using the AddCustomRectFontGlyph API.
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I load multiple fonts?
+Use the font atlas to pack them into a single texture:
+(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file and the code in ImFontAtlas for more details.)
+
+```cpp
+ImGuiIO& io = ImGui::GetIO();
+ImFont* font0 = io.Fonts->AddFontDefault();
+ImFont* font1 = io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
+ImFont* font2 = io.Fonts->AddFontFromFileTTF("myfontfile2.ttf", size_in_pixels);
+io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
+// the first loaded font gets used by default
+// use ImGui::PushFont()/ImGui::PopFont() to change the font at runtime
+
+// Options
+ImFontConfig config;
+config.OversampleH = 2;
+config.OversampleV = 1;
+config.GlyphOffset.y -= 1.0f; // Move everything by 1 pixels up
+config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters
+io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, &config);
+
+// Combine multiple fonts into one (e.g. for icon fonts)
+static ImWchar ranges[] = { 0xf000, 0xf3ff, 0 };
+ImFontConfig config;
+config.MergeMode = true;
+io.Fonts->AddFontDefault();
+io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font
+io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs
+```
+
+##### [Return to Index](#index)
+
+---
+
+### Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
+When loading a font, pass custom Unicode ranges to specify the glyphs to load.
+
+```cpp
+// Add default Japanese ranges
+io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+// Or create your own custom ranges (e.g. for a game you can feed your entire game script and only build the characters the game need)
+ImVector ranges;
+ImFontGlyphRangesBuilder builder;
+builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters)
+builder.AddChar(0x7262); // Add a specific character
+builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges
+builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted)
+io.Fonts->AddFontFromFileTTF("myfontfile.ttf", 16.0f, NULL, ranges.Data);
+```
+
+All your strings needs to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8
+by using the u8"hello" syntax. Specifying literal in your source code using a local code page
+(such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
+Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
+
+Text input: it is up to your application to pass the right character code by calling `io.AddInputCharacter()`.
+The applications in examples/ are doing that.
+Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
+You may also use MultiByteToWideChar() or ToUnicode() to retrieve Unicode codepoints from MultiByte characters or keyboard state.
+Windows: if your language is relying on an Input Method Editor (IME), you copy the HWND of your window to io.ImeWindowHandle in order for
+the default implementation of io.ImeSetInputScreenPosFn() to set your Microsoft IME position correctly.
+
+##### [Return to Index](#index)
+
+---
+
+# Q&A: Concerns
+
+### Q: Who uses Dear ImGui?
+
+You may take a look at:
+
+- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes)
+- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui)
+- [Gallery](https://github.com/ocornut/imgui/issues/3075)
+
+##### [Return to Index](#index)
+
+---
+
+### Q: Can you create elaborate/serious tools with Dear ImGui?
+
+Yes. People have written game editors, data browsers, debuggers, profilers and all sort of non-trivial tools with the library. In my experience the simplicity of the API is very empowering. Your UI runs close to your live data. Make the tools always-on and everybody in the team will be inclined to create new tools (as opposed to more "offline" UI toolkits where only a fraction of your team effectively creates tools). The list of sponsors below is also an indicator that serious game teams have been using the library.
+
+Dear ImGui is very programmer centric and the immediate-mode GUI paradigm might require you to readjust some habits before you can realize its full potential. Dear ImGui is about making things that are simple, efficient and powerful.
+
+Dear ImGui is built to be efficient and scalable toward the needs for AAA-quality applications running all day. The IMGUI paradigm offers different opportunities for optimization that the more typical RMGUI paradigm.
+
+##### [Return to Index](#index)
+
+---
+
+### Q: Can you reskin the look of Dear ImGui?
+
+Somehow. You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as Dear ImGui is designed and optimized to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. Dear ImGui is NOT designed to create user interface for games, although with ingenious use of the low-level API you can do it.
+
+A reasonably skinned application may look like (screenshot from [#2529](https://github.com/ocornut/imgui/issues/2529#issuecomment-524281119))
+
+
+##### [Return to Index](#index)
+
+---
+
+### Q: Why using C++ (as opposed to C)?
+
+Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost insanity/quagmire. Dear ImGui does NOT require C++11 so it can be used with most old C++ compilers. Dear ImGui doesn't use any C++ header file. Language-wise, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience.
+
+There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/cimgui/cimgui) by Sonoro1234 and Stephan Dilly. It is designed for creating binding to other languages. If possible, I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings) for various third-party bindings.
+
+##### [Return to Index](#index)
+
+---
+
+# Q&A: Community
+
+### Q: How can I help?
+- Businesses: please reach out to `contact AT dearimgui.org` if you work in a place using Dear ImGui! We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts. This is among the most useful thing you can do for Dear ImGui. With increased funding we can hire more people working on this project.
+- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md).
+- If you are experienced with Dear ImGui and C++, look at the [GitHub Issues](https://github.com/ocornut/imgui/issues), look at the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt) and see how you want to help and can help!
+- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
+You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/3075). Visuals are ideal as they inspire other programmers. Disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
+- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
+
+##### [Return to Index](#index)
+
diff --git a/third_party/imgui/docs/FONTS.md b/third_party/imgui/docs/FONTS.md
new file mode 100644
index 0000000000..158e08abc3
--- /dev/null
+++ b/third_party/imgui/docs/FONTS.md
@@ -0,0 +1,389 @@
+## Dear ImGui: Using Fonts
+
+(You may browse this document at https://github.com/ocornut/imgui/blob/master/docs/FONTS.md or view this file with any Markdown viewer.)
+
+The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' (by Tristan Grimmer),
+a 13 pixels high, pixel-perfect font used by default. We embed it in the source code so you can use Dear ImGui without any file system access. ProggyClean does not scale smoothly, therefore it is recommended that you load your own file when using Dear ImGui in an application aiming to look nice and wanting to support multiple resolutions.
+
+You may also load external .TTF/.OTF files.
+In the [misc/fonts/](https://github.com/ocornut/imgui/tree/master/misc/fonts) folder you can find a few suggested fonts, provided as a convenience.
+
+**Read the FAQ:** https://www.dearimgui.org/faq (there is a Fonts section!)
+
+**Use the Discord server**: http://discord.dearimgui.org and not the GitHub issue tracker for basic font loading questions.
+
+## Index
+- [Readme First](#readme-first)
+- [How should I handle DPI in my application?](#how-should-i-handle-dpi-in-my-application)
+- [Fonts Loading Instructions](#font-loading-instructions)
+- [Using Icons](#using-icons)
+- [Using FreeType Rasterizer](#using-freetype-rasterizer)
+- [Using Custom Glyph Ranges](#using-custom-glyph-ranges)
+- [Using Custom Colorful Icons](#using-custom-colorful-icons)
+- [Using Font Data Embedded In Source Code](#using-font-data-embedded-in-source-code)
+- [About filenames](#about-filenames)
+- [Credits/Licenses For Fonts Included In Repository](#creditslicenses-for-fonts-included-in-repository)
+- [Font Links](#font-links)
+
+---------------------------------------
+ ## Readme First
+
+- All loaded fonts glyphs are rendered into a single texture atlas ahead of time. Calling either of `io.Fonts->GetTexDataAsAlpha8()`, `io.Fonts->GetTexDataAsRGBA32()` or `io.Fonts->Build()` will build the atlas.
+
+- You can use the style editor `ImGui::ShowStyleEditor()` in the "Fonts" section to browse your fonts and understand what's going on if you have an issue. You can also reach it in `Demo->Tools->Style Editor->Fonts`:
+
+
+
+- Make sure your font ranges data are persistent (available during the calls to `GetTexDataAsAlpha8()`/`GetTexDataAsRGBA32()/`Build()`.
+
+- Use C++11 u8"my text" syntax to encode literal strings as UTF-8. e.g.:
+```cpp
+u8"hello"
+u8"こんにちは" // this will be encoded as UTF-8
+```
+
+##### [Return to Index](#index)
+
+## How should I handle DPI in my application?
+
+See [FAQ entry](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-should-i-handle-dpi-in-my-application).
+
+##### [Return to Index](#index)
+
+
+## Font Loading Instructions
+
+**Load default font:**
+```cpp
+ImGuiIO& io = ImGui::GetIO();
+io.Fonts->AddFontDefault();
+```
+
+
+**Load .TTF/.OTF file with:**
+```cpp
+ImGuiIO& io = ImGui::GetIO();
+io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
+```
+If you get an assert stating "Could not load font file!", your font filename is likely incorrect. Read "[About filenames](#about-filenames)" carefully.
+
+
+**Load multiple fonts:**
+```cpp
+ImGuiIO& io = ImGui::GetIO();
+ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
+ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels);
+
+// Select font at runtime
+ImGui::Text("Hello"); // use the default font (which is the first loaded font)
+ImGui::PushFont(font2);
+ImGui::Text("Hello with another font");
+ImGui::PopFont();
+```
+
+
+**For advanced options create a ImFontConfig structure and pass it to the AddFont() function (it will be copied internally):**
+```cpp
+ImFontConfig config;
+config.OversampleH = 2;
+config.OversampleV = 1;
+config.GlyphExtraSpacing.x = 1.0f;
+ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
+```
+
+
+**Combine multiple fonts into one:**
+```cpp
+// Load a first font
+ImFont* font = io.Fonts->AddFontDefault();
+
+// Add character ranges and merge into the previous font
+// The ranges array is not copied by the AddFont* functions and is used lazily
+// so ensure it is available at the time of building or calling GetTexDataAsRGBA32().
+static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // Will not be copied by AddFont* so keep in scope.
+ImFontConfig config;
+config.MergeMode = true;
+io.Fonts->AddFontFromFileTTF("DroidSans.ttf", 18.0f, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge into first font
+io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 18.0f, &config, icons_ranges); // Merge into first font
+io.Fonts->Build();
+```
+
+**Add a fourth parameter to bake specific font ranges only:**
+
+```cpp
+// Basic Latin, Extended Latin
+io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, NULL, io.Fonts->GetGlyphRangesDefault());
+
+// Default + Selection of 2500 Ideographs used by Simplified Chinese
+io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, NULL, io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
+
+// Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
+io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, NULL, io.Fonts->GetGlyphRangesJapanese());
+```
+See [Using Custom Glyph Ranges](#using-custom-glyph-ranges) section to create your own ranges.
+
+
+**Example loading and using a Japanese font:**
+
+```cpp
+ImGuiIO& io = ImGui::GetIO();
+io.Fonts->AddFontFromFileTTF("NotoSansCJKjp-Medium.otf", 20.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+```
+```cpp
+ImGui::Text(u8"こんにちは!テスト %d", 123);
+if (ImGui::Button(u8"ロード"))
+{
+ // do stuff
+}
+ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
+ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+```
+
+
+
_(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_
+
+
+**Offset font vertically by altering the `io.Font->DisplayOffset` value:**
+```cpp
+ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
+font->DisplayOffset.y = 1; // Render 1 pixel down
+```
+
+**Font Atlas too large?**
+
+- If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API. The typical result of failing to upload a texture is if every glyphs appears as white rectangles.
+- In particular, using a large range such as `GetGlyphRangesChineseSimplifiedCommon()` is not recommended unless you set `OversampleH`/`OversampleV` to 1 and use a small font size.
+- Mind the fact that some graphics drivers have texture size limitation.
+- If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
+
+Some solutions:
+
+1. Reduce glyphs ranges by calculating them from source localization data.
+ You can use the `ImFontGlyphRangesBuilder` for this purpose, this will be the biggest win!
+2. You may reduce oversampling, e.g. `font_config.OversampleH = font_config.OversampleV = 1`, this will largely reduce your texture size.
+3. Set `io.Fonts.TexDesiredWidth` to specify a texture width to minimize texture height (see comment in `ImFontAtlas::Build()` function).
+4. Set `io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;` to disable rounding the texture height to the next power of two.
+5. Read about oversampling [here](https://github.com/nothings/stb/blob/master/tests/oversample).
+
+##### [Return to Index](#index)
+
+## Using Icons
+
+Using an icon font (such as [FontAwesome](http://fontawesome.io) or [OpenFontIcons](https://github.com/traverseda/OpenFontIcons)) is an easy and practical way to use icons in your Dear ImGui application.
+A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without having to change fonts back and forth.
+
+To refer to the icon UTF-8 codepoints from your C++ code, you may use those headers files created by Juliette Foucaut: https://github.com/juliettef/IconFontCppHeaders.
+
+So you can use `ICON_FA_SEARCH` as a string that will render as a "Search" icon.
+
+Example Setup:
+```cpp
+// Merge icons into default tool font
+#include "IconsFontAwesome.h"
+ImGuiIO& io = ImGui::GetIO();
+io.Fonts->AddFontDefault();
+
+ImFontConfig config;
+config.MergeMode = true;
+config.GlyphMinAdvanceX = 13.0f; // Use if you want to make the icon monospaced
+static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
+io.Fonts->AddFontFromFileTTF("fonts/fontawesome-webfont.ttf", 13.0f, &config, icon_ranges);
+```
+Example Usage:
+```cpp
+// Usage, e.g.
+ImGui::Text("%s among %d items", ICON_FA_SEARCH, count);
+ImGui::Button(ICON_FA_SEARCH " Search");
+// C string _literals_ can be concatenated at compilation time, e.g. "hello" " world"
+// ICON_FA_SEARCH is defined as a string literal so this is the same as "A" "B" becoming "AB"
+```
+See Links below for other icons fonts and related tools.
+
+Here's an application using icons ("Avoyd", https://www.avoyd.com):
+
+
+##### [Return to Index](#index)
+
+## Using FreeType Rasterizer
+
+- Dear ImGui uses imstb\_truetype.h to rasterize fonts (with optional oversampling). This technique and its implementation are not ideal for fonts rendered at small sizes, which may appear a little blurry or hard to read.
+- There is an implementation of the ImFontAtlas builder using FreeType that you can use in the [misc/freetype/](https://github.com/ocornut/imgui/tree/master/misc/freetype) folder.
+- FreeType supports auto-hinting which tends to improve the readability of small fonts.
+- Read documentation in the [misc/freetype/](https://github.com/ocornut/imgui/tree/master/misc/freetype) folder.
+- Correct sRGB space blending will have an important effect on your font rendering quality.
+
+##### [Return to Index](#index)
+
+## Using Custom Glyph Ranges
+
+You can use the `ImFontGlyphRangesBuilder` helper to create glyph ranges based on text input. For example: for a game where your script is known, if you can feed your entire script to it and only build the characters the game needs.
+```cpp
+ImVector ranges;
+ImFontGlyphRangesBuilder builder;
+builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters)
+builder.AddChar(0x7262); // Add a specific character
+builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges
+builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted)
+
+io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, ranges.Data);
+io.Fonts->Build(); // Build the atlas while 'ranges' is still in scope and not deleted.
+```
+
+##### [Return to Index](#index)
+
+## Using Custom Colorful Icons
+
+**(This is a BETA api, use if you are familiar with dear imgui and with your rendering back-end)**
+
+- You can use the `ImFontAtlas::AddCustomRect()` and `ImFontAtlas::AddCustomRectFontGlyph()` api to register rectangles that will be packed into the font atlas texture. Register them before building the atlas, then call Build()`.
+- You can then use `ImFontAtlas::GetCustomRectByIndex(int)` to query the position/size of your rectangle within the texture, and blit/copy any graphics data of your choice into those rectangles.
+- This API is beta because it is likely to change in order to support multi-dpi (multiple viewports on multiple monitors with varying DPI scale).
+
+#### Pseudo-code:
+```cpp
+// Add font, then register two custom 13x13 rectangles mapped to glyph 'a' and 'b' of this font
+ImFont* font = io.Fonts->AddFontDefault();
+int rect_ids[2];
+rect_ids[0] = io.Fonts->AddCustomRectFontGlyph(font, 'a', 13, 13, 13+1);
+rect_ids[1] = io.Fonts->AddCustomRectFontGlyph(font, 'b', 13, 13, 13+1);
+
+// Build atlas
+io.Fonts->Build();
+
+// Retrieve texture in RGBA format
+unsigned char* tex_pixels = NULL;
+int tex_width, tex_height;
+io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_width, &tex_height);
+
+for (int rect_n = 0; rect_n < IM_ARRAYSIZE(rect_ids); rect_n++)
+{
+ int rect_id = rects_ids[rect_n];
+ if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id))
+ {
+ // Fill the custom rectangle with red pixels (in reality you would draw/copy your bitmap data here!)
+ for (int y = 0; y < rect->Height; y++)
+ {
+ ImU32* p = (ImU32*)tex_pixels + (rect->Y + y) * tex_width + (rect->X);
+ for (int x = rect->Width; x > 0; x--)
+ *p++ = IM_COL32(255, 0, 0, 255);
+ }
+ }
+}
+```
+
+##### [Return to Index](#index)
+
+## Using Font Data Embedded In Source Code
+
+- Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) to create a compressed C style array that you can embed in source code.
+- See the documentation in [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instruction on how to use the tool.
+- You may find a precompiled version binary_to_compressed_c.exe for Windows instead of demo binaries package (see [README](https://github.com/ocornut/imgui/blob/master/docs/README.md)).
+- The tool can optionally output Base85 encoding to reduce the size of _source code_ but the read-only arrays in the actual binary will be about 20% bigger.
+
+Then load the font with:
+```cpp
+ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels, ...);
+```
+or
+```cpp
+ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_base85, size_pixels, ...);
+```
+
+##### [Return to Index](#index)
+
+## About filenames
+
+**Please note that many new C/C++ users have issues their files _because the filename they provide is wrong_.**
+
+Two things to watch for:
+- Make sure your IDE/debugger settings starts your executable from the right working directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it oftens start from the folder where object or executable files are stored.
+```cpp
+// Relative filename depends on your Working Directory when running your program!
+io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...);
+
+// Load from the parent folder of your Working Directory
+io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...);
+```
+- In C/C++ and most programming languages if you want to use a backslash `\` within a string literal, you need to write it double backslash `\\`. At it happens, Windows uses backslashes as a path separator, so be mindful.
+```cpp
+io.Fonts->AddFontFromFileTTF("MyFiles\MyImage01.jpg", ...); // This is INCORRECT!!
+io.Fonts->AddFontFromFileTTF("MyFiles\\MyImage01.jpg", ...); // This is CORRECT
+```
+In some situations, you may also use `/` path separator under Windows.
+
+##### [Return to Index](#index)
+
+## Credits/Licenses For Fonts Included In Repository
+
+Some fonts files are available in the `misc/fonts/` folder:
+
+```
+Roboto-Medium.ttf
+ Apache License 2.0
+ by Christian Robetson
+ https://fonts.google.com/specimen/Roboto
+
+Cousine-Regular.ttf
+ by Steve Matteson
+ Digitized data copyright (c) 2010 Google Corporation.
+ Licensed under the SIL Open Font License, Version 1.1
+ https://fonts.google.com/specimen/Cousine
+
+DroidSans.ttf
+ Copyright (c) Steve Matteson
+ Apache License, version 2.0
+ https://www.fontsquirrel.com/fonts/droid-sans
+
+ProggyClean.ttf
+ Copyright (c) 2004, 2005 Tristan Grimmer
+ MIT License
+ recommended loading setting: Size = 13.0, DisplayOffset.Y = +1
+ http://www.proggyfonts.net/
+
+ProggyTiny.ttf
+ Copyright (c) 2004, 2005 Tristan Grimmer
+ MIT License
+ recommended loading setting: Size = 10.0, DisplayOffset.Y = +1
+ http://www.proggyfonts.net/
+
+Karla-Regular.ttf
+ Copyright (c) 2012, Jonathan Pinhorn
+ SIL OPEN FONT LICENSE Version 1.1
+```
+
+##### [Return to Index](#index)
+
+## Font Links
+
+#### ICON FONTS
+
+- C/C++ header for icon fonts (#define with code points to use in source code string literals) https://github.com/juliettef/IconFontCppHeaders
+- FontAwesome https://fortawesome.github.io/Font-Awesome
+- OpenFontIcons https://github.com/traverseda/OpenFontIcons
+- Google Icon Fonts https://design.google.com/icons/
+- Kenney Icon Font (Game Controller Icons) https://github.com/nicodinh/kenney-icon-font
+- IcoMoon - Custom Icon font builder https://icomoon.io/app
+
+#### REGULAR FONTS
+
+- Google Noto Fonts (worldwide languages) https://www.google.com/get/noto/
+- Open Sans Fonts https://fonts.google.com/specimen/Open+Sans
+- (Japanese) M+ fonts by Coji Morishita http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html
+
+#### MONOSPACE FONTS
+
+Pixel Perfect:
+- Proggy Fonts, by Tristan Grimmer http://www.proggyfonts.net or http://upperbounds.net
+- Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A) https://github.com/kmar/Sweet16Font (also include an .inl file to use directly in dear imgui.)
+
+Regular:
+- Google Noto Mono Fonts https://www.google.com/get/noto/
+- Typefaces for source code beautification https://github.com/chrissimpkins/codeface
+- Programmation fonts http://s9w.github.io/font_compare/
+- Inconsolata http://www.levien.com/type/myfonts/inconsolata.html
+- Adobe Source Code Pro: Monospaced font family for ui & coding environments https://github.com/adobe-fonts/source-code-pro
+- Monospace/Fixed Width Programmer's Fonts http://www.lowing.org/fonts/
+
+Or use Arial Unicode or other Unicode fonts provided with Windows for full characters coverage (not sure of their licensing).
+
+##### [Return to Index](#index)
diff --git a/third_party/imgui/docs/README.md b/third_party/imgui/docs/README.md
new file mode 100644
index 0000000000..a0ca6483c2
--- /dev/null
+++ b/third_party/imgui/docs/README.md
@@ -0,0 +1,227 @@
+Dear ImGui
+=====
+[](https://github.com/ocornut/imgui/actions?workflow=build)
+
+(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out.)
+
+Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
+
_E-mail: contact @ dearimgui dot com_
+
+Individuals: support continued maintenance and development with [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S).
+
+----
+
+Dear ImGui is a **bloat-free graphical user interface library for C++**. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
+
+Dear ImGui is designed to **enable fast iterations** and to **empower programmers** to create **content creation tools and visualization / debug tools** (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.
+
+Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.
+
+| [Usage](#usage) - [How it works](#how-it-works) - [Demo](#demo) - [Integration](#integration) |
+:----------------------------------------------------------: |
+| [Upcoming changes](#upcoming-changes) - [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](#sponsors) - [Credits](#credits) - [License](#license) |
+| [Wiki](https://github.com/ocornut/imgui/wiki) - [Language & frameworks bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
+
+### Usage
+
+**The core of Dear ImGui is self-contained within a few platform-agnostic files** which you can easily compile in your application/engine. They are all the files in the root folder of the repository (imgui.cpp, imgui.h, imgui_demo.cpp, imgui_draw.cpp etc.).
+
+**No specific build process is required**. You can add the .cpp files to your existing project.
+
+You will need a backend to integrate Dear ImGui in your app. The backend passes mouse/keyboard/gamepad inputs and variety of settings to Dear ImGui, and is in charge of rendering the resulting vertices.
+
+**Backends for a variety of graphics api and rendering platforms** are provided in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder, along with example applications. See the [Integration](#integration) section of this document for details. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui.
+
+After Dear ImGui is setup in your application, you can use it from \_anywhere\_ in your program loop:
+
+Code:
+```cp
+ImGui::Text("Hello, world %d", 123);
+if (ImGui::Button("Save"))
+ MySaveFunction();
+ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
+ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
+```
+Result:
+
 
+
_(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px / Rounding: 5)_
+
+Code:
+```cpp
+// Create a window called "My First Tool", with a menu bar.
+ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar);
+if (ImGui::BeginMenuBar())
+{
+ if (ImGui::BeginMenu("File"))
+ {
+ if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ }
+ if (ImGui::MenuItem("Save", "Ctrl+S")) { /* Do stuff */ }
+ if (ImGui::MenuItem("Close", "Ctrl+W")) { my_tool_active = false; }
+ ImGui::EndMenu();
+ }
+ ImGui::EndMenuBar();
+}
+
+// Edit a color (stored as ~4 floats)
+ImGui::ColorEdit4("Color", my_color);
+
+// Plot some values
+const float my_values[] = { 0.2f, 0.1f, 1.0f, 0.5f, 0.9f, 2.2f };
+ImGui::PlotLines("Frame Times", my_values, IM_ARRAYSIZE(my_values));
+
+// Display contents in a scrolling region
+ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff");
+ImGui::BeginChild("Scrolling");
+for (int n = 0; n < 50; n++)
+ ImGui::Text("%04d: Some text", n);
+ImGui::EndChild();
+ImGui::End();
+```
+Result:
+

+
+Dear ImGui allows you to **create elaborate tools** as well as very short-lived ones. On the extreme side of short-livedness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc.
+
+### How it works
+
+Check out the Wiki's [About the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#About-the-IMGUI-paradigm) section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
+
+Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase.
+
+_A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._
+
+### Demo
+
+Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcasing variety of features and examples. The code is always available for reference in `imgui_demo.cpp`.
+
+
+
+You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let us know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
+- [imgui-demo-binaries-20190715.zip](http://www.dearimgui.org/binaries/imgui-demo-binaries-20200412.zip) (Windows binaries, 1.76, built 2020/04/12, master branch) or [older demo binaries](http://www.dearimgui.org/binaries).
+
+The demo applications are not DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at different scale, and scale your style with `style.ScaleAllSizes()` (see [FAQ](https://www.dearimgui.org/faq)).
+
+### Integration
+
+On most platforms and when using C++, **you should be able to use a combination of the [imgui_impl_xxxx](https://github.com/ocornut/imgui/tree/master/examples) files without modification** (e.g. `imgui_impl_win32.cpp` + `imgui_impl_dx11.cpp`). If your engine supports multiple platforms, consider using more of the imgui_impl_xxxx files instead of rewriting them: this will be less work for you and you can get Dear ImGui running immediately. You can _later_ decide to rewrite a custom binding using your custom engine functions if you wish so.
+
+Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading one texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles. The [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder is populated with applications doing just that. If you are an experienced programmer at ease with those concepts, it should take you less than two hours to integrate Dear ImGui in your custom engine. **Make sure to spend time reading the [FAQ](https://www.dearimgui.org/faq), comments, and some of the examples/ application!**
+
+Officially maintained bindings (in repository):
+- Renderers: DirectX9, DirectX10, DirectX11, DirectX12, OpenGL (legacy), OpenGL3/ES/ES2 (modern), Vulkan, Metal.
+- Platforms: GLFW, SDL2, Win32, Glut, OSX.
+- Frameworks: Emscripten, Allegro5, Marmalade.
+
+Third-party bindings (see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings/) page):
+- Languages: C, C#/.Net, ChaiScript, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Kotlin, Lua, Odin, Pascal, PureBasic, Python, Ruby, Rust, Swift...
+- Frameworks: AGS/Adventure Game Studio, Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, GML/Game Maker Studio2, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, NanoRT, Nim Game Lib, Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, Photoshop, px_render, Qt/QtDirect3D, SFML, Sokol, Unity, Unreal Engine 4, vtk, Win32 GDI, WxWidgets.
+- Note that C bindings ([cimgui](https://github.com/cimgui/cimgui)) are auto-generated, you can use its json/lua output to generate bindings for other languages.
+
+Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
+
+### Upcoming Changes
+
+Some of the goals for 2020 are:
+- Work on docking. (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch)
+- Work on multiple viewports / multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
+- Work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))
+- Work on new Tables API (to replace Columns). (see [#2957](https://github.com/ocornut/imgui/issues/2957))
+- Work on automation and testing system, both to test the library and end-user apps. (see [#435](https://github.com/ocornut/imgui/issues/435))
+- Make the examples look better, improve styles, improve font support, make the examples hi-DPI and multi-DPI aware.
+
+### Gallery
+
+For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/3075)!
+
+Custom engine
+[](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png)
+
+Custom engine
+[](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v160/editor_white.png)
+
+[Tracy Profiler](https://bitbucket.org/wolfpld/tracy)
+
+
+### Support, Frequently Asked Questions (FAQ)
+
+Most common questions will be answered by the [Frequently Asked Questions (FAQ)](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) page.
+
+See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles.
+
+See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#Articles-about-the-IMGUI-paradigm) to read/learn about the Immediate Mode GUI paradigm.
+
+If you are new to Dear ImGui and have issues with: compiling, linking, adding fonts, wiring inputs, running or displaying Dear ImGui: you can use [Discord server](http://discord.dearimgui.org).
+
+Otherwise, for any other questions, bug reports, requests, feedback, you may post on https://github.com/ocornut/imgui/issues. Please read and fill the New Issue template carefully.
+
+Private support is available for paying business customers (E-mail: _contact @ dearimgui dot com_).
+
+**Which version should I get?**
+
+We occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported.
+
+You may also peak at the [Multi-Viewport](https://github.com/ocornut/imgui/issues/1542) and [Docking](https://github.com/ocornut/imgui/issues/2109) features in the `docking` branch. Many projects are using this branch and it is kept in sync with master regularly.
+
+**Who uses Dear ImGui?**
+
+See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also see the [Gallery Threads](https://github.com/ocornut/imgui/issues/3075)!
+
+How to help
+-----------
+
+**How can I help?**
+
+- You may participate in the [Discord server](http://discord.dearimgui.org), [GitHub forum/issues](https://github.com/ocornut/imgui/issues).
+- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest in the end-users and also to ease the maintainer into understanding and accepting it.
+- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
+- Have your company financially support this project (please reach by e-mail)
+
+**How can I help financing further development of Dear ImGui?**
+
+Your contributions are keeping this project alive. The library is available under a free and permissive license, but continued maintenance and development are a full-time endeavor and I would like to grow the team. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out for invoiced technical support and maintenance contracts. Thank you!
+
+Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
+
_E-mail: contact @ dearimgui.com_
+
+Individuals: support continued maintenance and development with [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S).
+
+Sponsors
+--------
+
+Ongoing Dear ImGui development is financially supported by users and private sponsors, recently:
+
+*Platinum-chocolate sponsors*
+- [Blizzard](https://careers.blizzard.com/en-us/openings/engineering/all/all/all/1), [Google](https://github.com/google/filament), [Nvidia](https://developer.nvidia.com/nvidia-omniverse), [Ubisoft](https://montreal.ubisoft.com/en/ubisoft-sponsors-user-interface-library-for-c-dear-imgui/)
+
+*Double-chocolate and Salty caramel sponsors*
+- [Activision](https://careers.activision.com/c/programmingsoftware-engineering-jobs), [Arkane Studios](https://www.arkane-studios.com), [Dotemu](http://www.dotemu.com), [Framefield](http://framefield.com), [Hexagon](https://hexagonxalt.com/the-technology/xalt-visualization), [Kylotonn](https://www.kylotonn.com), [Media Molecule](http://www.mediamolecule.com), [Mesh Consultants](https://www.meshconsultants.ca), [Mobigame](http://www.mobigame.net), [Nadeo](https://www.nadeo.com), [Next Level Games](https://www.nextlevelgames.com), [RAD Game Tools](http://www.radgametools.com/), [Supercell](http://www.supercell.com), [Remedy Entertainment](https://www.remedygames.com/), [Unit 2 Games](https://unit2games.com/)
+
+From November 2014 to December 2019, ongoing development has also been financially supported by its users on Patreon and through individual donations. Please see [detailed list of Dear ImGui supporters](https://github.com/ocornut/imgui/wiki/Sponsors).
+
+**THANK YOU to all past and present supporters for helping to keep this project alive and thriving!**
+
+Dear ImGui is using software and services provided free of charge for open source projects:
+- [PVS-Studio](https://www.viva64.com/en/b/0570/) for static analysis.
+- [GitHub actions](https://github.com/features/actions) for continuous integration systems.
+- [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage) for code coverage analysis.
+
+Credits
+-------
+
+Developed by [Omar Cornut](http://www.miracleworld.net) and every direct or indirect [contributors](https://github.com/ocornut/imgui/graphs/contributors) to the GitHub. The early version of this library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com) (PS Vita).
+
+Recurring contributors (2020): Omar Cornut [@ocornut](https://github.com/ocornut), Rokas Kupstys [@rokups](https://github.com/rokups), Ben Carter [@ShironekoBen](https://github.com/ShironekoBen).
+A large portion of work on automation systems, regression tests and other features are currently unpublished.
+
+"I first discovered the IMGUI paradigm at [Q-Games](http://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it."
+
+Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license).
+
+Embeds [stb_textedit.h, stb_truetype.h, stb_rect_pack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
+
+Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. And everybody posting feedback, questions and patches on the GitHub.
+
+License
+-------
+
+Dear ImGui is licensed under the MIT License, see [LICENSE.txt](https://github.com/ocornut/imgui/blob/master/LICENSE.txt) for more information.
diff --git a/third_party/imgui/docs/TODO.txt b/third_party/imgui/docs/TODO.txt
new file mode 100644
index 0000000000..abb9d513e9
--- /dev/null
+++ b/third_party/imgui/docs/TODO.txt
@@ -0,0 +1,401 @@
+dear imgui
+ISSUES & TODO LIST
+
+Issue numbers (#) refer to github issues listed at https://github.com/ocornut/imgui/issues/XXXX
+The list below consist mostly of ideas noted down before they are requested/discussed by users (at which point they usually exist on the github issue tracker).
+It's mostly a bunch of personal notes, probably incomplete. Feel free to query if you have any questions.
+
+ - doc/test: add a proper documentation+regression testing system (#435)
+ - doc/test: checklist app to verify binding/integration of imgui (test inputs, rendering, callback, etc.).
+ - doc/tips: tips of the day: website? applet in imgui_club?
+ - doc/wiki: work on the wiki https://github.com/ocornut/imgui/wiki
+
+ - window: preserve/restore relative focus ordering (persistent or not) (#2304) -> also see docking reference to same #.
+ - window: calling SetNextWindowSize() every frame with <= 0 doesn't do anything, may be useful to allow (particularly when used for a single axis). (#690)
+ - window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list. perhaps a lightweight explicit cleanup pass.
+ - window: auto-fit feedback loop when user relies on any dynamic layout (window width multiplier, column) appears weird to end-user. clarify.
+ - window: begin with *p_open == false could return false.
+ - window: get size/pos helpers given names (see discussion in #249)
+ - window: a collapsed window can be stuck behind the main menu bar?
+ - window: when window is very small, prioritize resize button over close button.
+ - window: detect extra End() call that pop the "Debug" window out and assert at End() call site instead of at end of frame.
+ - window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd.
+ - window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
+ - window: expose contents size. (#1045)
+ - window: using SetWindowPos() inside Begin() and moving the window with the mouse reacts a very ugly glitch. We should just defer the SetWindowPos() call.
+ - window: GetWindowSize() returns (0,0) when not calculated? (#1045)
+ - window: investigate better auto-positioning for new windows.
+ - window: top most window flag? (#2574)
+ - window/size: manually triggered auto-fit (double-click on grip) shouldn't resize window down to viewport size?
+ - window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. -> this may require enforcing that it is illegal to submit contents if Begin returns false.
+ - window/child: background options for child windows, border option (disable rounding).
+ - window/child: allow resizing of child windows (possibly given min/max for each axis?.)
+ - window/child: the first draw command of a child window could be moved into the current draw command of the parent window (unless child+tooltip?).
+ - window/child: border could be emitted in parent as well.
+ - window/child: allow SetNextWindowContentSize() to work on child windows.
+ - window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
+ - window/tabbing: add a way to signify that a window or docked window requires attention (e.g. blinking title bar).
+ ! scrolling: exposing horizontal scrolling with Shift+Wheel even when scrollbar is disabled expose lots of issues (#2424, #1463)
+ - scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
+ - scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
+ - scrolling: forward mouse wheel scrolling to parent window when at the edge of scrolling limits? (useful for listbox,tables?)
+ - scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro)
+ - scrolling/style: shadows on scrollable areas to denote that there is more contents (see e.g. DaVinci Resolve ui)
+
+ - drawdata: make it easy to clone (or swap?) a full ImDrawData so user can easily save that data if they use threaded rendering. (e.g. #2646)
+ ! drawlist: add calctextsize func to facilitate consistent code from user pov (currently need to use ImGui or ImFont alternatives!)
+ - drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
+ - drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
+ - drawlist: primitives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api
+ - drawlist: make it easier to toggle AA per primitive, so we can use e.g. non-AA fill + AA borders more naturally
+ - drawlist: non-AA strokes have gaps between points (#593, #288), glitch especially on RenderCheckmark() and ColorPicker4().
+ - drawlist: would be good to be able to deep copy of ImDrawData (we have a deep copy of ImDrawList now).
+ - drawlist: rendering: provide a way for imgui to output to a single/global vertex buffer, re-order indices only at the end of the frame (ref: https://gist.github.com/floooh/10388a0afbe08fce9e617d8aefa7d302)
+ - drawlist: callback: add an extra void* in ImDrawCallback to allow passing render-local data to the callback (would break API).
+ - drawlist: AddRect vs AddLine position confusing (#2441)
+ - drawlist: channel splitter should be external helper and not stored in ImDrawList.
+ - drawlist/opt: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding. (#1962)
+ - drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation.
+ - drawlist/opt: thick AA line could be doable in same number of triangles as 1.0 AA line by storing gradient+full color in atlas.
+
+ - main: find a way to preserve relative orders of multiple reappearing windows (so an app toggling between "modes" e.g. fullscreen vs all tools) won't lose relative ordering.
+ - main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
+ - main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
+
+ - widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc. (#395)
+ - widgets: clean up widgets internal toward exposing everything and stabilizing imgui_internals.h.
+ - widgets: add visuals for Disabled/ReadOnly mode and expose publicly (#211)
+ - widgets: add always-allow-overlap mode. This should perhaps be the default? one problem is that highlight after mouse-wheel scrolling gets deferred, makes scrolling more flickery.
+ - widgets: start exposing PushItemFlag() and ImGuiItemFlags
+ - widgets: alignment options in style (e.g. center Selectable, Right-Align within Button, etc.) #1260
+ - widgets: activate by identifier (trigger button, focus given id)
+ - widgets: a way to represent "mixed" values, so e.g. all values replaced with *, including check-boxes, colors, etc. with support for multi-components widgets (e.g. SliderFloat3, make only "Y" mixed) (#2644)
+ - widgets: checkbox: checkbox with custom glyph inside frame.
+ - widgets: coloredit: keep reporting as active when picker is on?
+ - widgets: group/scalarn functions: expose more per-component information. e.g. store NextItemData.ComponentIdx set by scalarn function, groups can expose them back somehow.
+ - selectable: using (size.x == 0.0f) and (SelectableTextAlign.x > 0.0f) followed by SameLine() is currently not supported.
+ - selectable: generic BeginSelectable()/EndSelectable() mechanism.
+ - selectable: a way to visualize partial/mixed selection (e.g. parent tree node has children with mixed selection)
+
+ - input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now and super fragile.
+ - input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
+ - input text: expose CursorPos in char filter event (#816)
+ - input text: try usage idiom of using InputText with data only exposed through get/set accessors, without extraneous copy/alloc. (#3009)
+ - input text: access public fields via a non-callback API e.g. InputTextGetState("xxx") that may return NULL if not active.
+ - input text: flag to disable live update of the user buffer (also applies to float/int text input) (#701)
+ - input text: hover tooltip could show unclamped text
+ - input text: option to Tab after an Enter validation.
+ - input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
+ - input text: easier ways to update buffer (from source char*) while owned. preserve some sort of cursor position for multi-line text.
+ - input text: add flag (e.g. ImGuiInputTextFlags_EscapeClearsBuffer) to clear instead of revert. what to do with focus? (also see #2890)
+ - input text: add discard flag (e.g. ImGuiInputTextFlags_DiscardActiveBuffer) or make it easier to clear active focus for text replacement during edition (#725)
+ - input text: display bug when clicking a drag/slider after an input text in a different window has all-selected text (order dependent). actually a very old bug but no one appears to have noticed it.
+ - input text: allow centering/positioning text so that ctrl+clicking Drag or Slider keeps the textual value at the same pixel position.
+ - input text: decorrelate layout from inputs - e.g. what's the easiest way to implement a nice IP/Mac address input editor?
+ - input text: global callback system so user can plug in an expression evaluator easily. (#1691)
+ - input text: force scroll to end or scroll to a given line/contents (so user can implement a log or a search feature)
+ - input text: a way to preview completion (e.g. disabled text completing from the cursor)
+ - input text: a side bar that could e.g. preview where errors are. probably left to the user to draw but we'd need to give them the info there.
+ - input text: a way for the user to provide syntax coloring.
+ - input text: Shift+TAB with ImGuiInputTextFlags_AllowTabInput could eat preceding blanks, up to tab_count.
+ - input text: facilitate patterns like if (InputText(..., obj.get_string_ref()) { obj.set_string(...); } relying on internally held buffer.
+ - input text multi-line: don't directly call AddText() which does an unnecessary vertex reserve for character count prior to clipping. and/or more line-based clipping to AddText(). and/or reorganize TextUnformatted/RenderText for more efficiency for large text (e.g TextUnformatted could clip and log separately, etc).
+ - input text multi-line: support for cut/paste without selection (cut/paste the current line)
+ - input text multi-line: line numbers? status bar? (follow up on #200)
+ - input text multi-line: behave better when user changes input buffer while editing is active (even though it is illegal behavior). namely, the change of buffer can create a scrollbar glitch (#725)
+ - input text multi-line: better horizontal scrolling support (#383, #1224)
+ - input text multi-line: single call to AddText() should be coarse clipped on InputTextEx() end.
+ - input number: optional range min/max for Input*() functions
+ - input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled)
+ - input number: use mouse wheel to step up/down
+ - input number: applying arithmetics ops (+,-,*,/) messes up with text edit undo stack.
+
+ - layout: helper or a way to express ImGui::SameLine(ImGui::GetCursorStartPos().x + ImGui::CalcItemWidth() + ImGui::GetStyle().ItemInnerSpacing.x); in a simpler manner.
+ - layout, font: horizontal tab support, A) text mode: forward only tabs (e.g. every 4 characters/N pixels from pos x1), B) manual mode: explicit tab stops acting as mini columns, no clipping (for menu items, many kind of uses, also vaguely relate to #267, #395)
+ - layout: horizontal layout helper (#97)
+ - layout: horizontal flow until no space left (#404)
+ - layout: more generic alignment state (left/right/centered) for single items?
+ - layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding.
+ - layout: vertical alignment of mixed height items (e.g. buttons) within a same line (#1284)
+ - layout: null layout mode were items are not rendered but user can query GetItemRectMin()/Max/Size.
+ - layout: (R&D) local multi-pass layout mode.
+ - layout: (R&D) bind authored layout data (created by an off-line tool), items fetch their pos/size at submission, self-optimize data structures to stable linear access.
+
+ - group: BeginGroup() needs a border option. (~#1496)
+ - group: IsHovered() after EndGroup() covers whole aabb rather than the intersection of individual items. Is that desirable?
+ - group: merge deactivation/activation within same group (fwd WasEdited flag). (#2550)
+
+ - columns: sizing policy (e.g. for each column: fixed size, %, fill, distribute default size among fills) (#513, #125)
+ - columns: add a conditional parameter to SetColumnOffset() (#513, #125)
+ - columns: headers. re-orderable. (#513, #125)
+ - columns: optional sorting modifiers (up/down), sort list so sorting can be done multi-criteria. notify user when sort order changed.
+ - columns: option to alternate background colors on odd/even scanlines.
+ - columns: allow columns to recurse.
+ - columns: allow a same columns set to be interrupted by e.g. CollapsingHeader and resume with columns in sync when moving them.
+ - columns: sizing is lossy when columns width is very small (default width may turn negative etc.)
+ - columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (#125)
+ - columns: flag to add horizontal separator above/below?
+ - columns/layout: setup minimum line height (equivalent of automatically calling AlignFirstTextHeightToWidgets)
+
+!- color: the color conversion helpers/types are a mess and needs sorting out.
+ - color: (api breaking) ImGui::ColorConvertXXX functions should be loose ImColorConvertXX to match imgui_internals.h
+
+ - plot: full featured plot/graph api w/ scrolling, zooming etc. all bell & whistle. why not!
+ - plot: PlotLines() should use the polygon-stroke facilities, less vertices (currently issues with averaging normals)
+ - plot: make it easier for user to draw extra stuff into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots)
+ - plot: "smooth" automatic scale over time, user give an input 0.0(full user scale) 1.0(full derived from value)
+ - plot: option/feature: draw the zero line
+ - plot: option/feature: draw grid, vertical markers
+ - plot: option/feature: draw unit
+ - plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID)
+
+ - clipper: ability to force display 1 item in the list would be convenient (for patterns where we need to set active id etc.)
+ - clipper: ability to disable the clipping through a simple flag/bool.
+ - clipper: ability to run without knowing full count in advance.
+ - clipper: horizontal clipping support. (#2580)
+
+ - separator: expose flags (#759)
+ - separator: width, thickness, centering (#1643)
+ - splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
+
+ - dock: merge docking branch (#2109)
+ - dock: dock out from a collapsing header? would work nicely but need emitting window to keep submitting the code.
+
+ - tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
+ - tabs: persistent order/focus in BeginTabBar() api (#261, #351)
+ - tabs: TabItem could honor SetNextItemWidth()?
+ - tabs: explicit api (even if internal) to cleanly manipulate tab order.
+ - tabs: Mouse wheel over tab bar could scroll? (#2702)
+
+ - image/image button: misalignment on padded/bordered button?
+ - image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that?
+ - image button: not taking an explicit id can be problematic. (#2464, #1390)
+ - button: provide a button that looks framed. (?)
+ - slider/drag: ctrl+click when format doesn't include a % character.. disable? display underlying value in default format? (see TempInputTextScalar)
+ - slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
+ - slider: initial absolute click is imprecise. change to relative movement slider (same as scrollbar). (#1946)
+ - slider: add dragging-based widgets to edit values with mouse (on 2 axises), saving screen real-estate.
+ - slider: tint background based on value (e.g. v_min -> v_max, or use 0.0f either side of the sign)
+ - slider: relative dragging? + precision dragging
+ - slider: step option (#1183)
+ - slider style: fill % of the bar instead of positioning a drag.
+ - knob: rotating knob widget (#942)
+ - drag float: power/logarithmic slider and drags are weird. (#1316)
+ - drag float: up/down axis
+ - drag float: power != 0.0f with current value being outside the range keeps the value stuck.
+ - drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits)
+
+ - combo: use clipper: make it easier to disable clipper with a single flag.
+ - combo: flag for BeginCombo to not return true when unchanged (#1182)
+ - combo: a way/helper to customize the combo preview (#1658)
+ - combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203)
+ - listbox: refactor and clean the begin/end api
+ - listbox: multiple selection.
+ - listbox: unselect option (#1208)
+ - listbox: make it easier/more natural to implement range-select (need some sort of info/ref about the last clicked/focused item that user can translate to an index?) (wip stash)
+ - listbox: user may want to initial scroll to focus on the one selected value?
+ - listbox: expose hovered item for a basic ListBox
+ - listbox: keyboard navigation.
+ - listbox: disable capturing mouse wheel if the listbox has no scrolling. (#1681)
+ - listbox: scrolling should track modified selection.
+ - listbox: future api should allow to enable horizontal scrolling (#2510)
+
+!- popups/menus: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331, #402)
+ - modals: make modal title bar blink when trying to click outside the modal
+ - modals: technically speaking, we could make Begin() with ImGuiWindowFlags_Modal work without involving popup. May help untangle a few things, as modals are more like regular windows than popups.
+ - popups: if the popup functions took explicit ImGuiID it would allow the user to manage the scope of those ID. (#331)
+ - popups: clicking outside (to close popup) and holding shouldn't drag window below.
+ - popups: add variant using global identifier similar to Begin/End (#402)
+ - popups: border options. richer api like BeginChild() perhaps? (#197)
+ - popups/modals: although it is sometimes convenient that popups/modals lifetime is owned by imgui, we could also a bool-owned-by-user api as long as Begin() return value testing is enforced.
+
+ - tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
+ - tooltip: tooltip that doesn't fit in entire screen seems to lose their "last preferred direction" and may teleport when moving mouse.
+ - tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
+ - tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485)
+ - tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers.
+
+ - menus: menu bars inside modal windows are acting weird.
+ - status-bar: add a per-window status bar helper similar to what menu-bar does.
+ - shortcuts: local-style shortcut api, e.g. parse "&Save"
+ - shortcuts,menus: global-style shortcut api e.g. "Save (CTRL+S)" -> explicit flag for recursing into closed menu
+ - shortcuts: programmatically access shortcuts "Focus("&Save"))
+ - menus: menu-bar: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
+ - menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer.
+ - menus: could merge draw call in most cases (how about storing an optional aabb in ImDrawCmd to move the burden of merging in a single spot).
+ - menus: would be nice if the Selectable() supported horizontal alignment (must be given the equivalent of WorkRect.Max.x matching the position of the shortcut column)
+
+ - tree node: add treenode/treepush int variants? not there because (void*) cast from int warns on some platforms/settings?
+ - tree node: try to apply scrolling at time of TreePop() if node was just opened and end of node is past scrolling limits?
+ - tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
+ - tree node: tweak color scheme to distinguish headers from selected tree node (#581)
+ - tree node: leaf/non-leaf highlight mismatch.
+ - tree node/opt: could avoid formatting when clipped (flag assuming we don't care about width/height, assume single line height?)
+
+ - settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
+ - settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437)
+ - settings/persistence: helpers to make TreeNodeBehavior persist (even during dev!) - may need to store some semantic and/or data type in ImGuiStoragePair
+
+ - style: better default styles. (#707)
+ - style: add a highlighted text color (for headers, etc.)
+ - style: border types: out-screen, in-screen, etc. (#447)
+ - style: add window shadow (fading away from the window. Paint-style calculation of vertices alpha after drawlist would be easier)
+ - style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps to other settings? avoid implementing duplicate helpers such as SmallCheckbox(), etc.
+ - style: try to make PushStyleVar() more robust to incorrect parameters (to be more friendly to edit & continues situation).
+ - style: global scale setting.
+ - style: FramePadding could be different for up vs down (#584)
+ - style: WindowPadding needs to be EVEN as the 0.5 multiplier used on this value probably have a subtle effect on clip rectangle
+ - style: have a more global HSV setter (e.g. alter hue on all elements). consider replacing active/hovered by offset in HSV space? (#438, #707, #1223)
+ - style: gradients fill (#1223) ~ 2 bg colors for each fill? tricky with rounded shapes and using textures for corners.
+ - style editor: color child window height expressed in multiple of line height.
+
+ - log: have more control over the log scope (e.g. stop logging when leaving current tree node scope)
+ - log: be able to log anything (e.g. right-click on a window/tree-node, shows context menu? log into tty/file/clipboard)
+ - log: let user copy any window content to clipboard easily (CTRL+C on windows? while moving it? context menu?). code is commented because it fails with multiple Begin/End pairs.
+ - log: obsolete LogButtons() all together.
+ - log: LogButtons() options for specifying depth and/or hiding depth slider
+ - log: enabling log ends up pushing and growing vertices buffersbecause we don't distinguish layout vs render clipping
+
+ - filters: set a current filter that tree node can automatically query to hide themselves
+ - filters: handle wild-cards (with implicit leading/trailing *), reg-exprs
+ - filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb)
+
+ - drag and drop: fix/support/options for overlapping drag sources.
+ - drag and drop: releasing a drop shows the "..." tooltip for one frame - since e13e598 (#1725)
+ - drag and drop: drag source on a group object (would need e.g. an invisible button covering group in EndGroup) https://twitter.com/paniq/status/1121446364909535233
+ - drag and drop: have some way to know when a drag begin from BeginDragDropSource() pov. (see 2018/01/11 post in #143)
+ - drag and drop: allow preview tooltip to be submitted from a different place than the drag source. (#1725)
+ - drag and drop: allow using with other mouse buttons (where activeid won't be set). (#1637)
+ - drag and drop: make it easier and provide a demo to have tooltip both are source and target site, with a more detailed one on target site (tooltip ordering problem)
+ - drag and drop: demo with reordering nodes (in a list, or a tree node). (#143)
+ - drag and drop: test integrating with os drag and drop (make it easy to do a naive WM_DROPFILE integration)
+ - drag and drop: allow for multiple payload types. (#143)
+ - drag and drop: make payload optional? payload promise? (see 2018/01/11 post in #143)
+ - drag and drop: (#143) "both an in-process pointer and a promise to generate a serialized version, for whether the drag ends inside or outside the same process"
+ - drag and drop: feedback when hovering a region blocked by modal (mouse cursor "NO"?)
+
+ - node/graph editors (#306) (also see https://github.com/ocornut/imgui/wiki#node-editors)
+ - pie menus patterns (#434)
+ - markup: simple markup language for color change? (#902)
+
+ - text: selectable text (for copy) as a generic feature (ItemFlags?)
+ - text: proper alignment options in imgui_internal.h
+ - text: it's currently impossible to have a window title with "##". perhaps an official workaround would be nice. \ style inhibitor? non-visible ascii code to insert between #?
+ - text: provided a framed text helper, e.g. https://pastebin.com/1Laxy8bT
+ - text: refactor TextUnformatted (or underlying function) to more explicitly request if we need width measurement or not
+ - text link/url button: underlined. should api expose an ID or use text contents as ID? which colors enum to use?
+ - text/wrapped: should be a more first-class citizen, e.g. wrapped text within a Selectable with known width.
+ - text/wrapped: custom separator for text wrapping. (#3002)
+ - text/wrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (#249)
+
+ - font: arbitrary line spacing. (#2945)
+ - font: MergeMode: flags to select overwriting or not (this is now very easy with refactored ImFontAtlasBuildWithStbTruetype)
+ - font: free the Alpha buffer if user only requested RGBA.
+!- font: better CalcTextSizeA() API, at least for simple use cases. current one is horrible (perhaps have simple vs extended versions).
+ - font: for the purpose of RenderTextEllipsis(), it might be useful that CalcTextSizeA() can ignore the trailing padding?
+ - font: a CalcTextHeight() helper could run faster than CalcTextSize().y
+ - font: enforce monospace through ImFontConfig (for icons?) + create dual ImFont output from same input, reusing rasterized data but with different glyphs/AdvanceX
+ - font: finish CustomRectRegister() to allow mapping Unicode codepoint to custom texture data
+ - font: remove ID from CustomRect registration, it seems unnecessary!
+ - font: make it easier to submit own bitmap font (same texture, another texture?). (#2127, #2575)
+ - font: PushFontSize API (#1018)
+ - font: MemoryTTF taking ownership confusing/not obvious, maybe default should be opposite?
+ - font: storing MinAdvanceX per font would allow us to skip calculating line width (under a threshold of character count) in loops looking for block width
+ - font/demo: add tools to show glyphs used by a text blob, display U16 value, list missing glyphs.
+ - font/demo: demonstrate use of ImFontGlyphRangesBuilder.
+ - font/atlas: add a missing Glyphs.reserve()
+ - font/atlas: incremental updates
+ - font/atlas: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier.
+ - font/draw: vertical and/or rotated text renderer (#705) - vertical is easier clipping wise
+ - font/draw: need to be able to specify wrap start position.
+ - font/draw: better reserve policy for large horizontal block of text (shouldn't reserve for all clipped lines)
+ - font/draw: underline, squiggle line rendering helpers.
+ - font: optimization: for monospace font (like the default one) we can trim IndexXAdvance as long as trailing value is == FallbackXAdvance (need to make sure TAB is still correct), would save on cache line.
+ - font: add support for kerning, probably optional. A) perhaps default to (32..128)^2 matrix ~ 9K entries = 36KB, then hash for non-ascii?. B) or sparse lookup into per-char list?
+ - font: add a simpler CalcTextSizeA() api? current one ok but not welcome if user needs to call it directly (without going through ImGui::CalcTextSize)
+ - font: fix AddRemapChar() to work before atlas has been built.
+ - font: support for unicode codepoints higher than 0xFFFF? (pr #2815)
+ - font: (api breaking) remove "TTF" from symbol names. also because it now supports OTF.
+ - font/opt: Considering storing standalone AdvanceX table as 16-bit fixed point integer?
+ - font/opt: Glyph currently 40 bytes (2+9*4). Consider storing UV as 16 bits integer? (->32 bytes). X0/Y0/X1/Y1 as 16 fixed-point integers? Or X0/Y0 as float and X1/Y1 as fixed8_8?
+
+ - nav: some features such as PageUp/Down/Home/End should probably work without ImGuiConfigFlags_NavEnableKeyboard? (where do we draw the line?)
+ ! nav: never clear NavId on some setup (e.g. gamepad centric)
+ - nav: code to focus child-window on restoring NavId appears to have issue: e.g. when focus change is implicit because of window closure.
+ - nav: configuration flag to disable global shortcuts (currently only CTRL-Tab) ?
+ - nav: Home/End behavior when navigable item is not fully visible at the edge of scrolling? should be backtrack to keep item into view?
+ - nav: NavScrollToBringItemIntoView() with item bigger than view should focus top-right? Repro: using Nav in "About Window"
+ - nav: wrap around logic to allow e.g. grid based layout (pressing NavRight on the right-most element would go to the next row, etc.). see internal's NavMoveRequestTryWrapping().
+ - nav: patterns to make it possible for arrows key to update selection
+ - nav: restore/find nearest NavId when current one disappear (e.g. pressed a button that disappear, or perhaps auto restoring when current button change name)
+ - nav: SetItemDefaultFocus() level of priority, so widget like Selectable when inside a popup could claim a low-priority default focus on the first selected iem
+ - nav: NavFlattened: ESC on a flattened child should select something.
+ - nav: NavFlattened: broken: in typical usage scenario, the items of a fully clipped child are currently not considered to enter into a NavFlattened child.
+ - nav: NavFlattened: init request doesn't select items that are part of a NavFlattened child
+ - nav: NavFlattened: cannot access menu-bar of a flattened child window with Alt/menu key (not a very common use case..).
+ - nav/treenode: Left within a tree node block as a fallback (ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default?)
+ - nav/menus: pressing left-right on a vertically clipped menu bar tends to jump to the collapse/close buttons.
+ - nav/menus: allow pressing Menu to leave a sub-menu.
+ - nav/menus: a way to access the main menu bar with Alt? (currently needs CTRL+TAB) or last focused window menu bar?
+ - nav/menus: when using the main menu bar, even though we restore focus after, the underlying window loses its title bar highlight during menu manipulation. could we prevent it?
+ - nav/menus: main menu bar currently cannot restore a NULL focus. Could save NavWindow at the time of being focused, similarly to what popup do?
+ - nav/menus: Alt,Up could open the first menu (e.g. "File") currently it tends to nav into the window/collapse menu. Do do that we would need custom transition?
+ - nav/windowing: configure fade-in/fade-out delay on Ctrl+Tab?
+ - nav/windowing: when CTRL-Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering.
+ - nav: simulate right-click or context activation? (SHIFT+F10)
+ - nav: tabs should go through most/all widgets (in submission order?).
+ - nav: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys.
+ - nav: when activating a button that changes label (without a static ID) or disappear, can we somehow automatically recover into a nearest highlight item?
+ - nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable.
+ - focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
+ - focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
+ - focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787)
+
+ - inputs: we need an explicit flag about whether the imgui window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors.
+ - inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71)
+ - inputs: support track pad style scrolling & slider edit.
+ - inputs/io: backspace and arrows in the context of a text input could use system repeat rate.
+ - inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808)
+ - inputs/scrolling: support for smooth scrolling (#2462, #2569)
+
+ - misc: idle: expose "woken up" boolean (set by inputs) and/or animation time (for cursor blink) for back-end to be able stop refreshing easily.
+ - misc: idle: if cursor blink if the _only_ visible animation, core imgui could rewrite vertex alpha to avoid CPU pass on ImGui:: calls.
+ - misc: idle: if cursor blink if the _only_ visible animation, could even expose a dirty rectangle that optionally can be leverage by some app to render in a smaller viewport, getting rid of much pixel shading cost.
+ - misc: no way to run a root-most GetID() with ImGui:: api since there's always a Debug window in the stack. (mentioned in #2960)
+ - misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?)
+ - misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL)
+ - misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682)
+ - misc: use more size_t in public api?
+ - misc: possible compile-time support for string view/range instead of char* would e.g. facilitate usage with Rust (#683)
+ - misc: possible compile-time support for wchar_t instead of char*?
+
+ - remote: make a system like RemoteImGui first-class citizen/project (#75)
+
+ - demo: find a way to demonstrate textures in the examples application, as it such a common issue for new users.
+ - demo: demonstrate using PushStyleVar() in more details.
+ - demo: add vertical separator demo
+ - demo: add virtual scrolling example?
+ - demo: demonstrate Plot offset
+ - demo: window size constraint: square demo is broken when resizing from edges (#1975), would need to rework the callback system to solve this
+
+ - examples: window minimize, maximize (#583)
+ - examples: provide a zero frame-rate/idle example.
+ - examples: dx11/dx12: try to use new swapchain blit models (#2970)
+ - backends: report it better when not able to create texture?
+ - backends: apple: example_apple should be using modern GL3.
+ - backends: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
+ - backends: opengl: rename imgui_impl_opengl2 to impl_opengl_legacy and imgui_impl_opengl3 to imgui_impl_opengl? (#1900)
+ - backends: opengl: could use a single vertex buffer and glBufferSubData for uploads?
+ - backends: opengl: explicitly disable GL_STENCIL_TEST in bindings.
+ - backends: opengl: consider gl_lite loader https://github.com/ApoorvaJ/Papaya/blob/3808e39b0f45d4ca4972621c847586e4060c042a/src/libs/gl_lite.h
+ - backends: vulkan: viewport: support for synchronized swapping of multiple swap chains.
+ - backends: bgfx: https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0
+ - backends: mscriptem: with refactored examples, we could provide a direct imgui_impl_emscripten platform layer (see eg. https://github.com/floooh/sokol-samples/blob/master/html5/imgui-emsc.cc#L42)
+
+ - optimization: replace vsnprintf with stb_printf? using IMGUI_USE_STB_SPRINTF.(#1038)
+ - optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
+ - optimization: add a flag to disable most of rendering, for the case where the user expect to skip it (#335)
+ - optimization: fully covered window (covered by another with non-translucent bg + WindowRounding worth of padding) may want to clip rendering.
+ - optimization: use another hash function than crc32, e.g. FNV1a
+ - optimization/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)?
+ - optimization: turn some the various stack vectors into statically-sized arrays
diff --git a/third_party/imgui/examples/.gitignore b/third_party/imgui/examples/.gitignore
deleted file mode 100644
index ff44bccb74..0000000000
--- a/third_party/imgui/examples/.gitignore
+++ /dev/null
@@ -1,25 +0,0 @@
-build/*
-*/Debug/*
-*/Release/*
-*/ipch/*
-*/x64/*
-*.opensdf
-*.sdf
-*.suo
-*.vcxproj.user
-*.o
-*.obj
-*.exe
-*.pdb
-*.ilk
-*.VC.db
-*.VC.VC.opendb
-
-## Unix executables
-opengl2_example/opengl2_example
-opengl3_example/opengl3_example
-sdl_opengl2_example/sdl_opengl2_example
-sdl_opengl3_example/sdl_opengl3_example
-
-## Dear ImGui Ini files
-imgui.ini
diff --git a/third_party/imgui/examples/README.txt b/third_party/imgui/examples/README.txt
index 171c338150..2137fe0961 100644
--- a/third_party/imgui/examples/README.txt
+++ b/third_party/imgui/examples/README.txt
@@ -1,108 +1,292 @@
-Those are standalone ready-to-build applications to demonstrate Dear ImGui.
-Binaries of some of those demos: http://www.miracleworld.net/imgui/binaries
+-----------------------------------------------------------------------
+ dear imgui, v1.77
+-----------------------------------------------------------------------
+ examples/README.txt
+ (This is the README file for the examples/ folder. See docs/ for more documentation)
+-----------------------------------------------------------------------
-Third party languages and frameworks bindings:
- https://github.com/ocornut/imgui/wiki/Links
-(languages: C, C#, ChaiScript, D, Go, Haxe, Odin, Python, Rust, Lua, Pascal)
-(other frameworks: OpenGLES, FreeGlut, Cinder, Cocos2d-x, SFML, GML/GameMaker Studio, Irrlicht,
- Ogre, OpenSceneGraph, openFrameworks, LOVE, NanoRT, Qt3d, SFML, Unreal Engine 4, etc.)
-(extras: RemoteImGui, ImWindow, imgui_wm, etc.)
+Dear ImGui is highly portable and only requires a few things to run and render:
-
-TL;DR;
- - Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
- - If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
- to your project and use them unmodified.
- - To LEARN how to setup imgui, you may refer to 'opengl2_example' because is the simplest one to read.
- However, do NOT USE the 'opengl2_example' if your code is using any modern GL3+ calls.
- Mixing old fixed-pipeline OpenGL2 and modern OpenGL3+ is going to make everything more complicated.
- Read comments below for details. If you are not sure, in doubt, use 'opengl3_example'.
- - If you have your own engine, you probably want to read a few of the examples first then adapt it to
- your engine. Please note that if your engine is based on OpenGL/DirectX you can perfectly use the
- existing rendering backends, don't feel forced to rewrite them with your own engine API, or you can
- do that later when you already got things to work.
-
-Dear ImGui is highly portable and only requires a few things to run and render.
- Providing mouse/keyboard inputs
- - Load the font atlas texture into graphics memory
+ - Uploading the font atlas texture into graphics memory
- Providing a render function to render indexed textured triangles
- Optional: clipboard support, mouse cursor supports, Windows IME support, etc.
-So this is essentially what those examples are doing + the obligatory cruft for portability.
-Unfortunately in 2018 it is still tedious to create and maintain portable build files using external
-libraries (the kind we're using here to create a window and render 3D triangles) without relying on
-third party software. For most examples here I choose to provide:
- - Makefiles for Linux/OSX
- - Batch files for Visual Studio 2008+
- - A .sln project file for Visual Studio 2010+
-Please let me know if they don't work with your setup!
-You can probably just import the imgui_impl_xxx.cpp/.h files into your own codebase or compile those
-directly with a command-line compiler.
+This is essentially what the example bindings in this folder are providing + obligatory portability cruft.
-Dear ImGui has zero to one frame of lag for most behaviors, at 60 FPS your experience should be pleasant.
-Consider that OS mouse cursors are typically drawn through a specific hardware accelerated route and may
-feel smoother than other GPU rendered contents. You may experiment with the io.MouseDrawCursor flag to
-request ImGui to draw a mouse cursor itself, to visualize the lag between a hardware cursor and a software
-cursor. It might be beneficial to the user experience to switch to a software rendered cursor when an
-interactive drag is in progress.
-Also note that some setup or GPU drivers may be causing extra lag (possibly by enforcing triple buffering),
-leaving you with little option but sadness (Intel GPU drivers were reported as such).
+It is important to understand the difference between the core Dear ImGui library (files in the root folder)
+and examples bindings which we are describing here (examples/ folder).
+You should be able to write bindings for pretty much any platform and any 3D graphics API. With some extra
+effort you can even perform the rendering remotely, on a different machine than the one running the logic.
+
+This folder contains two things:
+
+ - Example bindings for popular platforms/graphics API, which you can use as is or adapt for your own use.
+ They are the imgui_impl_XXXX files found in the examples/ folder.
+
+ - Example applications (standalone, ready-to-build) using the aforementioned bindings.
+ They are the in the XXXX_example/ sub-folders.
+
+You can find binaries of some of those example applications at:
+ http://www.dearimgui.org/binaries
-opengl2_example/
- **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
- **Prefer using the code in the opengl3_example/ folder**
- GLFW + OpenGL example (legacy, fixed pipeline).
- This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter.
- If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
- make things more complicated, will require your code to several OpenGL attributes to their initial state,
- and might confuse your GPU driver.
+---------------------------------------
+ GETTING STARTED
+---------------------------------------
-opengl3_example/
- GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
- This uses more modern OpenGL calls and custom shaders.
- Prefer using that if you are using modern OpenGL in your application (anything with shaders).
+ - Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
+ Please read the comments and instruction at the top of each file.
+ Please read FAQ at http://www.dearimgui.org/faq
-directx9_example/
- DirectX9 example, Windows only.
-
-directx10_example/
- DirectX10 example, Windows only.
- This is quite long and tedious, because: DirectX10.
+ - If you are using of the backend provided here, you can add the imgui_impl_xxx.cpp/h files
+ to your project and use them unmodified. Each imgui_impl_xxxx.cpp comes with its own individual
+ Changelog at the top of the .cpp files, so if you want to update them later it will be easier to
+ catch up with what changed.
-directx11_example/
- DirectX11 example, Windows only.
- This is quite long and tedious, because: DirectX11.
-
-directx12_example/
- DirectX12 example, Windows only.
- This is quite longer and tedious, because: DirectX12.
-
-apple_example/
- OSX & iOS example.
- On iOS, Using Synergy to access keyboard/mouse data from server computer.
- Synergy keyboard integration is rather hacky.
+ - Dear ImGui has no particular extra lag for most behaviors, e.g. the value of 'io.MousePos' provided in
+ NewFrame() will result at the time of EndFrame()/Render() in a moved windows rendered following that mouse
+ movement. At 60 FPS your experience should be pleasant.
+ However, consider that OS mouse cursors are typically drawn through a very specific hardware accelerated
+ path and will feel smoother than the majority of contents rendererd via regular graphics API (including,
+ but not limited to Dear ImGui windows). Because UI rendering and interaction happens on the same plane as
+ the mouse, that disconnect may be jarring to particularly sensitive users.
+ You may experiment with enabling the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor
+ using the regular graphics API, to help you visualize the difference between a "hardware" cursor and a
+ regularly rendered software cursor.
+ However, rendering a mouse cursor at 60 FPS will feel sluggish so you likely won't want to enable that at
+ all times. It might be beneficial for the user experience to switch to a software rendered cursor _only_
+ when an interactive drag is in progress.
+ Note that some setup or GPU drivers are likely to be causing extra display lag depending on their settings.
+ If you feel that dragging windows feels laggy and you are not sure what the cause is: try to build a simple
+ drawing a flat 2D shape directly under the mouse cursor.
-sdl_opengl2_example/
- **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
- **Prefer using the code in the sdl_opengl3_example/ folder**
- SDL2 + OpenGL example (legacy, fixed pipeline).
- This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter.
- If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
- make things more complicated, will require your code to several OpenGL attributes to their initial state,
- and might confuse your GPU driver.
-sdl_opengl3_example/
- SDL2 + OpenGL3 example.
- This uses more modern OpenGL calls and custom shaders.
- Prefer using that if you are using modern OpenGL in your application (anything with shaders).
+---------------------------------------
+ EXAMPLE BINDINGS
+---------------------------------------
-allegro5_example/
+Most the example bindings are split in 2 parts:
+
+ - The "Platform" bindings, in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.
+ Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl.cpp), etc.
+
+ - The "Renderer" bindings, in charge of: creating the main font texture, rendering imgui draw data.
+ Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp), etc.
+
+ - The example _applications_ usually combine 1 platform + 1 renderer binding to create a working program.
+ Examples: the example_win32_directx11/ application combines imgui_impl_win32.cpp + imgui_impl_dx11.cpp.
+
+ - Some bindings for higher level frameworks carry both "Platform" and "Renderer" parts in one file.
+ This is the case for Allegro 5 (imgui_impl_allegro5.cpp), Marmalade (imgui_impl_marmalade5.cpp).
+
+ - If you use your own engine, you may decide to use some of existing bindings and/or rewrite some using
+ your own API. As a recommendation, if you are new to Dear ImGui, try using the existing binding as-is
+ first, before moving on to rewrite some of the code. Although it is tempting to rewrite both of the
+ imgui_impl_xxxx files to fit under your coding style, consider that it is not necessary!
+ In fact, if you are new to Dear ImGui, rewriting them will almost always be harder.
+
+ Example: your engine is built over Windows + DirectX11 but you have your own high-level rendering
+ system layered over DirectX11.
+ Suggestion: step 1: try using imgui_impl_win32.cpp + imgui_impl_dx11.cpp first.
+ Once this work, _if_ you want you can replace the imgui_impl_dx11.cpp code with a custom renderer
+ using your own functions, etc.
+ Please consider using the bindings to the lower-level platform/graphics API as-is.
+
+ Example: your engine is multi-platform (consoles, phones, etc.), you have high-level systems everywhere.
+ Suggestion: step 1: try using a non-portable binding first (e.g. win32 + underlying graphics API)!
+ This is counter-intuitive, but this will get you running faster! Once you better understand how imgui
+ works and is bound, you can rewrite the code using your own systems.
+
+ - Road-map: Dear ImGui 1.80 (WIP currently in the "docking" branch) will allows imgui windows to be
+ seamlessly detached from the main application window. This is achieved using an extra layer to the
+ platform and renderer bindings, which allows Dear ImGui to communicate platform-specific requests.
+ If you decide to use unmodified imgui_impl_xxxx.cpp files, you will automatically benefit from
+ improvements and fixes related to viewports and platform windows without extra work on your side.
+
+
+List of Platforms Bindings in this repository:
+
+ imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/
+ imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl back-ends)
+ imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
+ imgui_impl_win32.cpp ; Win32 native API (Windows)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (absolutely not recommended in 2020!)
+
+List of Renderer Bindings in this repository:
+
+ imgui_impl_dx9.cpp ; DirectX9
+ imgui_impl_dx10.cpp ; DirectX10
+ imgui_impl_dx11.cpp ; DirectX11
+ imgui_impl_dx12.cpp ; DirectX12
+ imgui_impl_metal.mm ; Metal (with ObjC)
+ imgui_impl_opengl2.cpp ; OpenGL 2 (legacy, fixed pipeline <- don't use with modern OpenGL context)
+ imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline)
+ imgui_impl_vulkan.cpp ; Vulkan
+
+List of high-level Frameworks Bindings in this repository: (combine Platform + Renderer)
+
+ imgui_impl_allegro5.cpp
+ imgui_impl_marmalade.cpp
+
+Note that Dear ImGui works with Emscripten. The examples_emscripten/ app uses imgui_impl_sdl.cpp and
+imgui_impl_opengl3.cpp, but other combinations are possible.
+
+Third-party framework, graphics API and languages bindings are listed at:
+
+ https://github.com/ocornut/imgui/wiki/Bindings
+
+Including backends for:
+
+ AGS/Adventure Game Studio, Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium,
+ GML/Game Maker Studio2, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, NanoRT, Nim Game Lib,
+ Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, px_render, Qt/QtDirect3D, SFML, Sokol,
+ Unreal Engine 4, vtk, Win32 GDI, etc.
+
+Not sure which to use?
+Recommended platform/frameworks:
+
+ GLFW https://github.com/glfw/glfw Use imgui_impl_glfw.cpp
+ SDL2 https://www.libsdl.org Use imgui_impl_sdl.cpp
+ Sokol https://github.com/floooh/sokol Use util/sokol_imgui.h in Sokol repository.
+
+Those will allow you to create portable applications and will solve and abstract away many issues.
+
+
+---------------------------------------
+ EXAMPLE APPLICATIONS
+---------------------------------------
+
+Building:
+ Unfortunately in 2020 it is still tedious to create and maintain portable build files using external
+ libraries (the kind we're using here to create a window and render 3D triangles) without relying on
+ third party software. For most examples here we choose to provide:
+ - Makefiles for Linux/OSX
+ - Batch files for Visual Studio 2008+
+ - A .sln project file for Visual Studio 2012+
+ - Xcode project files for the Apple examples
+ Please let us know if they don't work with your setup!
+ You can probably just import the imgui_impl_xxx.cpp/.h files into your own codebase or compile those
+ directly with a command-line compiler.
+
+ If you are interested in using Cmake to build and links examples, see:
+ https://github.com/ocornut/imgui/pull/1713 and https://github.com/ocornut/imgui/pull/3027
+
+
+example_allegro5/
Allegro 5 example.
-
-marmalade_example/
- Marmalade example using IwGx
-
-vulkan_example/
- Vulkan example.
- This is quite longer and tedious, because: Vulkan.
+ = main.cpp + imgui_impl_allegro5.cpp
+
+example_apple_metal/
+ OSX & iOS + Metal.
+ = main.m + imgui_impl_osx.mm + imgui_impl_metal.mm
+ It is based on the "cross-platform" game template provided with Xcode as of Xcode 9.
+ (NB: imgui_impl_osx.mm is currently not as feature complete as other platforms back-ends.
+ You may prefer to use the GLFW Or SDL back-ends, which will also support Windows and Linux.)
+
+example_apple_opengl2/
+ OSX + OpenGL2.
+ = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp
+ (NB: imgui_impl_osx.mm is currently not as feature complete as other platforms back-ends.
+ You may prefer to use the GLFW Or SDL back-ends, which will also support Windows and Linux.)
+
+example_empscripten:
+ Emcripten + SDL2 + OpenGL3+/ES2/ES3 example.
+ = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
+ Note that other examples based on SDL or GLFW + OpenGL could easily be modified to work with Emscripten.
+ We provide this to make the Emscripten differences obvious, and have them not pollute all other examples.
+
+example_glfw_metal/
+ GLFW (Mac) + Metal example.
+ = main.mm + imgui_impl_glfw.cpp + imgui_impl_metal.mm
+
+example_glfw_opengl2/
+ GLFW + OpenGL2 example (legacy, fixed pipeline).
+ = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
+ **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
+ **Prefer using OPENGL3 code (with gl3w/glew/glad/glbinding, you can replace the OpenGL function loader)**
+ This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
+ If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
+ make things more complicated, will require your code to reset many OpenGL attributes to their initial
+ state, and might confuse your GPU driver. One star, not recommended.
+
+example_glfw_opengl3/
+ GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (programmable pipeline).
+ = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
+ This uses more modern OpenGL calls and custom shaders.
+ Prefer using that if you are using modern OpenGL in your application (anything with shaders).
+ (Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent
+ source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different
+ from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.)
+
+example_glfw_vulkan/
+ GLFW (Win32, Mac, Linux) + Vulkan example.
+ = main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
+ This is quite long and tedious, because: Vulkan.
+ For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/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
+ Note that GLUT/FreeGLUT is largely obsolete software, prefer using GLFW or SDL.
+
+example_marmalade/
+ Marmalade example using IwGx.
+ = main.cpp + imgui_impl_marmalade.cpp
+
+example_null
+ Null example, compile and link imgui, create context, run headless with no inputs and no graphics output.
+ = main.cpp
+ This is used to quickly test compilation of core imgui files in as many setups as possible.
+ Because this application doesn't create a window nor a graphic context, there's no graphics output.
+
+example_sdl_directx11/
+ SDL2 + DirectX11 example, Windows only.
+ = main.cpp + imgui_impl_sdl.cpp + imgui_impl_dx11.cpp
+ This to demonstrate usage of DirectX with SDL.
+
+example_sdl_metal/
+ SDL2 (Mac) + Metal example.
+ = main.mm + imgui_impl_sdl.cpp + imgui_impl_metal.mm
+
+example_sdl_opengl2/
+ SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
+ = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
+ **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
+ **Prefer using OPENGL3 code (with gl3w/glew/glad/glbinding, you can replace the OpenGL function loader)**
+ This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
+ If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
+ make things more complicated, will require your code to reset many OpenGL attributes to their initial
+ state, and might confuse your GPU driver. One star, not recommended.
+
+example_sdl_opengl3/
+ SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example.
+ = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
+ This uses more modern OpenGL calls and custom shaders.
+ Prefer using that if you are using modern OpenGL in your application (anything with shaders).
+ (Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent
+ source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different
+ from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.)
+
+example_sdl_vulkan/
+ SDL2 (Win32, Mac, Linux, etc.) + Vulkan example.
+ = main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp
+ This is quite long and tedious, because: Vulkan.
+ For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp.
+
+example_win32_directx9/
+ DirectX9 example, Windows only.
+ = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cpp
+
+example_win32_directx10/
+ DirectX10 example, Windows only.
+ = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx10.cpp
+
+example_win32_directx11/
+ DirectX11 example, Windows only.
+ = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cpp
+
+example_win32_directx12/
+ DirectX12 example, Windows only.
+ = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp
+ This is quite long and tedious, because: DirectX12.
diff --git a/third_party/imgui/examples/allegro5_example/README.md b/third_party/imgui/examples/allegro5_example/README.md
deleted file mode 100644
index dcd83b8a92..0000000000
--- a/third_party/imgui/examples/allegro5_example/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-
-# How to Build
-
-- On Ubuntu 14.04+
-
-```bash
-g++ -I ../.. main.cpp imgui_impl_a5.cpp ../../imgui*.cpp -lallegro -lallegro_primitives -o allegro5_example
-```
-
-- On Windows with Visual Studio's CLI
-
-```
-set ALLEGRODIR=path_to_your_allegro5_folder
-cl /Zi /MD /I %ALLEGRODIR%\include /I ..\.. main.cpp imgui_impl_a5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib
-```
diff --git a/third_party/imgui/examples/allegro5_example/imgui_impl_a5.cpp b/third_party/imgui/examples/allegro5_example/imgui_impl_a5.cpp
deleted file mode 100644
index 127bf196a0..0000000000
--- a/third_party/imgui/examples/allegro5_example/imgui_impl_a5.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-// ImGui Allegro 5 bindings
-
-// Implemented features:
-// [X] User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-// Missing features:
-// [ ] Clipboard support via al_set_clipboard_text/al_clipboard_has_text.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui, Original code by @birthggd
-
-// CHANGELOG
-// (minor and older changes stripped away, please see git history for details)
-// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplA5_RenderDrawData() in the .h file so you can call it yourself.
-// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-
-#include // uint64_t
-#include // memcpy
-#include "imgui.h"
-#include "imgui_impl_a5.h"
-#include
-#include
-
-#ifdef _WIN32
-#include
-#endif
-
-// Data
-static ALLEGRO_DISPLAY* g_Display = NULL;
-static ALLEGRO_BITMAP* g_Texture = NULL;
-static double g_Time = 0.0;
-static ALLEGRO_MOUSE_CURSOR* g_MouseCursorInvisible = NULL;
-static ALLEGRO_VERTEX_DECL* g_VertexDecl = NULL;
-
-struct ImDrawVertAllegro
-{
- ImVec2 pos;
- ImVec2 uv;
- ALLEGRO_COLOR col;
-};
-
-// Render function.
-// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
-void ImGui_ImplA5_RenderDrawData(ImDrawData* draw_data)
-{
- int op, src, dst;
- al_get_blender(&op, &src, &dst);
- al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
-
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
-
- // FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats
- static ImVector vertices;
- vertices.resize(cmd_list->VtxBuffer.Size);
- for (int i = 0; i < cmd_list->VtxBuffer.Size; ++i)
- {
- const ImDrawVert &dv = cmd_list->VtxBuffer[i];
- ImDrawVertAllegro v;
- v.pos = dv.pos;
- v.uv = dv.uv;
- unsigned char *c = (unsigned char*)&dv.col;
- v.col = al_map_rgba(c[0], c[1], c[2], c[3]);
- vertices[i] = v;
- }
-
- // FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
- // You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
- static ImVector indices;
- indices.resize(cmd_list->IdxBuffer.Size);
- for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
- indices[i] = (int)cmd_list->IdxBuffer.Data[i];
-
- int idx_offset = 0;
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- ALLEGRO_BITMAP* texture = (ALLEGRO_BITMAP*)pcmd->TextureId;
- al_set_clipping_rectangle(pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z-pcmd->ClipRect.x, pcmd->ClipRect.w-pcmd->ClipRect.y);
- al_draw_indexed_prim(&vertices[0], g_VertexDecl, texture, &indices[idx_offset], pcmd->ElemCount, ALLEGRO_PRIM_TRIANGLE_LIST);
- }
- idx_offset += pcmd->ElemCount;
- }
- }
-
- // Restore modified state
- al_set_blender(op, src, dst);
- al_set_clipping_rectangle(0, 0, al_get_display_width(g_Display), al_get_display_height(g_Display));
-}
-
-bool Imgui_ImplA5_CreateDeviceObjects()
-{
- // Build texture atlas
- ImGuiIO &io = ImGui::GetIO();
- unsigned char *pixels;
- int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
-
- // Create texture
- int flags = al_get_new_bitmap_flags();
- int fmt = al_get_new_bitmap_format();
- al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP|ALLEGRO_MIN_LINEAR|ALLEGRO_MAG_LINEAR);
- al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE);
- ALLEGRO_BITMAP* img = al_create_bitmap(width, height);
- al_set_new_bitmap_flags(flags);
- al_set_new_bitmap_format(fmt);
- if (!img)
- return false;
-
- ALLEGRO_LOCKED_REGION *locked_img = al_lock_bitmap(img, al_get_bitmap_format(img), ALLEGRO_LOCK_WRITEONLY);
- if (!locked_img)
- {
- al_destroy_bitmap(img);
- return false;
- }
- memcpy(locked_img->data, pixels, sizeof(int)*width*height);
- al_unlock_bitmap(img);
-
- // Convert software texture to hardware texture.
- ALLEGRO_BITMAP* cloned_img = al_clone_bitmap(img);
- al_destroy_bitmap(img);
- if (!cloned_img)
- return false;
-
- // Store our identifier
- io.Fonts->TexID = (void*)cloned_img;
- g_Texture = cloned_img;
-
- // Create an invisible mouse cursor
- // Because al_hide_mouse_cursor() seems to mess up with the actual inputs..
- ALLEGRO_BITMAP* mouse_cursor = al_create_bitmap(8,8);
- g_MouseCursorInvisible = al_create_mouse_cursor(mouse_cursor, 0, 0);
- al_destroy_bitmap(mouse_cursor);
-
- return true;
-}
-
-void ImGui_ImplA5_InvalidateDeviceObjects()
-{
- if (g_Texture)
- {
- al_destroy_bitmap(g_Texture);
- ImGui::GetIO().Fonts->TexID = NULL;
- g_Texture = NULL;
- }
- if (g_MouseCursorInvisible)
- {
- al_destroy_mouse_cursor(g_MouseCursorInvisible);
- g_MouseCursorInvisible = NULL;
- }
-}
-
-bool ImGui_ImplA5_Init(ALLEGRO_DISPLAY* display)
-{
- g_Display = display;
-
- // Create custom vertex declaration.
- // Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats.
- // We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion.
- ALLEGRO_VERTEX_ELEMENT elems[] =
- {
- { ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_2, IM_OFFSETOF(ImDrawVertAllegro, pos) },
- { ALLEGRO_PRIM_TEX_COORD, ALLEGRO_PRIM_FLOAT_2, IM_OFFSETOF(ImDrawVertAllegro, uv) },
- { ALLEGRO_PRIM_COLOR_ATTR, 0, IM_OFFSETOF(ImDrawVertAllegro, col) },
- { 0, 0, 0 }
- };
- g_VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = ALLEGRO_KEY_TAB;
- io.KeyMap[ImGuiKey_LeftArrow] = ALLEGRO_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = ALLEGRO_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = ALLEGRO_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = ALLEGRO_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = ALLEGRO_KEY_PGUP;
- io.KeyMap[ImGuiKey_PageDown] = ALLEGRO_KEY_PGDN;
- io.KeyMap[ImGuiKey_Home] = ALLEGRO_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = ALLEGRO_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = ALLEGRO_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = ALLEGRO_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = ALLEGRO_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Space] = ALLEGRO_KEY_SPACE;
- io.KeyMap[ImGuiKey_Enter] = ALLEGRO_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = ALLEGRO_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = ALLEGRO_KEY_A;
- io.KeyMap[ImGuiKey_C] = ALLEGRO_KEY_C;
- io.KeyMap[ImGuiKey_V] = ALLEGRO_KEY_V;
- io.KeyMap[ImGuiKey_X] = ALLEGRO_KEY_X;
- io.KeyMap[ImGuiKey_Y] = ALLEGRO_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = ALLEGRO_KEY_Z;
-
-#ifdef _WIN32
- io.ImeWindowHandle = al_get_win_window_handle(g_Display);
-#endif
-
- return true;
-}
-
-void ImGui_ImplA5_Shutdown()
-{
- ImGui_ImplA5_InvalidateDeviceObjects();
-}
-
-// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
-// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
-// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
-// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
-bool ImGui_ImplA5_ProcessEvent(ALLEGRO_EVENT *ev)
-{
- ImGuiIO &io = ImGui::GetIO();
-
- switch (ev->type)
- {
- case ALLEGRO_EVENT_MOUSE_AXES:
- io.MouseWheel += ev->mouse.dz;
- io.MouseWheelH += ev->mouse.dw;
- return true;
- case ALLEGRO_EVENT_KEY_CHAR:
- if (ev->keyboard.display == g_Display)
- if (ev->keyboard.unichar > 0 && ev->keyboard.unichar < 0x10000)
- io.AddInputCharacter((unsigned short)ev->keyboard.unichar);
- return true;
- case ALLEGRO_EVENT_KEY_DOWN:
- case ALLEGRO_EVENT_KEY_UP:
- if (ev->keyboard.display == g_Display)
- io.KeysDown[ev->keyboard.keycode] = (ev->type == ALLEGRO_EVENT_KEY_DOWN);
- return true;
- }
- return false;
-}
-
-void ImGui_ImplA5_NewFrame()
-{
- if (!g_Texture)
- Imgui_ImplA5_CreateDeviceObjects();
-
- ImGuiIO &io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- w = al_get_display_width(g_Display);
- h = al_get_display_height(g_Display);
- io.DisplaySize = ImVec2((float)w, (float)h);
-
- // Setup time step
- double current_time = al_get_time();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- ALLEGRO_KEYBOARD_STATE keys;
- al_get_keyboard_state(&keys);
- io.KeyCtrl = al_key_down(&keys, ALLEGRO_KEY_LCTRL) || al_key_down(&keys, ALLEGRO_KEY_RCTRL);
- io.KeyShift = al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT);
- io.KeyAlt = al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR);
- io.KeySuper = al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN);
-
- ALLEGRO_MOUSE_STATE mouse;
- if (keys.display == g_Display)
- {
- al_get_mouse_state(&mouse);
- io.MousePos = ImVec2((float)mouse.x, (float)mouse.y);
- }
- else
- {
- io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
- }
-
- al_get_mouse_state(&mouse);
- io.MouseDown[0] = mouse.buttons & (1 << 0);
- io.MouseDown[1] = mouse.buttons & (1 << 1);
- io.MouseDown[2] = mouse.buttons & (1 << 2);
-
- // Hide OS mouse cursor if ImGui is drawing it
- if (io.MouseDrawCursor)
- {
- al_set_mouse_cursor(g_Display, g_MouseCursorInvisible);
- }
- else
- {
- ALLEGRO_SYSTEM_MOUSE_CURSOR cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT;
- switch (ImGui::GetMouseCursor())
- {
- case ImGuiMouseCursor_TextInput: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_EDIT; break;
- case ImGuiMouseCursor_ResizeAll: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_MOVE; break;
- case ImGuiMouseCursor_ResizeNS: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_N; break;
- case ImGuiMouseCursor_ResizeEW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_E; break;
- case ImGuiMouseCursor_ResizeNESW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE; break;
- case ImGuiMouseCursor_ResizeNWSE: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW; break;
- }
- al_set_system_mouse_cursor(g_Display, cursor_id);
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
-}
diff --git a/third_party/imgui/examples/allegro5_example/imgui_impl_a5.h b/third_party/imgui/examples/allegro5_example/imgui_impl_a5.h
deleted file mode 100644
index ccc3ac45f1..0000000000
--- a/third_party/imgui/examples/allegro5_example/imgui_impl_a5.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// ImGui Allegro 5 bindings
-
-// Implemented features:
-// [X] User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-// Missing features:
-// [ ] Clipboard support via al_set_clipboard_text/al_clipboard_has_text.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui, Original code by @birthggd
-
-#pragma once
-
-struct ALLEGRO_DISPLAY;
-union ALLEGRO_EVENT;
-
-IMGUI_API bool ImGui_ImplA5_Init(ALLEGRO_DISPLAY* display);
-IMGUI_API void ImGui_ImplA5_Shutdown();
-IMGUI_API void ImGui_ImplA5_NewFrame();
-IMGUI_API void ImGui_ImplA5_RenderDrawData(ImDrawData* draw_data);
-IMGUI_API bool ImGui_ImplA5_ProcessEvent(ALLEGRO_EVENT* event);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API bool Imgui_ImplA5_CreateDeviceObjects();
-IMGUI_API void ImGui_ImplA5_InvalidateDeviceObjects();
diff --git a/third_party/imgui/examples/apple_example/.gitignore b/third_party/imgui/examples/apple_example/.gitignore
deleted file mode 100644
index 8feda89d3e..0000000000
--- a/third_party/imgui/examples/apple_example/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.DS_Store
-imguiex.xcodeproj/project.xcworkspace/
-imguiex.xcodeproj/xcuserdata/
\ No newline at end of file
diff --git a/third_party/imgui/examples/apple_example/README.md b/third_party/imgui/examples/apple_example/README.md
deleted file mode 100644
index 339f6bf857..0000000000
--- a/third_party/imgui/examples/apple_example/README.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# iOS / OSX example
-
-## Introduction
-
-This example is the default XCode "OpenGL" example code, modified to support ImGui and [Synergy](http://synergy-project.org/) to share mouse/keyboard on an iOS device.
-
-It is a rather complex and messy example because of all of the faff required to get an XCode/iOS application running. Refer to the regular OpenGL examples if you want to learn about integrating ImGui. **The opengl3_example/ should also work on OS X and is much simpler.** This is an integration for iOS with Synergy.
-
-Synergy (remote keyboard/mouse) is not required, but it's pretty hard to use ImGui without it. Synergy includes a "uSynergy" library that allows embedding a synergy client, this is what is used here. ImGui supports "TouchPadding", and this is enabled when Synergy is not active.
-
-## How to Use on iOS
-
-* In Synergy, go to Preferences, and uncheck "Use SSL encryption"
-* Run the example app.
-* Tap the "servername" button in the corner
-* Enter the name or the IP of your synergy host
-* If you had previously connected to a server, you may need to kill and re-start the app.
-
-## How to Build on OSX
-
-* Make sure you have install `brew`, if not, please refer to [Homebrew Website](http://brew.sh)
-* Run the command: `brew install glfw3`
-* Double click `imguiex.xcodeproj` and select `imguiex-osx` scheme
-* Click `Run` button
-
-## Notes and TODOs
-
-Things that would be nice but I didn't get around to doing:
-
-* iOS software keyboard not supported for text inputs
-* iOS hardware (bluetooth) keyboards not supported
-* Graceful disconnect/reconnect from uSynergy.
-* Copy/Paste not well-supported
-
-## C++ on iOS / OSX
-
-ImGui is a c++ library. If you want to include it directly, rename your Obj-C file to have the ".mm" extension.
-
-Alternatively, you can wrap your debug code in a C interface, this is what I am demonstrating here with the "debug_hud.h" interface. Either approach works, use whatever you prefer.
-
-In my case, most of my game code is already in C++ so it's not really an issue and I can use ImGui directly.
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/AppDelegate.h b/third_party/imgui/examples/apple_example/imguiex-ios/AppDelegate.h
deleted file mode 100644
index 82f1542eb3..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/AppDelegate.h
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// AppDelegate.h
-// imguiex
-
-#import
-
-@interface AppDelegate : UIResponder
-
-@property (strong, nonatomic) UIWindow *window;
-
-
-@end
-
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/AppDelegate.m b/third_party/imgui/examples/apple_example/imguiex-ios/AppDelegate.m
deleted file mode 100644
index ab83101e7b..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/AppDelegate.m
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// AppDelegate.m
-// imguiex
-
-#import "AppDelegate.h"
-
-@interface AppDelegate ()
-
-@end
-
-@implementation AppDelegate
-
-
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- // Override point for customization after application launch.
- return YES;
-}
-
-- (void)applicationWillResignActive:(UIApplication *)application {
- // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
- // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
-}
-
-- (void)applicationDidEnterBackground:(UIApplication *)application {
- // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
- // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
-}
-
-- (void)applicationWillEnterForeground:(UIApplication *)application {
- // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
-}
-
-- (void)applicationDidBecomeActive:(UIApplication *)application {
- // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
-}
-
-- (void)applicationWillTerminate:(UIApplication *)application {
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
-}
-
-@end
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Base.lproj/LaunchScreen.xib b/third_party/imgui/examples/apple_example/imguiex-ios/Base.lproj/LaunchScreen.xib
deleted file mode 100644
index 5717c00e28..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/Base.lproj/LaunchScreen.xib
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Base.lproj/Main.storyboard b/third_party/imgui/examples/apple_example/imguiex-ios/Base.lproj/Main.storyboard
deleted file mode 100644
index 90dfb2e67c..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/Base.lproj/Main.storyboard
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/GameViewController.h b/third_party/imgui/examples/apple_example/imguiex-ios/GameViewController.h
deleted file mode 100644
index 3323cfd55b..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/GameViewController.h
+++ /dev/null
@@ -1,12 +0,0 @@
-//
-// GameViewController.h
-// imguiex
-
-// This is the OpenGL Example template from XCode, modified to support ImGui
-
-#import
-#import
-
-@interface GameViewController : GLKViewController
-
-@end
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/GameViewController.m b/third_party/imgui/examples/apple_example/imguiex-ios/GameViewController.m
deleted file mode 100644
index 316fbd6ccc..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/GameViewController.m
+++ /dev/null
@@ -1,479 +0,0 @@
-//
-// GameViewController.m
-// imguiex
-//
-#import "GameViewController.h"
-#import
-
-#import "imgui_impl_ios.h"
-#import "debug_hud.h"
-
-#define BUFFER_OFFSET(i) ((char *)NULL + (i))
-
-#define SERVERNAME_KEY @"ServerName"
-
-#define SERVERNAME_ALERT_TAG (10)
-
-// Uniform index.
-enum
-{
- UNIFORM_MODELVIEWPROJECTION_MATRIX,
- UNIFORM_NORMAL_MATRIX,
- UNIFORM_DIFFUSE_COLOR,
-
- NUM_UNIFORMS
-};
-GLint uniforms[NUM_UNIFORMS];
-
-// Attribute index.
-enum
-{
- ATTRIB_VERTEX,
- ATTRIB_NORMAL,
- NUM_ATTRIBUTES
-};
-
-GLfloat gCubeVertexData[216] =
-{
- // Data layout for each line below is:
- // positionX, positionY, positionZ, normalX, normalY, normalZ,
- 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
- 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
- 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
- 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
- 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
- 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
-
- 0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
- -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
- 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
- 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
- -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
- -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
-
- -0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
- -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
- -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
- -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
- -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
- -0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
-
- -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
- 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
- -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
- -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
- 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
- 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
-
- 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
- -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
- 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
- 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
- -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
- -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
-
- 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
- -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
- 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
- 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
- -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
- -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f
-};
-
-@interface GameViewController ()
-{
- GLuint _program;
-
- GLKMatrix4 _modelViewProjectionMatrix;
- GLKMatrix3 _normalMatrix;
- float _rotation;
-
- GLuint _vertexArray;
- GLuint _vertexBuffer;
-
- DebugHUD _hud;
-}
-@property (strong, nonatomic) EAGLContext *context;
-@property (strong, nonatomic) GLKBaseEffect *effect;
-@property (strong, nonatomic) ImGuiHelper *imgui;
-@property (weak, nonatomic) IBOutlet UIButton *btnServername;
-
-@property (strong, nonatomic) NSString *serverName;
-
-- (IBAction)onServernameTapped:(id)sender;
-
-- (void)setupGL;
-- (void)tearDownGL;
-
-- (BOOL)loadShaders;
-- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file;
-- (BOOL)linkProgram:(GLuint)prog;
-- (BOOL)validateProgram:(GLuint)prog;
-@end
-
-@implementation GameViewController
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
-
- self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
-
- if (!self.context) {
- NSLog(@"Failed to create ES context");
- }
-
- GLKView *view = (GLKView *)self.view;
- view.context = self.context;
- view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
-
- [self.btnServername setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
-
- [self setupGL];
-
- NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
- self.serverName = [userDefaults objectForKey: SERVERNAME_KEY ];
- self.imgui = [[ImGuiHelper alloc] initWithView:self.view ];
- if (self.serverName)
- {
- [self.btnServername setTitle:self.serverName forState:UIControlStateNormal];
- [self.imgui connectServer: self.serverName ];
- }
-
- DebugHUD_InitDefaults( &_hud );
-}
-
-- (void)dealloc
-{
- [self tearDownGL];
-
- if ([EAGLContext currentContext] == self.context) {
- [EAGLContext setCurrentContext:nil];
- }
-}
-
-- (void)didReceiveMemoryWarning
-{
- [super didReceiveMemoryWarning];
-
- if ([self isViewLoaded] && ([[self view] window] == nil)) {
- self.view = nil;
-
- [self tearDownGL];
-
- if ([EAGLContext currentContext] == self.context) {
- [EAGLContext setCurrentContext:nil];
- }
- self.context = nil;
- }
-
- // Dispose of any resources that can be recreated.
-}
-
-
-- (BOOL)prefersStatusBarHidden {
- return YES;
-}
-
-- (IBAction)onServernameTapped:(id)sender
-{
- UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Set Server" message:@"Enter server name or IP for uSynergy" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil ];
- alert.alertViewStyle = UIAlertViewStylePlainTextInput;
- alert.tag = SERVERNAME_ALERT_TAG; // cheezy way to tell which alert view we're responding to
- [alert show];
-}
-
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
- if ((buttonIndex==0)&&(alertView.tag==SERVERNAME_ALERT_TAG))
- {
- // This is really janky. I usually just hardcode the servername since I'm building it anyway.
- // If you want to properly handle updating the server, you'll want to tear down and recreate
- // the usynergy stuff in connectServer
- BOOL serverNameWasSet = self.serverName.length > 0;
- NSString *serverName = [[alertView textFieldAtIndex:0] text];
-
- if ([serverName length] > 0) {
- self.serverName = serverName;
- NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
- [userDefaults setObject:serverName forKey:SERVERNAME_KEY ];
- [userDefaults synchronize];
-
- [self.btnServername setTitle:self.serverName forState:UIControlStateNormal];
-
- // If we hadn't previously connected, try now
- if (!serverNameWasSet) {
- [self.imgui connectServer:self.serverName];
- }
- else
- {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Servername Updated"
- message:@"Restart the app to connect the server"
- delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
- [alert show];
- }
- }
- }
-}
-
-- (void)setupGL
-{
- [EAGLContext setCurrentContext:self.context];
-
- [self loadShaders];
-
- self.effect = [[GLKBaseEffect alloc] init];
- self.effect.light0.enabled = GL_TRUE;
- self.effect.light0.diffuseColor = GLKVector4Make(1.0f, 0.4f, 0.4f, 1.0f);
-
- glEnable(GL_DEPTH_TEST);
-
- glGenVertexArraysOES(1, &_vertexArray);
- glBindVertexArrayOES(_vertexArray);
-
- glGenBuffers(1, &_vertexBuffer);
- glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
- glBufferData(GL_ARRAY_BUFFER, sizeof(gCubeVertexData), gCubeVertexData, GL_STATIC_DRAW);
-
- glEnableVertexAttribArray(GLKVertexAttribPosition);
- glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(0));
- glEnableVertexAttribArray(GLKVertexAttribNormal);
- glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(12));
-
- glBindVertexArrayOES(0);
-
-
-}
-
-- (void)tearDownGL
-{
- [EAGLContext setCurrentContext:self.context];
-
- glDeleteBuffers(1, &_vertexBuffer);
- glDeleteVertexArraysOES(1, &_vertexArray);
-
- self.effect = nil;
-
- if (_program) {
- glDeleteProgram(_program);
- _program = 0;
- }
-}
-
-#pragma mark - GLKView and GLKViewController delegate methods
-
-- (void)update
-{
- float aspect = fabs(self.view.bounds.size.width / self.view.bounds.size.height);
- GLKMatrix4 projectionMatrix = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(65.0f), aspect, 0.1f, 100.0f);
-
- self.effect.transform.projectionMatrix = projectionMatrix;
-
- GLKMatrix4 baseModelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -4.0f);
- baseModelViewMatrix = GLKMatrix4Rotate(baseModelViewMatrix, _rotation, 0.0f, 1.0f, 0.0f);
-
- // Compute the model view matrix for the object rendered with GLKit
- GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -1.5f);
- modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f);
- modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix);
-
- self.effect.transform.modelviewMatrix = modelViewMatrix;
-
- // Compute the model view matrix for the object rendered with ES2
- modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 1.5f);
- modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f);
- modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix);
-
- _normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL);
-
- _modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix);
-
- _rotation += self.timeSinceLastUpdate * (_hud.rotation_speed * (M_PI / 180.0));
-}
-
-
-- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
-{
- // Start the dear imgui frame
- [self.imgui newFrame];
-
- // Create some UI elements
- DebugHUD_DoInterface( &_hud );
-
- // Render
- glClearColor(0.65f, 0.65f, 0.65f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- glBindVertexArrayOES(_vertexArray);
-
- // Render the object with GLKit
- [self.effect prepareToDraw];
- glDrawArrays(GL_TRIANGLES, 0, 36);
-
- // Render the object again with ES2
- glUseProgram(_program);
- glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX], 1, 0, _modelViewProjectionMatrix.m);
- glUniformMatrix3fv(uniforms[UNIFORM_NORMAL_MATRIX], 1, 0, _normalMatrix.m);
- glUniform3f(uniforms[UNIFORM_DIFFUSE_COLOR], _hud.cubeColor1[0], _hud.cubeColor1[1], _hud.cubeColor1[2] );
- glDrawArrays(GL_TRIANGLES, 0, 36);
-
- self.effect.light0.diffuseColor = GLKVector4Make( _hud.cubeColor2[0], _hud.cubeColor2[1], _hud.cubeColor2[2], 1.0f);
-
- // Render dear imgui as the last thing in the frame if possible
- [self.imgui render];
-}
-
-#pragma mark - OpenGL ES 2 shader compilation
-
-- (BOOL)loadShaders
-{
- GLuint vertShader, fragShader;
- NSString *vertShaderPathname, *fragShaderPathname;
-
- // Create shader program.
- _program = glCreateProgram();
-
- // Create and compile vertex shader.
- vertShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"vsh"];
- if (![self compileShader:&vertShader type:GL_VERTEX_SHADER file:vertShaderPathname]) {
- NSLog(@"Failed to compile vertex shader");
- return NO;
- }
-
- // Create and compile fragment shader.
- fragShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"fsh"];
- if (![self compileShader:&fragShader type:GL_FRAGMENT_SHADER file:fragShaderPathname]) {
- NSLog(@"Failed to compile fragment shader");
- return NO;
- }
-
- // Attach vertex shader to program.
- glAttachShader(_program, vertShader);
-
- // Attach fragment shader to program.
- glAttachShader(_program, fragShader);
-
- // Bind attribute locations.
- // This needs to be done prior to linking.
- glBindAttribLocation(_program, GLKVertexAttribPosition, "position");
- glBindAttribLocation(_program, GLKVertexAttribNormal, "normal");
-
- // Link program.
- if (![self linkProgram:_program]) {
- NSLog(@"Failed to link program: %d", _program);
-
- if (vertShader) {
- glDeleteShader(vertShader);
- vertShader = 0;
- }
- if (fragShader) {
- glDeleteShader(fragShader);
- fragShader = 0;
- }
- if (_program) {
- glDeleteProgram(_program);
- _program = 0;
- }
-
- return NO;
- }
-
- // Get uniform locations.
- uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX] = glGetUniformLocation(_program, "modelViewProjectionMatrix");
- uniforms[UNIFORM_NORMAL_MATRIX] = glGetUniformLocation(_program, "normalMatrix");
- uniforms[UNIFORM_DIFFUSE_COLOR] = glGetUniformLocation(_program, "diffuseColor");
-
- // Release vertex and fragment shaders.
- if (vertShader) {
- glDetachShader(_program, vertShader);
- glDeleteShader(vertShader);
- }
- if (fragShader) {
- glDetachShader(_program, fragShader);
- glDeleteShader(fragShader);
- }
-
- return YES;
-}
-
-- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file
-{
- GLint status;
- const GLchar *source;
-
- source = (GLchar *)[[NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:nil] UTF8String];
- if (!source) {
- NSLog(@"Failed to load vertex shader");
- return NO;
- }
-
- *shader = glCreateShader(type);
- glShaderSource(*shader, 1, &source, NULL);
- glCompileShader(*shader);
-
-#if defined(DEBUG)
- GLint logLength;
- glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &logLength);
- if (logLength > 0) {
- GLchar *log = (GLchar *)malloc(logLength);
- glGetShaderInfoLog(*shader, logLength, &logLength, log);
- NSLog(@"Shader compile log:\n%s", log);
- free(log);
- }
-#endif
-
- glGetShaderiv(*shader, GL_COMPILE_STATUS, &status);
- if (status == 0) {
- glDeleteShader(*shader);
- return NO;
- }
-
- return YES;
-}
-
-- (BOOL)linkProgram:(GLuint)prog
-{
- GLint status;
- glLinkProgram(prog);
-
-#if defined(DEBUG)
- GLint logLength;
- glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength);
- if (logLength > 0) {
- GLchar *log = (GLchar *)malloc(logLength);
- glGetProgramInfoLog(prog, logLength, &logLength, log);
- NSLog(@"Program link log:\n%s", log);
- free(log);
- }
-#endif
-
- glGetProgramiv(prog, GL_LINK_STATUS, &status);
- if (status == 0) {
- return NO;
- }
-
- return YES;
-}
-
-- (BOOL)validateProgram:(GLuint)prog
-{
- GLint logLength, status;
-
- glValidateProgram(prog);
- glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength);
- if (logLength > 0) {
- GLchar *log = (GLchar *)malloc(logLength);
- glGetProgramInfoLog(prog, logLength, &logLength, log);
- NSLog(@"Program validate log:\n%s", log);
- free(log);
- }
-
- glGetProgramiv(prog, GL_VALIDATE_STATUS, &status);
- if (status == 0) {
- return NO;
- }
-
- return YES;
-}
-
-@end
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/Contents.json b/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/Contents.json
deleted file mode 100644
index 06b60d8b4b..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/Contents.json
+++ /dev/null
@@ -1,77 +0,0 @@
-{
- "images" : [
- {
- "idiom" : "iphone",
- "size" : "29x29",
- "scale" : "2x"
- },
- {
- "idiom" : "iphone",
- "size" : "29x29",
- "scale" : "3x"
- },
- {
- "idiom" : "iphone",
- "size" : "40x40",
- "scale" : "2x"
- },
- {
- "idiom" : "iphone",
- "size" : "40x40",
- "scale" : "3x"
- },
- {
- "size" : "60x60",
- "idiom" : "iphone",
- "filename" : "icon_imgui_60@2x~iphone.png",
- "scale" : "2x"
- },
- {
- "size" : "60x60",
- "idiom" : "iphone",
- "filename" : "icon_imgui_60@3x~iphone.png",
- "scale" : "3x"
- },
- {
- "idiom" : "ipad",
- "size" : "29x29",
- "scale" : "1x"
- },
- {
- "idiom" : "ipad",
- "size" : "29x29",
- "scale" : "2x"
- },
- {
- "idiom" : "ipad",
- "size" : "40x40",
- "scale" : "1x"
- },
- {
- "idiom" : "ipad",
- "size" : "40x40",
- "scale" : "2x"
- },
- {
- "size" : "76x76",
- "idiom" : "ipad",
- "filename" : "icon_imgui_76~ipad.png",
- "scale" : "1x"
- },
- {
- "size" : "76x76",
- "idiom" : "ipad",
- "filename" : "icon_imgui_76@2x~ipad.png",
- "scale" : "2x"
- },
- {
- "idiom" : "ipad",
- "size" : "83.5x83.5",
- "scale" : "2x"
- }
- ],
- "info" : {
- "version" : 1,
- "author" : "xcode"
- }
-}
\ No newline at end of file
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@2x~iphone.png b/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@2x~iphone.png
deleted file mode 100644
index d728bc3fe6..0000000000
Binary files a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@2x~iphone.png and /dev/null differ
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@3x~iphone.png b/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@3x~iphone.png
deleted file mode 100644
index f48b799dba..0000000000
Binary files a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@3x~iphone.png and /dev/null differ
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76@2x~ipad.png b/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76@2x~ipad.png
deleted file mode 100644
index 67b08b84c6..0000000000
Binary files a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76@2x~ipad.png and /dev/null differ
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76~ipad.png b/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76~ipad.png
deleted file mode 100644
index ae88e04d9c..0000000000
Binary files a/third_party/imgui/examples/apple_example/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76~ipad.png and /dev/null differ
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Shaders/Shader.fsh b/third_party/imgui/examples/apple_example/imguiex-ios/Shaders/Shader.fsh
deleted file mode 100644
index 4000524fc9..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/Shaders/Shader.fsh
+++ /dev/null
@@ -1,10 +0,0 @@
-//
-// Shader.fsh
-// imguiex
-
-varying lowp vec4 colorVarying;
-
-void main()
-{
- gl_FragColor = colorVarying;
-}
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Shaders/Shader.vsh b/third_party/imgui/examples/apple_example/imguiex-ios/Shaders/Shader.vsh
deleted file mode 100644
index 313c3d7a38..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/Shaders/Shader.vsh
+++ /dev/null
@@ -1,25 +0,0 @@
-//
-// Shader.vsh
-// imguiex
-
-attribute vec4 position;
-attribute vec3 normal;
-
-varying lowp vec4 colorVarying;
-
-uniform vec3 diffuseColor;
-uniform mat4 modelViewProjectionMatrix;
-uniform mat3 normalMatrix;
-
-void main()
-{
- vec3 eyeNormal = normalize(normalMatrix * normal);
- vec3 lightPosition = vec3(0.0, 0.0, 1.0);
-
- float nDotVP = max(0.0, dot(eyeNormal, normalize(lightPosition)));
-
- vec3 colorLit = diffuseColor * nDotVP;
- colorVarying = vec4( colorLit.x, colorLit.y, colorLit.z, 1.0 );
-
- gl_Position = modelViewProjectionMatrix * position;
-}
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/debug_hud.cpp b/third_party/imgui/examples/apple_example/imguiex-ios/debug_hud.cpp
deleted file mode 100644
index 28722b56de..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/debug_hud.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// debug_hud.cpp
-// imguiex
-
-#include
-
-#include "debug_hud.h"
-#include "imgui.h"
-
-void DebugHUD_InitDefaults( DebugHUD *hud )
-{
- hud->show_demo_window = true;
- hud->show_another_window = true;
- hud->rotation_speed = 15.0f;
-
- hud->cubeColor1[0] = 0.4f;
- hud->cubeColor1[1] = 0.4f;
- hud->cubeColor1[2] = 1.0f;
- hud->cubeColor1[3] = 1.0f;
-
- hud->cubeColor2[0] = 1.0f;
- hud->cubeColor2[1] = 0.4f;
- hud->cubeColor2[2] = 0.4f;
- hud->cubeColor2[3] = 1.0f;
-
- hud->clearColor[0] = 0.45f;
- hud->clearColor[1] = 0.55f;
- hud->clearColor[2] = 0.60f;
- hud->clearColor[3] = 1.00f;
-}
-
-void DebugHUD_DoInterface(DebugHUD *hud)
-{
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
- {
- static float f = 0.0f;
- static int counter = 0;
- ImGui::Text("Hello, world!"); // Display some text (you can use a format string too)
- ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
- ImGui::ColorEdit3("clear color", hud->clearColor); // Edit 3 floats representing a color
-
- ImGui::Checkbox("Demo Window", &hud->show_demo_window); // Edit bools storing our windows open/close state
- ImGui::Checkbox("Another Window", &hud->show_another_window);
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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);
- }
-
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
- if (hud->show_another_window)
- {
- ImGui::Begin("Another Window", &hud->show_another_window);
- ImGui::Text("Hello from another window!");
- ImGui::ColorEdit3("Cube 1 Color", hud->cubeColor1);
- ImGui::ColorEdit3("Cube 2 Color", hud->cubeColor2);
- ImGui::SliderFloat("Rotation Speed", &hud->rotation_speed, 0.0f, 200.0f);
- if (ImGui::Button("Close Me"))
- hud->show_another_window = false;
- ImGui::End();
- }
-
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (hud->show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&hud->show_demo_window);
- }
-}
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/debug_hud.h b/third_party/imgui/examples/apple_example/imguiex-ios/debug_hud.h
deleted file mode 100644
index 4ef535729c..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/debug_hud.h
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-// debug_hud.h
-// imguiex
-
-#pragma once
-
-typedef struct DebugHUD
-{
- bool show_demo_window;
- bool show_another_window;
- float rotation_speed;
- float cubeColor1[4];
- float cubeColor2[4];
- float clearColor[4];
-} DebugHUD;
-
-#if __cplusplus
-extern "C" {
-#endif
-
-void DebugHUD_InitDefaults(DebugHUD *hud);
-void DebugHUD_DoInterface(DebugHUD *hud);
-
-#if __cplusplus
-}
-#endif
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/imgui_ex_icon.png b/third_party/imgui/examples/apple_example/imguiex-ios/imgui_ex_icon.png
deleted file mode 100644
index 820e4d73e3..0000000000
Binary files a/third_party/imgui/examples/apple_example/imguiex-ios/imgui_ex_icon.png and /dev/null differ
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/imgui_impl_ios.h b/third_party/imgui/examples/apple_example/imguiex-ios/imgui_impl_ios.h
deleted file mode 100644
index 9b01dd3ba0..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/imgui_impl_ios.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// ImGui iOS+OpenGL+Synergy binding
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-// Providing a standalone iOS application with Synergy integration makes this sample more verbose than others. It also hasn't been tested as much.
-// Refer to other examples to get an easier understanding of how to integrate ImGui into your existing application.
-
-// by Joel Davis (joeld42@gmail.com)
-
-#pragma once
-
-#include
-#include
-
-@interface ImGuiHelper : NSObject
-
-- (id) initWithView: (UIView *)view;
-
-- (void)connectServer: (NSString*)serverName;
-
-- (void)render;
-- (void)newFrame;
-
-@end
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/imgui_impl_ios.mm b/third_party/imgui/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
deleted file mode 100644
index 440b586a8d..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-ios/imgui_impl_ios.mm
+++ /dev/null
@@ -1,808 +0,0 @@
-// ImGui iOS+OpenGL+Synergy binding
-// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
-// Providing a standalone iOS application with Synergy integration makes this sample more verbose than others. It also hasn't been tested as much.
-// Refer to other examples to get an easier understanding of how to integrate ImGui into your existing application.
-
-// TODO:
-// - Clipboard is not supported.
-
-#import
-#import
-
-#include
-#include
-#include
-#include
-
-#include "imgui_impl_ios.h"
-#include "imgui.h"
-
-#include "uSynergy.h"
-
-// From Carbon HIToolbox/Events.h
-// FIXME: Keyboard mapping is hacked in because Synergy doesn't give us character but only keycode which aren't really portable if you consider keyboard locale. See https://github.com/ocornut/imgui/pull/247
-enum {
- kVK_ANSI_A = 0x00,
- kVK_ANSI_S = 0x01,
- kVK_ANSI_D = 0x02,
- kVK_ANSI_F = 0x03,
- kVK_ANSI_H = 0x04,
- kVK_ANSI_G = 0x05,
- kVK_ANSI_Z = 0x06,
- kVK_ANSI_X = 0x07,
- kVK_ANSI_C = 0x08,
- kVK_ANSI_V = 0x09,
- kVK_ANSI_B = 0x0B,
- kVK_ANSI_Q = 0x0C,
- kVK_ANSI_W = 0x0D,
- kVK_ANSI_E = 0x0E,
- kVK_ANSI_R = 0x0F,
- kVK_ANSI_Y = 0x10,
- kVK_ANSI_T = 0x11,
- kVK_ANSI_1 = 0x12,
- kVK_ANSI_2 = 0x13,
- kVK_ANSI_3 = 0x14,
- kVK_ANSI_4 = 0x15,
- kVK_ANSI_6 = 0x16,
- kVK_ANSI_5 = 0x17,
- kVK_ANSI_Equal = 0x18,
- kVK_ANSI_9 = 0x19,
- kVK_ANSI_7 = 0x1A,
- kVK_ANSI_Minus = 0x1B,
- kVK_ANSI_8 = 0x1C,
- kVK_ANSI_0 = 0x1D,
- kVK_ANSI_RightBracket = 0x1E,
- kVK_ANSI_O = 0x1F,
- kVK_ANSI_U = 0x20,
- kVK_ANSI_LeftBracket = 0x21,
- kVK_ANSI_I = 0x22,
- kVK_ANSI_P = 0x23,
- kVK_ANSI_L = 0x25,
- kVK_ANSI_J = 0x26,
- kVK_ANSI_Quote = 0x27,
- kVK_ANSI_K = 0x28,
- kVK_ANSI_Semicolon = 0x29,
- kVK_ANSI_Backslash = 0x2A,
- kVK_ANSI_Comma = 0x2B,
- kVK_ANSI_Slash = 0x2C,
- kVK_ANSI_N = 0x2D,
- kVK_ANSI_M = 0x2E,
- kVK_ANSI_Period = 0x2F,
- kVK_ANSI_Grave = 0x32,
- kVK_ANSI_KeypadDecimal = 0x41,
- kVK_ANSI_KeypadMultiply = 0x43,
- kVK_ANSI_KeypadPlus = 0x45,
- kVK_ANSI_KeypadClear = 0x47,
- kVK_ANSI_KeypadDivide = 0x4B,
- kVK_ANSI_KeypadEnter = 0x4C,
- kVK_ANSI_KeypadMinus = 0x4E,
- kVK_ANSI_KeypadEquals = 0x51,
- kVK_ANSI_Keypad0 = 0x52,
- kVK_ANSI_Keypad1 = 0x53,
- kVK_ANSI_Keypad2 = 0x54,
- kVK_ANSI_Keypad3 = 0x55,
- kVK_ANSI_Keypad4 = 0x56,
- kVK_ANSI_Keypad5 = 0x57,
- kVK_ANSI_Keypad6 = 0x58,
- kVK_ANSI_Keypad7 = 0x59,
- kVK_ANSI_Keypad8 = 0x5B,
- kVK_ANSI_Keypad9 = 0x5C
-};
-
-/* keycodes for keys that are independent of keyboard layout*/
-enum {
- kVK_Return = 0x24,
- kVK_Tab = 0x30,
- kVK_Space = 0x31,
- kVK_Delete = 0x33,
- kVK_Escape = 0x35,
- kVK_Command = 0x37,
- kVK_Shift = 0x38,
- kVK_CapsLock = 0x39,
- kVK_Option = 0x3A,
- kVK_Control = 0x3B,
- kVK_RightShift = 0x3C,
- kVK_RightOption = 0x3D,
- kVK_RightControl = 0x3E,
- kVK_Function = 0x3F,
- kVK_F17 = 0x40,
- kVK_VolumeUp = 0x48,
- kVK_VolumeDown = 0x49,
- kVK_Mute = 0x4A,
- kVK_F18 = 0x4F,
- kVK_F19 = 0x50,
- kVK_F20 = 0x5A,
- kVK_F5 = 0x60,
- kVK_F6 = 0x61,
- kVK_F7 = 0x62,
- kVK_F3 = 0x63,
- kVK_F8 = 0x64,
- kVK_F9 = 0x65,
- kVK_F11 = 0x67,
- kVK_F13 = 0x69,
- kVK_F16 = 0x6A,
- kVK_F14 = 0x6B,
- kVK_F10 = 0x6D,
- kVK_F12 = 0x6F,
- kVK_F15 = 0x71,
- kVK_Help = 0x72,
- kVK_Home = 0x73,
- kVK_PageUp = 0x74,
- kVK_ForwardDelete = 0x75,
- kVK_F4 = 0x76,
- kVK_End = 0x77,
- kVK_F2 = 0x78,
- kVK_PageDown = 0x79,
- kVK_F1 = 0x7A,
- kVK_LeftArrow = 0x7B,
- kVK_RightArrow = 0x7C,
- kVK_DownArrow = 0x7D,
- kVK_UpArrow = 0x7E
-};
-
-static char g_keycodeCharUnshifted[256] = {};
-static char g_keycodeCharShifted[256] = {};
-
-//static double g_Time = 0.0f;
-static bool g_MousePressed[3] = { false, false, false };
-static float g_mouseWheelX = 0.0f;
-static float g_mouseWheelY = 0.0f;
-
-static GLuint g_FontTexture = 0;
-static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
-static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0;
-static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0;
-static size_t g_VboSize = 0;
-static unsigned int g_VboHandle = 0, g_VaoHandle = 0;
-static float g_displayScale;
-
-static int usynergy_sockfd;
-static bool g_synergyPtrActive = false;
-static uint16_t g_mousePosX = 0;
-static uint16_t g_mousePosY = 0;
-
-static void ImGui_ImplIOS_RenderDrawLists (ImDrawData *draw_data);
-bool ImGui_ImplIOS_CreateDeviceObjects();
-
-static NSString *g_serverName;
-
-uSynergyBool ImGui_ConnectFunc(uSynergyCookie cookie)
-{
- // NOTE: You need to turn off "Use SSL Encryption" in Synergy preferences, since
- // uSynergy does not support SSL.
-
- NSLog( @"Connect Func!");
- struct addrinfo hints, *res;
-
- // first, load up address structs with getaddrinfo():
- memset(&hints, 0, sizeof hints);
- hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6, whichever
- hints.ai_socktype = SOCK_STREAM;
-
- // get server address
- getaddrinfo([g_serverName UTF8String], "24800", &hints, &res);
-
- if (!res)
- {
- NSLog( @"Could not find server: %@", g_serverName );
- return USYNERGY_FALSE;
- }
-
- // make a socket:
- usynergy_sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
-
- // connect it to the address and port we passed in to getaddrinfo():
- int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen);
- if (!ret) {
- NSLog( @"Connect succeeded...");
- } else {
- NSLog( @"Connect failed, %d", ret );
- }
-
-
- return USYNERGY_TRUE;
-}
-
-uSynergyBool ImGui_SendFunc(uSynergyCookie cookie, const uint8_t *buffer, int length)
-{
-// NSLog( @"Send Func" );
- send( usynergy_sockfd, buffer, length, 0 );
-
- return USYNERGY_TRUE;
-}
-
-uSynergyBool ImGui_RecvFunc(uSynergyCookie cookie, uint8_t *buffer, int maxLength, int* outLength)
-{
- *outLength = (int)recv( usynergy_sockfd, buffer, maxLength, 0 );
-
- return USYNERGY_TRUE;
-}
-
-void ImGui_SleepFunc(uSynergyCookie cookie, int timeMs)
-{
- usleep( timeMs * 1000 );
-}
-
-uint32_t ImGui_GetTimeFunc()
-{
- struct timeval tv;
- gettimeofday(&tv, NULL);
-
- return (int32_t)((tv.tv_sec) * 1000 + (tv.tv_usec) / 1000);
-}
-
-void ImGui_TraceFunc(uSynergyCookie cookie, const char *text)
-{
- puts(text);
-}
-
-void ImGui_ScreenActiveCallback(uSynergyCookie cookie, uSynergyBool active)
-{
- g_synergyPtrActive = active;
-// printf( "Synergy: screen activate %s\n", active?"YES":"NO" );
-}
-
-void ImGui_MouseCallback(uSynergyCookie cookie, uint16_t x, uint16_t y, int16_t wheelX, int16_t wheelY,
- uSynergyBool buttonLeft, uSynergyBool buttonRight, uSynergyBool buttonMiddle)
-{
-// printf("Synergy: mouse callback %d %d -- wheel %d %d\n", x, y, wheelX, wheelY );
- uSynergyContext *ctx = (uSynergyContext*)cookie;
- g_mousePosX = x;
- g_mousePosY = y;
- g_mouseWheelX = wheelX;
- g_mouseWheelY = wheelY;
- g_MousePressed[0] = buttonLeft;
- g_MousePressed[1] = buttonMiddle;
- g_MousePressed[2] = buttonRight;
-
- ctx->m_mouseWheelX = 0;
- ctx->m_mouseWheelY = 0;
-}
-
-void ImGui_KeyboardCallback(uSynergyCookie cookie, uint16_t key,
- uint16_t modifiers, uSynergyBool down, uSynergyBool repeat)
-{
- int scanCode = key-1;
- // printf("Synergy: keyboard callback: 0x%02X (%s)", scanCode, down?"true":"false");
- ImGuiIO& io = ImGui::GetIO();
- io.KeysDown[key] = down;
- io.KeyShift = (modifiers & USYNERGY_MODIFIER_SHIFT);
- io.KeyCtrl = (modifiers & USYNERGY_MODIFIER_CTRL);
- io.KeyAlt = (modifiers & USYNERGY_MODIFIER_ALT);
- io.KeySuper = (modifiers & USYNERGY_MODIFIER_WIN);
-
- // Add this as keyboard input
- if ((down) && (key) && (scanCode<256) && !(modifiers & USYNERGY_MODIFIER_CTRL))
- {
- // If this key maps to a character input, apply it
- int charForKeycode = (modifiers & USYNERGY_MODIFIER_SHIFT) ? g_keycodeCharShifted[scanCode] : g_keycodeCharUnshifted[scanCode];
- io.AddInputCharacter((unsigned short)charForKeycode);
- }
-
-}
-
-void ImGui_JoystickCallback(uSynergyCookie cookie, uint8_t joyNum, uint16_t buttons, int8_t leftStickX, int8_t leftStickY, int8_t rightStickX, int8_t rightStickY)
-{
- printf("Synergy: joystick callback TODO\n");
-}
-
-void ImGui_ClipboardCallback(uSynergyCookie cookie, enum uSynergyClipboardFormat format, const uint8_t *data, uint32_t size)
-{
- printf("Synergy: clipboard callback TODO\n" );
-}
-
-@interface ImGuiHelper ()
-{
- BOOL _mouseDown;
- BOOL _mouseTapped;
- CGPoint _touchPos;
-
- uSynergyContext _synergyCtx;
- dispatch_queue_t _synergyQueue;
-}
-@property (nonatomic, weak) UIView *view;
-@property (nonatomic, strong) NSString *serverName;
-
-@end
-
-@implementation ImGuiHelper
-
-- (id) initWithView: (UIView *)view
-{
- self = [super init];
- if (self)
- {
- self.view = view;
-
- [self setupImGuiHooks];
- }
- return self;
-}
-
-- (void)setupKeymaps
-{
- // The keyboard mapping is a big headache. I tried for a while to find a better way to do this,
- // but this was the best I could come up with. There are some device independent API's available
- // to convert scan codes to unicode characters, but these are only available on mac and not
- // on iOS as far as I can tell (it's part of Carbon). I didn't see any better way to do
- // this or any way to get the character codes out of usynergy.
- g_keycodeCharUnshifted[ kVK_ANSI_A ]='a';
- g_keycodeCharUnshifted[ kVK_ANSI_S ]='s';
- g_keycodeCharUnshifted[ kVK_ANSI_D ]='d';
- g_keycodeCharUnshifted[ kVK_ANSI_F ]='f';
- g_keycodeCharUnshifted[ kVK_ANSI_H ]='h';
- g_keycodeCharUnshifted[ kVK_ANSI_G ]='g';
- g_keycodeCharUnshifted[ kVK_ANSI_Z ]='z';
- g_keycodeCharUnshifted[ kVK_ANSI_X ]='x';
- g_keycodeCharUnshifted[ kVK_ANSI_C ]='c';
- g_keycodeCharUnshifted[ kVK_ANSI_V ]='v';
- g_keycodeCharUnshifted[ kVK_ANSI_B ]='b';
- g_keycodeCharUnshifted[ kVK_ANSI_Q ]='q';
- g_keycodeCharUnshifted[ kVK_ANSI_W ]='w';
- g_keycodeCharUnshifted[ kVK_ANSI_E ]='e';
- g_keycodeCharUnshifted[ kVK_ANSI_R ]='r';
- g_keycodeCharUnshifted[ kVK_ANSI_Y ]='y';
- g_keycodeCharUnshifted[ kVK_ANSI_T ]='t';
- g_keycodeCharUnshifted[ kVK_ANSI_1 ]='1';
- g_keycodeCharUnshifted[ kVK_ANSI_2 ]='2';
- g_keycodeCharUnshifted[ kVK_ANSI_3 ]='3';
- g_keycodeCharUnshifted[ kVK_ANSI_4 ]='4';
- g_keycodeCharUnshifted[ kVK_ANSI_6 ]='6';
- g_keycodeCharUnshifted[ kVK_ANSI_5 ]='5';
- g_keycodeCharUnshifted[ kVK_ANSI_Equal ]='=';
- g_keycodeCharUnshifted[ kVK_ANSI_9 ]='9';
- g_keycodeCharUnshifted[ kVK_ANSI_7 ]='7';
- g_keycodeCharUnshifted[ kVK_ANSI_Minus ]='-';
- g_keycodeCharUnshifted[ kVK_ANSI_8 ]='8';
- g_keycodeCharUnshifted[ kVK_ANSI_0 ]='0';
- g_keycodeCharUnshifted[ kVK_ANSI_RightBracket ]=']';
- g_keycodeCharUnshifted[ kVK_ANSI_O ]='o';
- g_keycodeCharUnshifted[ kVK_ANSI_U ]='u';
- g_keycodeCharUnshifted[ kVK_ANSI_LeftBracket ]='[';
- g_keycodeCharUnshifted[ kVK_ANSI_I ]='i';
- g_keycodeCharUnshifted[ kVK_ANSI_P ]='p';
- g_keycodeCharUnshifted[ kVK_ANSI_L ]='l';
- g_keycodeCharUnshifted[ kVK_ANSI_J ]='j';
- g_keycodeCharUnshifted[ kVK_ANSI_Quote ]='\'';
- g_keycodeCharUnshifted[ kVK_ANSI_K ]='k';
- g_keycodeCharUnshifted[ kVK_ANSI_Semicolon ]=';';
- g_keycodeCharUnshifted[ kVK_ANSI_Backslash ]='\\';
- g_keycodeCharUnshifted[ kVK_ANSI_Comma ]=',';
- g_keycodeCharUnshifted[ kVK_ANSI_Slash ]='/';
- g_keycodeCharUnshifted[ kVK_ANSI_N ]='n';
- g_keycodeCharUnshifted[ kVK_ANSI_M ]='m';
- g_keycodeCharUnshifted[ kVK_ANSI_Period ]='.';
- g_keycodeCharUnshifted[ kVK_ANSI_Grave ]='`';
- g_keycodeCharUnshifted[ kVK_ANSI_KeypadDecimal ]='.';
- g_keycodeCharUnshifted[ kVK_ANSI_KeypadMultiply ]='*';
- g_keycodeCharUnshifted[ kVK_ANSI_KeypadPlus ]='+';
- g_keycodeCharUnshifted[ kVK_ANSI_KeypadDivide ]='/';
- g_keycodeCharUnshifted[ kVK_ANSI_KeypadEnter ]='\n';
- g_keycodeCharUnshifted[ kVK_ANSI_KeypadMinus ]='-';
- g_keycodeCharUnshifted[ kVK_ANSI_KeypadEquals ]='=';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad0 ]='0';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad1 ]='1';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad2 ]='2';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad3 ]='3';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad4 ]='4';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad5 ]='5';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad6 ]='6';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad7 ]='7';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad8 ]='8';
- g_keycodeCharUnshifted[ kVK_ANSI_Keypad9 ]='9';
- g_keycodeCharUnshifted[ kVK_Space ]=' ';
-
- g_keycodeCharShifted[ kVK_ANSI_A ]='A';
- g_keycodeCharShifted[ kVK_ANSI_S ]='S';
- g_keycodeCharShifted[ kVK_ANSI_D ]='D';
- g_keycodeCharShifted[ kVK_ANSI_F ]='F';
- g_keycodeCharShifted[ kVK_ANSI_H ]='H';
- g_keycodeCharShifted[ kVK_ANSI_G ]='G';
- g_keycodeCharShifted[ kVK_ANSI_Z ]='Z';
- g_keycodeCharShifted[ kVK_ANSI_X ]='X';
- g_keycodeCharShifted[ kVK_ANSI_C ]='C';
- g_keycodeCharShifted[ kVK_ANSI_V ]='V';
- g_keycodeCharShifted[ kVK_ANSI_B ]='B';
- g_keycodeCharShifted[ kVK_ANSI_Q ]='Q';
- g_keycodeCharShifted[ kVK_ANSI_W ]='W';
- g_keycodeCharShifted[ kVK_ANSI_E ]='E';
- g_keycodeCharShifted[ kVK_ANSI_R ]='R';
- g_keycodeCharShifted[ kVK_ANSI_Y ]='Y';
- g_keycodeCharShifted[ kVK_ANSI_T ]='T';
- g_keycodeCharShifted[ kVK_ANSI_1 ]='!';
- g_keycodeCharShifted[ kVK_ANSI_2 ]='@';
- g_keycodeCharShifted[ kVK_ANSI_3 ]='#';
- g_keycodeCharShifted[ kVK_ANSI_4 ]='$';
- g_keycodeCharShifted[ kVK_ANSI_6 ]='^';
- g_keycodeCharShifted[ kVK_ANSI_5 ]='%';
- g_keycodeCharShifted[ kVK_ANSI_Equal ]='+';
- g_keycodeCharShifted[ kVK_ANSI_9 ]='(';
- g_keycodeCharShifted[ kVK_ANSI_7 ]='&';
- g_keycodeCharShifted[ kVK_ANSI_Minus ]='_';
- g_keycodeCharShifted[ kVK_ANSI_8 ]='*';
- g_keycodeCharShifted[ kVK_ANSI_0 ]=')';
- g_keycodeCharShifted[ kVK_ANSI_RightBracket ]='}';
- g_keycodeCharShifted[ kVK_ANSI_O ]='O';
- g_keycodeCharShifted[ kVK_ANSI_U ]='U';
- g_keycodeCharShifted[ kVK_ANSI_LeftBracket ]='{';
- g_keycodeCharShifted[ kVK_ANSI_I ]='I';
- g_keycodeCharShifted[ kVK_ANSI_P ]='P';
- g_keycodeCharShifted[ kVK_ANSI_L ]='L';
- g_keycodeCharShifted[ kVK_ANSI_J ]='J';
- g_keycodeCharShifted[ kVK_ANSI_Quote ]='\"';
- g_keycodeCharShifted[ kVK_ANSI_K ]='K';
- g_keycodeCharShifted[ kVK_ANSI_Semicolon ]=':';
- g_keycodeCharShifted[ kVK_ANSI_Backslash ]='|';
- g_keycodeCharShifted[ kVK_ANSI_Comma ]='<';
- g_keycodeCharShifted[ kVK_ANSI_Slash ]='?';
- g_keycodeCharShifted[ kVK_ANSI_N ]='N';
- g_keycodeCharShifted[ kVK_ANSI_M ]='M';
- g_keycodeCharShifted[ kVK_ANSI_Period ]='>';
- g_keycodeCharShifted[ kVK_ANSI_Grave ]='~';
- g_keycodeCharShifted[ kVK_ANSI_KeypadDecimal ]='.';
- g_keycodeCharShifted[ kVK_ANSI_KeypadMultiply ]='*';
- g_keycodeCharShifted[ kVK_ANSI_KeypadPlus ]='+';
- g_keycodeCharShifted[ kVK_ANSI_KeypadDivide ]='/';
- g_keycodeCharShifted[ kVK_ANSI_KeypadEnter ]='\n';
- g_keycodeCharShifted[ kVK_ANSI_KeypadMinus ]='-';
- g_keycodeCharShifted[ kVK_ANSI_KeypadEquals ]='=';
- g_keycodeCharShifted[ kVK_ANSI_Keypad0 ]='0';
- g_keycodeCharShifted[ kVK_ANSI_Keypad1 ]='1';
- g_keycodeCharShifted[ kVK_ANSI_Keypad2 ]='2';
- g_keycodeCharShifted[ kVK_ANSI_Keypad3 ]='3';
- g_keycodeCharShifted[ kVK_ANSI_Keypad4 ]='4';
- g_keycodeCharShifted[ kVK_ANSI_Keypad5 ]='5';
- g_keycodeCharShifted[ kVK_ANSI_Keypad6 ]='6';
- g_keycodeCharShifted[ kVK_ANSI_Keypad7 ]='7';
- g_keycodeCharShifted[ kVK_ANSI_Keypad8 ]='8';
- g_keycodeCharShifted[ kVK_ANSI_Keypad9 ]='9';
- g_keycodeCharShifted[ kVK_Space ]=' ';
-}
-
-- (void)setupImGuiHooks
-{
- ImGuiIO &io = ImGui::GetIO();
-
- [self setupKeymaps];
-
- // Account for retina display for glScissor
- g_displayScale = [[UIScreen mainScreen] scale];
-
- ImGuiStyle &style = ImGui::GetStyle();
- style.TouchExtraPadding = ImVec2( 4.0, 4.0 );
-
- io.RenderDrawListsFn = ImGui_ImplIOS_RenderDrawLists;
-
- UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(viewDidPan:) ];
- [self.view addGestureRecognizer:panRecognizer];
-
- UITapGestureRecognizer *tapRecoginzer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector( viewDidTap:)];
- [self.view addGestureRecognizer:tapRecoginzer];
-
- // Fill out the Synergy key map
- // (for some reason synergy scan codes are off by 1)
- io.KeyMap[ImGuiKey_Tab] = kVK_Tab+1;
- io.KeyMap[ImGuiKey_LeftArrow] = kVK_LeftArrow+1;
- io.KeyMap[ImGuiKey_RightArrow] = kVK_RightArrow+1;
- io.KeyMap[ImGuiKey_UpArrow] = kVK_UpArrow+1;
- io.KeyMap[ImGuiKey_DownArrow] = kVK_DownArrow+1;
- io.KeyMap[ImGuiKey_Home] = kVK_Home+1;
- io.KeyMap[ImGuiKey_End] = kVK_End+1;
- io.KeyMap[ImGuiKey_Insert] = kVK_Help+1;
- io.KeyMap[ImGuiKey_Delete] = kVK_ForwardDelete+1;
- io.KeyMap[ImGuiKey_Backspace] = kVK_Delete+1;
- io.KeyMap[ImGuiKey_Space] = kVK_Space+1;
- io.KeyMap[ImGuiKey_Enter] = kVK_Return+1;
- io.KeyMap[ImGuiKey_Escape] = kVK_Escape+1;
- io.KeyMap[ImGuiKey_A] = kVK_ANSI_A+1;
- io.KeyMap[ImGuiKey_C] = kVK_ANSI_C+1;
- io.KeyMap[ImGuiKey_V] = kVK_ANSI_V+1;
- io.KeyMap[ImGuiKey_X] = kVK_ANSI_X+1;
- io.KeyMap[ImGuiKey_Y] = kVK_ANSI_Y+1;
- io.KeyMap[ImGuiKey_Z] = kVK_ANSI_Z+1;
-}
-
-- (void)connectServer: (NSString*)serverName
-{
- self.serverName = serverName;
- g_serverName = serverName;
-
- // Init synergy
- NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
-
- uSynergyInit( &_synergyCtx );
- _synergyCtx.m_clientName = strdup( [bundleName UTF8String] );
- _synergyCtx.m_clientWidth = self.view.bounds.size.width;
- _synergyCtx.m_clientHeight = self.view.bounds.size.height;
-
- _synergyCtx.m_connectFunc = ImGui_ConnectFunc;
- _synergyCtx.m_sendFunc = ImGui_SendFunc;
- _synergyCtx.m_receiveFunc = ImGui_RecvFunc;
- _synergyCtx.m_sleepFunc = ImGui_SleepFunc;
- _synergyCtx.m_traceFunc = ImGui_TraceFunc;
- _synergyCtx.m_getTimeFunc = ImGui_GetTimeFunc;
-
- _synergyCtx.m_traceFunc = ImGui_TraceFunc;
- _synergyCtx.m_screenActiveCallback = ImGui_ScreenActiveCallback;
- _synergyCtx.m_mouseCallback = ImGui_MouseCallback;
- _synergyCtx.m_keyboardCallback = ImGui_KeyboardCallback;
-
- _synergyCtx.m_cookie = (uSynergyCookie)&_synergyCtx;
-
- // Create a background thread for synergy
- _synergyQueue = dispatch_queue_create( "imgui-usynergy", NULL );
- dispatch_async( _synergyQueue, ^{
- while (1) {
- uSynergyUpdate( &_synergyCtx );
- }
- });
-}
-
-
-- (void)viewDidPan: (UIPanGestureRecognizer *)recognizer
-{
-
- if ((recognizer.state == UIGestureRecognizerStateBegan) ||
- (recognizer.state == UIGestureRecognizerStateChanged))
- {
- _mouseDown = YES;
- _touchPos = [recognizer locationInView:self.view];
- }
- else
- {
- _mouseDown = NO;
- _touchPos = CGPointMake( -1, -1 );
- }
-}
-
-- (void)viewDidTap: (UITapGestureRecognizer*)recognizer
-{
- _touchPos = [recognizer locationInView:self.view];
- _mouseTapped = YES;
-}
-
-- (void)render
-{
- ImGui::Render();
-}
-
-- (void)newFrame
-{
- ImGuiIO& io = ImGui::GetIO();
- ImGuiStyle &style = ImGui::GetStyle();
-
- if (!g_FontTexture)
- {
- ImGui_ImplIOS_CreateDeviceObjects();
- }
-
- io.DisplaySize = ImVec2( _view.bounds.size.width, _view.bounds.size.height );
-
- io.MouseDrawCursor = g_synergyPtrActive;
- if (g_synergyPtrActive)
- {
- style.TouchExtraPadding = ImVec2( 0.0, 0.0 );
- io.MousePos = ImVec2( g_mousePosX, g_mousePosY );
- for (int i=0; i < 3; i++)
- {
- io.MouseDown[i] = g_MousePressed[i];
- }
-
- // This is an arbitrary scaling factor that works for me. Not sure what units these mousewheel values from synergy are supposed to be in.
- io.MouseWheel = g_mouseWheelY / 500.0;
- io.MouseWheelH = g_mouseWheelX / 500.0;
- }
- else
- {
- // Synergy not active, use touch events
- style.TouchExtraPadding = ImVec2( 4.0, 4.0 );
- io.MousePos = ImVec2(_touchPos.x, _touchPos.y );
- if ((_mouseDown) || (_mouseTapped))
- {
- io.MouseDown[0] = true;
- _mouseTapped = NO;
- }
- else
- {
- io.MouseDown[0] = false;
- }
- }
-
- ImGui::NewFrame();
-}
-@end
-
-// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
-// If text or lines are blurry when integrating ImGui in your engine:
-// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
-// NOTE: this is copied pretty much entirely from the opengl3_example, with only minor changes for ES
-static void ImGui_ImplIOS_RenderDrawLists (ImDrawData *draw_data)
-{
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
- // FIXME: Backport changes from imgui_impl_glfw_gl3.cpp
- GLint last_program, last_texture;
- glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glEnable(GL_BLEND);
- glBlendEquation(GL_FUNC_ADD);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glActiveTexture(GL_TEXTURE0);
-
- // Setup orthographic projection matrix
- const float width = ImGui::GetIO().DisplaySize.x;
- const float height = ImGui::GetIO().DisplaySize.y;
- const float ortho_projection[4][4] =
- {
- { 2.0f/width, 0.0f, 0.0f, 0.0f },
- { 0.0f, 2.0f/-height, 0.0f, 0.0f },
- { 0.0f, 0.0f, -1.0f, 0.0f },
- { -1.0f, 1.0f, 0.0f, 1.0f },
- };
- glUseProgram(g_ShaderHandle);
- glUniform1i(g_AttribLocationTex, 0);
- glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
- glBindVertexArray(g_VaoHandle);
-
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- ImDrawList* cmd_list = draw_data->CmdLists[n];
- ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
-
- glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
- if (g_VboSize < needed_vtx_size)
- {
- // Grow our buffer if needed
- g_VboSize = needed_vtx_size + 2000 * sizeof(ImDrawVert);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)g_VboSize, NULL, GL_STREAM_DRAW);
- }
-
- unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
- if (!vtx_data)
- continue;
- memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
- glUnmapBuffer(GL_ARRAY_BUFFER);
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)(pcmd->ClipRect.x * g_displayScale),
- (int)((height - pcmd->ClipRect.w) * g_displayScale),
- (int)((pcmd->ClipRect.z - pcmd->ClipRect.x) * g_displayScale),
- (int)((pcmd->ClipRect.w - pcmd->ClipRect.y) * g_displayScale));
- glDrawElements( GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer );
- }
- idx_buffer += pcmd->ElemCount;
- }
- }
-
- // Restore modified state
- glBindVertexArray(0);
- glBindBuffer( GL_ARRAY_BUFFER, 0);
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
- glUseProgram(last_program);
- glDisable(GL_SCISSOR_TEST);
- glBindTexture(GL_TEXTURE_2D, last_texture);
-}
-
-void ImGui_ImplIOS_CreateFontsTexture()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-}
-
-bool ImGui_ImplIOS_CreateDeviceObjects()
-{
- const GLchar *vertex_shader =
- "uniform mat4 ProjMtx;\n"
- "attribute highp vec2 Position;\n"
- "attribute highp vec2 UV;\n"
- "attribute highp vec4 Color;\n"
- "varying vec2 Frag_UV;\n"
- "varying vec4 Frag_Color;\n"
- "void main()\n"
- "{\n"
- " Frag_UV = UV;\n"
- " Frag_Color = Color;\n"
- " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
- "}\n";
-
- const GLchar* fragment_shader =
- "uniform sampler2D Texture;\n"
- "varying highp vec2 Frag_UV;\n"
- "varying highp vec4 Frag_Color;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = Frag_Color * texture2D( Texture, Frag_UV.st);\n"
- "}\n";
-
- g_ShaderHandle = glCreateProgram();
- g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
- g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
- glShaderSource(g_VertHandle, 1, &vertex_shader, 0);
- glShaderSource(g_FragHandle, 1, &fragment_shader, 0);
- glCompileShader(g_VertHandle);
-
-#if defined(DEBUG)
- GLint logLength;
- glGetShaderiv( g_VertHandle, GL_INFO_LOG_LENGTH, &logLength);
- if (logLength > 0) {
- GLchar *log = (GLchar *)malloc(logLength);
- glGetShaderInfoLog(g_VertHandle, logLength, &logLength, log);
- NSLog(@"VERTEX Shader compile log:\n%s", log);
- free(log);
- }
-#endif
-
- glCompileShader(g_FragHandle);
-
-#if defined(DEBUG)
- glGetShaderiv( g_FragHandle, GL_INFO_LOG_LENGTH, &logLength);
- if (logLength > 0) {
- GLchar *log = (GLchar *)malloc(logLength);
- glGetShaderInfoLog(g_FragHandle, logLength, &logLength, log);
- NSLog(@"FRAGMENT Shader compile log:\n%s", log);
- free(log);
- }
-#endif
-
- glAttachShader(g_ShaderHandle, g_VertHandle);
- glAttachShader(g_ShaderHandle, g_FragHandle);
- glLinkProgram(g_ShaderHandle);
-
- g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
- g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
- g_AttribLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position");
- g_AttribLocationUV = glGetAttribLocation(g_ShaderHandle, "UV");
- g_AttribLocationColor = glGetAttribLocation(g_ShaderHandle, "Color");
-
- glGenBuffers(1, &g_VboHandle);
-
- glGenVertexArrays(1, &g_VaoHandle);
- glBindVertexArray(g_VaoHandle);
- glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glEnableVertexAttribArray(g_AttribLocationPosition);
- glEnableVertexAttribArray(g_AttribLocationUV);
- glEnableVertexAttribArray(g_AttribLocationColor);
-
- glVertexAttribPointer(g_AttribLocationPosition, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
- glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
- glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
-
- glBindVertexArray(0);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- ImGui_ImplIOS_CreateFontsTexture();
-
- return true;
-}
diff --git a/third_party/imgui/examples/apple_example/imguiex-osx/AppDelegate.h b/third_party/imgui/examples/apple_example/imguiex-osx/AppDelegate.h
deleted file mode 100644
index 33d199bbf6..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-osx/AppDelegate.h
+++ /dev/null
@@ -1,15 +0,0 @@
-//
-// AppDelegate.h
-// imguiex-osx
-//
-// Created by James Chen on 4/5/16.
-// Copyright © 2016 Joel Davis. All rights reserved.
-//
-
-#import
-
-@interface AppDelegate : NSObject
-
-
-@end
-
diff --git a/third_party/imgui/examples/apple_example/imguiex-osx/AppDelegate.m b/third_party/imgui/examples/apple_example/imguiex-osx/AppDelegate.m
deleted file mode 100644
index 59e877b39a..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-osx/AppDelegate.m
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-// AppDelegate.m
-// imguiex-osx
-//
-// Created by James Chen on 4/5/16.
-// Copyright © 2016 Joel Davis. All rights reserved.
-//
-
-#import "AppDelegate.h"
-
-@interface AppDelegate ()
-
-@property (weak) IBOutlet NSWindow *window;
-@end
-
-@implementation AppDelegate
-
-- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
- // Insert code here to initialize your application
-}
-
-- (void)applicationWillTerminate:(NSNotification *)aNotification {
- // Insert code here to tear down your application
-}
-
-@end
diff --git a/third_party/imgui/examples/apple_example/imguiex-osx/Assets.xcassets/AppIcon.appiconset/Contents.json b/third_party/imgui/examples/apple_example/imguiex-osx/Assets.xcassets/AppIcon.appiconset/Contents.json
deleted file mode 100644
index b13908fc66..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-osx/Assets.xcassets/AppIcon.appiconset/Contents.json
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "images" : [
- {
- "idiom" : "mac",
- "size" : "16x16",
- "scale" : "1x"
- },
- {
- "idiom" : "mac",
- "size" : "16x16",
- "scale" : "2x"
- },
- {
- "idiom" : "mac",
- "size" : "32x32",
- "scale" : "1x"
- },
- {
- "idiom" : "mac",
- "size" : "32x32",
- "scale" : "2x"
- },
- {
- "idiom" : "mac",
- "size" : "128x128",
- "scale" : "1x"
- },
- {
- "idiom" : "mac",
- "size" : "128x128",
- "scale" : "2x"
- },
- {
- "idiom" : "mac",
- "size" : "256x256",
- "scale" : "1x"
- },
- {
- "idiom" : "mac",
- "size" : "256x256",
- "scale" : "2x"
- },
- {
- "idiom" : "mac",
- "size" : "512x512",
- "scale" : "1x"
- },
- {
- "size" : "512x512",
- "idiom" : "mac",
- "filename" : "icon_imgui_180x180.png",
- "scale" : "2x"
- },
- {
- "idiom" : "mac",
- "size" : "512x512",
- "scale" : "2x"
- }
- ],
- "info" : {
- "version" : 1,
- "author" : "xcode"
- }
-}
\ No newline at end of file
diff --git a/third_party/imgui/examples/apple_example/imguiex-osx/Assets.xcassets/AppIcon.appiconset/icon_imgui_180x180.png b/third_party/imgui/examples/apple_example/imguiex-osx/Assets.xcassets/AppIcon.appiconset/icon_imgui_180x180.png
deleted file mode 100644
index f48b799dba..0000000000
Binary files a/third_party/imgui/examples/apple_example/imguiex-osx/Assets.xcassets/AppIcon.appiconset/icon_imgui_180x180.png and /dev/null differ
diff --git a/third_party/imgui/examples/apple_example/imguiex-osx/Assets.xcassets/Contents.json b/third_party/imgui/examples/apple_example/imguiex-osx/Assets.xcassets/Contents.json
deleted file mode 100644
index da4a164c91..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-osx/Assets.xcassets/Contents.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "info" : {
- "version" : 1,
- "author" : "xcode"
- }
-}
\ No newline at end of file
diff --git a/third_party/imgui/examples/apple_example/imguiex-osx/main.m b/third_party/imgui/examples/apple_example/imguiex-osx/main.m
deleted file mode 100644
index 20b0731376..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex-osx/main.m
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// main.m
-// imguiex-osx
-//
-// Created by James Chen on 4/5/16.
-// Copyright © 2016 Joel Davis. All rights reserved.
-//
-
-#import
-
-int main(int argc, const char * argv[]) {
- return NSApplicationMain(argc, argv);
-}
diff --git a/third_party/imgui/examples/apple_example/imguiex.xcodeproj/project.pbxproj b/third_party/imgui/examples/apple_example/imguiex.xcodeproj/project.pbxproj
deleted file mode 100644
index 3e5b078942..0000000000
--- a/third_party/imgui/examples/apple_example/imguiex.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,539 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 46;
- objects = {
-
-/* Begin PBXBuildFile section */
- 197E1E871B8943FE00E3FE6A /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */; };
- 197E1E891B89443600E3FE6A /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E881B89443600E3FE6A /* imgui_demo.cpp */; };
- 1A1A0F231CB39FB50090F036 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A1A0F221CB39FB50090F036 /* AppDelegate.m */; };
- 1A1A0F281CB39FB50090F036 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A1A0F271CB39FB50090F036 /* Assets.xcassets */; };
- 1A1A0F301CB3A0DA0090F036 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */; };
- 1A1A0F311CB3A0DA0090F036 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5861B2E64AB00C130BA /* imgui.cpp */; };
- 1A1A0F321CB3A0DE0090F036 /* uSynergy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6D1E39151B35EEF10017B40F /* uSynergy.c */; };
- 1A1A0F331CB3A0E10090F036 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E881B89443600E3FE6A /* imgui_demo.cpp */; };
- 1A1A0F341CB3A0EC0090F036 /* debug_hud.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */; };
- 1A1A0F481CB3A2E50090F036 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1A0F391CB3A1B20090F036 /* main.cpp */; };
- 1A1A0F4A1CB3A5070090F036 /* imgui_impl_glfw_gl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw_gl2.cpp */; };
- 1A1A0F4E1CB3C54D0090F036 /* libglfw.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A1A0F4D1CB3C54D0090F036 /* libglfw.dylib */; };
- 6D1E39171B35EEF10017B40F /* uSynergy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6D1E39151B35EEF10017B40F /* uSynergy.c */; };
- 6D2FC55A1B2E632000C130BA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5591B2E632000C130BA /* main.m */; };
- 6D2FC55D1B2E632000C130BA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC55C1B2E632000C130BA /* AppDelegate.m */; };
- 6D2FC55F1B2E632000C130BA /* Shader.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC55E1B2E632000C130BA /* Shader.fsh */; };
- 6D2FC5611B2E632000C130BA /* Shader.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC5601B2E632000C130BA /* Shader.vsh */; };
- 6D2FC5641B2E632000C130BA /* GameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5631B2E632000C130BA /* GameViewController.m */; };
- 6D2FC5671B2E632000C130BA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC5651B2E632000C130BA /* Main.storyboard */; };
- 6D2FC5691B2E632000C130BA /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC5681B2E632000C130BA /* Images.xcassets */; };
- 6D2FC56C1B2E632000C130BA /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC56A1B2E632000C130BA /* LaunchScreen.xib */; };
- 6D2FC5831B2E63A100C130BA /* imgui_impl_ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */; };
- 6D2FC5881B2E64AB00C130BA /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5861B2E64AB00C130BA /* imgui.cpp */; };
- 6D2FC58B1B2E6A5500C130BA /* debug_hud.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */; };
- 6D2FC5911B30773F00C130BA /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2FC5901B30773F00C130BA /* CFNetwork.framework */; };
- 6D2FC5931B30774900C130BA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2FC5921B30774900C130BA /* SystemConfiguration.framework */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXFileReference section */
- 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; };
- 197E1E881B89443600E3FE6A /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../../imgui_demo.cpp; sourceTree = ""; };
- 1A1A0F1F1CB39FB50090F036 /* imguiex-osx.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "imguiex-osx.app"; sourceTree = BUILT_PRODUCTS_DIR; };
- 1A1A0F211CB39FB50090F036 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
- 1A1A0F221CB39FB50090F036 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
- 1A1A0F271CB39FB50090F036 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
- 1A1A0F2C1CB39FB50090F036 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- 1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw_gl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = imgui_impl_glfw_gl2.cpp; sourceTree = ""; };
- 1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw_gl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imgui_impl_glfw_gl2.h; sourceTree = ""; };
- 1A1A0F391CB3A1B20090F036 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; };
- 1A1A0F4D1CB3C54D0090F036 /* libglfw.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libglfw.dylib; path = /usr/local/lib/libglfw.dylib; sourceTree = ""; };
- 6D1E39151B35EEF10017B40F /* uSynergy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uSynergy.c; sourceTree = ""; };
- 6D1E39161B35EEF10017B40F /* uSynergy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uSynergy.h; sourceTree = ""; };
- 6D2FC5541B2E632000C130BA /* imguiex-ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "imguiex-ios.app"; sourceTree = BUILT_PRODUCTS_DIR; };
- 6D2FC5581B2E632000C130BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- 6D2FC5591B2E632000C130BA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
- 6D2FC55B1B2E632000C130BA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
- 6D2FC55C1B2E632000C130BA /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
- 6D2FC55E1B2E632000C130BA /* Shader.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = Shader.fsh; path = Shaders/Shader.fsh; sourceTree = ""; };
- 6D2FC5601B2E632000C130BA /* Shader.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = Shader.vsh; path = Shaders/Shader.vsh; sourceTree = ""; };
- 6D2FC5621B2E632000C130BA /* GameViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameViewController.h; sourceTree = ""; };
- 6D2FC5631B2E632000C130BA /* GameViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GameViewController.m; sourceTree = ""; };
- 6D2FC5661B2E632000C130BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
- 6D2FC5681B2E632000C130BA /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
- 6D2FC56B1B2E632000C130BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
- 6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = imgui_impl_ios.mm; sourceTree = ""; };
- 6D2FC5821B2E63A100C130BA /* imgui_impl_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imgui_impl_ios.h; sourceTree = ""; };
- 6D2FC5851B2E64AB00C130BA /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = ""; };
- 6D2FC5861B2E64AB00C130BA /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; };
- 6D2FC5871B2E64AB00C130BA /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; };
- 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = debug_hud.cpp; sourceTree = ""; };
- 6D2FC58A1B2E6A5500C130BA /* debug_hud.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debug_hud.h; sourceTree = ""; };
- 6D2FC5901B30773F00C130BA /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
- 6D2FC5921B30774900C130BA /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- 1A1A0F1C1CB39FB50090F036 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 1A1A0F4E1CB3C54D0090F036 /* libglfw.dylib in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 6D2FC5511B2E632000C130BA /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 6D2FC5931B30774900C130BA /* SystemConfiguration.framework in Frameworks */,
- 6D2FC5911B30773F00C130BA /* CFNetwork.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- 1A1A0F201CB39FB50090F036 /* imguiex-osx */ = {
- isa = PBXGroup;
- children = (
- 1A1A0F4D1CB3C54D0090F036 /* libglfw.dylib */,
- 1A1A0F351CB3A1B20090F036 /* opengl2_example */,
- 1A1A0F211CB39FB50090F036 /* AppDelegate.h */,
- 1A1A0F221CB39FB50090F036 /* AppDelegate.m */,
- 1A1A0F271CB39FB50090F036 /* Assets.xcassets */,
- 1A1A0F2C1CB39FB50090F036 /* Info.plist */,
- 1A1A0F241CB39FB50090F036 /* Supporting Files */,
- );
- path = "imguiex-osx";
- sourceTree = "";
- };
- 1A1A0F241CB39FB50090F036 /* Supporting Files */ = {
- isa = PBXGroup;
- children = (
- );
- name = "Supporting Files";
- sourceTree = "";
- };
- 1A1A0F351CB3A1B20090F036 /* opengl2_example */ = {
- isa = PBXGroup;
- children = (
- 1A1A0F371CB3A1B20090F036 /* imgui_impl_glfw_gl2.cpp */,
- 1A1A0F381CB3A1B20090F036 /* imgui_impl_glfw_gl2.h */,
- 1A1A0F391CB3A1B20090F036 /* main.cpp */,
- );
- name = opengl2_example;
- path = ../../opengl2_example;
- sourceTree = "";
- };
- 6D1E39141B35EEF10017B40F /* usynergy */ = {
- isa = PBXGroup;
- children = (
- 6D1E39151B35EEF10017B40F /* uSynergy.c */,
- 6D1E39161B35EEF10017B40F /* uSynergy.h */,
- );
- name = usynergy;
- path = ../libs/usynergy;
- sourceTree = "";
- };
- 6D2FC54B1B2E632000C130BA = {
- isa = PBXGroup;
- children = (
- 6D1E39141B35EEF10017B40F /* usynergy */,
- 6D2FC5841B2E648D00C130BA /* imgui */,
- 6D2FC5561B2E632000C130BA /* imguiex-ios */,
- 1A1A0F201CB39FB50090F036 /* imguiex-osx */,
- 6D2FC5551B2E632000C130BA /* Products */,
- );
- sourceTree = "";
- };
- 6D2FC5551B2E632000C130BA /* Products */ = {
- isa = PBXGroup;
- children = (
- 6D2FC5541B2E632000C130BA /* imguiex-ios.app */,
- 1A1A0F1F1CB39FB50090F036 /* imguiex-osx.app */,
- );
- name = Products;
- sourceTree = "";
- };
- 6D2FC5561B2E632000C130BA /* imguiex-ios */ = {
- isa = PBXGroup;
- children = (
- 6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */,
- 6D2FC5821B2E63A100C130BA /* imgui_impl_ios.h */,
- 197E1E881B89443600E3FE6A /* imgui_demo.cpp */,
- 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */,
- 6D2FC58A1B2E6A5500C130BA /* debug_hud.h */,
- 6D2FC55B1B2E632000C130BA /* AppDelegate.h */,
- 6D2FC55C1B2E632000C130BA /* AppDelegate.m */,
- 6D2FC55E1B2E632000C130BA /* Shader.fsh */,
- 6D2FC5601B2E632000C130BA /* Shader.vsh */,
- 6D2FC5621B2E632000C130BA /* GameViewController.h */,
- 6D2FC5631B2E632000C130BA /* GameViewController.m */,
- 6D2FC5651B2E632000C130BA /* Main.storyboard */,
- 6D2FC5681B2E632000C130BA /* Images.xcassets */,
- 6D2FC56A1B2E632000C130BA /* LaunchScreen.xib */,
- 6D2FC5571B2E632000C130BA /* Supporting Files */,
- );
- path = "imguiex-ios";
- sourceTree = "";
- };
- 6D2FC5571B2E632000C130BA /* Supporting Files */ = {
- isa = PBXGroup;
- children = (
- 6D2FC5921B30774900C130BA /* SystemConfiguration.framework */,
- 6D2FC5901B30773F00C130BA /* CFNetwork.framework */,
- 6D2FC5581B2E632000C130BA /* Info.plist */,
- 6D2FC5591B2E632000C130BA /* main.m */,
- );
- name = "Supporting Files";
- sourceTree = "";
- };
- 6D2FC5841B2E648D00C130BA /* imgui */ = {
- isa = PBXGroup;
- children = (
- 6D2FC5851B2E64AB00C130BA /* imconfig.h */,
- 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */,
- 6D2FC5861B2E64AB00C130BA /* imgui.cpp */,
- 6D2FC5871B2E64AB00C130BA /* imgui.h */,
- );
- name = imgui;
- sourceTree = "";
- };
-/* End PBXGroup section */
-
-/* Begin PBXNativeTarget section */
- 1A1A0F1E1CB39FB50090F036 /* imguiex-osx */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 1A1A0F2F1CB39FB50090F036 /* Build configuration list for PBXNativeTarget "imguiex-osx" */;
- buildPhases = (
- 1A1A0F1B1CB39FB50090F036 /* Sources */,
- 1A1A0F1C1CB39FB50090F036 /* Frameworks */,
- 1A1A0F1D1CB39FB50090F036 /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = "imguiex-osx";
- productName = "imguiex-osx";
- productReference = 1A1A0F1F1CB39FB50090F036 /* imguiex-osx.app */;
- productType = "com.apple.product-type.application";
- };
- 6D2FC5531B2E632000C130BA /* imguiex-ios */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 6D2FC57B1B2E632000C130BA /* Build configuration list for PBXNativeTarget "imguiex-ios" */;
- buildPhases = (
- 6D2FC5501B2E632000C130BA /* Sources */,
- 6D2FC5511B2E632000C130BA /* Frameworks */,
- 6D2FC5521B2E632000C130BA /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = "imguiex-ios";
- productName = imguiex;
- productReference = 6D2FC5541B2E632000C130BA /* imguiex-ios.app */;
- productType = "com.apple.product-type.application";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- 6D2FC54C1B2E632000C130BA /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastUpgradeCheck = 0630;
- ORGANIZATIONNAME = "Joel Davis";
- TargetAttributes = {
- 1A1A0F1E1CB39FB50090F036 = {
- CreatedOnToolsVersion = 7.3;
- };
- 6D2FC5531B2E632000C130BA = {
- CreatedOnToolsVersion = 6.3.2;
- };
- };
- };
- buildConfigurationList = 6D2FC54F1B2E632000C130BA /* Build configuration list for PBXProject "imguiex" */;
- compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
- hasScannedForEncodings = 0;
- knownRegions = (
- en,
- Base,
- );
- mainGroup = 6D2FC54B1B2E632000C130BA;
- productRefGroup = 6D2FC5551B2E632000C130BA /* Products */;
- projectDirPath = "";
- projectRoot = "";
- targets = (
- 6D2FC5531B2E632000C130BA /* imguiex-ios */,
- 1A1A0F1E1CB39FB50090F036 /* imguiex-osx */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXResourcesBuildPhase section */
- 1A1A0F1D1CB39FB50090F036 /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 1A1A0F281CB39FB50090F036 /* Assets.xcassets in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 6D2FC5521B2E632000C130BA /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 6D2FC56C1B2E632000C130BA /* LaunchScreen.xib in Resources */,
- 6D2FC5671B2E632000C130BA /* Main.storyboard in Resources */,
- 6D2FC5691B2E632000C130BA /* Images.xcassets in Resources */,
- 6D2FC5611B2E632000C130BA /* Shader.vsh in Resources */,
- 6D2FC55F1B2E632000C130BA /* Shader.fsh in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
- 1A1A0F1B1CB39FB50090F036 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 1A1A0F301CB3A0DA0090F036 /* imgui_draw.cpp in Sources */,
- 1A1A0F311CB3A0DA0090F036 /* imgui.cpp in Sources */,
- 1A1A0F331CB3A0E10090F036 /* imgui_demo.cpp in Sources */,
- 1A1A0F341CB3A0EC0090F036 /* debug_hud.cpp in Sources */,
- 1A1A0F481CB3A2E50090F036 /* main.cpp in Sources */,
- 1A1A0F321CB3A0DE0090F036 /* uSynergy.c in Sources */,
- 1A1A0F231CB39FB50090F036 /* AppDelegate.m in Sources */,
- 1A1A0F4A1CB3A5070090F036 /* imgui_impl_glfw_gl2.cpp in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 6D2FC5501B2E632000C130BA /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 6D2FC55D1B2E632000C130BA /* AppDelegate.m in Sources */,
- 6D2FC5831B2E63A100C130BA /* imgui_impl_ios.mm in Sources */,
- 6D1E39171B35EEF10017B40F /* uSynergy.c in Sources */,
- 6D2FC5641B2E632000C130BA /* GameViewController.m in Sources */,
- 6D2FC55A1B2E632000C130BA /* main.m in Sources */,
- 6D2FC5881B2E64AB00C130BA /* imgui.cpp in Sources */,
- 6D2FC58B1B2E6A5500C130BA /* debug_hud.cpp in Sources */,
- 197E1E871B8943FE00E3FE6A /* imgui_draw.cpp in Sources */,
- 197E1E891B89443600E3FE6A /* imgui_demo.cpp in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXVariantGroup section */
- 6D2FC5651B2E632000C130BA /* Main.storyboard */ = {
- isa = PBXVariantGroup;
- children = (
- 6D2FC5661B2E632000C130BA /* Base */,
- );
- name = Main.storyboard;
- sourceTree = "";
- };
- 6D2FC56A1B2E632000C130BA /* LaunchScreen.xib */ = {
- isa = PBXVariantGroup;
- children = (
- 6D2FC56B1B2E632000C130BA /* Base */,
- );
- name = LaunchScreen.xib;
- sourceTree = "";
- };
-/* End PBXVariantGroup section */
-
-/* Begin XCBuildConfiguration section */
- 1A1A0F2D1CB39FB50090F036 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CLANG_ANALYZER_NONNULL = YES;
- CODE_SIGN_IDENTITY = "-";
- COMBINE_HIDPI_IMAGES = YES;
- DEBUG_INFORMATION_FORMAT = dwarf;
- ENABLE_TESTABILITY = YES;
- HEADER_SEARCH_PATHS = (
- "$(inherited)",
- "$(SRCROOT)/../../",
- /usr/local/include,
- );
- INFOPLIST_FILE = "imguiex-osx/Info.plist";
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
- LIBRARY_SEARCH_PATHS = /usr/local/lib;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
- PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.imguiex.imguiex-osx";
- PRODUCT_NAME = "$(TARGET_NAME)";
- SDKROOT = macosx;
- USER_HEADER_SEARCH_PATHS = "";
- };
- name = Debug;
- };
- 1A1A0F2E1CB39FB50090F036 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CLANG_ANALYZER_NONNULL = YES;
- CODE_SIGN_IDENTITY = "-";
- COMBINE_HIDPI_IMAGES = YES;
- HEADER_SEARCH_PATHS = (
- "$(inherited)",
- "$(SRCROOT)/../../",
- /usr/local/include,
- );
- INFOPLIST_FILE = "imguiex-osx/Info.plist";
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
- LIBRARY_SEARCH_PATHS = /usr/local/lib;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
- PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.imguiex.imguiex-osx";
- PRODUCT_NAME = "$(TARGET_NAME)";
- SDKROOT = macosx;
- USER_HEADER_SEARCH_PATHS = "";
- };
- name = Release;
- };
- 6D2FC5791B2E632000C130BA /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_ENABLE_MODULES = YES;
- CLANG_ENABLE_OBJC_ARC = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
- COPY_PHASE_STRIP = NO;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- GCC_SYMBOLS_PRIVATE_EXTERN = NO;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- HEADER_SEARCH_PATHS = "$(SRCROOT)/../../";
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
- MTL_ENABLE_DEBUG_INFO = YES;
- ONLY_ACTIVE_ARCH = YES;
- SDKROOT = iphoneos;
- TARGETED_DEVICE_FAMILY = "1,2";
- USER_HEADER_SEARCH_PATHS = "";
- };
- name = Debug;
- };
- 6D2FC57A1B2E632000C130BA /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_ENABLE_MODULES = YES;
- CLANG_ENABLE_OBJC_ARC = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
- COPY_PHASE_STRIP = NO;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- ENABLE_NS_ASSERTIONS = NO;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- HEADER_SEARCH_PATHS = "$(SRCROOT)/../../";
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
- MTL_ENABLE_DEBUG_INFO = NO;
- SDKROOT = iphoneos;
- TARGETED_DEVICE_FAMILY = "1,2";
- USER_HEADER_SEARCH_PATHS = "";
- VALIDATE_PRODUCT = YES;
- };
- name = Release;
- };
- 6D2FC57C1B2E632000C130BA /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- INFOPLIST_FILE = "imguiex-ios/Info.plist";
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
- PRODUCT_NAME = "$(TARGET_NAME)";
- };
- name = Debug;
- };
- 6D2FC57D1B2E632000C130BA /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- INFOPLIST_FILE = "imguiex-ios/Info.plist";
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
- PRODUCT_NAME = "$(TARGET_NAME)";
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- 1A1A0F2F1CB39FB50090F036 /* Build configuration list for PBXNativeTarget "imguiex-osx" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 1A1A0F2D1CB39FB50090F036 /* Debug */,
- 1A1A0F2E1CB39FB50090F036 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 6D2FC54F1B2E632000C130BA /* Build configuration list for PBXProject "imguiex" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 6D2FC5791B2E632000C130BA /* Debug */,
- 6D2FC57A1B2E632000C130BA /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 6D2FC57B1B2E632000C130BA /* Build configuration list for PBXNativeTarget "imguiex-ios" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 6D2FC57C1B2E632000C130BA /* Debug */,
- 6D2FC57D1B2E632000C130BA /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
- };
- rootObject = 6D2FC54C1B2E632000C130BA /* Project object */;
-}
diff --git a/third_party/imgui/examples/directx10_example/build_win32.bat b/third_party/imgui/examples/directx10_example/build_win32.bat
deleted file mode 100644
index 2b30786b51..0000000000
--- a/third_party/imgui/examples/directx10_example/build_win32.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\..\*.cpp /FeDebug/directx10_example.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d10.lib d3dcompiler.lib
-
diff --git a/third_party/imgui/examples/directx10_example/imgui_impl_dx10.h b/third_party/imgui/examples/directx10_example/imgui_impl_dx10.h
deleted file mode 100644
index a474184765..0000000000
--- a/third_party/imgui/examples/directx10_example/imgui_impl_dx10.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// ImGui Win32 + DirectX10 binding
-
-// Implemented features:
-// [X] User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct ID3D10Device;
-
-IMGUI_API bool ImGui_ImplDX10_Init(void* hwnd, ID3D10Device* device);
-IMGUI_API void ImGui_ImplDX10_Shutdown();
-IMGUI_API void ImGui_ImplDX10_NewFrame();
-IMGUI_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplDX10_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplDX10_CreateDeviceObjects();
-
-// Handler for Win32 messages, update mouse/keyboard data.
-// You may or not need this for your implementation, but it can serve as reference for handling inputs.
-// Commented out to avoid dragging dependencies on types. You can copy the extern declaration in your code.
-/*
-IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-*/
diff --git a/third_party/imgui/examples/directx11_example/build_win32.bat b/third_party/imgui/examples/directx11_example/build_win32.bat
deleted file mode 100644
index 2d1c40f80c..0000000000
--- a/third_party/imgui/examples/directx11_example/build_win32.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\..\*.cpp /FeDebug/directx11_example.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
-
diff --git a/third_party/imgui/examples/directx11_example/imgui_impl_dx11.h b/third_party/imgui/examples/directx11_example/imgui_impl_dx11.h
deleted file mode 100644
index 9364b0cabf..0000000000
--- a/third_party/imgui/examples/directx11_example/imgui_impl_dx11.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// ImGui Win32 + DirectX11 binding
-
-// Implemented features:
-// [X] User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct ID3D11Device;
-struct ID3D11DeviceContext;
-
-IMGUI_API bool ImGui_ImplDX11_Init(void* hwnd, ID3D11Device* device, ID3D11DeviceContext* device_context);
-IMGUI_API void ImGui_ImplDX11_Shutdown();
-IMGUI_API void ImGui_ImplDX11_NewFrame();
-IMGUI_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplDX11_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplDX11_CreateDeviceObjects();
-
-// Handler for Win32 messages, update mouse/keyboard data.
-// You may or not need this for your implementation, but it can serve as reference for handling inputs.
-// Commented out to avoid dragging dependencies on types. You can copy the extern declaration in your code.
-/*
-IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-*/
diff --git a/third_party/imgui/examples/directx12_example/build_win32.bat b/third_party/imgui/examples/directx12_example/build_win32.bat
deleted file mode 100644
index 0daf68b1cc..0000000000
--- a/third_party/imgui/examples/directx12_example/build_win32.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /D UNICODE /D _UNICODE *.cpp ..\..\*.cpp /FeDebug/directx12_example.exe /FoDebug/ /link d3d12.lib d3dcompiler.lib dxgi.lib
-
diff --git a/third_party/imgui/examples/directx12_example/imgui_impl_dx12.h b/third_party/imgui/examples/directx12_example/imgui_impl_dx12.h
deleted file mode 100644
index 628bbd497a..0000000000
--- a/third_party/imgui/examples/directx12_example/imgui_impl_dx12.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// ImGui Win32 + DirectX12 binding
-// FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*))
-
-// Implemented features:
-// [X] User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-enum DXGI_FORMAT;
-struct ID3D12Device;
-struct ID3D12GraphicsCommandList;
-struct D3D12_CPU_DESCRIPTOR_HANDLE;
-struct D3D12_GPU_DESCRIPTOR_HANDLE;
-
-// cmd_list is the command list that the implementation will use to render imgui draw lists.
-// Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate
-// render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle.
-// font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture.
-IMGUI_API bool ImGui_ImplDX12_Init(void* hwnd, int num_frames_in_flight,
- ID3D12Device* device,
- DXGI_FORMAT rtv_format,
- D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle,
- D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
-IMGUI_API void ImGui_ImplDX12_Shutdown();
-IMGUI_API void ImGui_ImplDX12_NewFrame(ID3D12GraphicsCommandList* cmd_list);
-IMGUI_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplDX12_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplDX12_CreateDeviceObjects();
-
-// Handler for Win32 messages, update mouse/keyboard data.
-// You may or not need this for your implementation, but it can serve as reference for handling inputs.
-// Commented out to avoid dragging dependencies on types. You can copy the extern declaration in your code.
-/*
-IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-*/
diff --git a/third_party/imgui/examples/directx9_example/build_win32.bat b/third_party/imgui/examples/directx9_example/build_win32.bat
deleted file mode 100644
index c3647d4c13..0000000000
--- a/third_party/imgui/examples/directx9_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I "%DXSDK_DIR%/Include" /D UNICODE /D _UNICODE *.cpp ..\..\*.cpp /FeDebug/directx9_example.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d9.lib
diff --git a/third_party/imgui/examples/directx9_example/imgui_impl_dx9.cpp b/third_party/imgui/examples/directx9_example/imgui_impl_dx9.cpp
deleted file mode 100644
index 194752fb8b..0000000000
--- a/third_party/imgui/examples/directx9_example/imgui_impl_dx9.cpp
+++ /dev/null
@@ -1,438 +0,0 @@
-// ImGui Win32 + DirectX9 binding
-
-// Implemented features:
-// [X] User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-// CHANGELOG
-// (minor and older changes stripped away, please see git history for details)
-// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
-// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself.
-// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-
-#include "imgui.h"
-#include "imgui_impl_dx9.h"
-
-// DirectX
-#include
-#define DIRECTINPUT_VERSION 0x0800
-#include
-
-// Win32 data
-static HWND g_hWnd = 0;
-static INT64 g_Time = 0;
-static INT64 g_TicksPerSecond = 0;
-static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_Count_;
-
-// DirectX data
-static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
-static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL;
-static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL;
-static LPDIRECT3DTEXTURE9 g_FontTexture = NULL;
-static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
-
-struct CUSTOMVERTEX
-{
- float pos[3];
- D3DCOLOR col;
- float uv[2];
-};
-#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
-
-// Render function.
-// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
-void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized
- ImGuiIO& io = ImGui::GetIO();
- if (io.DisplaySize.x <= 0.0f || io.DisplaySize.y <= 0.0f)
- return;
-
- // Create and grow buffers if needed
- if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
- {
- if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
- g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
- if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
- return;
- }
- if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
- {
- if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
- g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
- if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0)
- return;
- }
-
- // Backup the DX9 state
- IDirect3DStateBlock9* d3d9_state_block = NULL;
- if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0)
- return;
-
- // Copy and convert all vertices into a single contiguous buffer
- CUSTOMVERTEX* vtx_dst;
- ImDrawIdx* idx_dst;
- if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
- return;
- if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
- return;
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
- for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
- {
- vtx_dst->pos[0] = vtx_src->pos.x;
- vtx_dst->pos[1] = vtx_src->pos.y;
- vtx_dst->pos[2] = 0.0f;
- vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000)>>16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9
- vtx_dst->uv[0] = vtx_src->uv.x;
- vtx_dst->uv[1] = vtx_src->uv.y;
- vtx_dst++;
- vtx_src++;
- }
- memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
- idx_dst += cmd_list->IdxBuffer.Size;
- }
- g_pVB->Unlock();
- g_pIB->Unlock();
- g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
- g_pd3dDevice->SetIndices(g_pIB);
- g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
-
- // Setup viewport
- D3DVIEWPORT9 vp;
- vp.X = vp.Y = 0;
- vp.Width = (DWORD)io.DisplaySize.x;
- vp.Height = (DWORD)io.DisplaySize.y;
- vp.MinZ = 0.0f;
- vp.MaxZ = 1.0f;
- g_pd3dDevice->SetViewport(&vp);
-
- // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing
- g_pd3dDevice->SetPixelShader(NULL);
- g_pd3dDevice->SetVertexShader(NULL);
- g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, false);
- g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
- g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
- g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false);
- g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
- g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, true);
- g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
- g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
- g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
-
- // Setup orthographic projection matrix
- // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH()
- {
- const float L = 0.5f, R = io.DisplaySize.x+0.5f, T = 0.5f, B = io.DisplaySize.y+0.5f;
- D3DMATRIX mat_identity = { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } };
- D3DMATRIX mat_projection =
- {
- 2.0f/(R-L), 0.0f, 0.0f, 0.0f,
- 0.0f, 2.0f/(T-B), 0.0f, 0.0f,
- 0.0f, 0.0f, 0.5f, 0.0f,
- (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f,
- };
- g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity);
- g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity);
- g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection);
- }
-
- // Render command lists
- int vtx_offset = 0;
- int idx_offset = 0;
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
- g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
- g_pd3dDevice->SetScissorRect(&r);
- g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
- }
- idx_offset += pcmd->ElemCount;
- }
- vtx_offset += cmd_list->VtxBuffer.Size;
- }
-
- // Restore the DX9 state
- d3d9_state_block->Apply();
- d3d9_state_block->Release();
-}
-
-static void ImGui_ImplWin32_UpdateMouseCursor()
-{
- ImGuiIO& io = ImGui::GetIO();
- ImGuiMouseCursor imgui_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
- if (imgui_cursor == ImGuiMouseCursor_None)
- {
- // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
- ::SetCursor(NULL);
- }
- else
- {
- // Hardware cursor type
- LPTSTR win32_cursor = IDC_ARROW;
- switch (imgui_cursor)
- {
- case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break;
- case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break;
- case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break;
- case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break;
- case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break;
- case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
- case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
- }
- ::SetCursor(::LoadCursor(NULL, win32_cursor));
- }
-}
-
-// Process Win32 mouse/keyboard inputs.
-// 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.
-// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
-// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
-IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (ImGui::GetCurrentContext() == NULL)
- return 0;
-
- ImGuiIO& io = ImGui::GetIO();
- switch (msg)
- {
- case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
- case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
- case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
- {
- int button = 0;
- if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) button = 0;
- if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) button = 1;
- if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) button = 2;
- if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
- ::SetCapture(hwnd);
- io.MouseDown[button] = true;
- return 0;
- }
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MBUTTONUP:
- {
- int button = 0;
- if (msg == WM_LBUTTONUP) button = 0;
- if (msg == WM_RBUTTONUP) button = 1;
- if (msg == WM_MBUTTONUP) button = 2;
- io.MouseDown[button] = false;
- if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
- ::ReleaseCapture();
- return 0;
- }
- case WM_MOUSEWHEEL:
- io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
- return 0;
- case WM_MOUSEHWHEEL:
- io.MouseWheelH += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
- return 0;
- case WM_MOUSEMOVE:
- io.MousePos.x = (signed short)(lParam);
- io.MousePos.y = (signed short)(lParam >> 16);
- return 0;
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- if (wParam < 256)
- io.KeysDown[wParam] = 1;
- return 0;
- case WM_KEYUP:
- case WM_SYSKEYUP:
- if (wParam < 256)
- io.KeysDown[wParam] = 0;
- return 0;
- case WM_CHAR:
- // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
- if (wParam > 0 && wParam < 0x10000)
- io.AddInputCharacter((unsigned short)wParam);
- return 0;
- case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- ImGui_ImplWin32_UpdateMouseCursor();
- return 1;
- }
- return 0;
- }
- return 0;
-}
-
-bool ImGui_ImplDX9_Init(void* hwnd, IDirect3DDevice9* device)
-{
- g_hWnd = (HWND)hwnd;
- g_pd3dDevice = device;
-
- if (!QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
- return false;
- if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
- return false;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = VK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
- io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
- io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR;
- io.KeyMap[ImGuiKey_PageDown] = VK_NEXT;
- io.KeyMap[ImGuiKey_Home] = VK_HOME;
- io.KeyMap[ImGuiKey_End] = VK_END;
- io.KeyMap[ImGuiKey_Insert] = VK_INSERT;
- io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
- io.KeyMap[ImGuiKey_Space] = VK_SPACE;
- io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
- io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
- 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';
-
- io.ImeWindowHandle = g_hWnd;
-
- return true;
-}
-
-void ImGui_ImplDX9_Shutdown()
-{
- ImGui_ImplDX9_InvalidateDeviceObjects();
- g_pd3dDevice = NULL;
- g_hWnd = 0;
-}
-
-static bool ImGui_ImplDX9_CreateFontsTexture()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height, bytes_per_pixel;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel);
-
- // Upload texture to graphics system
- g_FontTexture = NULL;
- if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0)
- return false;
- D3DLOCKED_RECT tex_locked_rect;
- if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
- return false;
- for (int y = 0; y < height; y++)
- memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
- g_FontTexture->UnlockRect(0);
-
- // Store our identifier
- io.Fonts->TexID = (void *)g_FontTexture;
-
- return true;
-}
-
-bool ImGui_ImplDX9_CreateDeviceObjects()
-{
- if (!g_pd3dDevice)
- return false;
- if (!ImGui_ImplDX9_CreateFontsTexture())
- return false;
- return true;
-}
-
-void ImGui_ImplDX9_InvalidateDeviceObjects()
-{
- if (!g_pd3dDevice)
- return;
- if (g_pVB)
- {
- g_pVB->Release();
- g_pVB = NULL;
- }
- if (g_pIB)
- {
- g_pIB->Release();
- g_pIB = NULL;
- }
-
- // At this point note that we set ImGui::GetIO().Fonts->TexID to be == g_FontTexture, so clear both.
- ImGuiIO& io = ImGui::GetIO();
- IM_ASSERT(g_FontTexture == io.Fonts->TexID);
- if (g_FontTexture)
- g_FontTexture->Release();
- g_FontTexture = NULL;
- io.Fonts->TexID = NULL;
-}
-
-void ImGui_ImplDX9_NewFrame()
-{
- if (!g_FontTexture)
- ImGui_ImplDX9_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- RECT rect;
- GetClientRect(g_hWnd, &rect);
- io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
-
- // Setup time step
- INT64 current_time;
- QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
- io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
- g_Time = current_time;
-
- // Read keyboard modifiers inputs
- io.KeyCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
- io.KeyShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
- io.KeyAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;
- io.KeySuper = false;
- // io.KeysDown : filled by WM_KEYDOWN/WM_KEYUP events
- // io.MousePos : filled by WM_MOUSEMOVE events
- // io.MouseDown : filled by WM_*BUTTON* events
- // io.MouseWheel : filled by WM_MOUSEWHEEL events
-
- // Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
- if (io.WantMoveMouse)
- {
- POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
- ClientToScreen(g_hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
- }
-
- // Update OS mouse cursor with the cursor requested by imgui
- ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
- if (g_LastMouseCursor != mouse_cursor)
- {
- g_LastMouseCursor = mouse_cursor;
- ImGui_ImplWin32_UpdateMouseCursor();
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
-}
diff --git a/third_party/imgui/examples/directx9_example/imgui_impl_dx9.h b/third_party/imgui/examples/directx9_example/imgui_impl_dx9.h
deleted file mode 100644
index e0ea2deae9..0000000000
--- a/third_party/imgui/examples/directx9_example/imgui_impl_dx9.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// ImGui Win32 + DirectX9 binding
-
-// Implemented features:
-// [X] User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct IDirect3DDevice9;
-
-IMGUI_API bool ImGui_ImplDX9_Init(void* hwnd, IDirect3DDevice9* device);
-IMGUI_API void ImGui_ImplDX9_Shutdown();
-IMGUI_API void ImGui_ImplDX9_NewFrame();
-IMGUI_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplDX9_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplDX9_CreateDeviceObjects();
-
-// Handler for Win32 messages, update mouse/keyboard data.
-// You may or not need this for your implementation, but it can serve as reference for handling inputs.
-// Commented out to avoid dragging dependencies on types. You can copy the extern declaration in your code.
-/*
-IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-*/
diff --git a/third_party/imgui/examples/example_allegro5/README.md b/third_party/imgui/examples/example_allegro5/README.md
new file mode 100644
index 0000000000..10d9d6e94e
--- /dev/null
+++ b/third_party/imgui/examples/example_allegro5/README.md
@@ -0,0 +1,35 @@
+
+# Configuration
+
+Dear ImGui outputs 16-bit vertex indices by default.
+Allegro doesn't support them natively, so we have two solutions: convert the indices manually in imgui_impl_allegro5.cpp, or compile dear imgui with 32-bit indices.
+You can either modify imconfig.h that comes with Dear ImGui (easier), or set a C++ preprocessor option IMGUI_USER_CONFIG to find to a filename.
+We are providing `imconfig_allegro5.h` that enables 32-bit indices.
+Note that the back-end supports _BOTH_ 16-bit and 32-bit indices, but 32-bit indices will be slightly faster as they won't require a manual conversion.
+
+# How to Build
+
+### On Ubuntu 14.04+ and macOS
+
+```bash
+g++ -DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" -I .. -I ../.. main.cpp ../imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_main -lallegro_primitives -o allegro5_example
+```
+
+On macOS, install Allegro with homebrew: `brew install allegro`.
+
+### On Windows with Visual Studio's CLI
+
+You may install Allegro using vcpkg:
+```
+git clone https://github.com/Microsoft/vcpkg
+cd vcpkg
+.\bootstrap-vcpkg.bat
+.\vcpkg install allegro5
+.\vcpkg integrate install ; optional, automatically register include/libs in Visual Studio
+```
+
+Build:
+```
+set ALLEGRODIR=path_to_your_allegro5_folder
+cl /Zi /MD /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" /I .. /I ..\.. main.cpp ..\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib
+```
diff --git a/third_party/imgui/examples/example_allegro5/example_allegro5.vcxproj b/third_party/imgui/examples/example_allegro5/example_allegro5.vcxproj
new file mode 100644
index 0000000000..c86dcb2bc7
--- /dev/null
+++ b/third_party/imgui/examples/example_allegro5/example_allegro5.vcxproj
@@ -0,0 +1,179 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {2AE17FDE-F7F3-4CAC-ADAB-0710EDA4F741}
+ example_allegro5
+ 8.1
+
+
+
+ Application
+ true
+ MultiByte
+ v110
+
+
+ Application
+ true
+ MultiByte
+ v110
+
+
+ Application
+ false
+ true
+ MultiByte
+ v110
+
+
+ Application
+ false
+ true
+ MultiByte
+ v110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ ..\..;..;%(AdditionalIncludeDirectories)
+
+
+ true
+ %(AdditionalLibraryDirectories)
+ opengl32.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ ..\..;..;%(AdditionalIncludeDirectories)
+
+
+ true
+ %(AdditionalLibraryDirectories)
+ opengl32.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ ..\..;..;$(SolutionDir)\libs\gl3w;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ %(AdditionalLibraryDirectories)
+ opengl32.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ ..\..;..;$(SolutionDir)\libs\gl3w;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ %(AdditionalLibraryDirectories)
+ opengl32.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/third_party/imgui/examples/vulkan_example/vulkan_example.vcxproj.filters b/third_party/imgui/examples/example_allegro5/example_allegro5.vcxproj.filters
similarity index 83%
rename from third_party/imgui/examples/vulkan_example/vulkan_example.vcxproj.filters
rename to third_party/imgui/examples/example_allegro5/example_allegro5.vcxproj.filters
index f3ed8ede4d..8019ebfdc3 100644
--- a/third_party/imgui/examples/vulkan_example/vulkan_example.vcxproj.filters
+++ b/third_party/imgui/examples/example_allegro5/example_allegro5.vcxproj.filters
@@ -22,9 +22,15 @@
sources
-
+
sources
+
+ sources
+
+
+ imgui
+
@@ -36,7 +42,7 @@
imgui
-
+
sources
diff --git a/third_party/imgui/examples/example_allegro5/imconfig_allegro5.h b/third_party/imgui/examples/example_allegro5/imconfig_allegro5.h
new file mode 100644
index 0000000000..35afa67fd7
--- /dev/null
+++ b/third_party/imgui/examples/example_allegro5/imconfig_allegro5.h
@@ -0,0 +1,11 @@
+//-----------------------------------------------------------------------------
+// COMPILE-TIME OPTIONS FOR DEAR IMGUI ALLEGRO 5 EXAMPLE
+// See imconfig.h for the full template
+// Because Allegro doesn't support 16-bit vertex indices, we enable the compile-time option of imgui to use 32-bit indices
+//-----------------------------------------------------------------------------
+
+#pragma once
+
+// Use 32-bit vertex indices because Allegro doesn't support 16-bit ones
+// This allows us to avoid converting vertices format at runtime
+#define ImDrawIdx int
diff --git a/third_party/imgui/examples/allegro5_example/main.cpp b/third_party/imgui/examples/example_allegro5/main.cpp
similarity index 67%
rename from third_party/imgui/examples/allegro5_example/main.cpp
rename to third_party/imgui/examples/example_allegro5/main.cpp
index 1478573cce..c32125b681 100644
--- a/third_party/imgui/examples/allegro5_example/main.cpp
+++ b/third_party/imgui/examples/example_allegro5/main.cpp
@@ -1,11 +1,11 @@
-// ImGui - standalone example application for Allegro 5
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// dear imgui: standalone example application for Allegro 5
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
#include
#include
#include
#include "imgui.h"
-#include "imgui_impl_a5.h"
+#include "imgui_impl_allegro5.h"
int main(int, char**)
{
@@ -16,28 +16,31 @@ int main(int, char**)
al_init_primitives_addon();
al_set_new_display_flags(ALLEGRO_RESIZABLE);
ALLEGRO_DISPLAY* display = al_create_display(1280, 720);
- al_set_window_title(display, "ImGui Allegro 5 example");
+ al_set_window_title(display, "Dear ImGui Allegro 5 example");
ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue();
al_register_event_source(queue, al_get_display_event_source(display));
al_register_event_source(queue, al_get_keyboard_event_source());
al_register_event_source(queue, al_get_mouse_event_source());
- // Setup ImGui binding
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_ImplA5_Init(display);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- // Setup style
+ // Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();
+ // Setup Platform/Renderer bindings
+ ImGui_ImplAllegro5_Init(display);
+
// 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 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.
+ // - Read 'docs/FONTS.md' 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);
@@ -55,6 +58,7 @@ int main(int, char**)
bool running = true;
while (running)
{
+ // Poll and handle events (inputs, window resize, etc.)
// 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.
@@ -62,64 +66,67 @@ int main(int, char**)
ALLEGRO_EVENT ev;
while (al_get_next_event(queue, &ev))
{
- ImGui_ImplA5_ProcessEvent(&ev);
- if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
+ ImGui_ImplAllegro5_ProcessEvent(&ev);
+ if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
running = false;
if (ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE)
{
- ImGui_ImplA5_InvalidateDeviceObjects();
+ ImGui_ImplAllegro5_InvalidateDeviceObjects();
al_acknowledge_resize(display);
- Imgui_ImplA5_CreateDeviceObjects();
+ ImGui_ImplAllegro5_CreateDeviceObjects();
}
}
- ImGui_ImplA5_NewFrame();
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
+ // Start the Dear ImGui frame
+ ImGui_ImplAllegro5_NewFrame();
+ ImGui::NewFrame();
+
+ // 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::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
+ 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);
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: most widgets return true when edited/activated)
+ 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();
}
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
+ // 3. Show another simple window.
if (show_another_window)
{
- ImGui::Begin("Another Window", &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();
}
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
// Rendering
- al_clear_to_color(al_map_rgba_f(clear_color.x, clear_color.y, clear_color.z, clear_color.w));
ImGui::Render();
- ImGui_ImplA5_RenderDrawData(ImGui::GetDrawData());
+ al_clear_to_color(al_map_rgba_f(clear_color.x, clear_color.y, clear_color.z, clear_color.w));
+ ImGui_ImplAllegro5_RenderDrawData(ImGui::GetDrawData());
al_flip_display();
}
// Cleanup
- ImGui_ImplA5_Shutdown();
+ ImGui_ImplAllegro5_Shutdown();
ImGui::DestroyContext();
al_destroy_event_queue(queue);
al_destroy_display(display);
diff --git a/third_party/imgui/examples/example_apple_metal/README.md b/third_party/imgui/examples/example_apple_metal/README.md
new file mode 100644
index 0000000000..4f620327f7
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/README.md
@@ -0,0 +1,8 @@
+# iOS / OSX Metal example
+
+## Introduction
+
+This example shows how to integrate Dear ImGui with Metal. It is based on the "cross-platform" game template provided with Xcode as of Xcode 9.
+
+(NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.)
+
diff --git a/third_party/imgui/examples/example_apple_metal/Shared/AppDelegate.h b/third_party/imgui/examples/example_apple_metal/Shared/AppDelegate.h
new file mode 100644
index 0000000000..94878d948e
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/Shared/AppDelegate.h
@@ -0,0 +1,18 @@
+#import
+
+#if TARGET_OS_IPHONE
+
+#import
+
+@interface AppDelegate : UIResponder
+@property (strong, nonatomic) UIWindow *window;
+@end
+
+#else
+
+#import
+
+@interface AppDelegate : NSObject
+@end
+
+#endif
diff --git a/third_party/imgui/examples/example_apple_metal/Shared/AppDelegate.m b/third_party/imgui/examples/example_apple_metal/Shared/AppDelegate.m
new file mode 100644
index 0000000000..6947eb23b4
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/Shared/AppDelegate.m
@@ -0,0 +1,11 @@
+#import "AppDelegate.h"
+
+@implementation AppDelegate
+
+#if TARGET_OS_OSX
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
+ return YES;
+}
+#endif
+
+@end
diff --git a/third_party/imgui/examples/example_apple_metal/Shared/Renderer.h b/third_party/imgui/examples/example_apple_metal/Shared/Renderer.h
new file mode 100644
index 0000000000..81fc6f547e
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/Shared/Renderer.h
@@ -0,0 +1,8 @@
+#import
+
+@interface Renderer : NSObject
+
+-(nonnull instancetype)initWithView:(nonnull MTKView *)view;
+
+@end
+
diff --git a/third_party/imgui/examples/example_apple_metal/Shared/Renderer.mm b/third_party/imgui/examples/example_apple_metal/Shared/Renderer.mm
new file mode 100644
index 0000000000..efc3332bf9
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/Shared/Renderer.mm
@@ -0,0 +1,129 @@
+#import "Renderer.h"
+#import
+
+#include "imgui.h"
+#include "imgui_impl_metal.h"
+
+#if TARGET_OS_OSX
+#include "imgui_impl_osx.h"
+#endif
+
+@interface Renderer ()
+@property (nonatomic, strong) id device;
+@property (nonatomic, strong) id commandQueue;
+@end
+
+@implementation Renderer
+
+-(nonnull instancetype)initWithView:(nonnull MTKView *)view;
+{
+ self = [super init];
+ if(self)
+ {
+ _device = view.device;
+ _commandQueue = [_device newCommandQueue];
+
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGui::StyleColorsDark();
+
+ ImGui_ImplMetal_Init(_device);
+ }
+
+ return self;
+}
+
+- (void)drawInMTKView:(MTKView *)view
+{
+ ImGuiIO &io = ImGui::GetIO();
+ io.DisplaySize.x = view.bounds.size.width;
+ io.DisplaySize.y = view.bounds.size.height;
+
+#if TARGET_OS_OSX
+ CGFloat framebufferScale = view.window.screen.backingScaleFactor ?: NSScreen.mainScreen.backingScaleFactor;
+#else
+ CGFloat framebufferScale = view.window.screen.scale ?: UIScreen.mainScreen.scale;
+#endif
+ io.DisplayFramebufferScale = ImVec2(framebufferScale, framebufferScale);
+
+ io.DeltaTime = 1 / float(view.preferredFramesPerSecond ?: 60);
+
+ id commandBuffer = [self.commandQueue commandBuffer];
+
+ static bool show_demo_window = true;
+ static bool show_another_window = false;
+ static float clear_color[4] = { 0.28f, 0.36f, 0.5f, 1.0f };
+
+ MTLRenderPassDescriptor *renderPassDescriptor = view.currentRenderPassDescriptor;
+ if (renderPassDescriptor != nil)
+ {
+ renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
+
+ // Here, you could do additional rendering work, including other passes as necessary.
+
+ id renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
+ [renderEncoder pushDebugGroup:@"ImGui demo"];
+
+ // Start the Dear ImGui frame
+ ImGui_ImplMetal_NewFrame(renderPassDescriptor);
+#if TARGET_OS_OSX
+ ImGui_ImplOSX_NewFrame(view);
+#endif
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ ImDrawData *drawData = ImGui::GetDrawData();
+ ImGui_ImplMetal_RenderDrawData(drawData, commandBuffer, renderEncoder);
+
+ [renderEncoder popDebugGroup];
+ [renderEncoder endEncoding];
+
+ [commandBuffer presentDrawable:view.currentDrawable];
+ }
+
+ [commandBuffer commit];
+}
+
+- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size
+{
+}
+
+@end
diff --git a/third_party/imgui/examples/example_apple_metal/Shared/ViewController.h b/third_party/imgui/examples/example_apple_metal/Shared/ViewController.h
new file mode 100644
index 0000000000..137f93e130
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/Shared/ViewController.h
@@ -0,0 +1,19 @@
+#import
+#import
+#import "Renderer.h"
+
+#if TARGET_OS_IPHONE
+
+#import
+
+@interface ViewController : UIViewController
+@end
+
+#else
+
+#import
+
+@interface ViewController : NSViewController
+@end
+
+#endif
diff --git a/third_party/imgui/examples/example_apple_metal/Shared/ViewController.mm b/third_party/imgui/examples/example_apple_metal/Shared/ViewController.mm
new file mode 100644
index 0000000000..3c79cc1c4b
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/Shared/ViewController.mm
@@ -0,0 +1,153 @@
+#import "ViewController.h"
+#import "Renderer.h"
+#include "imgui.h"
+
+#if TARGET_OS_OSX
+#include "imgui_impl_osx.h"
+#endif
+
+@interface ViewController ()
+@property (nonatomic, readonly) MTKView *mtkView;
+@property (nonatomic, strong) Renderer *renderer;
+@end
+
+@implementation ViewController
+
+- (MTKView *)mtkView {
+ return (MTKView *)self.view;
+}
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ self.mtkView.device = MTLCreateSystemDefaultDevice();
+
+ if (!self.mtkView.device) {
+ NSLog(@"Metal is not supported");
+ abort();
+ }
+
+ self.renderer = [[Renderer alloc] initWithView:self.mtkView];
+
+ [self.renderer mtkView:self.mtkView drawableSizeWillChange:self.mtkView.bounds.size];
+
+ self.mtkView.delegate = self.renderer;
+
+#if TARGET_OS_OSX
+ // Add a tracking area in order to receive mouse events whenever the mouse is within the bounds of our view
+ NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:NSZeroRect
+ options:NSTrackingMouseMoved | NSTrackingInVisibleRect | NSTrackingActiveAlways
+ owner:self
+ userInfo:nil];
+ [self.view addTrackingArea:trackingArea];
+
+ // If we want to receive key events, we either need to be in the responder chain of the key view,
+ // or else we can install a local monitor. The consequence of this heavy-handed approach is that
+ // we receive events for all controls, not just Dear ImGui widgets. If we had native controls in our
+ // window, we'd want to be much more careful than just ingesting the complete event stream, though we
+ // do make an effort to be good citizens by passing along events when Dear ImGui doesn't want to capture.
+ NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged | NSEventTypeScrollWheel;
+ [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event) {
+ BOOL wantsCapture = ImGui_ImplOSX_HandleEvent(event, self.view);
+ if (event.type == NSEventTypeKeyDown && wantsCapture) {
+ return nil;
+ } else {
+ return event;
+ }
+
+ }];
+
+ ImGui_ImplOSX_Init();
+#endif
+}
+
+#if TARGET_OS_OSX
+
+- (void)mouseMoved:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)mouseDown:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)rightMouseDown:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)otherMouseDown:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)mouseUp:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)rightMouseUp:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)otherMouseUp:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)mouseDragged:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)rightMouseDragged:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)otherMouseDragged:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+- (void)scrollWheel:(NSEvent *)event {
+ ImGui_ImplOSX_HandleEvent(event, self.view);
+}
+
+#elif TARGET_OS_IOS
+
+// This touch mapping is super cheesy/hacky. We treat any touch on the screen
+// as if it were a depressed left mouse button, and we don't bother handling
+// multitouch correctly at all. This causes the "cursor" to behave very erratically
+// when there are multiple active touches. But for demo purposes, single-touch
+// interaction actually works surprisingly well.
+- (void)updateIOWithTouchEvent:(UIEvent *)event {
+ UITouch *anyTouch = event.allTouches.anyObject;
+ CGPoint touchLocation = [anyTouch locationInView:self.view];
+ ImGuiIO &io = ImGui::GetIO();
+ io.MousePos = ImVec2(touchLocation.x, touchLocation.y);
+
+ BOOL hasActiveTouch = NO;
+ for (UITouch *touch in event.allTouches) {
+ if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled) {
+ hasActiveTouch = YES;
+ break;
+ }
+ }
+ io.MouseDown[0] = hasActiveTouch;
+}
+
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
+ [self updateIOWithTouchEvent:event];
+}
+
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
+ [self updateIOWithTouchEvent:event];
+}
+
+- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
+ [self updateIOWithTouchEvent:event];
+}
+
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
+ [self updateIOWithTouchEvent:event];
+}
+
+#endif
+
+@end
+
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/main.m b/third_party/imgui/examples/example_apple_metal/Shared/main.m
similarity index 53%
rename from third_party/imgui/examples/apple_example/imguiex-ios/main.m
rename to third_party/imgui/examples/example_apple_metal/Shared/main.m
index faba09928a..15938a906e 100644
--- a/third_party/imgui/examples/apple_example/imguiex-ios/main.m
+++ b/third_party/imgui/examples/example_apple_metal/Shared/main.m
@@ -1,7 +1,6 @@
-//
-// main.m
-// imguiex
-//
+#import
+
+#if TARGET_OS_IPHONE
#import
#import "AppDelegate.h"
@@ -11,3 +10,13 @@ int main(int argc, char * argv[]) {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
+
+#else
+
+#import
+
+int main(int argc, const char * argv[]) {
+ return NSApplicationMain(argc, argv);
+}
+
+#endif
diff --git a/third_party/imgui/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj b/third_party/imgui/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj
new file mode 100644
index 0000000000..f1c10494f8
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj
@@ -0,0 +1,539 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 48;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
+ 07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
+ 8307E7CC20E9F9C900473790 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7CB20E9F9C900473790 /* ViewController.mm */; };
+ 8307E7CF20E9F9C900473790 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8307E7CD20E9F9C900473790 /* Main.storyboard */; };
+ 8307E7DE20E9F9C900473790 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7DD20E9F9C900473790 /* AppDelegate.m */; };
+ 8307E7E420E9F9C900473790 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8307E7E220E9F9C900473790 /* Main.storyboard */; };
+ 8307E7E720E9F9C900473790 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7E620E9F9C900473790 /* main.m */; };
+ 8307E7E820E9F9C900473790 /* Renderer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7BC20E9F9C700473790 /* Renderer.mm */; };
+ 8307E7E920E9F9C900473790 /* Renderer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7BC20E9F9C700473790 /* Renderer.mm */; };
+ 836D2A2E20EE208E0098E909 /* imgui_impl_osx.mm in Sources */ = {isa = PBXBuildFile; fileRef = 836D2A2D20EE208E0098E909 /* imgui_impl_osx.mm */; };
+ 836D2A3020EE4A180098E909 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 836D2A2F20EE4A180098E909 /* Default-568h@2x.png */; };
+ 836D2A3220EE4A900098E909 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 836D2A3120EE4A900098E909 /* Launch Screen.storyboard */; };
+ 83BBE9DE20EB3FFC00295997 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7E620E9F9C900473790 /* main.m */; };
+ 83BBE9DF20EB40AE00295997 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7DD20E9F9C900473790 /* AppDelegate.m */; };
+ 83BBE9E020EB42D000295997 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7CB20E9F9C900473790 /* ViewController.mm */; };
+ 83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E420EB46B900295997 /* Metal.framework */; };
+ 83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E620EB46BD00295997 /* MetalKit.framework */; };
+ 83BBE9E920EB46C100295997 /* ModelIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E820EB46C100295997 /* ModelIO.framework */; };
+ 83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EA20EB471700295997 /* MetalKit.framework */; };
+ 83BBE9ED20EB471700295997 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EB20EB471700295997 /* Metal.framework */; };
+ 83BBE9EF20EB471C00295997 /* ModelIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EE20EB471C00295997 /* ModelIO.framework */; };
+ 83BBE9FE20EB54D800295997 /* imgui_impl_metal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */; };
+ 83BBE9FF20EB54D800295997 /* imgui_impl_metal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */; };
+ 83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0120EB54E700295997 /* imgui_draw.cpp */; };
+ 83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0120EB54E700295997 /* imgui_draw.cpp */; };
+ 83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0220EB54E700295997 /* imgui_demo.cpp */; };
+ 83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0220EB54E700295997 /* imgui_demo.cpp */; };
+ 83BBEA0920EB54E700295997 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0320EB54E700295997 /* imgui.cpp */; };
+ 83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0320EB54E700295997 /* imgui.cpp */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = ""; };
+ 07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = ""; };
+ 8307E7BB20E9F9C700473790 /* Renderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Renderer.h; sourceTree = ""; };
+ 8307E7BC20E9F9C700473790 /* Renderer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Renderer.mm; sourceTree = ""; };
+ 8307E7C420E9F9C900473790 /* example_apple_metal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example_apple_metal.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8307E7CA20E9F9C900473790 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
+ 8307E7CB20E9F9C900473790 /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewController.mm; sourceTree = ""; };
+ 8307E7CE20E9F9C900473790 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
+ 8307E7D320E9F9C900473790 /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = ""; };
+ 8307E7DA20E9F9C900473790 /* example_apple_metal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example_apple_metal.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8307E7DC20E9F9C900473790 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
+ 8307E7DD20E9F9C900473790 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
+ 8307E7E320E9F9C900473790 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
+ 8307E7E520E9F9C900473790 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-macOS.plist"; sourceTree = ""; };
+ 8307E7E620E9F9C900473790 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
+ 836D2A2C20EE208D0098E909 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../imgui_impl_osx.h; sourceTree = ""; };
+ 836D2A2D20EE208E0098E909 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../../imgui_impl_osx.mm; sourceTree = ""; };
+ 836D2A2F20EE4A180098E909 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; };
+ 836D2A3120EE4A900098E909 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; };
+ 83BBE9E420EB46B900295997 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/Metal.framework; sourceTree = DEVELOPER_DIR; };
+ 83BBE9E620EB46BD00295997 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/MetalKit.framework; sourceTree = DEVELOPER_DIR; };
+ 83BBE9E820EB46C100295997 /* ModelIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ModelIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/ModelIO.framework; sourceTree = DEVELOPER_DIR; };
+ 83BBE9EA20EB471700295997 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; };
+ 83BBE9EB20EB471700295997 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; };
+ 83BBE9EE20EB471C00295997 /* ModelIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ModelIO.framework; path = System/Library/Frameworks/ModelIO.framework; sourceTree = SDKROOT; };
+ 83BBE9FC20EB54D800295997 /* imgui_impl_metal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_metal.h; path = ../../imgui_impl_metal.h; sourceTree = ""; };
+ 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_metal.mm; path = ../../imgui_impl_metal.mm; sourceTree = ""; };
+ 83BBEA0020EB54E700295997 /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; };
+ 83BBEA0120EB54E700295997 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; };
+ 83BBEA0220EB54E700295997 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = ""; };
+ 83BBEA0320EB54E700295997 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; };
+ 83BBEA0420EB54E700295997 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 8307E7C120E9F9C900473790 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 83BBE9E920EB46C100295997 /* ModelIO.framework in Frameworks */,
+ 83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */,
+ 83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 8307E7D720E9F9C900473790 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 83BBE9EF20EB471C00295997 /* ModelIO.framework in Frameworks */,
+ 83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */,
+ 83BBE9ED20EB471700295997 /* Metal.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 8307E7B520E9F9C700473790 = {
+ isa = PBXGroup;
+ children = (
+ 83BBE9F020EB544400295997 /* imgui */,
+ 8307E7BA20E9F9C700473790 /* Shared */,
+ 8307E7C620E9F9C900473790 /* iOS */,
+ 8307E7DB20E9F9C900473790 /* macOS */,
+ 8307E7C520E9F9C900473790 /* Products */,
+ 83BBE9E320EB46B800295997 /* Frameworks */,
+ );
+ sourceTree = "";
+ };
+ 8307E7BA20E9F9C700473790 /* Shared */ = {
+ isa = PBXGroup;
+ children = (
+ 83BBE9FC20EB54D800295997 /* imgui_impl_metal.h */,
+ 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */,
+ 836D2A2C20EE208D0098E909 /* imgui_impl_osx.h */,
+ 836D2A2D20EE208E0098E909 /* imgui_impl_osx.mm */,
+ 8307E7DC20E9F9C900473790 /* AppDelegate.h */,
+ 8307E7DD20E9F9C900473790 /* AppDelegate.m */,
+ 8307E7BB20E9F9C700473790 /* Renderer.h */,
+ 8307E7BC20E9F9C700473790 /* Renderer.mm */,
+ 8307E7CA20E9F9C900473790 /* ViewController.h */,
+ 8307E7CB20E9F9C900473790 /* ViewController.mm */,
+ 8307E7E620E9F9C900473790 /* main.m */,
+ );
+ path = Shared;
+ sourceTree = "";
+ };
+ 8307E7C520E9F9C900473790 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 8307E7C420E9F9C900473790 /* example_apple_metal.app */,
+ 8307E7DA20E9F9C900473790 /* example_apple_metal.app */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 8307E7C620E9F9C900473790 /* iOS */ = {
+ isa = PBXGroup;
+ children = (
+ 836D2A2F20EE4A180098E909 /* Default-568h@2x.png */,
+ 8307E7CD20E9F9C900473790 /* Main.storyboard */,
+ 8307E7D320E9F9C900473790 /* Info-iOS.plist */,
+ 836D2A3120EE4A900098E909 /* Launch Screen.storyboard */,
+ );
+ path = iOS;
+ sourceTree = "";
+ };
+ 8307E7DB20E9F9C900473790 /* macOS */ = {
+ isa = PBXGroup;
+ children = (
+ 8307E7E220E9F9C900473790 /* Main.storyboard */,
+ 8307E7E520E9F9C900473790 /* Info-macOS.plist */,
+ );
+ path = macOS;
+ sourceTree = "";
+ };
+ 83BBE9E320EB46B800295997 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 83BBE9EE20EB471C00295997 /* ModelIO.framework */,
+ 83BBE9EB20EB471700295997 /* Metal.framework */,
+ 83BBE9EA20EB471700295997 /* MetalKit.framework */,
+ 83BBE9E820EB46C100295997 /* ModelIO.framework */,
+ 83BBE9E620EB46BD00295997 /* MetalKit.framework */,
+ 83BBE9E420EB46B900295997 /* Metal.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
+ 83BBE9F020EB544400295997 /* imgui */ = {
+ isa = PBXGroup;
+ children = (
+ 83BBEA0420EB54E700295997 /* imconfig.h */,
+ 83BBEA0320EB54E700295997 /* imgui.cpp */,
+ 83BBEA0020EB54E700295997 /* imgui.h */,
+ 83BBEA0220EB54E700295997 /* imgui_demo.cpp */,
+ 83BBEA0120EB54E700295997 /* imgui_draw.cpp */,
+ 07A82ED62139413C0078D120 /* imgui_internal.h */,
+ 07A82ED72139413C0078D120 /* imgui_widgets.cpp */,
+ );
+ name = imgui;
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 8307E7C320E9F9C900473790 /* example_apple_metal_ios */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 8307E7F020E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_ios" */;
+ buildPhases = (
+ 8307E7C020E9F9C900473790 /* Sources */,
+ 8307E7C120E9F9C900473790 /* Frameworks */,
+ 8307E7C220E9F9C900473790 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = example_apple_metal_ios;
+ productName = "imguiex iOS";
+ productReference = 8307E7C420E9F9C900473790 /* example_apple_metal.app */;
+ productType = "com.apple.product-type.application";
+ };
+ 8307E7D920E9F9C900473790 /* example_apple_metal_macos */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 8307E7F320E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_macos" */;
+ buildPhases = (
+ 8307E7D620E9F9C900473790 /* Sources */,
+ 8307E7D720E9F9C900473790 /* Frameworks */,
+ 8307E7D820E9F9C900473790 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = example_apple_metal_macos;
+ productName = "imguiex macOS";
+ productReference = 8307E7DA20E9F9C900473790 /* example_apple_metal.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 8307E7B620E9F9C700473790 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0940;
+ ORGANIZATIONNAME = "Warren Moore";
+ TargetAttributes = {
+ 8307E7C320E9F9C900473790 = {
+ CreatedOnToolsVersion = 9.4.1;
+ ProvisioningStyle = Automatic;
+ };
+ 8307E7D920E9F9C900473790 = {
+ CreatedOnToolsVersion = 9.4.1;
+ ProvisioningStyle = Automatic;
+ };
+ };
+ };
+ buildConfigurationList = 8307E7B920E9F9C700473790 /* Build configuration list for PBXProject "example_apple_metal" */;
+ compatibilityVersion = "Xcode 8.0";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 8307E7B520E9F9C700473790;
+ productRefGroup = 8307E7C520E9F9C900473790 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 8307E7C320E9F9C900473790 /* example_apple_metal_ios */,
+ 8307E7D920E9F9C900473790 /* example_apple_metal_macos */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 8307E7C220E9F9C900473790 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 836D2A3220EE4A900098E909 /* Launch Screen.storyboard in Resources */,
+ 8307E7CF20E9F9C900473790 /* Main.storyboard in Resources */,
+ 836D2A3020EE4A180098E909 /* Default-568h@2x.png in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 8307E7D820E9F9C900473790 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8307E7E420E9F9C900473790 /* Main.storyboard in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 8307E7C020E9F9C900473790 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8307E7E820E9F9C900473790 /* Renderer.mm in Sources */,
+ 8307E7CC20E9F9C900473790 /* ViewController.mm in Sources */,
+ 83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */,
+ 83BBE9DF20EB40AE00295997 /* AppDelegate.m in Sources */,
+ 83BBEA0920EB54E700295997 /* imgui.cpp in Sources */,
+ 83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */,
+ 83BBE9FE20EB54D800295997 /* imgui_impl_metal.mm in Sources */,
+ 07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */,
+ 83BBE9DE20EB3FFC00295997 /* main.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 8307E7D620E9F9C900473790 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 83BBE9E020EB42D000295997 /* ViewController.mm in Sources */,
+ 8307E7E920E9F9C900473790 /* Renderer.mm in Sources */,
+ 83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */,
+ 07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */,
+ 8307E7E720E9F9C900473790 /* main.m in Sources */,
+ 83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */,
+ 83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */,
+ 83BBE9FF20EB54D800295997 /* imgui_impl_metal.mm in Sources */,
+ 836D2A2E20EE208E0098E909 /* imgui_impl_osx.mm in Sources */,
+ 8307E7DE20E9F9C900473790 /* AppDelegate.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 8307E7CD20E9F9C900473790 /* Main.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 8307E7CE20E9F9C900473790 /* Base */,
+ );
+ name = Main.storyboard;
+ sourceTree = "";
+ };
+ 8307E7E220E9F9C900473790 /* Main.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 8307E7E320E9F9C900473790 /* Base */,
+ );
+ name = Main.storyboard;
+ sourceTree = "";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 8307E7EE20E9F9C900473790 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ };
+ name = Debug;
+ };
+ 8307E7EF20E9F9C900473790 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ };
+ name = Release;
+ };
+ 8307E7F120E9F9C900473790 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = "";
+ INFOPLIST_FILE = "$(SRCROOT)/iOS/Info-iOS.plist";
+ IPHONEOS_DEPLOYMENT_TARGET = 10.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-ios";
+ PRODUCT_NAME = example_apple_metal;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 8307E7F220E9F9C900473790 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = "";
+ INFOPLIST_FILE = "$(SRCROOT)/iOS/Info-iOS.plist";
+ IPHONEOS_DEPLOYMENT_TARGET = 10.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-ios";
+ PRODUCT_NAME = example_apple_metal;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 8307E7F420E9F9C900473790 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ DEVELOPMENT_TEAM = "";
+ INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
+ PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-macos";
+ PRODUCT_NAME = example_apple_metal;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ 8307E7F520E9F9C900473790 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ DEVELOPMENT_TEAM = "";
+ INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
+ PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-macos";
+ PRODUCT_NAME = example_apple_metal;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 8307E7B920E9F9C700473790 /* Build configuration list for PBXProject "example_apple_metal" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 8307E7EE20E9F9C900473790 /* Debug */,
+ 8307E7EF20E9F9C900473790 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 8307E7F020E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_ios" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 8307E7F120E9F9C900473790 /* Debug */,
+ 8307E7F220E9F9C900473790 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 8307E7F320E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_macos" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 8307E7F420E9F9C900473790 /* Debug */,
+ 8307E7F520E9F9C900473790 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 8307E7B620E9F9C700473790 /* Project object */;
+}
diff --git a/third_party/imgui/examples/example_apple_metal/iOS/Base.lproj/Main.storyboard b/third_party/imgui/examples/example_apple_metal/iOS/Base.lproj/Main.storyboard
new file mode 100644
index 0000000000..24a4009ef7
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/iOS/Base.lproj/Main.storyboard
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/third_party/imgui/examples/example_apple_metal/iOS/Default-568h@2x.png b/third_party/imgui/examples/example_apple_metal/iOS/Default-568h@2x.png
new file mode 100644
index 0000000000..e3ce940a36
Binary files /dev/null and b/third_party/imgui/examples/example_apple_metal/iOS/Default-568h@2x.png differ
diff --git a/third_party/imgui/examples/apple_example/imguiex-ios/Info.plist b/third_party/imgui/examples/example_apple_metal/iOS/Info-iOS.plist
similarity index 83%
rename from third_party/imgui/examples/apple_example/imguiex-ios/Info.plist
rename to third_party/imgui/examples/example_apple_metal/iOS/Info-iOS.plist
index bc6f548cb9..8d919d1e50 100644
--- a/third_party/imgui/examples/apple_example/imguiex-ios/Info.plist
+++ b/third_party/imgui/examples/example_apple_metal/iOS/Info-iOS.plist
@@ -3,33 +3,34 @@
CFBundleDevelopmentRegion
- en
+ $(DEVELOPMENT_LANGUAGE)
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
- org.imgui.example.$(PRODUCT_NAME:rfc1034identifier)
+ $(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
- $(PRODUCT_NAME)
+ imgui
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
- CFBundleSignature
- ????
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
- LaunchScreen
+ Launch Screen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
+ metal
+ UIRequiresFullScreen
+
UIStatusBarHidden
UISupportedInterfaceOrientations
@@ -37,6 +38,7 @@
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
+ UIInterfaceOrientationPortraitUpsideDown
UISupportedInterfaceOrientations~ipad
diff --git a/third_party/imgui/examples/example_apple_metal/iOS/Launch Screen.storyboard b/third_party/imgui/examples/example_apple_metal/iOS/Launch Screen.storyboard
new file mode 100644
index 0000000000..96047e1fc7
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/iOS/Launch Screen.storyboard
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/third_party/imgui/examples/example_apple_metal/macOS/Base.lproj/Main.storyboard b/third_party/imgui/examples/example_apple_metal/macOS/Base.lproj/Main.storyboard
new file mode 100644
index 0000000000..cf41461705
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_metal/macOS/Base.lproj/Main.storyboard
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/third_party/imgui/examples/apple_example/imguiex-osx/Info.plist b/third_party/imgui/examples/example_apple_metal/macOS/Info-macOS.plist
similarity index 78%
rename from third_party/imgui/examples/apple_example/imguiex-osx/Info.plist
rename to third_party/imgui/examples/example_apple_metal/macOS/Info-macOS.plist
index ba1c2bb00a..52d992048f 100644
--- a/third_party/imgui/examples/apple_example/imguiex-osx/Info.plist
+++ b/third_party/imgui/examples/example_apple_metal/macOS/Info-macOS.plist
@@ -3,7 +3,7 @@
CFBundleDevelopmentRegion
- en
+ $(DEVELOPMENT_LANGUAGE)
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIconFile
@@ -13,21 +13,19 @@
CFBundleInfoDictionaryVersion
6.0
CFBundleName
- $(PRODUCT_NAME)
+ imgui
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
- CFBundleSignature
- ????
CFBundleVersion
1
LSMinimumSystemVersion
$(MACOSX_DEPLOYMENT_TARGET)
NSHumanReadableCopyright
- Copyright © 2016 Joel Davis. All rights reserved.
- NSMainNibFile
- MainMenu
+ Copyright © 2018 Warren Moore. All rights reserved.
+ NSMainStoryboardFile
+ Main
NSPrincipalClass
NSApplication
diff --git a/third_party/imgui/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj b/third_party/imgui/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj
new file mode 100644
index 0000000000..5bdf74b583
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj
@@ -0,0 +1,326 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 48;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 07A82EDB213941D00078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82EDA213941D00078D120 /* imgui_widgets.cpp */; };
+ 4080A99820B02D340036BA46 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4080A98A20B02CD90036BA46 /* main.mm */; };
+ 4080A9A220B034280036BA46 /* imgui_impl_opengl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */; };
+ 4080A9AD20B0343C0036BA46 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */; };
+ 4080A9AE20B0343C0036BA46 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A9A720B0343C0036BA46 /* imgui.cpp */; };
+ 4080A9AF20B0343C0036BA46 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */; };
+ 4080A9B020B0347A0036BA46 /* imgui_impl_osx.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */; };
+ 4080A9B320B034E40036BA46 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4080A9B220B034E40036BA46 /* Cocoa.framework */; };
+ 4080A9B520B034EA0036BA46 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4080A9B420B034EA0036BA46 /* OpenGL.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 4080A96920B029B00036BA46 /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 07A82EDA213941D00078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = ""; };
+ 4080A96B20B029B00036BA46 /* example_osx_opengl2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = example_osx_opengl2; sourceTree = BUILT_PRODUCTS_DIR; };
+ 4080A98A20B02CD90036BA46 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = SOURCE_ROOT; };
+ 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_opengl2.cpp; path = ../imgui_impl_opengl2.cpp; sourceTree = ""; };
+ 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../imgui_impl_osx.mm; sourceTree = ""; };
+ 4080A9A020B034280036BA46 /* imgui_impl_opengl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_opengl2.h; path = ../imgui_impl_opengl2.h; sourceTree = ""; };
+ 4080A9A120B034280036BA46 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../imgui_impl_osx.h; sourceTree = ""; };
+ 4080A9A520B0343C0036BA46 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = ""; };
+ 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = ""; };
+ 4080A9A720B0343C0036BA46 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; };
+ 4080A9A820B0343C0036BA46 /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; };
+ 4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; };
+ 4080A9AC20B0343C0036BA46 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = ""; };
+ 4080A9B220B034E40036BA46 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
+ 4080A9B420B034EA0036BA46 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 4080A96820B029B00036BA46 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 4080A9B520B034EA0036BA46 /* OpenGL.framework in Frameworks */,
+ 4080A9B320B034E40036BA46 /* Cocoa.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 4080A96220B029B00036BA46 = {
+ isa = PBXGroup;
+ children = (
+ 4080A9AC20B0343C0036BA46 /* imconfig.h */,
+ 4080A9A720B0343C0036BA46 /* imgui.cpp */,
+ 4080A9A820B0343C0036BA46 /* imgui.h */,
+ 07A82EDA213941D00078D120 /* imgui_widgets.cpp */,
+ 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */,
+ 4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */,
+ 4080A9A520B0343C0036BA46 /* imgui_internal.h */,
+ 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */,
+ 4080A9A020B034280036BA46 /* imgui_impl_opengl2.h */,
+ 4080A9A120B034280036BA46 /* imgui_impl_osx.h */,
+ 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */,
+ 4080A98A20B02CD90036BA46 /* main.mm */,
+ 4080A96C20B029B00036BA46 /* Products */,
+ 4080A9B120B034E40036BA46 /* Frameworks */,
+ );
+ sourceTree = "";
+ };
+ 4080A96C20B029B00036BA46 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 4080A96B20B029B00036BA46 /* example_osx_opengl2 */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 4080A9B120B034E40036BA46 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 4080A9B420B034EA0036BA46 /* OpenGL.framework */,
+ 4080A9B220B034E40036BA46 /* Cocoa.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 4080A96A20B029B00036BA46 /* example_osx_opengl2 */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 4080A97220B029B00036BA46 /* Build configuration list for PBXNativeTarget "example_osx_opengl2" */;
+ buildPhases = (
+ 4080A96720B029B00036BA46 /* Sources */,
+ 4080A96820B029B00036BA46 /* Frameworks */,
+ 4080A96920B029B00036BA46 /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = example_osx_opengl2;
+ productName = example_osx_opengl2;
+ productReference = 4080A96B20B029B00036BA46 /* example_osx_opengl2 */;
+ productType = "com.apple.product-type.tool";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 4080A96320B029B00036BA46 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0930;
+ ORGANIZATIONNAME = ImGui;
+ TargetAttributes = {
+ 4080A96A20B029B00036BA46 = {
+ CreatedOnToolsVersion = 9.3.1;
+ ProvisioningStyle = Automatic;
+ };
+ };
+ };
+ buildConfigurationList = 4080A96620B029B00036BA46 /* Build configuration list for PBXProject "example_apple_opengl2" */;
+ compatibilityVersion = "Xcode 8.0";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 4080A96220B029B00036BA46;
+ productRefGroup = 4080A96C20B029B00036BA46 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 4080A96A20B029B00036BA46 /* example_osx_opengl2 */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 4080A96720B029B00036BA46 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 4080A99820B02D340036BA46 /* main.mm in Sources */,
+ 4080A9AD20B0343C0036BA46 /* imgui_demo.cpp in Sources */,
+ 4080A9AF20B0343C0036BA46 /* imgui_draw.cpp in Sources */,
+ 4080A9A220B034280036BA46 /* imgui_impl_opengl2.cpp in Sources */,
+ 4080A9B020B0347A0036BA46 /* imgui_impl_osx.mm in Sources */,
+ 4080A9AE20B0343C0036BA46 /* imgui.cpp in Sources */,
+ 07A82EDB213941D00078D120 /* imgui_widgets.cpp in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 4080A97020B029B00036BA46 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.13;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ 4080A97120B029B00036BA46 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.13;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ 4080A97320B029B00036BA46 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SYSTEM_HEADER_SEARCH_PATHS = ../libs/gl3w;
+ USER_HEADER_SEARCH_PATHS = ../..;
+ };
+ name = Debug;
+ };
+ 4080A97420B029B00036BA46 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ MACOSX_DEPLOYMENT_TARGET = 10.12;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SYSTEM_HEADER_SEARCH_PATHS = ../libs/gl3w;
+ USER_HEADER_SEARCH_PATHS = ../..;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 4080A96620B029B00036BA46 /* Build configuration list for PBXProject "example_apple_opengl2" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 4080A97020B029B00036BA46 /* Debug */,
+ 4080A97120B029B00036BA46 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 4080A97220B029B00036BA46 /* Build configuration list for PBXNativeTarget "example_osx_opengl2" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 4080A97320B029B00036BA46 /* Debug */,
+ 4080A97420B029B00036BA46 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 4080A96320B029B00036BA46 /* Project object */;
+}
diff --git a/third_party/imgui/examples/example_apple_opengl2/main.mm b/third_party/imgui/examples/example_apple_opengl2/main.mm
new file mode 100644
index 0000000000..7cbf3409a0
--- /dev/null
+++ b/third_party/imgui/examples/example_apple_opengl2/main.mm
@@ -0,0 +1,287 @@
+// dear imgui: standalone example application for OSX + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+#include "imgui.h"
+#include "../imgui_impl_osx.h"
+#include "../imgui_impl_opengl2.h"
+#include
+#import
+#import
+#import
+
+//-----------------------------------------------------------------------------------
+// ImGuiExampleView
+//-----------------------------------------------------------------------------------
+
+@interface ImGuiExampleView : NSOpenGLView
+{
+ NSTimer* animationTimer;
+}
+@end
+
+@implementation ImGuiExampleView
+
+-(void)animationTimerFired:(NSTimer*)timer
+{
+ [self setNeedsDisplay:YES];
+}
+
+-(void)prepareOpenGL
+{
+ [super prepareOpenGL];
+
+#ifndef DEBUG
+ GLint swapInterval = 1;
+ [[self openGLContext] setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
+ if (swapInterval == 0)
+ NSLog(@"Error: Cannot set swap interval.");
+#endif
+}
+
+-(void)updateAndDrawDemoView
+{
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplOSX_NewFrame(self);
+ ImGui::NewFrame();
+
+ // Global data for the demo
+ 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);
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ [[self openGLContext] makeCurrentContext];
+
+ ImDrawData* draw_data = ImGui::GetDrawData();
+ GLsizei width = (GLsizei)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
+ GLsizei height = (GLsizei)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
+ glViewport(0, 0, width, height);
+
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui_ImplOpenGL2_RenderDrawData(draw_data);
+
+ // Present
+ [[self openGLContext] flushBuffer];
+
+ if (!animationTimer)
+ animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES];
+}
+
+-(void)reshape
+{
+ [[self openGLContext] update];
+ [self updateAndDrawDemoView];
+}
+
+-(void)drawRect:(NSRect)bounds
+{
+ [self updateAndDrawDemoView];
+}
+
+-(BOOL)acceptsFirstResponder
+{
+ return (YES);
+}
+
+-(BOOL)becomeFirstResponder
+{
+ return (YES);
+}
+
+-(BOOL)resignFirstResponder
+{
+ return (YES);
+}
+
+-(void)dealloc
+{
+ animationTimer = nil;
+}
+
+// Forward Mouse/Keyboard events to dear imgui OSX back-end. It returns true when imgui is expecting to use the event.
+-(void)keyUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)keyDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)flagsChanged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)rightMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)otherMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)rightMouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)otherMouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)mouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)rightMouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)otherMouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)mouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)rightMouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)otherMouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+-(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
+
+@end
+
+//-----------------------------------------------------------------------------------
+// ImGuiExampleAppDelegate
+//-----------------------------------------------------------------------------------
+
+@interface ImGuiExampleAppDelegate : NSObject
+@property (nonatomic, readonly) NSWindow* window;
+@end
+
+@implementation ImGuiExampleAppDelegate
+@synthesize window = _window;
+
+-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
+{
+ return YES;
+}
+
+-(NSWindow*)window
+{
+ if (_window != nil)
+ return (_window);
+
+ NSRect viewRect = NSMakeRect(100.0, 100.0, 100.0 + 1280.0, 100 + 720.0);
+
+ _window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES];
+ [_window setTitle:@"Dear ImGui OSX+OpenGL2 Example"];
+ [_window setAcceptsMouseMovedEvents:YES];
+ [_window setOpaque:YES];
+ [_window makeKeyAndOrderFront:NSApp];
+
+ return (_window);
+}
+
+-(void)setupMenu
+{
+ NSMenu* mainMenuBar = [[NSMenu alloc] init];
+ NSMenu* appMenu;
+ NSMenuItem* menuItem;
+
+ appMenu = [[NSMenu alloc] initWithTitle:@"Dear ImGui OSX+OpenGL2 Example"];
+ menuItem = [appMenu addItemWithTitle:@"Quit Dear ImGui OSX+OpenGL2 Example" action:@selector(terminate:) keyEquivalent:@"q"];
+ [menuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand];
+
+ menuItem = [[NSMenuItem alloc] init];
+ [menuItem setSubmenu:appMenu];
+
+ [mainMenuBar addItem:menuItem];
+
+ appMenu = nil;
+ [NSApp setMainMenu:mainMenuBar];
+}
+
+-(void)dealloc
+{
+ _window = nil;
+}
+
+-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+ // Make the application a foreground application (else it won't receive keyboard events)
+ ProcessSerialNumber psn = {0, kCurrentProcess};
+ TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+
+ // Menu
+ [self setupMenu];
+
+ NSOpenGLPixelFormatAttribute attrs[] =
+ {
+ NSOpenGLPFADoubleBuffer,
+ NSOpenGLPFADepthSize, 32,
+ 0
+ };
+
+ NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
+ ImGuiExampleView* view = [[ImGuiExampleView alloc] initWithFrame:self.window.frame pixelFormat:format];
+ format = nil;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
+ [view setWantsBestResolutionOpenGLSurface:YES];
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+ [self.window setContentView:view];
+
+ if ([view openGLContext] == nil)
+ NSLog(@"No OpenGL Context!");
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplOSX_Init();
+ 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 'docs/FONTS.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);
+}
+
+@end
+
+int main(int argc, const char* argv[])
+{
+ @autoreleasepool
+ {
+ NSApp = [NSApplication sharedApplication];
+ ImGuiExampleAppDelegate* delegate = [[ImGuiExampleAppDelegate alloc] init];
+ [[NSApplication sharedApplication] setDelegate:delegate];
+ [NSApp run];
+ }
+ return NSApplicationMain(argc, argv);
+}
diff --git a/third_party/imgui/examples/example_emscripten/Makefile b/third_party/imgui/examples/example_emscripten/Makefile
new file mode 100644
index 0000000000..9833270e5d
--- /dev/null
+++ b/third_party/imgui/examples/example_emscripten/Makefile
@@ -0,0 +1,84 @@
+#
+# Makefile to use with emscripten
+# See https://emscripten.org/docs/getting_started/downloads.html
+# for installation instructions.
+#
+# This Makefile assumes you have loaded emscripten's environment.
+# (On Windows, you may need to execute emsdk_env.bat or encmdprompt.bat ahead)
+#
+# Running `make` will produce three files:
+# - example_emscripten.html
+# - example_emscripten.js
+# - example_emscripten.wasm
+#
+# All three are needed to run the demo.
+
+CC = emcc
+CXX = em++
+EXE = example_emscripten.html
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+UNAME_S := $(shell uname -s)
+
+##---------------------------------------------------------------------
+## EMSCRIPTEN OPTIONS
+##---------------------------------------------------------------------
+
+EMS += -s USE_SDL=2 -s WASM=1
+EMS += -s ALLOW_MEMORY_GROWTH=1
+EMS += -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=0
+EMS += -s ASSERTIONS=1
+
+# Uncomment next line to fix possible rendering bugs with Emscripten version older then 1.39.0 (https://github.com/ocornut/imgui/issues/2877)
+#EMS += -s BINARYEN_TRAP_MODE=clamp
+#EMS += -s SAFE_HEAP=1 ## Adds overhead
+
+# Emscripten allows preloading a file or folder to be accessible at runtime.
+# The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts"
+# See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html
+# (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
+USE_FILE_SYSTEM ?= 0
+ifeq ($(USE_FILE_SYSTEM), 0)
+EMS += -s NO_FILESYSTEM=1 -DIMGUI_DISABLE_FILE_FUNCTIONS
+endif
+ifeq ($(USE_FILE_SYSTEM), 1)
+LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts
+endif
+
+##---------------------------------------------------------------------
+## FINAL BUILD FLAGS
+##---------------------------------------------------------------------
+
+CPPFLAGS += -I../ -I../../
+#CPPFLAGS += -g
+CPPFLAGS += -Wall -Wformat -Os
+CPPFLAGS += $(EMS)
+LIBS += $(EMS)
+LDFLAGS += --shell-file shell_minimal.html
+
+##---------------------------------------------------------------------
+## BUILD RULES
+##---------------------------------------------------------------------
+
+%.o:%.cpp
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../libs/gl3w/GL/%.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(EXE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(LIBS) $(LDFLAGS)
+
+clean:
+ rm -f $(EXE) $(OBJS) *.js *.wasm *.wasm.pre
diff --git a/third_party/imgui/examples/example_emscripten/README.md b/third_party/imgui/examples/example_emscripten/README.md
new file mode 100644
index 0000000000..dcb7c1a72a
--- /dev/null
+++ b/third_party/imgui/examples/example_emscripten/README.md
@@ -0,0 +1,12 @@
+
+# How to Build
+
+- You need to install Emscripten from https://emscripten.org/docs/getting_started/downloads.html, and have the environment variables set, as described in https://emscripten.org/docs/getting_started/downloads.html#installation-instructions
+
+- Depending on your configuration, in Windows you may need to run `emsdk/emsdk_env.bat` in your console to access the Emscripten command-line tools.
+
+- Then build using `make` while in the `example_emscripten/` directory.
+
+- Note that Emscripten 1.39.0 (October 2019) obsoleted the `BINARYEN_TRAP_MODE=clamp` compilation flag which was required with version older than 1.39.0 to avoid rendering artefacts. See [#2877](https://github.com/ocornut/imgui/issues/2877) for details. If you use an older version, uncomment this line in the Makefile:
+
+`#EMS += -s BINARYEN_TRAP_MODE=clamp`
diff --git a/third_party/imgui/examples/example_emscripten/main.cpp b/third_party/imgui/examples/example_emscripten/main.cpp
new file mode 100644
index 0000000000..6867b4cd90
--- /dev/null
+++ b/third_party/imgui/examples/example_emscripten/main.cpp
@@ -0,0 +1,173 @@
+// dear imgui: standalone example application for Emscripten, using SDL2 + OpenGL3
+// This is mostly the same code as the SDL2 + OpenGL3 example, simply with the modifications needed to run on Emscripten.
+// It is possible to combine both code into a single source file that will compile properly on Desktop and using Emscripten.
+// See https://github.com/ocornut/imgui/pull/2492 as an example on how to do just that.
+//
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/)
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+#include "imgui_impl_opengl3.h"
+#include
+#include
+#include
+#include
+
+// Emscripten requires to have full control over the main loop. We're going to store our SDL book-keeping variables globally.
+// Having a single function that acts as a loop prevents us to store state in the stack of said function. So we need some location for this.
+SDL_Window* g_Window = NULL;
+SDL_GLContext g_GLContext = NULL;
+
+// For clarity, our main loop code is declared at the end.
+void main_loop(void*);
+
+int main(int, char**)
+{
+ // Setup SDL
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
+ {
+ printf("Error: %s\n", SDL_GetError());
+ return -1;
+ }
+
+ // For the browser using Emscripten, we are going to use WebGL1 with GL ES2. See the Makefile. for requirement details.
+ // It is very likely the generated file won't work in many browsers. Firefox is the only sure bet, but I have successfully
+ // run this code on Chrome for Android for example.
+ const char* glsl_version = "#version 100";
+ //const char* glsl_version = "#version 300 es";
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
+
+ // Create window with graphics context
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
+ SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
+ SDL_DisplayMode current;
+ SDL_GetCurrentDisplayMode(0, ¤t);
+ SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
+ g_Window = SDL_CreateWindow("Dear ImGui Emscripten example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
+ g_GLContext = SDL_GL_CreateContext(g_Window);
+ if (!g_GLContext)
+ {
+ fprintf(stderr, "Failed to initialize WebGL context!\n");
+ return 1;
+ }
+ SDL_GL_SetSwapInterval(1); // Enable vsync
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file.
+ // You may manually call LoadIniSettingsFromMemory() to load settings from your own storage.
+ io.IniFilename = NULL;
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplSDL2_InitForOpenGL(g_Window, g_GLContext);
+ ImGui_ImplOpenGL3_Init(glsl_version);
+
+ // 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 'docs/FONTS.md' 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 \\ !
+ // - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details.
+ //io.Fonts->AddFontDefault();
+#ifndef IMGUI_DISABLE_FILE_FUNCTIONS
+ io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f);
+ //io.Fonts->AddFontFromFileTTF("fonts/DroidSans.ttf", 16.0f);
+ //io.Fonts->AddFontFromFileTTF("fonts/ProggyTiny.ttf", 10.0f);
+ //ImFont* font = io.Fonts->AddFontFromFileTTF("fonts/ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
+ //IM_ASSERT(font != NULL);
+#endif
+
+ // This function call won't return, and will engage in an infinite loop, processing events from the browser, and dispatching them.
+ emscripten_set_main_loop_arg(main_loop, NULL, 0, true);
+}
+
+void main_loop(void* arg)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_UNUSED(arg); // We can pass this argument as the second parameter of emscripten_set_main_loop_arg(), but we don't use that.
+
+ // Our state (make them static = more or less global) as a convenience to keep the example terse.
+ 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);
+
+ // Poll and handle events (inputs, window resize, etc.)
+ // 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.
+ SDL_Event event;
+ while (SDL_PollEvent(&event))
+ {
+ ImGui_ImplSDL2_ProcessEvent(&event);
+ // Capture events here, based on io.WantCaptureMouse and io.WantCaptureKeyboard
+ }
+
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL3_NewFrame();
+ ImGui_ImplSDL2_NewFrame(g_Window);
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ SDL_GL_MakeCurrent(g_Window, g_GLContext);
+ glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
+ SDL_GL_SwapWindow(g_Window);
+}
diff --git a/third_party/imgui/examples/example_emscripten/shell_minimal.html b/third_party/imgui/examples/example_emscripten/shell_minimal.html
new file mode 100644
index 0000000000..514385d7cf
--- /dev/null
+++ b/third_party/imgui/examples/example_emscripten/shell_minimal.html
@@ -0,0 +1,64 @@
+
+
+
+
+
+ Dear ImGui Emscripten example
+
+
+
+
+
+ {{{ SCRIPT }}}
+
+
diff --git a/third_party/imgui/examples/example_glfw_metal/Makefile b/third_party/imgui/examples/example_glfw_metal/Makefile
new file mode 100644
index 0000000000..35f1773773
--- /dev/null
+++ b/third_party/imgui/examples/example_glfw_metal/Makefile
@@ -0,0 +1,44 @@
+#
+# You will need GLFW (http://www.glfw.org):
+# brew install glfw
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glfw_metal
+SOURCES = main.mm
+SOURCES += ../imgui_impl_glfw.cpp ../imgui_impl_metal.mm
+SOURCES += ../../imgui.cpp ../../imgui_widgets.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore
+LIBS += -L/usr/local/lib -lglfw
+
+CXXFLAGS = -I../ -I../../ -I/usr/local/include
+CXXFLAGS += -Wall -Wformat
+CFLAGS = $(CXXFLAGS)
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.mm
+ $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $<
+
+%.o:%.mm
+ $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/third_party/imgui/examples/example_glfw_metal/main.mm b/third_party/imgui/examples/example_glfw_metal/main.mm
new file mode 100644
index 0000000000..d6f9ae3f60
--- /dev/null
+++ b/third_party/imgui/examples/example_glfw_metal/main.mm
@@ -0,0 +1,170 @@
+// dear imgui: standalone example application for GLFW + Metal, using programmable pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
+
+#include "imgui.h"
+#include "imgui_impl_glfw.h"
+#include "imgui_impl_metal.h"
+#include
+
+#define GLFW_INCLUDE_NONE
+#define GLFW_EXPOSE_NATIVE_COCOA
+#include
+#include
+
+#import
+#import
+
+static void glfw_error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Glfw Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup Dear ImGui binding
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // 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 'docs/FONTS.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);
+
+ // Setup window
+ glfwSetErrorCallback(glfw_error_callback);
+ if (!glfwInit())
+ return 1;
+
+ // Create window with graphics context
+ glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Metal example", NULL, NULL);
+ if (window == NULL)
+ return 1;
+
+ id device = MTLCreateSystemDefaultDevice();;
+ id commandQueue = [device newCommandQueue];
+
+ ImGui_ImplGlfw_InitForOpenGL(window, true);
+ ImGui_ImplMetal_Init(device);
+
+ NSWindow *nswin = glfwGetCocoaWindow(window);
+ CAMetalLayer *layer = [CAMetalLayer layer];
+ layer.device = device;
+ layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
+ nswin.contentView.layer = layer;
+ nswin.contentView.wantsLayer = YES;
+
+ MTLRenderPassDescriptor *renderPassDescriptor = [MTLRenderPassDescriptor new];
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ float clear_color[4] = {0.45f, 0.55f, 0.60f, 1.00f};
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ @autoreleasepool
+ {
+ // Poll and handle events (inputs, window resize, etc.)
+ // 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.
+ glfwPollEvents();
+
+ int width, height;
+ glfwGetFramebufferSize(window, &width, &height);
+ layer.drawableSize = CGSizeMake(width, height);
+ id drawable = [layer nextDrawable];
+
+ id commandBuffer = [commandQueue commandBuffer];
+ renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
+ renderPassDescriptor.colorAttachments[0].texture = drawable.texture;
+ renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
+ renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore;
+ id renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
+ [renderEncoder pushDebugGroup:@"ImGui demo"];
+
+ // Start the Dear ImGui frame
+ ImGui_ImplMetal_NewFrame(renderPassDescriptor);
+ ImGui_ImplGlfw_NewFrame();
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
+
+ [renderEncoder popDebugGroup];
+ [renderEncoder endEncoding];
+
+ [commandBuffer presentDrawable:drawable];
+ [commandBuffer commit];
+ }
+ }
+
+ // Cleanup
+ ImGui_ImplMetal_Shutdown();
+ ImGui_ImplGlfw_Shutdown();
+ ImGui::DestroyContext();
+
+ glfwDestroyWindow(window);
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/third_party/imgui/examples/example_glfw_opengl2/Makefile b/third_party/imgui/examples/example_glfw_opengl2/Makefile
new file mode 100644
index 0000000000..38f865bae1
--- /dev/null
+++ b/third_party/imgui/examples/example_glfw_opengl2/Makefile
@@ -0,0 +1,80 @@
+#
+# Cross Platform Makefile
+# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
+#
+# You will need GLFW (http://www.glfw.org):
+# Linux:
+# apt-get install libglfw-dev
+# Mac OS X:
+# brew install glfw
+# MSYS2:
+# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glfw_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glfw.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)
+
+CXXFLAGS = -I../ -I../../
+CXXFLAGS += -g -Wall -Wformat
+LIBS =
+
+##---------------------------------------------------------------------
+## BUILD FLAGS PER PLATFORM
+##---------------------------------------------------------------------
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS += -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS += `pkg-config --cflags glfw3`
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -L/opt/local/lib
+ #LIBS += -lglfw3
+ LIBS += -lglfw
+
+ CXXFLAGS += -I/usr/local/include -I/opt/local/include
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "MinGW"
+ LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS += `pkg-config --cflags glfw3`
+ CFLAGS = $(CXXFLAGS)
+endif
+
+##---------------------------------------------------------------------
+## BUILD RULES
+##---------------------------------------------------------------------
+
+%.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/third_party/imgui/examples/example_glfw_opengl2/build_win32.bat b/third_party/imgui/examples/example_glfw_opengl2/build_win32.bat
new file mode 100644
index 0000000000..538d9a52b2
--- /dev/null
+++ b/third_party/imgui/examples/example_glfw_opengl2/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include *.cpp ..\imgui_impl_opengl2.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_opengl2.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/third_party/imgui/examples/opengl2_example/opengl2_example.vcxproj b/third_party/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj
similarity index 83%
rename from third_party/imgui/examples/opengl2_example/opengl2_example.vcxproj
rename to third_party/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj
index 3756748d32..b265fea045 100644
--- a/third_party/imgui/examples/opengl2_example/opengl2_example.vcxproj
+++ b/third_party/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj
@@ -20,30 +20,35 @@
{9CDA7840-B7A5-496D-A527-E95571496D18}
- opengl2_example
+ example_glfw_opengl2
+ 8.1
Application
true
MultiByte
+ v110
Application
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
@@ -85,11 +90,11 @@
Level4
Disabled
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;..\libs\glfw\include;%(AdditionalIncludeDirectories)
true
- $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ ..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
opengl32.lib;glfw3.lib;%(AdditionalDependencies)
Console
msvcrt.lib
@@ -99,11 +104,11 @@
Level4
Disabled
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;..\libs\glfw\include;%(AdditionalIncludeDirectories)
true
- $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ ..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
opengl32.lib;glfw3.lib;%(AdditionalDependencies)
Console
msvcrt.lib
@@ -115,14 +120,14 @@
MaxSpeed
true
true
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
true
true
true
- $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ ..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
opengl32.lib;glfw3.lib;%(AdditionalDependencies)
Console
@@ -135,14 +140,14 @@
MaxSpeed
true
true
- $(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
true
true
true
- $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ ..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
opengl32.lib;glfw3.lib;%(AdditionalDependencies)
Console
@@ -153,14 +158,17 @@
-
+
+
+
-
+
+
diff --git a/third_party/imgui/examples/opengl2_example/opengl2_example.vcxproj.filters b/third_party/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters
similarity index 78%
rename from third_party/imgui/examples/opengl2_example/opengl2_example.vcxproj.filters
rename to third_party/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters
index 0c85d9fa38..b7a37e68a5 100644
--- a/third_party/imgui/examples/opengl2_example/opengl2_example.vcxproj.filters
+++ b/third_party/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters
@@ -16,15 +16,21 @@
imgui
-
- sources
-
imgui
imgui
+
+ sources
+
+
+ sources
+
+
+ imgui
+
@@ -33,12 +39,15 @@
imgui
-
- sources
-
imgui
+
+ sources
+
+
+ sources
+
diff --git a/third_party/imgui/examples/opengl2_example/main.cpp b/third_party/imgui/examples/example_glfw_opengl2/main.cpp
similarity index 52%
rename from third_party/imgui/examples/opengl2_example/main.cpp
rename to third_party/imgui/examples/example_glfw_opengl2/main.cpp
index caae8c2b66..411062faf7 100644
--- a/third_party/imgui/examples/opengl2_example/main.cpp
+++ b/third_party/imgui/examples/example_glfw_opengl2/main.cpp
@@ -1,47 +1,65 @@
-// ImGui - standalone example application for GLFW + OpenGL2, using legacy fixed pipeline
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
+// dear imgui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
-// **Prefer using the code in the opengl3_example/ folder**
+// **Prefer using the code in the example_glfw_opengl2/ folder**
// See imgui_impl_glfw.cpp for details.
#include "imgui.h"
-#include "imgui_impl_glfw_gl2.h"
+#include "imgui_impl_glfw.h"
+#include "imgui_impl_opengl2.h"
#include
+#ifdef __APPLE__
+#define GL_SILENCE_DEPRECATION
+#endif
#include
-static void error_callback(int error, const char* description)
+// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
+// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.
+// Your own project should not be affected, as you are likely to link with a newer binary of GLFW that is adequate for your version of Visual Studio.
+#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
+#pragma comment(lib, "legacy_stdio_definitions")
+#endif
+
+static void glfw_error_callback(int error, const char* description)
{
- fprintf(stderr, "Error %d: %s\n", error, description);
+ fprintf(stderr, "Glfw Error %d: %s\n", error, description);
}
int main(int, char**)
{
// Setup window
- glfwSetErrorCallback(error_callback);
+ glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
- GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+OpenGL2 example", NULL, NULL);
+ if (window == NULL)
+ return 1;
glfwMakeContextCurrent(window);
glfwSwapInterval(1); // Enable vsync
- // Setup ImGui binding
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_ImplGlfwGL2_Init(window, true);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
- // Setup style
+ // Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGlfw_InitForOpenGL(window, true);
+ 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 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.
+ // - Read 'docs/FONTS.md' 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);
@@ -51,6 +69,7 @@ int main(int, char**)
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
//IM_ASSERT(font != NULL);
+ // Our state
bool show_demo_window = true;
bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
@@ -58,65 +77,81 @@ int main(int, char**)
// Main loop
while (!glfwWindowShouldClose(window))
{
+ // Poll and handle events (inputs, window resize, etc.)
// 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.
glfwPollEvents();
- ImGui_ImplGlfwGL2_NewFrame();
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplGlfw_NewFrame();
+ ImGui::NewFrame();
+
+ // 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::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
+ 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);
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: most widgets return true when edited/activated)
+ 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();
}
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
+ // 3. Show another simple window.
if (show_another_window)
{
- ImGui::Begin("Another Window", &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();
}
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
// Rendering
+ ImGui::Render();
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
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::Render();
- ImGui_ImplGlfwGL2_RenderDrawData(ImGui::GetDrawData());
+
+ // 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 commented lines below.
+ //GLint last_program;
+ //glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
+ //glUseProgram(0);
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
+ //glUseProgram(last_program);
+
+ glfwMakeContextCurrent(window);
glfwSwapBuffers(window);
}
// Cleanup
- ImGui_ImplGlfwGL2_Shutdown();
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
+
+ glfwDestroyWindow(window);
glfwTerminate();
return 0;
diff --git a/third_party/imgui/examples/example_glfw_opengl3/Makefile b/third_party/imgui/examples/example_glfw_opengl3/Makefile
new file mode 100644
index 0000000000..3bc72b6f02
--- /dev/null
+++ b/third_party/imgui/examples/example_glfw_opengl3/Makefile
@@ -0,0 +1,111 @@
+#
+# Cross Platform Makefile
+# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
+#
+# You will need GLFW (http://www.glfw.org):
+# Linux:
+# apt-get install libglfw-dev
+# Mac OS X:
+# brew install glfw
+# MSYS2:
+# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_glfw_opengl3
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_glfw.cpp ../imgui_impl_opengl3.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+UNAME_S := $(shell uname -s)
+
+CXXFLAGS = -I../ -I../../
+CXXFLAGS += -g -Wall -Wformat
+LIBS =
+
+##---------------------------------------------------------------------
+## OPENGL LOADER
+##---------------------------------------------------------------------
+
+## Using OpenGL loader: gl3w [default]
+SOURCES += ../libs/gl3w/GL/gl3w.c
+CXXFLAGS += -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W
+
+## Using OpenGL loader: glew
+## (This assumes a system-wide installation)
+# CXXFLAGS += -DIMGUI_IMPL_OPENGL_LOADER_GLEW
+# LIBS += -lGLEW
+
+## Using OpenGL loader: glad
+# SOURCES += ../libs/glad/src/glad.c
+# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
+
+## Using OpenGL loader: glbinding
+## This assumes a system-wide installation
+## of either version 3.0.0 (or newer)
+# CXXFLAGS += -DIMGUI_IMPL_OPENGL_LOADER_GLBINDING3
+# LIBS += -lglbinding
+## or the older version 2.x
+# CXXFLAGS += -DIMGUI_IMPL_OPENGL_LOADER_GLBINDING2
+# LIBS += -lglbinding
+
+##---------------------------------------------------------------------
+## BUILD FLAGS PER PLATFORM
+##---------------------------------------------------------------------
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS += -lGL `pkg-config --static --libs glfw3`
+
+ CXXFLAGS += `pkg-config --cflags glfw3`
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
+ LIBS += -L/usr/local/lib -L/opt/local/lib
+ #LIBS += -lglfw3
+ LIBS += -lglfw
+
+ CXXFLAGS += -I/usr/local/include -I/opt/local/include
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "MinGW"
+ LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
+
+ CXXFLAGS += `pkg-config --cflags glfw3`
+ CFLAGS = $(CXXFLAGS)
+endif
+
+##---------------------------------------------------------------------
+## BUILD RULES
+##---------------------------------------------------------------------
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../libs/gl3w/GL/%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.o:../libs/glad/src/%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/third_party/imgui/examples/example_glfw_opengl3/build_win32.bat b/third_party/imgui/examples/example_glfw_opengl3/build_win32.bat
new file mode 100644
index 0000000000..e5c15c532a
--- /dev/null
+++ b/third_party/imgui/examples/example_glfw_opengl3/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I ..\libs\gl3w *.cpp ..\imgui_impl_glfw.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_glfw_opengl3.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/third_party/imgui/examples/opengl3_example/opengl3_example.vcxproj b/third_party/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj
similarity index 83%
rename from third_party/imgui/examples/opengl3_example/opengl3_example.vcxproj
rename to third_party/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj
index e3a9c82047..47d2538045 100644
--- a/third_party/imgui/examples/opengl3_example/opengl3_example.vcxproj
+++ b/third_party/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj
@@ -20,30 +20,35 @@
{4a1fb5ea-22f5-42a8-ab92-1d2df5d47fb9}
- opengl3_example
+ example_glfw_opengl3
+ 8.1
Application
true
MultiByte
+ v110
Application
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
@@ -85,11 +90,11 @@
Level4
Disabled
- $(SolutionDir)\libs\glfw\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories)
true
- $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ ..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
opengl32.lib;glfw3.lib;%(AdditionalDependencies)
Console
msvcrt.lib
@@ -99,11 +104,11 @@
Level4
Disabled
- $(SolutionDir)\libs\glfw\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories)
true
- $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ ..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
opengl32.lib;glfw3.lib;%(AdditionalDependencies)
Console
msvcrt.lib
@@ -115,14 +120,14 @@
MaxSpeed
true
true
- $(SolutionDir)\libs\glfw\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories)
false
true
true
true
- $(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ ..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
opengl32.lib;glfw3.lib;%(AdditionalDependencies)
Console
@@ -135,14 +140,14 @@
MaxSpeed
true
true
- $(SolutionDir)\libs\glfw\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories)
false
true
true
true
- $(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ ..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
opengl32.lib;glfw3.lib;%(AdditionalDependencies)
Console
@@ -153,17 +158,20 @@
+
+
+
-
+
+
-
diff --git a/third_party/imgui/examples/opengl3_example/opengl3_example.vcxproj.filters b/third_party/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters
similarity index 82%
rename from third_party/imgui/examples/opengl3_example/opengl3_example.vcxproj.filters
rename to third_party/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters
index 0170ab4693..efb570cec9 100644
--- a/third_party/imgui/examples/opengl3_example/opengl3_example.vcxproj.filters
+++ b/third_party/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters
@@ -19,9 +19,6 @@
imgui
-
- sources
-
gl3w
@@ -31,6 +28,15 @@
imgui
+
+ sources
+
+
+ sources
+
+
+ imgui
+
@@ -39,9 +45,6 @@
imgui
-
- sources
-
gl3w
@@ -51,6 +54,12 @@
imgui
+
+ sources
+
+
+ sources
+
diff --git a/third_party/imgui/examples/example_glfw_opengl3/main.cpp b/third_party/imgui/examples/example_glfw_opengl3/main.cpp
new file mode 100644
index 0000000000..6a3592f162
--- /dev/null
+++ b/third_party/imgui/examples/example_glfw_opengl3/main.cpp
@@ -0,0 +1,210 @@
+// dear imgui: standalone example application for GLFW + OpenGL 3, using programmable pipeline
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
+
+#include "imgui.h"
+#include "imgui_impl_glfw.h"
+#include "imgui_impl_opengl3.h"
+#include
+
+// About Desktop OpenGL function loaders:
+// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
+// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
+// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
+#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
+#include // Initialize with gl3wInit()
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
+#include // Initialize with glewInit()
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
+#include // Initialize with gladLoadGL()
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
+#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
+#include // Initialize with glbinding::Binding::initialize()
+#include
+using namespace gl;
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
+#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
+#include // Initialize with glbinding::initialize()
+#include
+using namespace gl;
+#else
+#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
+#endif
+
+// Include glfw3.h after our OpenGL definitions
+#include
+
+// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
+// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.
+// Your own project should not be affected, as you are likely to link with a newer binary of GLFW that is adequate for your version of Visual Studio.
+#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
+#pragma comment(lib, "legacy_stdio_definitions")
+#endif
+
+static void glfw_error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Glfw Error %d: %s\n", error, description);
+}
+
+int main(int, char**)
+{
+ // Setup window
+ glfwSetErrorCallback(glfw_error_callback);
+ if (!glfwInit())
+ return 1;
+
+ // Decide GL+GLSL versions
+#if __APPLE__
+ // GL 3.2 + GLSL 150
+ const char* glsl_version = "#version 150";
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
+ glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
+ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
+#else
+ // GL 3.0 + GLSL 130
+ const char* glsl_version = "#version 130";
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
+ //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
+ //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // 3.0+ only
+#endif
+
+ // Create window with graphics context
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+OpenGL3 example", NULL, NULL);
+ if (window == NULL)
+ return 1;
+ glfwMakeContextCurrent(window);
+ glfwSwapInterval(1); // Enable vsync
+
+ // Initialize OpenGL loader
+#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
+ bool err = gl3wInit() != 0;
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
+ bool err = glewInit() != GLEW_OK;
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
+ bool err = gladLoadGL() == 0;
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
+ bool err = false;
+ glbinding::Binding::initialize();
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
+ bool err = false;
+ glbinding::initialize([](const char* name) { return (glbinding::ProcAddress)glfwGetProcAddress(name); });
+#else
+ bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader is likely to requires some form of initialization.
+#endif
+ if (err)
+ {
+ fprintf(stderr, "Failed to initialize OpenGL loader!\n");
+ return 1;
+ }
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGlfw_InitForOpenGL(window, true);
+ ImGui_ImplOpenGL3_Init(glsl_version);
+
+ // 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 'docs/FONTS.md' 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);
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ // Poll and handle events (inputs, window resize, etc.)
+ // 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.
+ glfwPollEvents();
+
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL3_NewFrame();
+ ImGui_ImplGlfw_NewFrame();
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ int display_w, display_h;
+ glfwGetFramebufferSize(window, &display_w, &display_h);
+ glViewport(0, 0, display_w, display_h);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
+
+ glfwSwapBuffers(window);
+ }
+
+ // Cleanup
+ ImGui_ImplOpenGL3_Shutdown();
+ ImGui_ImplGlfw_Shutdown();
+ ImGui::DestroyContext();
+
+ glfwDestroyWindow(window);
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/third_party/imgui/examples/vulkan_example/CMakeLists.txt b/third_party/imgui/examples/example_glfw_vulkan/CMakeLists.txt
similarity index 66%
rename from third_party/imgui/examples/vulkan_example/CMakeLists.txt
rename to third_party/imgui/examples/example_glfw_vulkan/CMakeLists.txt
index d05b451631..68155ec883 100644
--- a/third_party/imgui/examples/vulkan_example/CMakeLists.txt
+++ b/third_party/imgui/examples/example_glfw_vulkan/CMakeLists.txt
@@ -1,5 +1,10 @@
+# Example usage:
+# mkdir build
+# cd build
+# cmake -g "Visual Studio 14 2015" ..
+
cmake_minimum_required(VERSION 2.8)
-project(ImGuiGLFWVulkanExample C CXX)
+project(imgui_example_glfw_vulkan C CXX)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
@@ -18,9 +23,9 @@ option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
add_subdirectory(${GLFW_DIR} binary_dir EXCLUDE_FROM_ALL)
include_directories(${GLFW_DIR}/include)
-# ImGui
+# Dear ImGui
set(IMGUI_DIR ../../)
-include_directories(${IMGUI_DIR})
+include_directories(${IMGUI_DIR} ..)
# Libraries
find_library(VULKAN_LIBRARY
@@ -32,5 +37,5 @@ include_directories(${GLFW_DIR}/deps)
file(GLOB sources *.cpp)
-add_executable(vulkan_example ${sources} ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp)
-target_link_libraries(vulkan_example ${LIBRARIES})
+add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/examples/imgui_impl_glfw.cpp ${IMGUI_DIR}/examples/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_widgets.cpp)
+target_link_libraries(example_glfw_vulkan ${LIBRARIES})
diff --git a/third_party/imgui/examples/vulkan_example/build_win32.bat b/third_party/imgui/examples/example_glfw_vulkan/build_win32.bat
similarity index 52%
rename from third_party/imgui/examples/vulkan_example/build_win32.bat
rename to third_party/imgui/examples/example_glfw_vulkan/build_win32.bat
index bacb639439..0d991b9d2f 100644
--- a/third_party/imgui/examples/vulkan_example/build_win32.bat
+++ b/third_party/imgui/examples/example_glfw_vulkan/build_win32.bat
@@ -1,7 +1,7 @@
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\*.cpp /FeDebug/vulkan_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
+cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\imgui_impl_vulkan.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_vulkan.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
mkdir Release
-cl /nologo /Zi /MD /Ox /Oi /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\*.cpp /FeRelease/vulkan_example.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
+cl /nologo /Zi /MD /Ox /Oi /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\imgui_impl_vulkan.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeRelease/example_glfw_vulkan.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
diff --git a/third_party/imgui/examples/vulkan_example/build_win64.bat b/third_party/imgui/examples/example_glfw_vulkan/build_win64.bat
similarity index 51%
rename from third_party/imgui/examples/vulkan_example/build_win64.bat
rename to third_party/imgui/examples/example_glfw_vulkan/build_win64.bat
index 71e557b19d..ddedf597c9 100644
--- a/third_party/imgui/examples/vulkan_example/build_win64.bat
+++ b/third_party/imgui/examples/example_glfw_vulkan/build_win64.bat
@@ -1,7 +1,7 @@
@REM Build for Visual Studio compiler. Run your copy of amd64/vcvars32.bat to setup 64-bit command-line compiler.
mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\*.cpp /FeDebug/vulkan_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
+cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\imgui_impl_vulkan.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_vulkan.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
mkdir Release
-cl /nologo /Zi /MD /Ox /Oi /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\*.cpp /FeRelease/vulkan_example.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
+cl /nologo /Zi /MD /Ox /Oi /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\imgui_impl_vulkan.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeRelease/example_glfw_vulkan.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
diff --git a/third_party/imgui/examples/vulkan_example/vulkan_example.vcxproj b/third_party/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj
similarity index 81%
rename from third_party/imgui/examples/vulkan_example/vulkan_example.vcxproj
rename to third_party/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj
index a315d69ea2..9e2c9b3825 100644
--- a/third_party/imgui/examples/vulkan_example/vulkan_example.vcxproj
+++ b/third_party/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj
@@ -20,30 +20,35 @@
{57E2DF5A-6FC8-45BB-99DD-91A18C646E80}
- opengl3_example
+ example_glfw_vulkan
+ 8.1
Application
true
MultiByte
+ v110
Application
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
@@ -85,11 +90,11 @@
Level4
Disabled
- %VULKAN_SDK%\include;$(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)
true
- %VULKAN_SDK%\lib32;$(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ %VULKAN_SDK%\lib32;..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)
Console
msvcrt.lib
@@ -99,11 +104,11 @@
Level4
Disabled
- %VULKAN_SDK%\include;$(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)
true
- %VULKAN_SDK%\lib;$(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ %VULKAN_SDK%\lib;..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)
Console
msvcrt.lib
@@ -115,14 +120,14 @@
MaxSpeed
true
true
- %VULKAN_SDK%\include;$(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
true
true
true
- %VULKAN_SDK%\lib32;$(SolutionDir)\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
+ %VULKAN_SDK%\lib32;..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories)
vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)
Console
@@ -135,14 +140,14 @@
MaxSpeed
true
true
- %VULKAN_SDK%\include;$(SolutionDir)\libs\glfw\include;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)
false
true
true
true
- %VULKAN_SDK%\lib;$(SolutionDir)\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
+ %VULKAN_SDK%\lib;..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories)
vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)
Console
@@ -153,14 +158,17 @@
-
+
+
+
-
+
+
diff --git a/third_party/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters b/third_party/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters
new file mode 100644
index 0000000000..98a445d4d2
--- /dev/null
+++ b/third_party/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {20b90ce4-7fcb-4731-b9a0-075f875de82d}
+
+
+ {f18ab499-84e1-499f-8eff-9754361e0e52}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
\ No newline at end of file
diff --git a/third_party/imgui/examples/vulkan_example/gen_spv.sh b/third_party/imgui/examples/example_glfw_vulkan/gen_spv.sh
similarity index 100%
rename from third_party/imgui/examples/vulkan_example/gen_spv.sh
rename to third_party/imgui/examples/example_glfw_vulkan/gen_spv.sh
diff --git a/third_party/imgui/examples/vulkan_example/glsl_shader.frag b/third_party/imgui/examples/example_glfw_vulkan/glsl_shader.frag
similarity index 86%
rename from third_party/imgui/examples/vulkan_example/glsl_shader.frag
rename to third_party/imgui/examples/example_glfw_vulkan/glsl_shader.frag
index 313a888041..ce7e6f72b2 100644
--- a/third_party/imgui/examples/vulkan_example/glsl_shader.frag
+++ b/third_party/imgui/examples/example_glfw_vulkan/glsl_shader.frag
@@ -3,7 +3,7 @@ layout(location = 0) out vec4 fColor;
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/third_party/imgui/examples/vulkan_example/glsl_shader.vert b/third_party/imgui/examples/example_glfw_vulkan/glsl_shader.vert
similarity index 64%
rename from third_party/imgui/examples/vulkan_example/glsl_shader.vert
rename to third_party/imgui/examples/example_glfw_vulkan/glsl_shader.vert
index 20b2908278..9425365a53 100644
--- a/third_party/imgui/examples/vulkan_example/glsl_shader.vert
+++ b/third_party/imgui/examples/example_glfw_vulkan/glsl_shader.vert
@@ -3,16 +3,16 @@ layout(location = 0) in vec2 aPos;
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 @@ void main()
{
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/third_party/imgui/examples/example_glfw_vulkan/main.cpp b/third_party/imgui/examples/example_glfw_vulkan/main.cpp
new file mode 100644
index 0000000000..80763a01e2
--- /dev/null
+++ b/third_party/imgui/examples/example_glfw_vulkan/main.cpp
@@ -0,0 +1,535 @@
+// dear imgui: standalone example application for Glfw + Vulkan
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
+// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
+// You will use those if you want to use this rendering back-end in your engine/app.
+// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by
+// the back-end itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code.
+// Read comments in imgui_impl_vulkan.h.
+
+#include "imgui.h"
+#include "imgui_impl_glfw.h"
+#include "imgui_impl_vulkan.h"
+#include // printf, fprintf
+#include // abort
+#define GLFW_INCLUDE_NONE
+#define GLFW_INCLUDE_VULKAN
+#include
+#include
+
+// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
+// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.
+// Your own project should not be affected, as you are likely to link with a newer binary of GLFW that is adequate for your version of Visual Studio.
+#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
+#pragma comment(lib, "legacy_stdio_definitions")
+#endif
+
+//#define IMGUI_UNLIMITED_FRAME_RATE
+#ifdef _DEBUG
+#define IMGUI_VULKAN_DEBUG_REPORT
+#endif
+
+static VkAllocationCallbacks* g_Allocator = NULL;
+static VkInstance g_Instance = VK_NULL_HANDLE;
+static VkPhysicalDevice g_PhysicalDevice = VK_NULL_HANDLE;
+static VkDevice g_Device = VK_NULL_HANDLE;
+static uint32_t g_QueueFamily = (uint32_t)-1;
+static VkQueue g_Queue = VK_NULL_HANDLE;
+static VkDebugReportCallbackEXT g_DebugReport = VK_NULL_HANDLE;
+static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE;
+static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
+
+static ImGui_ImplVulkanH_Window g_MainWindowData;
+static int g_MinImageCount = 2;
+static bool g_SwapChainRebuild = false;
+static int g_SwapChainResizeWidth = 0;
+static int g_SwapChainResizeHeight = 0;
+
+static void check_vk_result(VkResult err)
+{
+ if (err == 0)
+ return;
+ fprintf(stderr, "[vulkan] Error: VkResult = %d\n", err);
+ if (err < 0)
+ abort();
+}
+
+#ifdef IMGUI_VULKAN_DEBUG_REPORT
+static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
+{
+ (void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments
+ fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
+ return VK_FALSE;
+}
+#endif // IMGUI_VULKAN_DEBUG_REPORT
+
+static void SetupVulkan(const char** extensions, uint32_t extensions_count)
+{
+ VkResult err;
+
+ // Create Vulkan Instance
+ {
+ VkInstanceCreateInfo create_info = {};
+ create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
+ create_info.enabledExtensionCount = extensions_count;
+ create_info.ppEnabledExtensionNames = extensions;
+
+#ifdef IMGUI_VULKAN_DEBUG_REPORT
+ // Enabling multiple validation layers grouped as LunarG standard validation
+ const char* layers[] = { "VK_LAYER_LUNARG_standard_validation" };
+ create_info.enabledLayerCount = 1;
+ create_info.ppEnabledLayerNames = layers;
+
+ // Enable debug report extension (we need additional storage, so we duplicate the user array to add our new extension to it)
+ const char** extensions_ext = (const char**)malloc(sizeof(const char*) * (extensions_count + 1));
+ memcpy(extensions_ext, extensions, extensions_count * sizeof(const char*));
+ extensions_ext[extensions_count] = "VK_EXT_debug_report";
+ create_info.enabledExtensionCount = extensions_count + 1;
+ create_info.ppEnabledExtensionNames = extensions_ext;
+
+ // Create Vulkan Instance
+ err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
+ check_vk_result(err);
+ free(extensions_ext);
+
+ // Get the function pointer (required for any extensions)
+ auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
+ IM_ASSERT(vkCreateDebugReportCallbackEXT != NULL);
+
+ // Setup the debug report callback
+ VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
+ debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
+ debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
+ debug_report_ci.pfnCallback = debug_report;
+ debug_report_ci.pUserData = NULL;
+ err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
+ check_vk_result(err);
+#else
+ // Create Vulkan Instance without any debug feature
+ err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
+ check_vk_result(err);
+ IM_UNUSED(g_DebugReport);
+#endif
+ }
+
+ // Select GPU
+ {
+ uint32_t gpu_count;
+ err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, NULL);
+ check_vk_result(err);
+ IM_ASSERT(gpu_count > 0);
+
+ VkPhysicalDevice* gpus = (VkPhysicalDevice*)malloc(sizeof(VkPhysicalDevice) * gpu_count);
+ err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus);
+ check_vk_result(err);
+
+ // If a number >1 of GPUs got reported, you should find the best fit GPU for your purpose
+ // e.g. VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU if available, or with the greatest memory available, etc.
+ // for sake of simplicity we'll just take the first one, assuming it has a graphics queue family.
+ g_PhysicalDevice = gpus[0];
+ free(gpus);
+ }
+
+ // Select graphics queue family
+ {
+ uint32_t count;
+ vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, NULL);
+ VkQueueFamilyProperties* queues = (VkQueueFamilyProperties*)malloc(sizeof(VkQueueFamilyProperties) * count);
+ vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, queues);
+ for (uint32_t i = 0; i < count; i++)
+ if (queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
+ {
+ g_QueueFamily = i;
+ break;
+ }
+ free(queues);
+ IM_ASSERT(g_QueueFamily != (uint32_t)-1);
+ }
+
+ // Create Logical Device (with 1 queue)
+ {
+ int device_extension_count = 1;
+ const char* device_extensions[] = { "VK_KHR_swapchain" };
+ const float queue_priority[] = { 1.0f };
+ VkDeviceQueueCreateInfo queue_info[1] = {};
+ queue_info[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
+ queue_info[0].queueFamilyIndex = g_QueueFamily;
+ queue_info[0].queueCount = 1;
+ queue_info[0].pQueuePriorities = queue_priority;
+ VkDeviceCreateInfo create_info = {};
+ create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
+ create_info.queueCreateInfoCount = sizeof(queue_info) / sizeof(queue_info[0]);
+ create_info.pQueueCreateInfos = queue_info;
+ create_info.enabledExtensionCount = device_extension_count;
+ create_info.ppEnabledExtensionNames = device_extensions;
+ err = vkCreateDevice(g_PhysicalDevice, &create_info, g_Allocator, &g_Device);
+ check_vk_result(err);
+ vkGetDeviceQueue(g_Device, g_QueueFamily, 0, &g_Queue);
+ }
+
+ // Create Descriptor Pool
+ {
+ VkDescriptorPoolSize pool_sizes[] =
+ {
+ { VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
+ { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 },
+ { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
+ { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 },
+ { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 },
+ { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
+ { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 }
+ };
+ VkDescriptorPoolCreateInfo pool_info = {};
+ pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
+ pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
+ pool_info.maxSets = 1000 * IM_ARRAYSIZE(pool_sizes);
+ pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
+ pool_info.pPoolSizes = pool_sizes;
+ err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
+ check_vk_result(err);
+ }
+}
+
+// All the ImGui_ImplVulkanH_XXX structures/functions are optional helpers used by the demo.
+// Your real engine/app may not use them.
+static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface, int width, int height)
+{
+ wd->Surface = surface;
+
+ // Check for WSI support
+ VkBool32 res;
+ vkGetPhysicalDeviceSurfaceSupportKHR(g_PhysicalDevice, g_QueueFamily, wd->Surface, &res);
+ if (res != VK_TRUE)
+ {
+ fprintf(stderr, "Error no WSI support on physical device 0\n");
+ exit(-1);
+ }
+
+ // Select Surface Format
+ const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
+ const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
+ wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
+
+ // Select Present Mode
+#ifdef IMGUI_UNLIMITED_FRAME_RATE
+ VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
+#else
+ VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
+#endif
+ wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes));
+ //printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode);
+
+ // Create SwapChain, RenderPass, Framebuffer, etc.
+ IM_ASSERT(g_MinImageCount >= 2);
+ ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
+}
+
+static void CleanupVulkan()
+{
+ vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
+
+#ifdef IMGUI_VULKAN_DEBUG_REPORT
+ // Remove the debug report callback
+ auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
+ vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
+#endif // IMGUI_VULKAN_DEBUG_REPORT
+
+ vkDestroyDevice(g_Device, g_Allocator);
+ vkDestroyInstance(g_Instance, g_Allocator);
+}
+
+static void CleanupVulkanWindow()
+{
+ ImGui_ImplVulkanH_DestroyWindow(g_Instance, g_Device, &g_MainWindowData, g_Allocator);
+}
+
+static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
+{
+ VkResult err;
+
+ VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].ImageAcquiredSemaphore;
+ VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
+
+ ImGui_ImplVulkanH_Frame* 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 = 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 = fd->Framebuffer;
+ 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 dear imgui primitives into command buffer
+ ImGui_ImplVulkan_RenderDrawData(draw_data, 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 = &render_complete_semaphore;
+
+ 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_Window* wd)
+{
+ VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &render_complete_semaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
+ wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
+}
+
+static void glfw_error_callback(int error, const char* description)
+{
+ fprintf(stderr, "Glfw Error %d: %s\n", error, description);
+}
+
+static void glfw_resize_callback(GLFWwindow*, int w, int h)
+{
+ g_SwapChainRebuild = true;
+ g_SwapChainResizeWidth = w;
+ g_SwapChainResizeHeight = h;
+}
+
+int main(int, char**)
+{
+ // Setup GLFW window
+ glfwSetErrorCallback(glfw_error_callback);
+ if (!glfwInit())
+ return 1;
+
+ glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Vulkan example", NULL, NULL);
+
+ // Setup Vulkan
+ if (!glfwVulkanSupported())
+ {
+ printf("GLFW: Vulkan Not Supported\n");
+ return 1;
+ }
+ uint32_t extensions_count = 0;
+ const char** extensions = glfwGetRequiredInstanceExtensions(&extensions_count);
+ SetupVulkan(extensions, extensions_count);
+
+ // Create Window Surface
+ VkSurfaceKHR surface;
+ VkResult err = glfwCreateWindowSurface(g_Instance, window, g_Allocator, &surface);
+ check_vk_result(err);
+
+ // Create Framebuffers
+ int w, h;
+ glfwGetFramebufferSize(window, &w, &h);
+ glfwSetFramebufferSizeCallback(window, glfw_resize_callback);
+ ImGui_ImplVulkanH_Window* wd = &g_MainWindowData;
+ SetupVulkanWindow(wd, surface, w, h);
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplGlfw_InitForVulkan(window, true);
+ ImGui_ImplVulkan_InitInfo init_info = {};
+ init_info.Instance = g_Instance;
+ init_info.PhysicalDevice = g_PhysicalDevice;
+ init_info.Device = g_Device;
+ init_info.QueueFamily = g_QueueFamily;
+ init_info.Queue = g_Queue;
+ init_info.PipelineCache = g_PipelineCache;
+ init_info.DescriptorPool = g_DescriptorPool;
+ init_info.Allocator = g_Allocator;
+ init_info.MinImageCount = g_MinImageCount;
+ init_info.ImageCount = wd->ImageCount;
+ init_info.CheckVkResultFn = check_vk_result;
+ ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
+
+ // 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 'docs/FONTS.md' 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);
+
+ // Upload Fonts
+ {
+ // Use any command queue
+ VkCommandPool command_pool = wd->Frames[wd->FrameIndex].CommandPool;
+ VkCommandBuffer command_buffer = wd->Frames[wd->FrameIndex].CommandBuffer;
+
+ err = vkResetCommandPool(g_Device, command_pool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo begin_info = {};
+ begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ begin_info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(command_buffer, &begin_info);
+ check_vk_result(err);
+
+ ImGui_ImplVulkan_CreateFontsTexture(command_buffer);
+
+ VkSubmitInfo end_info = {};
+ end_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ end_info.commandBufferCount = 1;
+ end_info.pCommandBuffers = &command_buffer;
+ err = vkEndCommandBuffer(command_buffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &end_info, VK_NULL_HANDLE);
+ check_vk_result(err);
+
+ err = vkDeviceWaitIdle(g_Device);
+ check_vk_result(err);
+ ImGui_ImplVulkan_DestroyFontUploadObjects();
+ }
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+ // Main loop
+ while (!glfwWindowShouldClose(window))
+ {
+ // Poll and handle events (inputs, window resize, etc.)
+ // 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.
+ glfwPollEvents();
+
+ // Resize swap chain?
+ if (g_SwapChainRebuild && g_SwapChainResizeWidth > 0 && g_SwapChainResizeHeight > 0)
+ {
+ g_SwapChainRebuild = false;
+ ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
+ ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, g_SwapChainResizeWidth, g_SwapChainResizeHeight, g_MinImageCount);
+ g_MainWindowData.FrameIndex = 0;
+ }
+
+ // Start the Dear ImGui frame
+ ImGui_ImplVulkan_NewFrame();
+ ImGui_ImplGlfw_NewFrame();
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ ImDrawData* draw_data = ImGui::GetDrawData();
+ const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
+ if (!is_minimized)
+ {
+ FrameRender(wd, draw_data);
+ FramePresent(wd);
+ }
+ }
+
+ // Cleanup
+ err = vkDeviceWaitIdle(g_Device);
+ check_vk_result(err);
+ ImGui_ImplVulkan_Shutdown();
+ ImGui_ImplGlfw_Shutdown();
+ ImGui::DestroyContext();
+
+ CleanupVulkanWindow();
+ CleanupVulkan();
+
+ glfwDestroyWindow(window);
+ glfwTerminate();
+
+ return 0;
+}
diff --git a/third_party/imgui/examples/example_glut_opengl2/Makefile b/third_party/imgui/examples/example_glut_opengl2/Makefile
new file mode 100644
index 0000000000..70576b8f94
--- /dev/null
+++ b/third_party/imgui/examples/example_glut_opengl2/Makefile
@@ -0,0 +1,74 @@
+#
+# Cross Platform Makefile
+# Compatible with MSYS2/MINGW, 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)
+
+CXXFLAGS = -I../ -I../../
+CXXFLAGS += -g -Wall -Wformat
+LIBS =
+
+##---------------------------------------------------------------------
+## BUILD FLAGS PER PLATFORM
+##---------------------------------------------------------------------
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS += -lGL -lglut
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS += -framework OpenGL -framework GLUT
+ LIBS += -L/usr/local/lib -L/opt/local/lib
+
+ CXXFLAGS += -I/usr/local/include -I/opt/local/include
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "MinGW"
+ LIBS += -lgdi32 -lopengl32 -limm32
+ifeq ($(shell pkg-config freeglut --exists 2> /dev/null && echo yes || echo no),yes)
+ CXXFLAGS += $(shell pkg-config freeglut --cflags)
+ LIBS += $(shell pkg-config freeglut --libs)
+else
+ LIBS += -lglut
+endif
+ CFLAGS = $(CXXFLAGS)
+endif
+
+##---------------------------------------------------------------------
+## BUILD RULES
+##---------------------------------------------------------------------
+
+%.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/third_party/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/third_party/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
new file mode 100644
index 0000000000..9a23951694
--- /dev/null
+++ b/third_party/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj
@@ -0,0 +1,180 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {F90D0333-5FB1-440D-918D-DD39A1B5187E}
+ example_glut_opengl2
+ 8.1
+
+
+
+ Application
+ true
+ MultiByte
+ v110
+
+
+ Application
+ true
+ MultiByte
+ v110
+
+
+ Application
+ false
+ true
+ MultiByte
+ v110
+
+
+ Application
+ false
+ true
+ MultiByte
+ v110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(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/third_party/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/third_party/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters
new file mode 100644
index 0000000000..290d43d7bc
--- /dev/null
+++ b/third_party/imgui/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/third_party/imgui/examples/example_glut_opengl2/main.cpp b/third_party/imgui/examples/example_glut_opengl2/main.cpp
new file mode 100644
index 0000000000..997eeaef33
--- /dev/null
+++ b/third_party/imgui/examples/example_glut_opengl2/main.cpp
@@ -0,0 +1,146 @@
+// 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 2020, you are being abused. Please show some resistance. !!!
+// !!! Nowadays, prefer using GLFW or SDL instead!
+
+#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
+
+// Our state
+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_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+
+ // 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 'docs/FONTS.md' 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/third_party/imgui/examples/marmalade_example/data/app.icf b/third_party/imgui/examples/example_marmalade/data/app.icf
similarity index 100%
rename from third_party/imgui/examples/marmalade_example/data/app.icf
rename to third_party/imgui/examples/example_marmalade/data/app.icf
diff --git a/third_party/imgui/examples/marmalade_example/main.cpp b/third_party/imgui/examples/example_marmalade/main.cpp
similarity index 71%
rename from third_party/imgui/examples/marmalade_example/main.cpp
rename to third_party/imgui/examples/example_marmalade/main.cpp
index f2ddae4048..9f2ef7987f 100644
--- a/third_party/imgui/examples/marmalade_example/main.cpp
+++ b/third_party/imgui/examples/example_marmalade/main.cpp
@@ -1,8 +1,8 @@
-// ImGui - standalone example application for Marmalade
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// dear imgui: standalone example application for Marmalade
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
// Copyright (C) 2015 by Giovanni Zito
-// This file is part of ImGui
+// This file is part of Dear ImGui
#include "imgui.h"
#include "imgui_impl_marmalade.h"
@@ -16,22 +16,25 @@ int main(int, char**)
{
IwGxInit();
- // Setup ImGui binding
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_Marmalade_Init(true);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
- // Setup style
+ // Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();
+ // Setup Platform/Renderer bindings
+ ImGui_Marmalade_Init(true);
+
// 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 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.
+ // - Read 'docs/FONTS.md' 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);
@@ -41,6 +44,7 @@ int main(int, char**)
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
//IM_ASSERT(font != NULL);
+ // Our state
bool show_demo_window = true;
bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
@@ -51,55 +55,59 @@ int main(int, char**)
if (s3eDeviceCheckQuitRequest())
break;
+ // Poll and handle inputs
// 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.
s3eKeyboardUpdate();
s3ePointerUpdate();
- ImGui_Marmalade_NewFrame();
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
+ // Start the Dear ImGui frame
+ ImGui_Marmalade_NewFrame();
+ ImGui::NewFrame();
+
+ // 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::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
+ 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);
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: most widgets return true when edited/activated)
+ 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();
}
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
+ // 3. Show another simple window.
if (show_another_window)
{
- ImGui::Begin("Another Window", &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();
}
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
// Rendering
+ ImGui::Render();
IwGxSetColClear(clear_color.x * 255, clear_color.y * 255, clear_color.z * 255, clear_color.w * 255);
IwGxClear();
- ImGui::Render();
ImGui_Marmalade_RenderDrawData(ImGui::GetDrawData());
IwGxSwapBuffers();
diff --git a/third_party/imgui/examples/marmalade_example/marmalade_example.mkb b/third_party/imgui/examples/example_marmalade/marmalade_example.mkb
similarity index 83%
rename from third_party/imgui/examples/marmalade_example/marmalade_example.mkb
rename to third_party/imgui/examples/example_marmalade/marmalade_example.mkb
index 9f8ea44ae8..34315b9a72 100644
--- a/third_party/imgui/examples/marmalade_example/marmalade_example.mkb
+++ b/third_party/imgui/examples/example_marmalade/marmalade_example.mkb
@@ -17,6 +17,7 @@ options
includepaths
{
+ ..
../..
}
@@ -32,13 +33,14 @@ files
../../imgui.cpp
../../imgui_demo.cpp
../../imgui_draw.cpp
+ ../../imgui_widgets.cpp
../../imconfig.h
../../imgui.h
- ../../imgui_internal.h
+ ../../imgui_internal.h
["imgui","Marmalade binding"]
- imgui_impl_marmalade.h
- imgui_impl_marmalade.cpp
+ ../imgui_impl_marmalade.h
+ ../imgui_impl_marmalade.cpp
main.cpp
}
diff --git a/third_party/imgui/examples/example_null/Makefile b/third_party/imgui/examples/example_null/Makefile
new file mode 100644
index 0000000000..15c547a5f4
--- /dev/null
+++ b/third_party/imgui/examples/example_null/Makefile
@@ -0,0 +1,90 @@
+#
+# Cross Platform Makefile
+# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
+#
+# Important: This is a "null back-end" application, with no visible output or interaction!
+# This is used for testing purpose and continuous integration, and has little use for end-user.
+#
+
+# Options
+WITH_EXTRA_WARNINGS ?= 0
+WITH_FREETYPE ?= 0
+
+EXE = example_null
+SOURCES = main.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+UNAME_S := $(shell uname -s)
+
+CXXFLAGS += -I../ -I../../
+CXXFLAGS += -g -Wall -Wformat
+LIBS =
+
+# We use the WITH_EXTRA_WARNINGS flag on our CI setup to eagerly catch zealous warnings
+ifeq ($(WITH_EXTRA_WARNINGS), 1)
+ CXXFLAGS += -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros
+endif
+
+# We use the WITH_FREETYPE flag on our CI setup to test compiling misc/freetype/imgui_freetype.cpp
+# (only supported on Linux, and note that the imgui_freetype code currently won't be executed)
+ifeq ($(WITH_FREETYPE), 1)
+ SOURCES += ../../misc/freetype/imgui_freetype.cpp
+ CXXFLAGS += $(shell pkg-config --cflags freetype2)
+ LIBS += $(shell pkg-config --libs freetype2)
+endif
+
+##---------------------------------------------------------------------
+## BUILD FLAGS PER PLATFORM
+##---------------------------------------------------------------------
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ ifneq ($(WITH_EXTRA_WARNINGS), 0)
+ CXXFLAGS += -Wextra -Wpedantic
+ ifeq ($(shell $(CXX) -v 2>&1 | grep -c "clang version"), 1)
+ CXXFLAGS += -Wshadow -Wsign-conversion
+ endif
+ endif
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ ifneq ($(WITH_EXTRA_WARNINGS), 0)
+ CXXFLAGS += -Weverything -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-padded -Wno-c++11-long-long
+ endif
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "MinGW"
+ ifneq ($(WITH_EXTRA_WARNINGS), 0)
+ CXXFLAGS += -Wextra -Wpedantic
+ endif
+ CFLAGS = $(CXXFLAGS)
+endif
+
+##---------------------------------------------------------------------
+## BUILD RULES
+##---------------------------------------------------------------------
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../misc/freetype/%.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/third_party/imgui/examples/null_example/build_win32.bat b/third_party/imgui/examples/example_null/build_win32.bat
similarity index 53%
rename from third_party/imgui/examples/null_example/build_win32.bat
rename to third_party/imgui/examples/example_null/build_win32.bat
index 7bb78232af..38e791481e 100644
--- a/third_party/imgui/examples/null_example/build_win32.bat
+++ b/third_party/imgui/examples/example_null/build_win32.bat
@@ -1,3 +1,3 @@
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
mkdir Debug
-cl /nologo /Zi /MD /I ..\.. *.cpp ..\..\*.cpp /FeDebug/null_example.exe /FoDebug/ /link gdi32.lib shell32.lib
+cl /nologo /Zi /MD /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib
diff --git a/third_party/imgui/examples/null_example/main.cpp b/third_party/imgui/examples/example_null/main.cpp
similarity index 74%
rename from third_party/imgui/examples/null_example/main.cpp
rename to third_party/imgui/examples/example_null/main.cpp
index 482d689bfa..aa2f6dba57 100644
--- a/third_party/imgui/examples/null_example/main.cpp
+++ b/third_party/imgui/examples/example_null/main.cpp
@@ -1,9 +1,12 @@
-// ImGui - null/dummy example application (compile and link imgui with no inputs, no outputs)
+// dear imgui: null/dummy example application
+// (compile and link imgui, create context, run headless with NO INPUTS, NO GRAPHICS OUTPUT)
+// This is useful to test building, but you cannot interact with anything here!
#include "imgui.h"
#include
int main(int, char**)
{
+ IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
@@ -12,7 +15,7 @@ int main(int, char**)
int tex_w, tex_h;
io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h);
- for (int n = 0; n < 50; n++)
+ for (int n = 0; n < 20; n++)
{
printf("NewFrame() %d\n", n);
io.DisplaySize = ImVec2(1920, 1080);
diff --git a/third_party/imgui/examples/example_sdl_directx11/build_win32.bat b/third_party/imgui/examples/example_sdl_directx11/build_win32.bat
new file mode 100644
index 0000000000..8fc702bb61
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_directx11/build_win32.bat
@@ -0,0 +1,8 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+set OUT_DIR=Debug
+set OUT_EXE=example_sdl_directx11
+set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include"
+set SOURCES=main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_dx11.cpp ..\..\imgui*.cpp
+set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
+mkdir %OUT_DIR%
+cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
diff --git a/third_party/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj b/third_party/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj
new file mode 100644
index 0000000000..804bd500d7
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj
@@ -0,0 +1,181 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {9E1987E3-1F19-45CA-B9C9-D31E791836D8}
+ example_sdl_directx11
+ 8.1
+ example_sdl_directx11
+
+
+
+ Application
+ true
+ MultiByte
+ v110
+
+
+ Application
+ true
+ MultiByte
+ v110
+
+
+ Application
+ false
+ true
+ MultiByte
+ v110
+
+
+ Application
+ false
+ true
+ MultiByte
+ v110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+
+
+ true
+ %SDL2_DIR%\lib\x86;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)
+ SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+
+
+ true
+ %SDL2_DIR%\lib\x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)
+ SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ %SDL2_DIR%\lib\x86;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)
+ SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ %SDL2_DIR%\lib\x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)
+ SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/third_party/imgui/examples/directx10_example/directx10_example.vcxproj.filters b/third_party/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters
similarity index 78%
rename from third_party/imgui/examples/directx10_example/directx10_example.vcxproj.filters
rename to third_party/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters
index aef010adf0..879f0dbe62 100644
--- a/third_party/imgui/examples/directx10_example/directx10_example.vcxproj.filters
+++ b/third_party/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters
@@ -15,12 +15,15 @@
imgui
-
- sources
-
imgui
+
+ sources
+
+
+ sources
+
@@ -29,15 +32,21 @@
sources
-
- sources
-
imgui
imgui
+
+ sources
+
+
+ imgui
+
+
+ sources
+
diff --git a/third_party/imgui/examples/example_sdl_directx11/main.cpp b/third_party/imgui/examples/example_sdl_directx11/main.cpp
new file mode 100644
index 0000000000..61a9307093
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_directx11/main.cpp
@@ -0,0 +1,228 @@
+// dear imgui: standalone example application for SDL2 + DirectX 11
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+#include "imgui_impl_dx11.h"
+#include
+#include
+#include
+#include
+
+// Data
+static ID3D11Device* g_pd3dDevice = NULL;
+static ID3D11DeviceContext* g_pd3dDeviceContext = NULL;
+static IDXGISwapChain* g_pSwapChain = NULL;
+static ID3D11RenderTargetView* g_mainRenderTargetView = NULL;
+
+// Forward declarations of helper functions
+bool CreateDeviceD3D(HWND hWnd);
+void CleanupDeviceD3D();
+void CreateRenderTarget();
+void CleanupRenderTarget();
+
+// Main code
+int main(int, char**)
+{
+ // Setup SDL
+ // (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
+ // depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!)
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
+ {
+ printf("Error: %s\n", SDL_GetError());
+ return -1;
+ }
+
+ // Setup window
+ SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
+ SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+DirectX11 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
+ SDL_SysWMinfo wmInfo;
+ SDL_VERSION(&wmInfo.version);
+ SDL_GetWindowWMInfo(window, &wmInfo);
+ HWND hwnd = (HWND)wmInfo.info.win.window;
+
+ // Initialize Direct3D
+ if (!CreateDeviceD3D(hwnd))
+ {
+ CleanupDeviceD3D();
+ return 1;
+ }
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplSDL2_InitForD3D(window);
+ ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
+
+ // 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 'docs/FONTS.md' 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);
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+ // Main loop
+ bool done = false;
+ while (!done)
+ {
+ // Poll and handle events (inputs, window resize, etc.)
+ // 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.
+ SDL_Event event;
+ while (SDL_PollEvent(&event))
+ {
+ ImGui_ImplSDL2_ProcessEvent(&event);
+ if (event.type == SDL_QUIT)
+ done = true;
+ if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
+ done = true;
+ if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED && event.window.windowID == SDL_GetWindowID(window))
+ {
+ // Release all outstanding references to the swap chain's buffers before resizing.
+ CleanupRenderTarget();
+ g_pSwapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0);
+ CreateRenderTarget();
+ }
+ }
+
+ // Start the Dear ImGui frame
+ ImGui_ImplDX11_NewFrame();
+ ImGui_ImplSDL2_NewFrame(window);
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
+ g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color);
+ ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
+
+ g_pSwapChain->Present(1, 0); // Present with vsync
+ //g_pSwapChain->Present(0, 0); // Present without vsync
+ }
+
+ // Cleanup
+ ImGui_ImplDX11_Shutdown();
+ ImGui_ImplSDL2_Shutdown();
+ ImGui::DestroyContext();
+
+ CleanupDeviceD3D();
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+
+ return 0;
+}
+
+// Helper functions
+
+bool CreateDeviceD3D(HWND hWnd)
+{
+ // Setup swap chain
+ DXGI_SWAP_CHAIN_DESC sd;
+ ZeroMemory(&sd, sizeof(sd));
+ sd.BufferCount = 2;
+ sd.BufferDesc.Width = 0;
+ sd.BufferDesc.Height = 0;
+ sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ sd.BufferDesc.RefreshRate.Numerator = 60;
+ sd.BufferDesc.RefreshRate.Denominator = 1;
+ sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
+ sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
+ sd.OutputWindow = hWnd;
+ sd.SampleDesc.Count = 1;
+ sd.SampleDesc.Quality = 0;
+ sd.Windowed = TRUE;
+ sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
+
+ UINT createDeviceFlags = 0;
+ //createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
+ D3D_FEATURE_LEVEL featureLevel;
+ const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
+ if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
+ return false;
+
+ CreateRenderTarget();
+ return true;
+}
+
+void CleanupDeviceD3D()
+{
+ CleanupRenderTarget();
+ if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; }
+ if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; }
+ if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
+}
+
+void CreateRenderTarget()
+{
+ ID3D11Texture2D* pBackBuffer;
+ g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
+ g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView);
+ pBackBuffer->Release();
+}
+
+void CleanupRenderTarget()
+{
+ if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; }
+}
diff --git a/third_party/imgui/examples/example_sdl_metal/Makefile b/third_party/imgui/examples/example_sdl_metal/Makefile
new file mode 100644
index 0000000000..9d0d5e0f0c
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_metal/Makefile
@@ -0,0 +1,46 @@
+#
+# You will need SDL2 (http://www.libsdl.org):
+# brew install sdl2
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_sdl_metal
+SOURCES = main.mm
+SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_metal.mm
+SOURCES += ../../imgui.cpp ../../imgui_widgets.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+
+LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore
+LIBS += `sdl2-config --libs`
+LIBS += -L/usr/local/lib
+
+CXXFLAGS = -I../ -I../../ -I/usr/local/include
+CXXFLAGS += `sdl2-config --cflags`
+CXXFLAGS += -Wall -Wformat
+CFLAGS = $(CXXFLAGS)
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.mm
+ $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $<
+
+%.o:%.mm
+ $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/third_party/imgui/examples/example_sdl_metal/main.mm b/third_party/imgui/examples/example_sdl_metal/main.mm
new file mode 100644
index 0000000000..3cb1ea4d3d
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_metal/main.mm
@@ -0,0 +1,179 @@
+// Dear ImGui: standalone example application for SDL2 + Metal
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+#include "imgui_impl_metal.h"
+#include
+#include
+
+#import
+#import
+
+int main(int, char**)
+{
+ // Setup Dear ImGui binding
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // 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 'docs/FONTS.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);
+
+ // Setup SDL
+ // (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
+ // depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!)
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
+ {
+ printf("Error: %s\n", SDL_GetError());
+ return -1;
+ }
+
+ // Inform SDL that we will be using metal for rendering. Without this hint initialization of metal renderer may fail.
+ SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");
+
+ SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL+Metal example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
+ if (window == NULL)
+ {
+ printf("Error creating window: %s\n", SDL_GetError());
+ return -2;
+ }
+
+ SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
+ if (renderer == NULL)
+ {
+ printf("Error creating renderer: %s\n", SDL_GetError());
+ return -3;
+ }
+
+ CAMetalLayer* layer = (__bridge CAMetalLayer*)SDL_RenderGetMetalLayer(renderer);
+ layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
+ ImGui_ImplMetal_Init(layer.device);
+ ImGui_ImplSDL2_InitForMetal(window);
+
+ id commandQueue = [layer.device newCommandQueue];
+ MTLRenderPassDescriptor* renderPassDescriptor = [MTLRenderPassDescriptor new];
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ float clear_color[4] = {0.45f, 0.55f, 0.60f, 1.00f};
+
+ // Main loop
+ bool done = false;
+ while (!done)
+ {
+ @autoreleasepool
+ {
+ // Poll and handle events (inputs, window resize, etc.)
+ // 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.
+ SDL_Event event;
+ while (SDL_PollEvent(&event))
+ {
+ ImGui_ImplSDL2_ProcessEvent(&event);
+ if (event.type == SDL_QUIT)
+ done = true;
+ if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
+ done = true;
+ }
+
+ int width, height;
+ SDL_GetRendererOutputSize(renderer, &width, &height);
+ layer.drawableSize = CGSizeMake(width, height);
+ id drawable = [layer nextDrawable];
+
+ id commandBuffer = [commandQueue commandBuffer];
+ renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
+ renderPassDescriptor.colorAttachments[0].texture = drawable.texture;
+ renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
+ renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore;
+ id renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
+ [renderEncoder pushDebugGroup:@"ImGui demo"];
+
+ // Start the Dear ImGui frame
+ ImGui_ImplMetal_NewFrame(renderPassDescriptor);
+ ImGui_ImplSDL2_NewFrame(window);
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
+
+ [renderEncoder popDebugGroup];
+ [renderEncoder endEncoding];
+
+ [commandBuffer presentDrawable:drawable];
+ [commandBuffer commit];
+ }
+ }
+
+ // Cleanup
+ ImGui_ImplMetal_Shutdown();
+ ImGui_ImplSDL2_Shutdown();
+ ImGui::DestroyContext();
+
+ SDL_DestroyRenderer(renderer);
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+
+ return 0;
+}
diff --git a/third_party/imgui/examples/example_sdl_opengl2/Makefile b/third_party/imgui/examples/example_sdl_opengl2/Makefile
new file mode 100644
index 0000000000..9c57337e96
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_opengl2/Makefile
@@ -0,0 +1,78 @@
+#
+# Cross Platform Makefile
+# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
+#
+# You will need SDL2 (http://www.libsdl.org):
+# Linux:
+# apt-get install libsdl2-dev
+# Mac OS X:
+# brew install sdl2
+# MSYS2:
+# pacman -S mingw-w64-i686-SDL2
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_sdl_opengl2
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_sdl.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)
+
+CXXFLAGS = -I../ -I../../
+CXXFLAGS += -g -Wall -Wformat
+LIBS =
+
+##---------------------------------------------------------------------
+## BUILD FLAGS PER PLATFORM
+##---------------------------------------------------------------------
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS += -lGL -ldl `sdl2-config --libs`
+
+ CXXFLAGS += `sdl2-config --cflags`
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
+ LIBS += -L/usr/local/lib -L/opt/local/lib
+
+ CXXFLAGS += `sdl2-config --cflags`
+ CXXFLAGS += -I/usr/local/include -I/opt/local/include
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "MinGW"
+ LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
+
+ CXXFLAGS += `pkg-config --cflags sdl2`
+ CFLAGS = $(CXXFLAGS)
+endif
+
+##---------------------------------------------------------------------
+## BUILD RULES
+##---------------------------------------------------------------------
+
+%.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/third_party/imgui/examples/example_sdl_opengl2/README.md b/third_party/imgui/examples/example_sdl_opengl2/README.md
new file mode 100644
index 0000000000..60a5e377fd
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_opengl2/README.md
@@ -0,0 +1,25 @@
+
+# How to Build
+
+- On Windows with Visual Studio's CLI
+
+```
+set SDL2_DIR=path_to_your_sdl2_folder
+cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
+# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
+# or for 64-bit:
+cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
+```
+
+- On Linux and similar Unixes
+
+```
+c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL
+```
+
+- On Mac OS X
+
+```
+brew install sdl2
+c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl
+```
diff --git a/third_party/imgui/examples/example_sdl_opengl2/build_win32.bat b/third_party/imgui/examples/example_sdl_opengl2/build_win32.bat
new file mode 100644
index 0000000000..d209b2a2ad
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_opengl2/build_win32.bat
@@ -0,0 +1,8 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+set OUT_DIR=Debug
+set OUT_EXE=example_sdl_opengl2
+set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include
+set SOURCES=main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp
+set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib
+mkdir %OUT_DIR%
+cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
diff --git a/third_party/imgui/examples/sdl_opengl2_example/sdl_opengl2_example.vcxproj b/third_party/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj
similarity index 88%
rename from third_party/imgui/examples/sdl_opengl2_example/sdl_opengl2_example.vcxproj
rename to third_party/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj
index 1f9f817748..83a6a8a02c 100644
--- a/third_party/imgui/examples/sdl_opengl2_example/sdl_opengl2_example.vcxproj
+++ b/third_party/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj
@@ -20,30 +20,35 @@
{2AE17FDE-F7F3-4CAC-ADAB-0710EDA4F741}
- opengl3_example
+ example_sdl_opengl2
+ 8.1
Application
true
MultiByte
+ v110
Application
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
@@ -85,7 +90,7 @@
Level4
Disabled
- %SDL2_DIR%\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
true
@@ -99,7 +104,7 @@
Level4
Disabled
- %SDL2_DIR%\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
true
@@ -115,7 +120,7 @@
MaxSpeed
true
true
- %SDL2_DIR%\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
false
@@ -135,7 +140,7 @@
MaxSpeed
true
true
- %SDL2_DIR%\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
false
@@ -153,14 +158,17 @@
-
+
+
+
-
+
+
diff --git a/third_party/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters b/third_party/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters
new file mode 100644
index 0000000000..e0c1bf2ebb
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters
@@ -0,0 +1,58 @@
+
+
+
+
+ {20b90ce4-7fcb-4731-b9a0-075f875de82d}
+
+
+ {f18ab499-84e1-499f-8eff-9754361e0e52}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+
+ sources
+
+
+
\ No newline at end of file
diff --git a/third_party/imgui/examples/sdl_opengl2_example/main.cpp b/third_party/imgui/examples/example_sdl_opengl2/main.cpp
similarity index 59%
rename from third_party/imgui/examples/sdl_opengl2_example/main.cpp
rename to third_party/imgui/examples/example_sdl_opengl2/main.cpp
index 8f4ca93dcb..fcd9ae3255 100644
--- a/third_party/imgui/examples/sdl_opengl2_example/main.cpp
+++ b/third_party/imgui/examples/example_sdl_opengl2/main.cpp
@@ -1,21 +1,25 @@
-// ImGui - standalone example application for SDL2 + OpenGL
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
+// dear imgui: standalone example application for SDL2 + OpenGL
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
-// **Prefer using the code in the sdl_opengl3_example/ folder**
+// **Prefer using the code in the example_sdl_opengl3/ folder**
// See imgui_impl_sdl.cpp for details.
#include "imgui.h"
-#include "imgui_impl_sdl_gl2.h"
+#include "imgui_impl_sdl.h"
+#include "imgui_impl_opengl2.h"
#include
#include
#include
+// Main code
int main(int, char**)
{
// Setup SDL
- if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0)
+ // (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
+ // depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!)
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
{
printf("Error: %s\n", SDL_GetError());
return -1;
@@ -27,28 +31,33 @@ int main(int, char**)
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
- SDL_DisplayMode current;
- SDL_GetCurrentDisplayMode(0, ¤t);
- SDL_Window *window = SDL_CreateWindow("ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
- SDL_GLContext glcontext = SDL_GL_CreateContext(window);
+ SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
+ SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
+ SDL_GLContext gl_context = SDL_GL_CreateContext(window);
+ SDL_GL_MakeCurrent(window, gl_context);
SDL_GL_SetSwapInterval(1); // Enable vsync
- // Setup ImGui binding
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_ImplSdlGL2_Init(window);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
- // Setup style
+ // Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();
+ // Setup Platform/Renderer bindings
+ ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
+ 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 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.
+ // - Read 'docs/FONTS.md' 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);
@@ -58,6 +67,7 @@ int main(int, char**)
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
//IM_ASSERT(font != NULL);
+ // Our state
bool show_demo_window = true;
bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
@@ -66,6 +76,7 @@ int main(int, char**)
bool done = false;
while (!done)
{
+ // Poll and handle events (inputs, window resize, etc.)
// 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.
@@ -73,64 +84,69 @@ int main(int, char**)
SDL_Event event;
while (SDL_PollEvent(&event))
{
- ImGui_ImplSdlGL2_ProcessEvent(&event);
+ ImGui_ImplSDL2_ProcessEvent(&event);
if (event.type == SDL_QUIT)
done = true;
}
- ImGui_ImplSdlGL2_NewFrame(window);
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL2_NewFrame();
+ ImGui_ImplSDL2_NewFrame(window);
+ ImGui::NewFrame();
+
+ // 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::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
+ 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);
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: most widgets return true when edited/activated)
+ 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();
}
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
+ // 3. Show another simple window.
if (show_another_window)
{
- ImGui::Begin("Another Window", &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();
}
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
// Rendering
- glViewport(0, 0, (int)ImGui::GetIO().DisplaySize.x, (int)ImGui::GetIO().DisplaySize.y);
+ ImGui::Render();
+ glViewport(0, 0, (int)io.DisplaySize.x, (int)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
- ImGui::Render();
- ImGui_ImplSdlGL2_RenderDrawData(ImGui::GetDrawData());
+ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
SDL_GL_SwapWindow(window);
}
// Cleanup
- ImGui_ImplSdlGL2_Shutdown();
+ ImGui_ImplOpenGL2_Shutdown();
+ ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext();
- SDL_GL_DeleteContext(glcontext);
+ SDL_GL_DeleteContext(gl_context);
SDL_DestroyWindow(window);
SDL_Quit();
diff --git a/third_party/imgui/examples/example_sdl_opengl3/Makefile b/third_party/imgui/examples/example_sdl_opengl3/Makefile
new file mode 100644
index 0000000000..41826741b2
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_opengl3/Makefile
@@ -0,0 +1,110 @@
+#
+# Cross Platform Makefile
+# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
+#
+# You will need SDL2 (http://www.libsdl.org):
+# Linux:
+# apt-get install libsdl2-dev
+# Mac OS X:
+# brew install sdl2
+# MSYS2:
+# pacman -S mingw-w64-i686-SDL2
+#
+
+#CXX = g++
+#CXX = clang++
+
+EXE = example_sdl_opengl3
+SOURCES = main.cpp
+SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
+OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
+UNAME_S := $(shell uname -s)
+
+CXXFLAGS = -I../ -I../../
+CXXFLAGS += -g -Wall -Wformat
+LIBS =
+
+##---------------------------------------------------------------------
+## OPENGL LOADER
+##---------------------------------------------------------------------
+
+## Using OpenGL loader: gl3w [default]
+SOURCES += ../libs/gl3w/GL/gl3w.c
+CXXFLAGS += -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W
+
+## Using OpenGL loader: glew
+## (This assumes a system-wide installation)
+# CXXFLAGS += -DIMGUI_IMPL_OPENGL_LOADER_GLEW
+# LIBS += -lGLEW
+
+## Using OpenGL loader: glad
+# SOURCES += ../libs/glad/src/glad.c
+# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
+
+## Using OpenGL loader: glbinding
+## This assumes a system-wide installation
+## of either version 3.0.0 (or newer)
+# CXXFLAGS += -DIMGUI_IMPL_OPENGL_LOADER_GLBINDING3
+# LIBS += -lglbinding
+## or the older version 2.x
+# CXXFLAGS += -DIMGUI_IMPL_OPENGL_LOADER_GLBINDING2
+# LIBS += -lglbinding
+
+##---------------------------------------------------------------------
+## BUILD FLAGS PER PLATFORM
+##---------------------------------------------------------------------
+
+ifeq ($(UNAME_S), Linux) #LINUX
+ ECHO_MESSAGE = "Linux"
+ LIBS += -lGL -ldl `sdl2-config --libs`
+
+ CXXFLAGS += `sdl2-config --cflags`
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(UNAME_S), Darwin) #APPLE
+ ECHO_MESSAGE = "Mac OS X"
+ LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
+ LIBS += -L/usr/local/lib -L/opt/local/lib
+
+ CXXFLAGS += `sdl2-config --cflags`
+ CXXFLAGS += -I/usr/local/include -I/opt/local/include
+ CFLAGS = $(CXXFLAGS)
+endif
+
+ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
+ ECHO_MESSAGE = "MinGW"
+ LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
+
+ CXXFLAGS += `pkg-config --cflags sdl2`
+ CFLAGS = $(CXXFLAGS)
+endif
+
+##---------------------------------------------------------------------
+## BUILD RULES
+##---------------------------------------------------------------------
+
+%.o:%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../../%.cpp
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+%.o:../libs/gl3w/GL/%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.o:../libs/glad/src/%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+all: $(EXE)
+ @echo Build complete for $(ECHO_MESSAGE)
+
+$(EXE): $(OBJS)
+ $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
+
+clean:
+ rm -f $(EXE) $(OBJS)
diff --git a/third_party/imgui/examples/example_sdl_opengl3/README.md b/third_party/imgui/examples/example_sdl_opengl3/README.md
new file mode 100644
index 0000000000..ec21fb78aa
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_opengl3/README.md
@@ -0,0 +1,25 @@
+
+# How to Build
+
+- On Windows with Visual Studio's CLI
+
+```
+set SDL2_DIR=path_to_your_sdl2_folder
+cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include /I..\libs\gl3w main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
+# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
+# or for 64-bit:
+cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include /I..\libs\gl3w main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
+```
+
+- On Linux and similar Unixes
+
+```
+c++ `sdl2-config --cflags` -I .. -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -lGL -ldl
+```
+
+- On Mac OS X
+
+```
+brew install sdl2
+c++ `sdl2-config --cflags` -I .. -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -framework OpenGl -framework CoreFoundation
+```
diff --git a/third_party/imgui/examples/example_sdl_opengl3/build_win32.bat b/third_party/imgui/examples/example_sdl_opengl3/build_win32.bat
new file mode 100644
index 0000000000..ce105602f7
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_opengl3/build_win32.bat
@@ -0,0 +1,8 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+set OUT_DIR=Debug
+set OUT_EXE=example_sdl_opengl3
+set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include /I..\libs\gl3w
+set SOURCES=main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c
+set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib
+mkdir %OUT_DIR%
+cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
diff --git a/third_party/imgui/examples/sdl_opengl3_example/sdl_opengl3_example.vcxproj b/third_party/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj
similarity index 88%
rename from third_party/imgui/examples/sdl_opengl3_example/sdl_opengl3_example.vcxproj
rename to third_party/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj
index 7bae65a8d8..54aaa79661 100644
--- a/third_party/imgui/examples/sdl_opengl3_example/sdl_opengl3_example.vcxproj
+++ b/third_party/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj
@@ -20,30 +20,35 @@
{BBAEB705-1669-40F3-8567-04CF6A991F4C}
- opengl3_example
+ example_sdl_opengl3
+ 8.1
Application
true
MultiByte
+ v110
Application
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
Application
false
true
MultiByte
+ v110
@@ -85,7 +90,7 @@
Level4
Disabled
- %SDL2_DIR%\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories)
true
@@ -99,7 +104,7 @@
Level4
Disabled
- %SDL2_DIR%\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories)
true
@@ -115,7 +120,7 @@
MaxSpeed
true
true
- %SDL2_DIR%\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories)
false
@@ -135,7 +140,7 @@
MaxSpeed
true
true
- %SDL2_DIR%\include;$(SolutionDir)\libs\gl3w;..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories)
false
@@ -153,17 +158,20 @@
+
+
+
-
+
+
-
diff --git a/third_party/imgui/examples/sdl_opengl3_example/sdl_opengl3_example.vcxproj.filters b/third_party/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters
similarity index 82%
rename from third_party/imgui/examples/sdl_opengl3_example/sdl_opengl3_example.vcxproj.filters
rename to third_party/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters
index f8f434155c..fbef18ac91 100644
--- a/third_party/imgui/examples/sdl_opengl3_example/sdl_opengl3_example.vcxproj.filters
+++ b/third_party/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters
@@ -22,15 +22,21 @@
imgui
-
- sources
-
sources
gl3w
+
+ sources
+
+
+ sources
+
+
+ imgui
+
@@ -42,15 +48,18 @@
imgui
-
- sources
-
gl3w
gl3w
+
+ sources
+
+
+ sources
+
diff --git a/third_party/imgui/examples/example_sdl_opengl3/main.cpp b/third_party/imgui/examples/example_sdl_opengl3/main.cpp
new file mode 100644
index 0000000000..3146084dcd
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_opengl3/main.cpp
@@ -0,0 +1,212 @@
+// dear imgui: standalone example application for SDL2 + OpenGL
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
+// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+#include "imgui_impl_opengl3.h"
+#include
+#include
+
+// About Desktop OpenGL function loaders:
+// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
+// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
+// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
+#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
+#include // Initialize with gl3wInit()
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
+#include // Initialize with glewInit()
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
+#include // Initialize with gladLoadGL()
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
+#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
+#include // Initialize with glbinding::Binding::initialize()
+#include
+using namespace gl;
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
+#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
+#include // Initialize with glbinding::initialize()
+#include
+using namespace gl;
+#else
+#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
+#endif
+
+// Main code
+int main(int, char**)
+{
+ // Setup SDL
+ // (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
+ // depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!)
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
+ {
+ printf("Error: %s\n", SDL_GetError());
+ return -1;
+ }
+
+ // Decide GL+GLSL versions
+#if __APPLE__
+ // GL 3.2 Core + GLSL 150
+ const char* glsl_version = "#version 150";
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); // Always required on Mac
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
+#else
+ // GL 3.0 + GLSL 130
+ const char* glsl_version = "#version 130";
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
+#endif
+
+ // Create window with graphics context
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
+ SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
+ SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
+ SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
+ SDL_GLContext gl_context = SDL_GL_CreateContext(window);
+ SDL_GL_MakeCurrent(window, gl_context);
+ SDL_GL_SetSwapInterval(1); // Enable vsync
+
+ // Initialize OpenGL loader
+#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
+ bool err = gl3wInit() != 0;
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
+ bool err = glewInit() != GLEW_OK;
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
+ bool err = gladLoadGL() == 0;
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
+ bool err = false;
+ glbinding::Binding::initialize();
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
+ bool err = false;
+ glbinding::initialize([](const char* name) { return (glbinding::ProcAddress)SDL_GL_GetProcAddress(name); });
+#else
+ bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader is likely to requires some form of initialization.
+#endif
+ if (err)
+ {
+ fprintf(stderr, "Failed to initialize OpenGL loader!\n");
+ return 1;
+ }
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
+ ImGui_ImplOpenGL3_Init(glsl_version);
+
+ // 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 'docs/FONTS.md' 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);
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+ // Main loop
+ bool done = false;
+ while (!done)
+ {
+ // Poll and handle events (inputs, window resize, etc.)
+ // 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.
+ SDL_Event event;
+ while (SDL_PollEvent(&event))
+ {
+ ImGui_ImplSDL2_ProcessEvent(&event);
+ if (event.type == SDL_QUIT)
+ done = true;
+ if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
+ done = true;
+ }
+
+ // Start the Dear ImGui frame
+ ImGui_ImplOpenGL3_NewFrame();
+ ImGui_ImplSDL2_NewFrame(window);
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
+ glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
+ SDL_GL_SwapWindow(window);
+ }
+
+ // Cleanup
+ ImGui_ImplOpenGL3_Shutdown();
+ ImGui_ImplSDL2_Shutdown();
+ ImGui::DestroyContext();
+
+ SDL_GL_DeleteContext(gl_context);
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+
+ return 0;
+}
diff --git a/third_party/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj b/third_party/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj
new file mode 100644
index 0000000000..ac701a2a80
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj
@@ -0,0 +1,180 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {BAE3D0B5-9695-4EB1-AD0F-75890EB4A3B3}
+ example_sdl_vulkan
+ 8.1
+
+
+
+ Application
+ true
+ MultiByte
+ v110
+
+
+ Application
+ true
+ MultiByte
+ v110
+
+
+ Application
+ false
+ true
+ MultiByte
+ v110
+
+
+ Application
+ false
+ true
+ MultiByte
+ v110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+ $(ProjectDir)$(Configuration)\
+ $(ProjectDir)$(Configuration)\
+ $(IncludePath)
+
+
+
+ Level4
+ Disabled
+ ..\..;..;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+
+
+ true
+ %VULKAN_SDK%\lib32;%SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories)
+ vulkan-1.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ Disabled
+ ..\..;..;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+
+
+ true
+ %VULKAN_SDK%\lib;%SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories)
+ vulkan-1.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies)
+ Console
+ msvcrt.lib
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ ..\..;..;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ %VULKAN_SDK%\lib32;%SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories)
+ vulkan-1.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+ Level4
+ MaxSpeed
+ true
+ true
+ ..\..;..;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)
+ false
+
+
+ true
+ true
+ true
+ %VULKAN_SDK%\lib;%SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories)
+ vulkan-1.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies)
+ Console
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/third_party/imgui/examples/sdl_opengl2_example/sdl_opengl2_example.vcxproj.filters b/third_party/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters
similarity index 78%
rename from third_party/imgui/examples/sdl_opengl2_example/sdl_opengl2_example.vcxproj.filters
rename to third_party/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters
index 1c505f4e57..6f08252419 100644
--- a/third_party/imgui/examples/sdl_opengl2_example/sdl_opengl2_example.vcxproj.filters
+++ b/third_party/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters
@@ -19,12 +19,18 @@
imgui
+
+ sources
+
sources
-
+
sources
+
+ imgui
+
@@ -36,7 +42,10 @@
imgui
-
+
+ sources
+
+
sources
diff --git a/third_party/imgui/examples/example_sdl_vulkan/main.cpp b/third_party/imgui/examples/example_sdl_vulkan/main.cpp
new file mode 100644
index 0000000000..0a2ea9ee78
--- /dev/null
+++ b/third_party/imgui/examples/example_sdl_vulkan/main.cpp
@@ -0,0 +1,535 @@
+// dear imgui: standalone example application for SDL2 + Vulkan
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
+
+// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
+// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
+// You will use those if you want to use this rendering back-end in your engine/app.
+// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by
+// the back-end itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code.
+// Read comments in imgui_impl_vulkan.h.
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+#include "imgui_impl_vulkan.h"
+#include // printf, fprintf
+#include // abort
+#include
+#include
+#include
+
+//#define IMGUI_UNLIMITED_FRAME_RATE
+#ifdef _DEBUG
+#define IMGUI_VULKAN_DEBUG_REPORT
+#endif
+
+static VkAllocationCallbacks* g_Allocator = NULL;
+static VkInstance g_Instance = VK_NULL_HANDLE;
+static VkPhysicalDevice g_PhysicalDevice = VK_NULL_HANDLE;
+static VkDevice g_Device = VK_NULL_HANDLE;
+static uint32_t g_QueueFamily = (uint32_t)-1;
+static VkQueue g_Queue = VK_NULL_HANDLE;
+static VkDebugReportCallbackEXT g_DebugReport = VK_NULL_HANDLE;
+static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE;
+static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
+
+static ImGui_ImplVulkanH_Window g_MainWindowData;
+static uint32_t g_MinImageCount = 2;
+static bool g_SwapChainRebuild = false;
+static int g_SwapChainResizeWidth = 0;
+static int g_SwapChainResizeHeight = 0;
+
+static void check_vk_result(VkResult err)
+{
+ if (err == 0)
+ return;
+ fprintf(stderr, "[vulkan] Error: VkResult = %d\n", err);
+ if (err < 0)
+ abort();
+}
+
+#ifdef IMGUI_VULKAN_DEBUG_REPORT
+static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
+{
+ (void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments
+ fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
+ return VK_FALSE;
+}
+#endif // IMGUI_VULKAN_DEBUG_REPORT
+
+static void SetupVulkan(const char** extensions, uint32_t extensions_count)
+{
+ VkResult err;
+
+ // Create Vulkan Instance
+ {
+ VkInstanceCreateInfo create_info = {};
+ create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
+ create_info.enabledExtensionCount = extensions_count;
+ create_info.ppEnabledExtensionNames = extensions;
+
+#ifdef IMGUI_VULKAN_DEBUG_REPORT
+ // Enabling multiple validation layers grouped as LunarG standard validation
+ const char* layers[] = { "VK_LAYER_LUNARG_standard_validation" };
+ create_info.enabledLayerCount = 1;
+ create_info.ppEnabledLayerNames = layers;
+
+ // Enable debug report extension (we need additional storage, so we duplicate the user array to add our new extension to it)
+ const char** extensions_ext = (const char**)malloc(sizeof(const char*) * (extensions_count + 1));
+ memcpy(extensions_ext, extensions, extensions_count * sizeof(const char*));
+ extensions_ext[extensions_count] = "VK_EXT_debug_report";
+ create_info.enabledExtensionCount = extensions_count + 1;
+ create_info.ppEnabledExtensionNames = extensions_ext;
+
+ // Create Vulkan Instance
+ err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
+ check_vk_result(err);
+ free(extensions_ext);
+
+ // Get the function pointer (required for any extensions)
+ auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
+ IM_ASSERT(vkCreateDebugReportCallbackEXT != NULL);
+
+ // Setup the debug report callback
+ VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
+ debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
+ debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
+ debug_report_ci.pfnCallback = debug_report;
+ debug_report_ci.pUserData = NULL;
+ err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
+ check_vk_result(err);
+#else
+ // Create Vulkan Instance without any debug feature
+ err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
+ check_vk_result(err);
+ IM_UNUSED(g_DebugReport);
+#endif
+ }
+
+ // Select GPU
+ {
+ uint32_t gpu_count;
+ err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, NULL);
+ check_vk_result(err);
+ IM_ASSERT(gpu_count > 0);
+
+ VkPhysicalDevice* gpus = (VkPhysicalDevice*)malloc(sizeof(VkPhysicalDevice) * gpu_count);
+ err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus);
+ check_vk_result(err);
+
+ // If a number >1 of GPUs got reported, you should find the best fit GPU for your purpose
+ // e.g. VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU if available, or with the greatest memory available, etc.
+ // for sake of simplicity we'll just take the first one, assuming it has a graphics queue family.
+ g_PhysicalDevice = gpus[0];
+ free(gpus);
+ }
+
+ // Select graphics queue family
+ {
+ uint32_t count;
+ vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, NULL);
+ VkQueueFamilyProperties* queues = (VkQueueFamilyProperties*)malloc(sizeof(VkQueueFamilyProperties) * count);
+ vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, queues);
+ for (uint32_t i = 0; i < count; i++)
+ if (queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
+ {
+ g_QueueFamily = i;
+ break;
+ }
+ free(queues);
+ IM_ASSERT(g_QueueFamily != (uint32_t)-1);
+ }
+
+ // Create Logical Device (with 1 queue)
+ {
+ int device_extension_count = 1;
+ const char* device_extensions[] = { "VK_KHR_swapchain" };
+ const float queue_priority[] = { 1.0f };
+ VkDeviceQueueCreateInfo queue_info[1] = {};
+ queue_info[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
+ queue_info[0].queueFamilyIndex = g_QueueFamily;
+ queue_info[0].queueCount = 1;
+ queue_info[0].pQueuePriorities = queue_priority;
+ VkDeviceCreateInfo create_info = {};
+ create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
+ create_info.queueCreateInfoCount = sizeof(queue_info) / sizeof(queue_info[0]);
+ create_info.pQueueCreateInfos = queue_info;
+ create_info.enabledExtensionCount = device_extension_count;
+ create_info.ppEnabledExtensionNames = device_extensions;
+ err = vkCreateDevice(g_PhysicalDevice, &create_info, g_Allocator, &g_Device);
+ check_vk_result(err);
+ vkGetDeviceQueue(g_Device, g_QueueFamily, 0, &g_Queue);
+ }
+
+ // Create Descriptor Pool
+ {
+ VkDescriptorPoolSize pool_sizes[] =
+ {
+ { VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
+ { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 },
+ { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
+ { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 },
+ { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 },
+ { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
+ { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
+ { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 }
+ };
+ VkDescriptorPoolCreateInfo pool_info = {};
+ pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
+ pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
+ pool_info.maxSets = 1000 * IM_ARRAYSIZE(pool_sizes);
+ pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
+ pool_info.pPoolSizes = pool_sizes;
+ err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
+ check_vk_result(err);
+ }
+}
+
+// All the ImGui_ImplVulkanH_XXX structures/functions are optional helpers used by the demo.
+// Your real engine/app may not use them.
+static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface, int width, int height)
+{
+ wd->Surface = surface;
+
+ // Check for WSI support
+ VkBool32 res;
+ vkGetPhysicalDeviceSurfaceSupportKHR(g_PhysicalDevice, g_QueueFamily, wd->Surface, &res);
+ if (res != VK_TRUE)
+ {
+ fprintf(stderr, "Error no WSI support on physical device 0\n");
+ exit(-1);
+ }
+
+ // Select Surface Format
+ const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
+ const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
+ wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
+
+ // Select Present Mode
+#ifdef IMGUI_UNLIMITED_FRAME_RATE
+ VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
+#else
+ VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
+#endif
+ wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes));
+ //printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode);
+
+ // Create SwapChain, RenderPass, Framebuffer, etc.
+ IM_ASSERT(g_MinImageCount >= 2);
+ ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
+}
+
+static void CleanupVulkan()
+{
+ vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
+
+#ifdef IMGUI_VULKAN_DEBUG_REPORT
+ // Remove the debug report callback
+ auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
+ vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
+#endif // IMGUI_VULKAN_DEBUG_REPORT
+
+ vkDestroyDevice(g_Device, g_Allocator);
+ vkDestroyInstance(g_Instance, g_Allocator);
+}
+
+static void CleanupVulkanWindow()
+{
+ ImGui_ImplVulkanH_DestroyWindow(g_Instance, g_Device, &g_MainWindowData, g_Allocator);
+}
+
+static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
+{
+ VkResult err;
+
+ VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].ImageAcquiredSemaphore;
+ VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
+ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
+ check_vk_result(err);
+
+ ImGui_ImplVulkanH_Frame* 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 = 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 = fd->Framebuffer;
+ 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 dear imgui primitives into command buffer
+ ImGui_ImplVulkan_RenderDrawData(draw_data, 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 = &render_complete_semaphore;
+
+ 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_Window* wd)
+{
+ VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
+ VkPresentInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ info.waitSemaphoreCount = 1;
+ info.pWaitSemaphores = &render_complete_semaphore;
+ info.swapchainCount = 1;
+ info.pSwapchains = &wd->Swapchain;
+ info.pImageIndices = &wd->FrameIndex;
+ VkResult err = vkQueuePresentKHR(g_Queue, &info);
+ check_vk_result(err);
+ wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
+}
+
+int main(int, char**)
+{
+ // Setup SDL
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
+ {
+ printf("Error: %s\n", SDL_GetError());
+ return -1;
+ }
+
+ // Setup window
+ SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
+ SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
+
+ // Setup Vulkan
+ uint32_t extensions_count = 0;
+ SDL_Vulkan_GetInstanceExtensions(window, &extensions_count, NULL);
+ const char** extensions = new const char*[extensions_count];
+ SDL_Vulkan_GetInstanceExtensions(window, &extensions_count, extensions);
+ SetupVulkan(extensions, extensions_count);
+ delete[] extensions;
+
+ // Create Window Surface
+ VkSurfaceKHR surface;
+ VkResult err;
+ if (SDL_Vulkan_CreateSurface(window, g_Instance, &surface) == 0)
+ {
+ printf("Failed to create Vulkan surface.\n");
+ return 1;
+ }
+
+ // Create Framebuffers
+ int w, h;
+ SDL_GetWindowSize(window, &w, &h);
+ ImGui_ImplVulkanH_Window* wd = &g_MainWindowData;
+ SetupVulkanWindow(wd, surface, w, h);
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplSDL2_InitForVulkan(window);
+ ImGui_ImplVulkan_InitInfo init_info = {};
+ init_info.Instance = g_Instance;
+ init_info.PhysicalDevice = g_PhysicalDevice;
+ init_info.Device = g_Device;
+ init_info.QueueFamily = g_QueueFamily;
+ init_info.Queue = g_Queue;
+ init_info.PipelineCache = g_PipelineCache;
+ init_info.DescriptorPool = g_DescriptorPool;
+ init_info.Allocator = g_Allocator;
+ init_info.MinImageCount = g_MinImageCount;
+ init_info.ImageCount = wd->ImageCount;
+ init_info.CheckVkResultFn = check_vk_result;
+ ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
+
+ // 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 'docs/FONTS.md' 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);
+
+ // Upload Fonts
+ {
+ // Use any command queue
+ VkCommandPool command_pool = wd->Frames[wd->FrameIndex].CommandPool;
+ VkCommandBuffer command_buffer = wd->Frames[wd->FrameIndex].CommandBuffer;
+
+ err = vkResetCommandPool(g_Device, command_pool, 0);
+ check_vk_result(err);
+ VkCommandBufferBeginInfo begin_info = {};
+ begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ begin_info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ err = vkBeginCommandBuffer(command_buffer, &begin_info);
+ check_vk_result(err);
+
+ ImGui_ImplVulkan_CreateFontsTexture(command_buffer);
+
+ VkSubmitInfo end_info = {};
+ end_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ end_info.commandBufferCount = 1;
+ end_info.pCommandBuffers = &command_buffer;
+ err = vkEndCommandBuffer(command_buffer);
+ check_vk_result(err);
+ err = vkQueueSubmit(g_Queue, 1, &end_info, VK_NULL_HANDLE);
+ check_vk_result(err);
+
+ err = vkDeviceWaitIdle(g_Device);
+ check_vk_result(err);
+ ImGui_ImplVulkan_DestroyFontUploadObjects();
+ }
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+ // Main loop
+ bool done = false;
+ while (!done)
+ {
+ // Poll and handle events (inputs, window resize, etc.)
+ // 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.
+ SDL_Event event;
+ while (SDL_PollEvent(&event))
+ {
+ ImGui_ImplSDL2_ProcessEvent(&event);
+ if (event.type == SDL_QUIT)
+ done = true;
+ if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED && event.window.windowID == SDL_GetWindowID(window))
+ {
+ // Note: your own application may rely on SDL_WINDOWEVENT_MINIMIZED/SDL_WINDOWEVENT_RESTORED to skip updating all-together.
+ // Here ImGui_ImplSDL2_NewFrame() will set io.DisplaySize to zero which will disable rendering but let application run.
+ // Please note that you can't Present into a minimized window.
+ g_SwapChainResizeWidth = (int)event.window.data1;
+ g_SwapChainResizeHeight = (int)event.window.data2;
+ g_SwapChainRebuild = true;
+ }
+ }
+
+ // Resize swap chain?
+ if (g_SwapChainRebuild && g_SwapChainResizeWidth > 0 && g_SwapChainResizeHeight > 0)
+ {
+ g_SwapChainRebuild = false;
+ ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
+ ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, g_SwapChainResizeWidth, g_SwapChainResizeHeight, g_MinImageCount);
+ g_MainWindowData.FrameIndex = 0;
+ }
+
+ // Start the Dear ImGui frame
+ ImGui_ImplVulkan_NewFrame();
+ ImGui_ImplSDL2_NewFrame(window);
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ ImDrawData* draw_data = ImGui::GetDrawData();
+ const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
+ if (!is_minimized)
+ {
+ FrameRender(wd, draw_data);
+ FramePresent(wd);
+ }
+ }
+
+ // Cleanup
+ err = vkDeviceWaitIdle(g_Device);
+ check_vk_result(err);
+ ImGui_ImplVulkan_Shutdown();
+ ImGui_ImplSDL2_Shutdown();
+ ImGui::DestroyContext();
+
+ CleanupVulkanWindow();
+ CleanupVulkan();
+
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+
+ return 0;
+}
diff --git a/third_party/imgui/examples/example_win32_directx10/build_win32.bat b/third_party/imgui/examples/example_win32_directx10/build_win32.bat
new file mode 100644
index 0000000000..d79cb8f7b5
--- /dev/null
+++ b/third_party/imgui/examples/example_win32_directx10/build_win32.bat
@@ -0,0 +1,4 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_win32.cpp ..\imgui_impl_dx10.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx10.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d10.lib d3dcompiler.lib
+
diff --git a/third_party/imgui/examples/directx10_example/directx10_example.vcxproj b/third_party/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj
similarity index 87%
rename from third_party/imgui/examples/directx10_example/directx10_example.vcxproj
rename to third_party/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj
index 64b57ddf17..5c3aa69f4a 100644
--- a/third_party/imgui/examples/directx10_example/directx10_example.vcxproj
+++ b/third_party/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj
@@ -20,30 +20,35 @@
{345A953E-A004-4648-B442-DC5F9F11068C}
- directx10_example
+ example_win32_directx10
+ 8.1
Application
true
Unicode
+ v110
Application
true
Unicode
+ v110
Application
false
true
Unicode
+ v110
Application
false
true
Unicode
+ v110
@@ -81,7 +86,7 @@
Level4
Disabled
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);
true
@@ -94,7 +99,7 @@
Level4
Disabled
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);
true
@@ -109,14 +114,14 @@
MaxSpeed
true
true
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);
false
true
true
true
- d3d10.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies)
+ d3d10.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)
$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)
Console
@@ -127,14 +132,14 @@
MaxSpeed
true
true
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);
false
true
true
true
- d3d10.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies)
+ d3d10.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)
$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)
Console
@@ -143,13 +148,16 @@
-
+
+
-
+
+
+
diff --git a/third_party/imgui/examples/directx11_example/directx11_example.vcxproj.filters b/third_party/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters
similarity index 77%
rename from third_party/imgui/examples/directx11_example/directx11_example.vcxproj.filters
rename to third_party/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters
index 57b74dee49..976200285b 100644
--- a/third_party/imgui/examples/directx11_example/directx11_example.vcxproj.filters
+++ b/third_party/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters
@@ -15,12 +15,15 @@
imgui
-
- sources
-
imgui
+
+ sources
+
+
+ sources
+
@@ -29,15 +32,21 @@
sources
-
- sources
-
imgui
imgui
+
+ sources
+
+
+ sources
+
+
+ imgui
+
diff --git a/third_party/imgui/examples/directx10_example/main.cpp b/third_party/imgui/examples/example_win32_directx10/main.cpp
similarity index 67%
rename from third_party/imgui/examples/directx10_example/main.cpp
rename to third_party/imgui/examples/example_win32_directx10/main.cpp
index 346fd35e29..f6b8b2155c 100644
--- a/third_party/imgui/examples/directx10_example/main.cpp
+++ b/third_party/imgui/examples/example_win32_directx10/main.cpp
@@ -1,7 +1,8 @@
-// ImGui - standalone example application for DirectX 10
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// dear imgui: standalone example application for DirectX 10
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
#include "imgui.h"
+#include "imgui_impl_win32.h"
#include "imgui_impl_dx10.h"
#include
#include
@@ -14,20 +15,151 @@ static ID3D10Device* g_pd3dDevice = NULL;
static IDXGISwapChain* g_pSwapChain = NULL;
static ID3D10RenderTargetView* g_mainRenderTargetView = NULL;
-void CreateRenderTarget()
+// Forward declarations of helper functions
+bool CreateDeviceD3D(HWND hWnd);
+void CleanupDeviceD3D();
+void CreateRenderTarget();
+void CleanupRenderTarget();
+LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// Main code
+int main(int, char**)
{
- ID3D10Texture2D* pBackBuffer;
- g_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer);
- g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView);
- pBackBuffer->Release();
+ // Create application window
+ WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
+ ::RegisterClassEx(&wc);
+ HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX10 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
+
+ // Initialize Direct3D
+ if (!CreateDeviceD3D(hwnd))
+ {
+ CleanupDeviceD3D();
+ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
+ return 1;
+ }
+
+ // Show the window
+ ::ShowWindow(hwnd, SW_SHOWDEFAULT);
+ ::UpdateWindow(hwnd);
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplWin32_Init(hwnd);
+ ImGui_ImplDX10_Init(g_pd3dDevice);
+
+ // 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 'docs/FONTS.md' 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);
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+ // Main loop
+ MSG msg;
+ ZeroMemory(&msg, sizeof(msg));
+ while (msg.message != WM_QUIT)
+ {
+ // Poll and handle messages (inputs, window resize, etc.)
+ // 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.
+ if (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
+ {
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ continue;
+ }
+
+ // Start the Dear ImGui frame
+ ImGui_ImplDX10_NewFrame();
+ ImGui_ImplWin32_NewFrame();
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
+ g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color);
+ ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
+
+ g_pSwapChain->Present(1, 0); // Present with vsync
+ //g_pSwapChain->Present(0, 0); // Present without vsync
+ }
+
+ ImGui_ImplDX10_Shutdown();
+ ImGui_ImplWin32_Shutdown();
+ ImGui::DestroyContext();
+
+ CleanupDeviceD3D();
+ ::DestroyWindow(hwnd);
+ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
+
+ return 0;
}
-void CleanupRenderTarget()
-{
- if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; }
-}
+// Helper functions
-HRESULT CreateDeviceD3D(HWND hWnd)
+bool CreateDeviceD3D(HWND hWnd)
{
// Setup swap chain
DXGI_SWAP_CHAIN_DESC sd;
@@ -49,11 +181,10 @@ HRESULT CreateDeviceD3D(HWND hWnd)
UINT createDeviceFlags = 0;
//createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
if (D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, D3D10_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice) != S_OK)
- return E_FAIL;
+ return false;
CreateRenderTarget();
-
- return S_OK;
+ return true;
}
void CleanupDeviceD3D()
@@ -63,7 +194,23 @@ void CleanupDeviceD3D()
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
}
-extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+void CreateRenderTarget()
+{
+ ID3D10Texture2D* pBackBuffer;
+ g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
+ g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView);
+ pBackBuffer->Release();
+}
+
+void CleanupRenderTarget()
+{
+ if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; }
+}
+
+// Forward declare message handler from imgui_impl_win32.cpp
+extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// Win32 message handler
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
@@ -74,11 +221,9 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SIZE:
if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED)
{
- ImGui_ImplDX10_InvalidateDeviceObjects();
CleanupRenderTarget();
g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0);
CreateRenderTarget();
- ImGui_ImplDX10_CreateDeviceObjects();
}
return 0;
case WM_SYSCOMMAND:
@@ -86,129 +231,8 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return 0;
break;
case WM_DESTROY:
- PostQuitMessage(0);
+ ::PostQuitMessage(0);
return 0;
}
- return DefWindowProc(hWnd, msg, wParam, lParam);
-}
-
-int main(int, char**)
-{
- // Create application window
- WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
- RegisterClassEx(&wc);
- HWND hwnd = CreateWindow(_T("ImGui Example"), _T("ImGui DirectX10 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
-
- // Initialize Direct3D
- if (CreateDeviceD3D(hwnd) < 0)
- {
- CleanupDeviceD3D();
- UnregisterClass(_T("ImGui Example"), wc.hInstance);
- return 1;
- }
-
- // Show the window
- ShowWindow(hwnd, SW_SHOWDEFAULT);
- UpdateWindow(hwnd);
-
- // Setup ImGui binding
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_ImplDX10_Init(hwnd, g_pd3dDevice);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
-
- // Setup style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // 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);
-
- bool show_demo_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
- // Main loop
- MSG msg;
- ZeroMemory(&msg, sizeof(msg));
- while (msg.message != WM_QUIT)
- {
- // 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.
- if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- continue;
- }
- ImGui_ImplDX10_NewFrame();
-
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
- {
- static float f = 0.0f;
- static int counter = 0;
- ImGui::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
-
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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);
- }
-
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
- // Rendering
- g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
- g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color);
- ImGui::Render();
- ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
-
- g_pSwapChain->Present(1, 0); // Present with vsync
- //g_pSwapChain->Present(0, 0); // Present without vsync
- }
-
- ImGui_ImplDX10_Shutdown();
- ImGui::DestroyContext();
-
- CleanupDeviceD3D();
- UnregisterClass(_T("ImGui Example"), wc.hInstance);
-
- return 0;
+ return ::DefWindowProc(hWnd, msg, wParam, lParam);
}
diff --git a/third_party/imgui/examples/example_win32_directx11/build_win32.bat b/third_party/imgui/examples/example_win32_directx11/build_win32.bat
new file mode 100644
index 0000000000..05e6a6f6ca
--- /dev/null
+++ b/third_party/imgui/examples/example_win32_directx11/build_win32.bat
@@ -0,0 +1,4 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_dx11.cpp ..\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx11.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
+
diff --git a/third_party/imgui/examples/directx11_example/directx11_example.vcxproj b/third_party/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj
similarity index 88%
rename from third_party/imgui/examples/directx11_example/directx11_example.vcxproj
rename to third_party/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj
index c07939f776..bcb71bc43e 100644
--- a/third_party/imgui/examples/directx11_example/directx11_example.vcxproj
+++ b/third_party/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj
@@ -20,30 +20,34 @@
{9F316E83-5AE5-4939-A723-305A94F48005}
- directx11_example
+ example_win32_directx11
Application
true
Unicode
+ v110
Application
true
Unicode
+ v110
Application
false
true
Unicode
+ v110
Application
false
true
Unicode
+ v110
@@ -81,7 +85,7 @@
Level4
Disabled
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);
true
@@ -94,7 +98,7 @@
Level4
Disabled
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);
true
@@ -109,14 +113,14 @@
MaxSpeed
true
true
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);
false
true
true
true
- d3d11.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies)
+ d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)
$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)
Console
@@ -127,14 +131,14 @@
MaxSpeed
true
true
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);
false
true
true
true
- d3d11.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies)
+ d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)
$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)
Console
@@ -143,13 +147,16 @@
-
+
+
-
+
+
+
diff --git a/third_party/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters b/third_party/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters
new file mode 100644
index 0000000000..1df6a0c415
--- /dev/null
+++ b/third_party/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters
@@ -0,0 +1,57 @@
+
+
+
+
+ {0587d7a3-f2ce-4d56-b84f-a0005d3bfce6}
+
+
+ {08e36723-ce4f-4cff-9662-c40801cf1acf}
+
+
+
+
+ imgui
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+
+
+ imgui
+
+
+ sources
+
+
+ imgui
+
+
+ imgui
+
+
+ sources
+
+
+ sources
+
+
+ imgui
+
+
+
+
+
+ sources
+
+
+
\ No newline at end of file
diff --git a/third_party/imgui/examples/directx11_example/main.cpp b/third_party/imgui/examples/example_win32_directx11/main.cpp
similarity index 68%
rename from third_party/imgui/examples/directx11_example/main.cpp
rename to third_party/imgui/examples/example_win32_directx11/main.cpp
index 518aa7c272..2cc36a7f13 100644
--- a/third_party/imgui/examples/directx11_example/main.cpp
+++ b/third_party/imgui/examples/example_win32_directx11/main.cpp
@@ -1,7 +1,8 @@
-// ImGui - standalone example application for DirectX 11
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// dear imgui - standalone example application for DirectX 11
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
#include "imgui.h"
+#include "imgui_impl_win32.h"
#include "imgui_impl_dx11.h"
#include
#define DIRECTINPUT_VERSION 0x0800
@@ -14,20 +15,152 @@ static ID3D11DeviceContext* g_pd3dDeviceContext = NULL;
static IDXGISwapChain* g_pSwapChain = NULL;
static ID3D11RenderTargetView* g_mainRenderTargetView = NULL;
-void CreateRenderTarget()
+// Forward declarations of helper functions
+bool CreateDeviceD3D(HWND hWnd);
+void CleanupDeviceD3D();
+void CreateRenderTarget();
+void CleanupRenderTarget();
+LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// Main code
+int main(int, char**)
{
- ID3D11Texture2D* pBackBuffer;
- g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
- g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView);
- pBackBuffer->Release();
+ // Create application window
+ WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
+ ::RegisterClassEx(&wc);
+ HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX11 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
+
+ // Initialize Direct3D
+ if (!CreateDeviceD3D(hwnd))
+ {
+ CleanupDeviceD3D();
+ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
+ return 1;
+ }
+
+ // Show the window
+ ::ShowWindow(hwnd, SW_SHOWDEFAULT);
+ ::UpdateWindow(hwnd);
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplWin32_Init(hwnd);
+ ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
+
+ // 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 'docs/FONTS.md' 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);
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+ // Main loop
+ MSG msg;
+ ZeroMemory(&msg, sizeof(msg));
+ while (msg.message != WM_QUIT)
+ {
+ // Poll and handle messages (inputs, window resize, etc.)
+ // 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.
+ if (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
+ {
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ continue;
+ }
+
+ // Start the Dear ImGui frame
+ ImGui_ImplDX11_NewFrame();
+ ImGui_ImplWin32_NewFrame();
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ ImGui::Render();
+ g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
+ g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color);
+ ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
+
+ g_pSwapChain->Present(1, 0); // Present with vsync
+ //g_pSwapChain->Present(0, 0); // Present without vsync
+ }
+
+ // Cleanup
+ ImGui_ImplDX11_Shutdown();
+ ImGui_ImplWin32_Shutdown();
+ ImGui::DestroyContext();
+
+ CleanupDeviceD3D();
+ ::DestroyWindow(hwnd);
+ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
+
+ return 0;
}
-void CleanupRenderTarget()
-{
- if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; }
-}
+// Helper functions
-HRESULT CreateDeviceD3D(HWND hWnd)
+bool CreateDeviceD3D(HWND hWnd)
{
// Setup swap chain
DXGI_SWAP_CHAIN_DESC sd;
@@ -51,11 +184,10 @@ HRESULT CreateDeviceD3D(HWND hWnd)
D3D_FEATURE_LEVEL featureLevel;
const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
- return E_FAIL;
+ return false;
CreateRenderTarget();
-
- return S_OK;
+ return true;
}
void CleanupDeviceD3D()
@@ -66,7 +198,23 @@ void CleanupDeviceD3D()
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
}
-extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+void CreateRenderTarget()
+{
+ ID3D11Texture2D* pBackBuffer;
+ g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
+ g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView);
+ pBackBuffer->Release();
+}
+
+void CleanupRenderTarget()
+{
+ if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; }
+}
+
+// Forward declare message handler from imgui_impl_win32.cpp
+extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// Win32 message handler
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
@@ -77,11 +225,9 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SIZE:
if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED)
{
- ImGui_ImplDX11_InvalidateDeviceObjects();
CleanupRenderTarget();
g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0);
CreateRenderTarget();
- ImGui_ImplDX11_CreateDeviceObjects();
}
return 0;
case WM_SYSCOMMAND:
@@ -89,129 +235,8 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return 0;
break;
case WM_DESTROY:
- PostQuitMessage(0);
+ ::PostQuitMessage(0);
return 0;
}
- return DefWindowProc(hWnd, msg, wParam, lParam);
-}
-
-int main(int, char**)
-{
- // Create application window
- WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
- RegisterClassEx(&wc);
- HWND hwnd = CreateWindow(_T("ImGui Example"), _T("ImGui DirectX11 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
-
- // Initialize Direct3D
- if (CreateDeviceD3D(hwnd) < 0)
- {
- CleanupDeviceD3D();
- UnregisterClass(_T("ImGui Example"), wc.hInstance);
- return 1;
- }
-
- // Show the window
- ShowWindow(hwnd, SW_SHOWDEFAULT);
- UpdateWindow(hwnd);
-
- // Setup ImGui binding
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_ImplDX11_Init(hwnd, g_pd3dDevice, g_pd3dDeviceContext);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
-
- // Setup style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // 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);
-
- bool show_demo_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
- // Main loop
- MSG msg;
- ZeroMemory(&msg, sizeof(msg));
- while (msg.message != WM_QUIT)
- {
- // 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.
- if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- continue;
- }
- ImGui_ImplDX11_NewFrame();
-
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
- {
- static float f = 0.0f;
- static int counter = 0;
- ImGui::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
-
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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);
- }
-
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
- // Rendering
- g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
- g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color);
- ImGui::Render();
- ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
-
- g_pSwapChain->Present(1, 0); // Present with vsync
- //g_pSwapChain->Present(0, 0); // Present without vsync
- }
-
- ImGui_ImplDX11_Shutdown();
- ImGui::DestroyContext();
-
- CleanupDeviceD3D();
- UnregisterClass(_T("ImGui Example"), wc.hInstance);
-
- return 0;
+ return ::DefWindowProc(hWnd, msg, wParam, lParam);
}
diff --git a/third_party/imgui/examples/example_win32_directx12/build_win32.bat b/third_party/imgui/examples/example_win32_directx12/build_win32.bat
new file mode 100644
index 0000000000..2cd7fcdff7
--- /dev/null
+++ b/third_party/imgui/examples/example_win32_directx12/build_win32.bat
@@ -0,0 +1,4 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_dx12.cpp ..\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx12.exe /FoDebug/ /link d3d12.lib d3dcompiler.lib dxgi.lib
+
diff --git a/third_party/imgui/examples/directx12_example/directx12_example.vcxproj b/third_party/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj
similarity index 90%
rename from third_party/imgui/examples/directx12_example/directx12_example.vcxproj
rename to third_party/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj
index d3962a3173..dabd6d8409 100644
--- a/third_party/imgui/examples/directx12_example/directx12_example.vcxproj
+++ b/third_party/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj
@@ -20,8 +20,8 @@
{b4cf9797-519d-4afe-a8f4-5141a6b521d3}
- directx12_example
- 10.0.16299.0
+ example_win32_directx12
+ 10.0.14393.0
@@ -86,7 +86,7 @@
Level4
Disabled
- ..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%(AdditionalIncludeDirectories)
true
@@ -99,7 +99,7 @@
Level4
Disabled
- ..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%(AdditionalIncludeDirectories)
true
@@ -114,7 +114,7 @@
MaxSpeed
true
true
- ..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%(AdditionalIncludeDirectories)
true
@@ -131,7 +131,7 @@
MaxSpeed
true
true
- ..\..;%(AdditionalIncludeDirectories)
+ ..\..;..;%(AdditionalIncludeDirectories)
true
@@ -146,13 +146,16 @@
-
+
+
-
+
+
+
diff --git a/third_party/imgui/examples/directx12_example/directx12_example.vcxproj.filters b/third_party/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters
similarity index 76%
rename from third_party/imgui/examples/directx12_example/directx12_example.vcxproj.filters
rename to third_party/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters
index 6baac5986c..28a25572eb 100644
--- a/third_party/imgui/examples/directx12_example/directx12_example.vcxproj.filters
+++ b/third_party/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters
@@ -15,12 +15,15 @@
imgui
-
- sources
-
imgui
+
+ sources
+
+
+ sources
+
@@ -29,15 +32,21 @@
sources
-
- sources
-
imgui
imgui
+
+ sources
+
+
+ sources
+
+
+ imgui
+
diff --git a/third_party/imgui/examples/directx12_example/main.cpp b/third_party/imgui/examples/example_win32_directx12/main.cpp
similarity index 75%
rename from third_party/imgui/examples/directx12_example/main.cpp
rename to third_party/imgui/examples/example_win32_directx12/main.cpp
index 6a4b78d85e..6ea896bc61 100644
--- a/third_party/imgui/examples/directx12_example/main.cpp
+++ b/third_party/imgui/examples/example_win32_directx12/main.cpp
@@ -1,14 +1,22 @@
-// ImGui - standalone example application for DirectX 12
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// dear imgui: standalone example application for DirectX 12
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
// FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*))
#include "imgui.h"
+#include "imgui_impl_win32.h"
#include "imgui_impl_dx12.h"
#include
#include
#include
-#define DX12_ENABLE_DEBUG_LAYER 0
+#ifdef _DEBUG
+#define DX12_ENABLE_DEBUG_LAYER
+#endif
+
+#ifdef DX12_ENABLE_DEBUG_LAYER
+#include
+#pragma comment(lib, "dxguid.lib")
+#endif
struct FrameContext
{
@@ -35,17 +43,328 @@ static HANDLE g_hSwapChainWaitableObject = NULL;
static ID3D12Resource* g_mainRenderTargetResource[NUM_BACK_BUFFERS] = {};
static D3D12_CPU_DESCRIPTOR_HANDLE g_mainRenderTargetDescriptor[NUM_BACK_BUFFERS] = {};
+// Forward declarations of helper functions
+bool CreateDeviceD3D(HWND hWnd);
+void CleanupDeviceD3D();
+void CreateRenderTarget();
+void CleanupRenderTarget();
+void WaitForLastSubmittedFrame();
+FrameContext* WaitForNextFrameResources();
+void ResizeSwapChain(HWND hWnd, int width, int height);
+LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// Main code
+int main(int, char**)
+{
+ // Create application window
+ WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
+ ::RegisterClassEx(&wc);
+ HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX12 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
+
+ // Initialize Direct3D
+ if (!CreateDeviceD3D(hwnd))
+ {
+ CleanupDeviceD3D();
+ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
+ return 1;
+ }
+
+ // Show the window
+ ::ShowWindow(hwnd, SW_SHOWDEFAULT);
+ ::UpdateWindow(hwnd);
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO(); (void)io;
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
+
+ // Setup Dear ImGui style
+ ImGui::StyleColorsDark();
+ //ImGui::StyleColorsClassic();
+
+ // Setup Platform/Renderer bindings
+ ImGui_ImplWin32_Init(hwnd);
+ ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,
+ DXGI_FORMAT_R8G8B8A8_UNORM, g_pd3dSrvDescHeap,
+ g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(),
+ g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());
+
+ // 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 'docs/FONTS.md' 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);
+
+ // Our state
+ bool show_demo_window = true;
+ bool show_another_window = false;
+ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
+
+ // Main loop
+ MSG msg;
+ ZeroMemory(&msg, sizeof(msg));
+ while (msg.message != WM_QUIT)
+ {
+ // Poll and handle messages (inputs, window resize, etc.)
+ // 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.
+ if (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
+ {
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ continue;
+ }
+
+ // Start the Dear ImGui frame
+ ImGui_ImplDX12_NewFrame();
+ ImGui_ImplWin32_NewFrame();
+ ImGui::NewFrame();
+
+ // 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();
+ }
+
+ // Rendering
+ FrameContext* frameCtxt = WaitForNextFrameResources();
+ UINT backBufferIdx = g_pSwapChain->GetCurrentBackBufferIndex();
+ frameCtxt->CommandAllocator->Reset();
+
+ D3D12_RESOURCE_BARRIER barrier = {};
+ barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
+ barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
+ barrier.Transition.pResource = g_mainRenderTargetResource[backBufferIdx];
+ barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
+ barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
+ barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
+
+ g_pd3dCommandList->Reset(frameCtxt->CommandAllocator, NULL);
+ g_pd3dCommandList->ResourceBarrier(1, &barrier);
+ g_pd3dCommandList->ClearRenderTargetView(g_mainRenderTargetDescriptor[backBufferIdx], (float*)&clear_color, 0, NULL);
+ g_pd3dCommandList->OMSetRenderTargets(1, &g_mainRenderTargetDescriptor[backBufferIdx], FALSE, NULL);
+ g_pd3dCommandList->SetDescriptorHeaps(1, &g_pd3dSrvDescHeap);
+ ImGui::Render();
+ ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), g_pd3dCommandList);
+ barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
+ barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
+ g_pd3dCommandList->ResourceBarrier(1, &barrier);
+ g_pd3dCommandList->Close();
+
+ g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
+
+ g_pSwapChain->Present(1, 0); // Present with vsync
+ //g_pSwapChain->Present(0, 0); // Present without vsync
+
+ UINT64 fenceValue = g_fenceLastSignaledValue + 1;
+ g_pd3dCommandQueue->Signal(g_fence, fenceValue);
+ g_fenceLastSignaledValue = fenceValue;
+ frameCtxt->FenceValue = fenceValue;
+ }
+
+ WaitForLastSubmittedFrame();
+ ImGui_ImplDX12_Shutdown();
+ ImGui_ImplWin32_Shutdown();
+ ImGui::DestroyContext();
+
+ CleanupDeviceD3D();
+ ::DestroyWindow(hwnd);
+ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
+
+ return 0;
+}
+
+// Helper functions
+
+bool CreateDeviceD3D(HWND hWnd)
+{
+ // Setup swap chain
+ DXGI_SWAP_CHAIN_DESC1 sd;
+ {
+ ZeroMemory(&sd, sizeof(sd));
+ sd.BufferCount = NUM_BACK_BUFFERS;
+ sd.Width = 0;
+ sd.Height = 0;
+ sd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ sd.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
+ sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
+ sd.SampleDesc.Count = 1;
+ sd.SampleDesc.Quality = 0;
+ sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
+ sd.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
+ sd.Scaling = DXGI_SCALING_STRETCH;
+ sd.Stereo = FALSE;
+ }
+
+#ifdef DX12_ENABLE_DEBUG_LAYER
+ ID3D12Debug* pdx12Debug = NULL;
+ if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&pdx12Debug))))
+ {
+ pdx12Debug->EnableDebugLayer();
+ pdx12Debug->Release();
+ }
+#endif
+
+ D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
+ if (D3D12CreateDevice(NULL, featureLevel, IID_PPV_ARGS(&g_pd3dDevice)) != S_OK)
+ return false;
+
+ {
+ D3D12_DESCRIPTOR_HEAP_DESC desc = {};
+ desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
+ desc.NumDescriptors = NUM_BACK_BUFFERS;
+ desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
+ desc.NodeMask = 1;
+ if (g_pd3dDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&g_pd3dRtvDescHeap)) != S_OK)
+ return false;
+
+ SIZE_T rtvDescriptorSize = g_pd3dDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
+ D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = g_pd3dRtvDescHeap->GetCPUDescriptorHandleForHeapStart();
+ for (UINT i = 0; i < NUM_BACK_BUFFERS; i++)
+ {
+ g_mainRenderTargetDescriptor[i] = rtvHandle;
+ rtvHandle.ptr += rtvDescriptorSize;
+ }
+ }
+
+ {
+ D3D12_DESCRIPTOR_HEAP_DESC desc = {};
+ desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
+ desc.NumDescriptors = 1;
+ desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
+ if (g_pd3dDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&g_pd3dSrvDescHeap)) != S_OK)
+ return false;
+ }
+
+ {
+ D3D12_COMMAND_QUEUE_DESC desc = {};
+ desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
+ desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
+ desc.NodeMask = 1;
+ if (g_pd3dDevice->CreateCommandQueue(&desc, IID_PPV_ARGS(&g_pd3dCommandQueue)) != S_OK)
+ return false;
+ }
+
+ for (UINT i = 0; i < NUM_FRAMES_IN_FLIGHT; i++)
+ if (g_pd3dDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&g_frameContext[i].CommandAllocator)) != S_OK)
+ return false;
+
+ if (g_pd3dDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, g_frameContext[0].CommandAllocator, NULL, IID_PPV_ARGS(&g_pd3dCommandList)) != S_OK ||
+ g_pd3dCommandList->Close() != S_OK)
+ return false;
+
+ if (g_pd3dDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&g_fence)) != S_OK)
+ return false;
+
+ g_fenceEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (g_fenceEvent == NULL)
+ return false;
+
+ {
+ IDXGIFactory4* dxgiFactory = NULL;
+ IDXGISwapChain1* swapChain1 = NULL;
+ if (CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory)) != S_OK ||
+ dxgiFactory->CreateSwapChainForHwnd(g_pd3dCommandQueue, hWnd, &sd, NULL, NULL, &swapChain1) != S_OK ||
+ swapChain1->QueryInterface(IID_PPV_ARGS(&g_pSwapChain)) != S_OK)
+ return false;
+ swapChain1->Release();
+ dxgiFactory->Release();
+ g_pSwapChain->SetMaximumFrameLatency(NUM_BACK_BUFFERS);
+ g_hSwapChainWaitableObject = g_pSwapChain->GetFrameLatencyWaitableObject();
+ }
+
+ CreateRenderTarget();
+ return true;
+}
+
+void CleanupDeviceD3D()
+{
+ CleanupRenderTarget();
+ if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; }
+ if (g_hSwapChainWaitableObject != NULL) { CloseHandle(g_hSwapChainWaitableObject); }
+ for (UINT i = 0; i < NUM_FRAMES_IN_FLIGHT; i++)
+ if (g_frameContext[i].CommandAllocator) { g_frameContext[i].CommandAllocator->Release(); g_frameContext[i].CommandAllocator = NULL; }
+ if (g_pd3dCommandQueue) { g_pd3dCommandQueue->Release(); g_pd3dCommandQueue = NULL; }
+ if (g_pd3dCommandList) { g_pd3dCommandList->Release(); g_pd3dCommandList = NULL; }
+ if (g_pd3dRtvDescHeap) { g_pd3dRtvDescHeap->Release(); g_pd3dRtvDescHeap = NULL; }
+ if (g_pd3dSrvDescHeap) { g_pd3dSrvDescHeap->Release(); g_pd3dSrvDescHeap = NULL; }
+ if (g_fence) { g_fence->Release(); g_fence = NULL; }
+ if (g_fenceEvent) { CloseHandle(g_fenceEvent); g_fenceEvent = NULL; }
+ if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
+
+#ifdef DX12_ENABLE_DEBUG_LAYER
+ IDXGIDebug1* pDebug = NULL;
+ if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&pDebug))))
+ {
+ pDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_SUMMARY);
+ pDebug->Release();
+ }
+#endif
+}
+
void CreateRenderTarget()
{
- ID3D12Resource* pBackBuffer;
for (UINT i = 0; i < NUM_BACK_BUFFERS; i++)
{
+ ID3D12Resource* pBackBuffer = NULL;
g_pSwapChain->GetBuffer(i, IID_PPV_ARGS(&pBackBuffer));
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, g_mainRenderTargetDescriptor[i]);
g_mainRenderTargetResource[i] = pBackBuffer;
}
}
+void CleanupRenderTarget()
+{
+ WaitForLastSubmittedFrame();
+
+ for (UINT i = 0; i < NUM_BACK_BUFFERS; i++)
+ if (g_mainRenderTargetResource[i]) { g_mainRenderTargetResource[i]->Release(); g_mainRenderTargetResource[i] = NULL; }
+}
+
void WaitForLastSubmittedFrame()
{
FrameContext* frameCtxt = &g_frameContext[g_frameIndex % NUM_FRAMES_IN_FLIGHT];
@@ -92,7 +411,7 @@ void ResizeSwapChain(HWND hWnd, int width, int height)
sd.Width = width;
sd.Height = height;
- IDXGIFactory4* dxgiFactory = nullptr;
+ IDXGIFactory4* dxgiFactory = NULL;
g_pSwapChain->GetParent(IID_PPV_ARGS(&dxgiFactory));
g_pSwapChain->Release();
@@ -110,134 +429,10 @@ void ResizeSwapChain(HWND hWnd, int width, int height)
assert(g_hSwapChainWaitableObject != NULL);
}
-void CleanupRenderTarget()
-{
- WaitForLastSubmittedFrame();
+// Forward declare message handler from imgui_impl_win32.cpp
+extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
- for (UINT i = 0; i < NUM_BACK_BUFFERS; i++)
- if (g_mainRenderTargetResource[i]) { g_mainRenderTargetResource[i]->Release(); g_mainRenderTargetResource[i] = NULL; }
-}
-
-HRESULT CreateDeviceD3D(HWND hWnd)
-{
- // Setup swap chain
- DXGI_SWAP_CHAIN_DESC1 sd;
- {
- ZeroMemory(&sd, sizeof(sd));
- sd.BufferCount = NUM_BACK_BUFFERS;
- sd.Width = 0;
- sd.Height = 0;
- sd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- sd.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
- sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
- sd.SampleDesc.Count = 1;
- sd.SampleDesc.Quality = 0;
- sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
- sd.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
- sd.Scaling = DXGI_SCALING_STRETCH;
- sd.Stereo = FALSE;
- }
-
- if (DX12_ENABLE_DEBUG_LAYER)
- {
- ID3D12Debug* dx12Debug = NULL;
- if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&dx12Debug))))
- {
- dx12Debug->EnableDebugLayer();
- dx12Debug->Release();
- }
- }
-
- D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
- if (D3D12CreateDevice(NULL, featureLevel, IID_PPV_ARGS(&g_pd3dDevice)) != S_OK)
- return E_FAIL;
-
- {
- D3D12_DESCRIPTOR_HEAP_DESC desc = {};
- desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
- desc.NumDescriptors = NUM_BACK_BUFFERS;
- desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
- desc.NodeMask = 1;
- if (g_pd3dDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&g_pd3dRtvDescHeap)) != S_OK)
- return E_FAIL;
-
- SIZE_T rtvDescriptorSize = g_pd3dDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
- D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = g_pd3dRtvDescHeap->GetCPUDescriptorHandleForHeapStart();
- for (UINT i = 0; i < NUM_BACK_BUFFERS; i++)
- {
- g_mainRenderTargetDescriptor[i] = rtvHandle;
- rtvHandle.ptr += rtvDescriptorSize;
- }
- }
-
- {
- D3D12_DESCRIPTOR_HEAP_DESC desc = {};
- desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
- desc.NumDescriptors = 1;
- desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
- if (g_pd3dDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&g_pd3dSrvDescHeap)) != S_OK)
- return E_FAIL;
- }
-
- {
- D3D12_COMMAND_QUEUE_DESC desc = {};
- desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
- desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
- desc.NodeMask = 1;
- if (g_pd3dDevice->CreateCommandQueue(&desc, IID_PPV_ARGS(&g_pd3dCommandQueue)) != S_OK)
- return E_FAIL;
- }
-
- for (UINT i = 0; i < NUM_FRAMES_IN_FLIGHT; i++)
- if (g_pd3dDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&g_frameContext[i].CommandAllocator)) != S_OK)
- return E_FAIL;
-
- if (g_pd3dDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, g_frameContext[0].CommandAllocator, NULL, IID_PPV_ARGS(&g_pd3dCommandList)) != S_OK ||
- g_pd3dCommandList->Close() != S_OK)
- return E_FAIL;
-
- if (g_pd3dDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&g_fence)) != S_OK)
- return E_FAIL;
-
- g_fenceEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (g_fenceEvent == NULL)
- return E_FAIL;
-
- {
- IDXGIFactory4* dxgiFactory = NULL;
- IDXGISwapChain1* swapChain1 = NULL;
- if (CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory)) != S_OK ||
- dxgiFactory->CreateSwapChainForHwnd(g_pd3dCommandQueue, hWnd, &sd, NULL, NULL, &swapChain1) != S_OK ||
- swapChain1->QueryInterface(IID_PPV_ARGS(&g_pSwapChain)) != S_OK)
- return E_FAIL;
- swapChain1->Release();
- dxgiFactory->Release();
- g_pSwapChain->SetMaximumFrameLatency(NUM_BACK_BUFFERS);
- g_hSwapChainWaitableObject = g_pSwapChain->GetFrameLatencyWaitableObject();
- }
-
- CreateRenderTarget();
-
- return S_OK;
-}
-
-void CleanupDeviceD3D()
-{
- CleanupRenderTarget();
- if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; }
- if (g_hSwapChainWaitableObject != NULL) { CloseHandle(g_hSwapChainWaitableObject); }
- for (UINT i = 0; i < NUM_FRAMES_IN_FLIGHT; i++)
- if (g_frameContext[i].CommandAllocator) { g_frameContext[i].CommandAllocator->Release(); g_frameContext[i].CommandAllocator = NULL; }
- if (g_pd3dCommandQueue) { g_pd3dCommandQueue->Release(); g_pd3dCommandQueue = NULL; }
- if (g_pd3dCommandList) { g_pd3dCommandList->Release(); g_pd3dCommandList = NULL; }
- if (g_pd3dRtvDescHeap) { g_pd3dRtvDescHeap->Release(); g_pd3dRtvDescHeap = NULL; }
- if (g_pd3dSrvDescHeap) { g_pd3dSrvDescHeap->Release(); g_pd3dSrvDescHeap = NULL; }
- if (g_fence) { g_fence->Release(); g_fence = NULL; }
- if (g_fenceEvent) { CloseHandle(g_fenceEvent); g_fenceEvent = NULL; }
- if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
-}
-
-extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+// Win32 message handler
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
@@ -248,6 +443,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SIZE:
if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED)
{
+ WaitForLastSubmittedFrame();
ImGui_ImplDX12_InvalidateDeviceObjects();
CleanupRenderTarget();
ResizeSwapChain(hWnd, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam));
@@ -260,158 +456,8 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return 0;
break;
case WM_DESTROY:
- PostQuitMessage(0);
+ ::PostQuitMessage(0);
return 0;
}
- return DefWindowProc(hWnd, msg, wParam, lParam);
-}
-
-int main(int, char**)
-{
- // Create application window
- WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
- RegisterClassEx(&wc);
- HWND hwnd = CreateWindow(_T("ImGui Example"), _T("ImGui DirectX12 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
-
- // Initialize Direct3D
- if (CreateDeviceD3D(hwnd) < 0)
- {
- CleanupDeviceD3D();
- UnregisterClass(_T("ImGui Example"), wc.hInstance);
- return 1;
- }
-
- // Show the window
- ShowWindow(hwnd, SW_SHOWDEFAULT);
- UpdateWindow(hwnd);
-
- // Setup ImGui binding
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
- ImGui_ImplDX12_Init(hwnd, NUM_FRAMES_IN_FLIGHT, g_pd3dDevice,
- DXGI_FORMAT_R8G8B8A8_UNORM,
- g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(),
- g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());
-
- // Setup style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // 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);
-
- bool show_demo_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
- // Main loop
- MSG msg;
- ZeroMemory(&msg, sizeof(msg));
- while (msg.message != WM_QUIT)
- {
- // 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.
- if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- continue;
- }
- ImGui_ImplDX12_NewFrame(g_pd3dCommandList);
-
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
- {
- static float f = 0.0f;
- static int counter = 0;
- ImGui::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
-
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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);
- }
-
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
- // Rendering
- FrameContext* frameCtxt = WaitForNextFrameResources();
- UINT backBufferIdx = g_pSwapChain->GetCurrentBackBufferIndex();
- frameCtxt->CommandAllocator->Reset();
-
- D3D12_RESOURCE_BARRIER barrier = {};
- barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
- barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
- barrier.Transition.pResource = g_mainRenderTargetResource[backBufferIdx];
- barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
- barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
- barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
-
- g_pd3dCommandList->Reset(frameCtxt->CommandAllocator, NULL);
- g_pd3dCommandList->ResourceBarrier(1, &barrier);
- g_pd3dCommandList->ClearRenderTargetView(g_mainRenderTargetDescriptor[backBufferIdx], (float*)&clear_color, 0, NULL);
- g_pd3dCommandList->OMSetRenderTargets(1, &g_mainRenderTargetDescriptor[backBufferIdx], FALSE, NULL);
- g_pd3dCommandList->SetDescriptorHeaps(1, &g_pd3dSrvDescHeap);
- ImGui::Render();
- ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData());
- barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
- barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
- g_pd3dCommandList->ResourceBarrier(1, &barrier);
- g_pd3dCommandList->Close();
-
- g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
-
- g_pSwapChain->Present(1, 0); // Present with vsync
- //g_pSwapChain->Present(0, 0); // Present without vsync
-
- UINT64 fenceValue = g_fenceLastSignaledValue + 1;
- g_pd3dCommandQueue->Signal(g_fence, fenceValue);
- g_fenceLastSignaledValue = fenceValue;
- frameCtxt->FenceValue = fenceValue;
- }
-
- WaitForLastSubmittedFrame();
- ImGui_ImplDX12_Shutdown();
- ImGui::DestroyContext();
- CleanupDeviceD3D();
- UnregisterClass(_T("ImGui Example"), wc.hInstance);
-
- return 0;
+ return ::DefWindowProc(hWnd, msg, wParam, lParam);
}
diff --git a/third_party/imgui/examples/example_win32_directx9/build_win32.bat b/third_party/imgui/examples/example_win32_directx9/build_win32.bat
new file mode 100644
index 0000000000..4db27653e5
--- /dev/null
+++ b/third_party/imgui/examples/example_win32_directx9/build_win32.bat
@@ -0,0 +1,3 @@
+@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
+mkdir Debug
+cl /nologo /Zi /MD /I .. /I ..\.. /I "%DXSDK_DIR%/Include" /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_dx9.cpp ..\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx9.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d9.lib
diff --git a/third_party/imgui/examples/directx9_example/directx9_example.vcxproj b/third_party/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj
similarity index 82%
rename from third_party/imgui/examples/directx9_example/directx9_example.vcxproj
rename to third_party/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj
index 89f3ae6ecc..25bdd8599d 100644
--- a/third_party/imgui/examples/directx9_example/directx9_example.vcxproj
+++ b/third_party/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj
@@ -20,30 +20,35 @@
{4165A294-21F2-44CA-9B38-E3F935ABADF5}
- directx9_example
+ example_win32_directx9
+ 8.1
Application
true
Unicode
+ v110
Application
true
Unicode
+ v110
Application
false
true
Unicode
+ v110
Application
false
true
Unicode
+ v110
@@ -81,11 +86,11 @@
Level4
Disabled
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
true
- $(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)
+ $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)
d3d9.lib;%(AdditionalDependencies)
Console
@@ -94,11 +99,11 @@
Level4
Disabled
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
true
- $(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)
+ $(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)
d3d9.lib;%(AdditionalDependencies)
Console
@@ -109,14 +114,14 @@
MaxSpeed
true
true
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
false
true
true
true
- $(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)
+ $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)
d3d9.lib;%(AdditionalDependencies)
Console
@@ -127,14 +132,14 @@
MaxSpeed
true
true
- ..\..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
+ ..\..;..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include;
false
true
true
true
- $(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)
+ $(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)
d3d9.lib;%(AdditionalDependencies)
Console
@@ -143,14 +148,17 @@
-
+
+
+
-
+
+
diff --git a/third_party/imgui/examples/directx9_example/directx9_example.vcxproj.filters b/third_party/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters
similarity index 78%
rename from third_party/imgui/examples/directx9_example/directx9_example.vcxproj.filters
rename to third_party/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters
index 555ef06d7e..914cd260cb 100644
--- a/third_party/imgui/examples/directx9_example/directx9_example.vcxproj.filters
+++ b/third_party/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters
@@ -16,15 +16,21 @@
imgui
-
- sources
-
imgui
imgui
+
+ sources
+
+
+ sources
+
+
+ imgui
+
@@ -33,12 +39,15 @@
imgui
-
- sources
-
imgui
+
+ sources
+
+
+ sources
+
diff --git a/third_party/imgui/examples/directx9_example/main.cpp b/third_party/imgui/examples/example_win32_directx9/main.cpp
similarity index 55%
rename from third_party/imgui/examples/directx9_example/main.cpp
rename to third_party/imgui/examples/example_win32_directx9/main.cpp
index f4c7a9f0c6..c8ad69f12c 100644
--- a/third_party/imgui/examples/directx9_example/main.cpp
+++ b/third_party/imgui/examples/example_win32_directx9/main.cpp
@@ -1,95 +1,66 @@
-// ImGui - standalone example application for DirectX 9
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// dear imgui: standalone example application for DirectX 9
+// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
#include "imgui.h"
#include "imgui_impl_dx9.h"
+#include "imgui_impl_win32.h"
#include
#define DIRECTINPUT_VERSION 0x0800
#include
#include
// Data
+static LPDIRECT3D9 g_pD3D = NULL;
static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
-static D3DPRESENT_PARAMETERS g_d3dpp;
+static D3DPRESENT_PARAMETERS g_d3dpp = {};
-extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
- return true;
-
- switch (msg)
- {
- case WM_SIZE:
- if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED)
- {
- ImGui_ImplDX9_InvalidateDeviceObjects();
- g_d3dpp.BackBufferWidth = LOWORD(lParam);
- g_d3dpp.BackBufferHeight = HIWORD(lParam);
- HRESULT hr = g_pd3dDevice->Reset(&g_d3dpp);
- if (hr == D3DERR_INVALIDCALL)
- IM_ASSERT(0);
- ImGui_ImplDX9_CreateDeviceObjects();
- }
- return 0;
- case WM_SYSCOMMAND:
- if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
- return 0;
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProc(hWnd, msg, wParam, lParam);
-}
+// Forward declarations of helper functions
+bool CreateDeviceD3D(HWND hWnd);
+void CleanupDeviceD3D();
+void ResetDevice();
+LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+// Main code
int main(int, char**)
{
// Create application window
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
- RegisterClassEx(&wc);
- HWND hwnd = CreateWindow(_T("ImGui Example"), _T("ImGui DirectX9 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
+ ::RegisterClassEx(&wc);
+ HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX9 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
// Initialize Direct3D
- LPDIRECT3D9 pD3D;
- if ((pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL)
+ if (!CreateDeviceD3D(hwnd))
{
- UnregisterClass(_T("ImGui Example"), wc.hInstance);
- return 0;
- }
- ZeroMemory(&g_d3dpp, sizeof(g_d3dpp));
- g_d3dpp.Windowed = TRUE;
- g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
- g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
- g_d3dpp.EnableAutoDepthStencil = TRUE;
- g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
- g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // Present with vsync
- //g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync, maximum unthrottled framerate
-
- // Create the D3DDevice
- if (pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0)
- {
- pD3D->Release();
- UnregisterClass(_T("ImGui Example"), wc.hInstance);
- return 0;
+ CleanupDeviceD3D();
+ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
+ return 1;
}
- // Setup ImGui binding
+ // Show the window
+ ::ShowWindow(hwnd, SW_SHOWDEFAULT);
+ ::UpdateWindow(hwnd);
+
+ // Setup Dear ImGui context
+ IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_ImplDX9_Init(hwnd, g_pd3dDevice);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
+ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
- // Setup style
+ // Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();
+ // Setup Platform/Renderer bindings
+ ImGui_ImplWin32_Init(hwnd);
+ ImGui_ImplDX9_Init(g_pd3dDevice);
+
// 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 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.
+ // - Read 'docs/FONTS.md' 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);
@@ -99,6 +70,7 @@ int main(int, char**)
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
//IM_ASSERT(font != NULL);
+ // Our state
bool show_demo_window = true;
bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
@@ -106,64 +78,67 @@ int main(int, char**)
// Main loop
MSG msg;
ZeroMemory(&msg, sizeof(msg));
- ShowWindow(hwnd, SW_SHOWDEFAULT);
- UpdateWindow(hwnd);
while (msg.message != WM_QUIT)
{
+ // Poll and handle messages (inputs, window resize, etc.)
// 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.
- if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
+ if (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
continue;
}
- ImGui_ImplDX9_NewFrame();
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
+ // Start the Dear ImGui frame
+ ImGui_ImplDX9_NewFrame();
+ ImGui_ImplWin32_NewFrame();
+ ImGui::NewFrame();
+
+ // 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::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
+ 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);
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: most widgets return true when edited/activated)
+ 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();
}
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
+ // 3. Show another simple window.
if (show_another_window)
{
- ImGui::Begin("Another Window", &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();
}
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
// Rendering
ImGui::EndFrame();
- g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
- g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
- g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
+ g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
+ g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*255.0f), (int)(clear_color.y*255.0f), (int)(clear_color.z*255.0f), (int)(clear_color.w*255.0f));
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0);
if (g_pd3dDevice->BeginScene() >= 0)
@@ -176,19 +151,83 @@ int main(int, char**)
// Handle loss of D3D9 device
if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET)
- {
- ImGui_ImplDX9_InvalidateDeviceObjects();
- g_pd3dDevice->Reset(&g_d3dpp);
- ImGui_ImplDX9_CreateDeviceObjects();
- }
+ ResetDevice();
}
ImGui_ImplDX9_Shutdown();
+ ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext();
- if (g_pd3dDevice) g_pd3dDevice->Release();
- if (pD3D) pD3D->Release();
- UnregisterClass(_T("ImGui Example"), wc.hInstance);
+ CleanupDeviceD3D();
+ ::DestroyWindow(hwnd);
+ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
return 0;
}
+
+// Helper functions
+
+bool CreateDeviceD3D(HWND hWnd)
+{
+ if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL)
+ return false;
+
+ // Create the D3DDevice
+ ZeroMemory(&g_d3dpp, sizeof(g_d3dpp));
+ g_d3dpp.Windowed = TRUE;
+ g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
+ g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
+ g_d3dpp.EnableAutoDepthStencil = TRUE;
+ g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
+ g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // Present with vsync
+ //g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync, maximum unthrottled framerate
+ if (g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0)
+ return false;
+
+ return true;
+}
+
+void CleanupDeviceD3D()
+{
+ if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
+ if (g_pD3D) { g_pD3D->Release(); g_pD3D = NULL; }
+}
+
+void ResetDevice()
+{
+ ImGui_ImplDX9_InvalidateDeviceObjects();
+ HRESULT hr = g_pd3dDevice->Reset(&g_d3dpp);
+ if (hr == D3DERR_INVALIDCALL)
+ IM_ASSERT(0);
+ ImGui_ImplDX9_CreateDeviceObjects();
+}
+
+// Forward declare message handler from imgui_impl_win32.cpp
+extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// Win32 message handler
+LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
+ return true;
+
+ switch (msg)
+ {
+ case WM_SIZE:
+ if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED)
+ {
+ g_d3dpp.BackBufferWidth = LOWORD(lParam);
+ g_d3dpp.BackBufferHeight = HIWORD(lParam);
+ ResetDevice();
+ }
+ return 0;
+ case WM_SYSCOMMAND:
+ if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
+ return 0;
+ break;
+ case WM_DESTROY:
+ ::PostQuitMessage(0);
+ return 0;
+ }
+ return ::DefWindowProc(hWnd, msg, wParam, lParam);
+}
diff --git a/third_party/imgui/examples/imgui_examples.sln b/third_party/imgui/examples/imgui_examples.sln
index 6ae2e4f16e..49b2ff89a5 100644
--- a/third_party/imgui/examples/imgui_examples.sln
+++ b/third_party/imgui/examples/imgui_examples.sln
@@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl2_example", "opengl2_example\opengl2_example.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_directx9", "example_win32_directx9\example_win32_directx9.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx9_example", "directx9_example\directx9_example.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_directx10", "example_win32_directx10\example_win32_directx10.vcxproj", "{345A953E-A004-4648-B442-DC5F9F11068C}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx11_example", "directx11_example\directx11_example.vcxproj", "{9F316E83-5AE5-4939-A723-305A94F48005}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_directx11", "example_win32_directx11\example_win32_directx11.vcxproj", "{9F316E83-5AE5-4939-A723-305A94F48005}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opengl3_example", "opengl3_example\opengl3_example.vcxproj", "{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_glfw_opengl2", "example_glfw_opengl2\example_glfw_opengl2.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "directx10_example", "directx10_example\directx10_example.vcxproj", "{345A953E-A004-4648-B442-DC5F9F11068C}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_glfw_opengl3", "example_glfw_opengl3\example_glfw_opengl3.vcxproj", "{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/third_party/imgui/examples/imgui_impl_allegro5.cpp b/third_party/imgui/examples/imgui_impl_allegro5.cpp
new file mode 100644
index 0000000000..2c7df9a924
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_allegro5.cpp
@@ -0,0 +1,428 @@
+// dear imgui: Renderer + Platform Binding for Allegro 5
+// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Platform: Clipboard support (from Allegro 5.1.12)
+// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
+// Issues:
+// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
+// [ ] 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, Original Allegro 5 code by @birthggd
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
+// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
+// 2019-05-11: Inputs: Don't filter character value from ALLEGRO_EVENT_KEY_CHAR before calling AddInputCharacter().
+// 2019-04-30: Renderer: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
+// 2018-11-30: Platform: Added touchscreen support.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName/io.BackendRendererName so they can be displayed in the About Window.
+// 2018-06-13: Platform: Added clipboard support (from Allegro 5.1.12).
+// 2018-06-13: Renderer: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
+// 2018-06-13: Renderer: Backup/restore transform and clipping rectangle.
+// 2018-06-11: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
+// 2018-04-18: Misc: Renamed file from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
+// 2018-04-18: Misc: Added support for 32-bit vertex indices to avoid conversion at runtime. Added imconfig_allegro5.h to enforce 32-bit indices when included from imgui.h.
+// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplAllegro5_RenderDrawData() in the .h file so you can call it yourself.
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
+
+#include // uint64_t
+#include // memcpy
+#include "imgui.h"
+#include "imgui_impl_allegro5.h"
+
+// Allegro
+#include
+#include
+#ifdef _WIN32
+#include
+#endif
+#define ALLEGRO_HAS_CLIPBOARD (ALLEGRO_VERSION_INT >= ((5 << 24) | (1 << 16) | (12 << 8))) // Clipboard only supported from Allegro 5.1.12
+
+// Visual Studio warnings
+#ifdef _MSC_VER
+#pragma warning (disable: 4127) // condition expression is constant
+#endif
+
+// Data
+static ALLEGRO_DISPLAY* g_Display = NULL;
+static ALLEGRO_BITMAP* g_Texture = NULL;
+static double g_Time = 0.0;
+static ALLEGRO_MOUSE_CURSOR* g_MouseCursorInvisible = NULL;
+static ALLEGRO_VERTEX_DECL* g_VertexDecl = NULL;
+static char* g_ClipboardTextData = NULL;
+
+struct ImDrawVertAllegro
+{
+ ImVec2 pos;
+ ImVec2 uv;
+ ALLEGRO_COLOR col;
+};
+
+static void ImGui_ImplAllegro5_SetupRenderState(ImDrawData* draw_data)
+{
+ // Setup blending
+ al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
+
+ // Setup orthographic projection matrix
+ // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right).
+ {
+ float L = draw_data->DisplayPos.x;
+ float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
+ float T = draw_data->DisplayPos.y;
+ float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
+ ALLEGRO_TRANSFORM transform;
+ al_identity_transform(&transform);
+ al_use_transform(&transform);
+ al_orthographic_transform(&transform, L, T, 1.0f, R, B, -1.0f);
+ al_use_projection_transform(&transform);
+ }
+}
+
+// Render function.
+// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
+void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized
+ if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
+ return;
+
+ // Backup Allegro state that will be modified
+ ALLEGRO_TRANSFORM last_transform = *al_get_current_transform();
+ ALLEGRO_TRANSFORM last_projection_transform = *al_get_current_projection_transform();
+ int last_clip_x, last_clip_y, last_clip_w, last_clip_h;
+ al_get_clipping_rectangle(&last_clip_x, &last_clip_y, &last_clip_w, &last_clip_h);
+ int last_blender_op, last_blender_src, last_blender_dst;
+ al_get_blender(&last_blender_op, &last_blender_src, &last_blender_dst);
+
+ // Setup desired render state
+ ImGui_ImplAllegro5_SetupRenderState(draw_data);
+
+ // Render command lists
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+
+ // Allegro's implementation of al_draw_indexed_prim() for DX9 is completely broken. Unindex our buffers ourselves.
+ // FIXME-OPT: Unfortunately Allegro doesn't support 32-bit packed colors so we have to convert them to 4 float as well..
+ static ImVector vertices;
+ vertices.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; i++)
+ {
+ const ImDrawVert* src_v = &cmd_list->VtxBuffer[cmd_list->IdxBuffer[i]];
+ ImDrawVertAllegro* dst_v = &vertices[i];
+ dst_v->pos = src_v->pos;
+ dst_v->uv = src_v->uv;
+ unsigned char* c = (unsigned char*)&src_v->col;
+ dst_v->col = al_map_rgba(c[0], c[1], c[2], c[3]);
+ }
+
+ const int* indices = NULL;
+ if (sizeof(ImDrawIdx) == 2)
+ {
+ // FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices.. You can '#define ImDrawIdx int' in imconfig.h to request Dear ImGui to output 32-bit indices.
+ // Otherwise, we convert them from 16-bit to 32-bit at runtime here, which works perfectly but is a little wasteful.
+ static ImVector indices_converted;
+ indices_converted.resize(cmd_list->IdxBuffer.Size);
+ for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i)
+ indices_converted[i] = (int)cmd_list->IdxBuffer.Data[i];
+ indices = indices_converted.Data;
+ }
+ else if (sizeof(ImDrawIdx) == 4)
+ {
+ indices = (const int*)cmd_list->IdxBuffer.Data;
+ }
+
+ // Render command lists
+ int idx_offset = 0;
+ ImVec2 clip_off = draw_data->DisplayPos;
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ // User callback, registered via ImDrawList::AddCallback()
+ // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
+ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
+ ImGui_ImplAllegro5_SetupRenderState(draw_data);
+ else
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ // Draw
+ ALLEGRO_BITMAP* texture = (ALLEGRO_BITMAP*)pcmd->TextureId;
+ al_set_clipping_rectangle(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y, pcmd->ClipRect.z - pcmd->ClipRect.x, pcmd->ClipRect.w - pcmd->ClipRect.y);
+ al_draw_prim(&vertices[0], g_VertexDecl, texture, idx_offset, idx_offset + pcmd->ElemCount, ALLEGRO_PRIM_TRIANGLE_LIST);
+ }
+ idx_offset += pcmd->ElemCount;
+ }
+ }
+
+ // Restore modified Allegro state
+ al_set_blender(last_blender_op, last_blender_src, last_blender_dst);
+ al_set_clipping_rectangle(last_clip_x, last_clip_y, last_clip_w, last_clip_h);
+ al_use_transform(&last_transform);
+ al_use_projection_transform(&last_projection_transform);
+}
+
+bool ImGui_ImplAllegro5_CreateDeviceObjects()
+{
+ // Build texture atlas
+ ImGuiIO &io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
+
+ // Create texture
+ int flags = al_get_new_bitmap_flags();
+ int fmt = al_get_new_bitmap_format();
+ al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP|ALLEGRO_MIN_LINEAR|ALLEGRO_MAG_LINEAR);
+ al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE);
+ ALLEGRO_BITMAP* img = al_create_bitmap(width, height);
+ al_set_new_bitmap_flags(flags);
+ al_set_new_bitmap_format(fmt);
+ if (!img)
+ return false;
+
+ ALLEGRO_LOCKED_REGION *locked_img = al_lock_bitmap(img, al_get_bitmap_format(img), ALLEGRO_LOCK_WRITEONLY);
+ if (!locked_img)
+ {
+ al_destroy_bitmap(img);
+ return false;
+ }
+ memcpy(locked_img->data, pixels, sizeof(int)*width*height);
+ al_unlock_bitmap(img);
+
+ // Convert software texture to hardware texture.
+ ALLEGRO_BITMAP* cloned_img = al_clone_bitmap(img);
+ al_destroy_bitmap(img);
+ if (!cloned_img)
+ return false;
+
+ // Store our identifier
+ io.Fonts->TexID = (void*)cloned_img;
+ g_Texture = cloned_img;
+
+ // Create an invisible mouse cursor
+ // Because al_hide_mouse_cursor() seems to mess up with the actual inputs..
+ ALLEGRO_BITMAP* mouse_cursor = al_create_bitmap(8,8);
+ g_MouseCursorInvisible = al_create_mouse_cursor(mouse_cursor, 0, 0);
+ al_destroy_bitmap(mouse_cursor);
+
+ return true;
+}
+
+void ImGui_ImplAllegro5_InvalidateDeviceObjects()
+{
+ if (g_Texture)
+ {
+ al_destroy_bitmap(g_Texture);
+ ImGui::GetIO().Fonts->TexID = NULL;
+ g_Texture = NULL;
+ }
+ if (g_MouseCursorInvisible)
+ {
+ al_destroy_mouse_cursor(g_MouseCursorInvisible);
+ g_MouseCursorInvisible = NULL;
+ }
+}
+
+#if ALLEGRO_HAS_CLIPBOARD
+static const char* ImGui_ImplAllegro5_GetClipboardText(void*)
+{
+ if (g_ClipboardTextData)
+ al_free(g_ClipboardTextData);
+ g_ClipboardTextData = al_get_clipboard_text(g_Display);
+ return g_ClipboardTextData;
+}
+
+static void ImGui_ImplAllegro5_SetClipboardText(void*, const char* text)
+{
+ al_set_clipboard_text(g_Display, text);
+}
+#endif
+
+bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
+{
+ g_Display = display;
+
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+ io.BackendPlatformName = io.BackendRendererName = "imgui_impl_allegro5";
+
+ // Create custom vertex declaration.
+ // Unfortunately Allegro doesn't support 32-bit packed colors so we have to convert them to 4 floats.
+ // We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion.
+ ALLEGRO_VERTEX_ELEMENT elems[] =
+ {
+ { ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_2, IM_OFFSETOF(ImDrawVertAllegro, pos) },
+ { ALLEGRO_PRIM_TEX_COORD, ALLEGRO_PRIM_FLOAT_2, IM_OFFSETOF(ImDrawVertAllegro, uv) },
+ { ALLEGRO_PRIM_COLOR_ATTR, 0, IM_OFFSETOF(ImDrawVertAllegro, col) },
+ { 0, 0, 0 }
+ };
+ g_VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
+
+ io.KeyMap[ImGuiKey_Tab] = ALLEGRO_KEY_TAB;
+ io.KeyMap[ImGuiKey_LeftArrow] = ALLEGRO_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = ALLEGRO_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = ALLEGRO_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = ALLEGRO_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = ALLEGRO_KEY_PGUP;
+ io.KeyMap[ImGuiKey_PageDown] = ALLEGRO_KEY_PGDN;
+ io.KeyMap[ImGuiKey_Home] = ALLEGRO_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = ALLEGRO_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = ALLEGRO_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = ALLEGRO_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = ALLEGRO_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Space] = ALLEGRO_KEY_SPACE;
+ io.KeyMap[ImGuiKey_Enter] = ALLEGRO_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = ALLEGRO_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_KeyPadEnter] = ALLEGRO_KEY_PAD_ENTER;
+ io.KeyMap[ImGuiKey_A] = ALLEGRO_KEY_A;
+ io.KeyMap[ImGuiKey_C] = ALLEGRO_KEY_C;
+ io.KeyMap[ImGuiKey_V] = ALLEGRO_KEY_V;
+ io.KeyMap[ImGuiKey_X] = ALLEGRO_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = ALLEGRO_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = ALLEGRO_KEY_Z;
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+
+#if ALLEGRO_HAS_CLIPBOARD
+ io.SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
+ io.ClipboardUserData = NULL;
+#endif
+
+ return true;
+}
+
+void ImGui_ImplAllegro5_Shutdown()
+{
+ ImGui_ImplAllegro5_InvalidateDeviceObjects();
+
+ g_Display = NULL;
+ g_Time = 0.0;
+
+ if (g_VertexDecl)
+ al_destroy_vertex_decl(g_VertexDecl);
+ g_VertexDecl = NULL;
+
+ if (g_ClipboardTextData)
+ al_free(g_ClipboardTextData);
+ g_ClipboardTextData = NULL;
+}
+
+// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
+// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
+// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
+// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
+bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT *ev)
+{
+ ImGuiIO& io = ImGui::GetIO();
+
+ switch (ev->type)
+ {
+ case ALLEGRO_EVENT_MOUSE_AXES:
+ if (ev->mouse.display == g_Display)
+ {
+ io.MouseWheel += ev->mouse.dz;
+ io.MouseWheelH += ev->mouse.dw;
+ io.MousePos = ImVec2(ev->mouse.x, ev->mouse.y);
+ }
+ return true;
+ case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
+ case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
+ if (ev->mouse.display == g_Display && ev->mouse.button <= 5)
+ io.MouseDown[ev->mouse.button - 1] = (ev->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN);
+ return true;
+ case ALLEGRO_EVENT_TOUCH_MOVE:
+ if (ev->touch.display == g_Display)
+ io.MousePos = ImVec2(ev->touch.x, ev->touch.y);
+ return true;
+ case ALLEGRO_EVENT_TOUCH_BEGIN:
+ case ALLEGRO_EVENT_TOUCH_END:
+ case ALLEGRO_EVENT_TOUCH_CANCEL:
+ if (ev->touch.display == g_Display && ev->touch.primary)
+ io.MouseDown[0] = (ev->type == ALLEGRO_EVENT_TOUCH_BEGIN);
+ return true;
+ case ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY:
+ if (ev->mouse.display == g_Display)
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+ return true;
+ case ALLEGRO_EVENT_KEY_CHAR:
+ if (ev->keyboard.display == g_Display)
+ if (ev->keyboard.unichar != 0)
+ io.AddInputCharacter((unsigned int)ev->keyboard.unichar);
+ return true;
+ case ALLEGRO_EVENT_KEY_DOWN:
+ case ALLEGRO_EVENT_KEY_UP:
+ if (ev->keyboard.display == g_Display)
+ io.KeysDown[ev->keyboard.keycode] = (ev->type == ALLEGRO_EVENT_KEY_DOWN);
+ return true;
+ }
+ return false;
+}
+
+static void ImGui_ImplAllegro5_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
+ return;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ al_set_mouse_cursor(g_Display, g_MouseCursorInvisible);
+ }
+ else
+ {
+ ALLEGRO_SYSTEM_MOUSE_CURSOR cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT;
+ switch (imgui_cursor)
+ {
+ case ImGuiMouseCursor_TextInput: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_EDIT; break;
+ case ImGuiMouseCursor_ResizeAll: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_MOVE; break;
+ case ImGuiMouseCursor_ResizeNS: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_N; break;
+ case ImGuiMouseCursor_ResizeEW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_E; break;
+ case ImGuiMouseCursor_ResizeNESW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE; break;
+ case ImGuiMouseCursor_ResizeNWSE: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW; break;
+ case ImGuiMouseCursor_NotAllowed: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_UNAVAILABLE; break;
+ }
+ al_set_system_mouse_cursor(g_Display, cursor_id);
+ }
+}
+
+void ImGui_ImplAllegro5_NewFrame()
+{
+ if (!g_Texture)
+ ImGui_ImplAllegro5_CreateDeviceObjects();
+
+ ImGuiIO &io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ w = al_get_display_width(g_Display);
+ h = al_get_display_height(g_Display);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+
+ // Setup time step
+ double current_time = al_get_time();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ // Setup inputs
+ ALLEGRO_KEYBOARD_STATE keys;
+ al_get_keyboard_state(&keys);
+ io.KeyCtrl = al_key_down(&keys, ALLEGRO_KEY_LCTRL) || al_key_down(&keys, ALLEGRO_KEY_RCTRL);
+ io.KeyShift = al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT);
+ io.KeyAlt = al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR);
+ io.KeySuper = al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN);
+
+ ImGui_ImplAllegro5_UpdateMouseCursor();
+}
diff --git a/third_party/imgui/examples/imgui_impl_allegro5.h b/third_party/imgui/examples/imgui_impl_allegro5.h
new file mode 100644
index 0000000000..f41e4c9096
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_allegro5.h
@@ -0,0 +1,30 @@
+// dear imgui: Renderer + Platform Binding for Allegro 5
+// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Platform: Clipboard support (from Allegro 5.1.12)
+// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
+// Issues:
+// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
+// [ ] 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, Original Allegro 5 code by @birthggd
+
+#pragma once
+#include "imgui.h" // IMGUI_IMPL_API
+
+struct ALLEGRO_DISPLAY;
+union ALLEGRO_EVENT;
+
+IMGUI_IMPL_API bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display);
+IMGUI_IMPL_API void ImGui_ImplAllegro5_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplAllegro5_NewFrame();
+IMGUI_IMPL_API void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data);
+IMGUI_IMPL_API bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* event);
+
+// Use if you want to reset your rendering device without losing Dear ImGui state.
+IMGUI_IMPL_API bool ImGui_ImplAllegro5_CreateDeviceObjects();
+IMGUI_IMPL_API void ImGui_ImplAllegro5_InvalidateDeviceObjects();
diff --git a/third_party/imgui/examples/directx10_example/imgui_impl_dx10.cpp b/third_party/imgui/examples/imgui_impl_dx10.cpp
similarity index 57%
rename from third_party/imgui/examples/directx10_example/imgui_impl_dx10.cpp
rename to third_party/imgui/examples/imgui_impl_dx10.cpp
index ed1efeef56..23ade277dc 100644
--- a/third_party/imgui/examples/directx10_example/imgui_impl_dx10.cpp
+++ b/third_party/imgui/examples/imgui_impl_dx10.cpp
@@ -1,53 +1,49 @@
-// ImGui Win32 + DirectX10 binding
+// dear imgui: Renderer for DirectX10
+// This needs to be used along with a Platform Binding (e.g. Win32)
// Implemented features:
-// [X] User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
+// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// 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
+// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
-// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
+// 2019-07-21: DirectX10: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX10_RenderDrawData().
+// 2019-05-29: DirectX10: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
+// 2019-04-30: DirectX10: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
+// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().
+// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
+// 2018-07-13: DirectX10: Fixed unreleased resources in Init and Shutdown functions.
+// 2018-06-08: Misc: Extracted imgui_impl_dx10.cpp/.h away from the old combined DX10+Win32 example.
+// 2018-06-08: DirectX10: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
+// 2018-04-09: Misc: Fixed erroneous call to io.Fonts->ClearInputData() + ClearTexData() that was left in DX10 example but removed in 1.47 (Nov 2015) on other back-ends.
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX10_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-// 2018-02-06: Inputs: Honoring the io.WantMoveMouse by repositioning the mouse by using navigation and ImGuiNavFlags_MoveMouse is set.
-// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
-// 2018-01-08: Inputs: Added mapping for ImGuiKey_Insert.
-// 2018-01-05: Inputs: Added WM_LBUTTONDBLCLK double-click handlers for window classes with the CS_DBLCLKS flag.
-// 2017-10-23: Inputs: Added WM_SYSKEYDOWN / WM_SYSKEYUP handlers so e.g. the VK_MENU key can be read.
-// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
-// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set.
// 2016-05-07: DirectX10: Disabling depth-write.
#include "imgui.h"
#include "imgui_impl_dx10.h"
// DirectX
+#include
#include
#include
#include
-#define DIRECTINPUT_VERSION 0x0800
-#include
-
-// Win32 Data
-static HWND g_hWnd = 0;
-static INT64 g_Time = 0;
-static INT64 g_TicksPerSecond = 0;
-static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_Count_;
+#ifdef _MSC_VER
+#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
+#endif
// DirectX data
static ID3D10Device* g_pd3dDevice = NULL;
+static IDXGIFactory* g_pFactory = NULL;
static ID3D10Buffer* g_pVB = NULL;
static ID3D10Buffer* g_pIB = NULL;
-static ID3D10Blob * g_pVertexShaderBlob = NULL;
static ID3D10VertexShader* g_pVertexShader = NULL;
static ID3D10InputLayout* g_pInputLayout = NULL;
static ID3D10Buffer* g_pVertexConstantBuffer = NULL;
-static ID3D10Blob * g_pPixelShaderBlob = NULL;
static ID3D10PixelShader* g_pPixelShader = NULL;
static ID3D10SamplerState* g_pFontSampler = NULL;
static ID3D10ShaderResourceView*g_pFontTextureView = NULL;
@@ -58,13 +54,49 @@ static int g_VertexBufferSize = 5000, g_IndexBufferSize = 1
struct VERTEX_CONSTANT_BUFFER
{
- float mvp[4][4];
+ float mvp[4][4];
};
+static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* ctx)
+{
+ // Setup viewport
+ D3D10_VIEWPORT vp;
+ memset(&vp, 0, sizeof(D3D10_VIEWPORT));
+ vp.Width = (UINT)draw_data->DisplaySize.x;
+ vp.Height = (UINT)draw_data->DisplaySize.y;
+ vp.MinDepth = 0.0f;
+ vp.MaxDepth = 1.0f;
+ vp.TopLeftX = vp.TopLeftY = 0;
+ ctx->RSSetViewports(1, &vp);
+
+ // Bind shader and vertex buffers
+ unsigned int stride = sizeof(ImDrawVert);
+ unsigned int offset = 0;
+ ctx->IASetInputLayout(g_pInputLayout);
+ ctx->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
+ ctx->IASetIndexBuffer(g_pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
+ ctx->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ctx->VSSetShader(g_pVertexShader);
+ ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
+ ctx->PSSetShader(g_pPixelShader);
+ ctx->PSSetSamplers(0, 1, &g_pFontSampler);
+ ctx->GSSetShader(NULL);
+
+ // Setup render state
+ const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
+ ctx->OMSetBlendState(g_pBlendState, blend_factor, 0xffffffff);
+ ctx->OMSetDepthStencilState(g_pDepthStencilState, 0);
+ ctx->RSSetState(g_pRasterizerState);
+}
+
// Render function
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
{
+ // Avoid rendering when minimized
+ if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
+ return;
+
ID3D10Device* ctx = g_pd3dDevice;
// Create and grow vertex/index buffers if needed
@@ -114,16 +146,17 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
g_pIB->Unmap();
// Setup orthographic projection matrix into our constant buffer
+ // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
{
void* mapped_resource;
if (g_pVertexConstantBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
return;
VERTEX_CONSTANT_BUFFER* constant_buffer = (VERTEX_CONSTANT_BUFFER*)mapped_resource;
- const float L = 0.0f;
- const float R = ImGui::GetIO().DisplaySize.x;
- const float B = ImGui::GetIO().DisplaySize.y;
- const float T = 0.0f;
- const float mvp[4][4] =
+ float L = draw_data->DisplayPos.x;
+ float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
+ float T = draw_data->DisplayPos.y;
+ float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
+ float mvp[4][4] =
{
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
@@ -150,6 +183,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
ID3D10SamplerState* PSSampler;
ID3D10PixelShader* PS;
ID3D10VertexShader* VS;
+ ID3D10GeometryShader* GS;
D3D10_PRIMITIVE_TOPOLOGY PrimitiveTopology;
ID3D10Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer;
UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset;
@@ -168,42 +202,20 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
ctx->PSGetShader(&old.PS);
ctx->VSGetShader(&old.VS);
ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
+ ctx->GSGetShader(&old.GS);
ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology);
ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
ctx->IAGetInputLayout(&old.InputLayout);
- // Setup viewport
- D3D10_VIEWPORT vp;
- memset(&vp, 0, sizeof(D3D10_VIEWPORT));
- vp.Width = (UINT)ImGui::GetIO().DisplaySize.x;
- vp.Height = (UINT)ImGui::GetIO().DisplaySize.y;
- vp.MinDepth = 0.0f;
- vp.MaxDepth = 1.0f;
- vp.TopLeftX = vp.TopLeftY = 0;
- ctx->RSSetViewports(1, &vp);
-
- // Bind shader and vertex buffers
- unsigned int stride = sizeof(ImDrawVert);
- unsigned int offset = 0;
- ctx->IASetInputLayout(g_pInputLayout);
- ctx->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
- ctx->IASetIndexBuffer(g_pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
- ctx->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
- ctx->VSSetShader(g_pVertexShader);
- ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
- ctx->PSSetShader(g_pPixelShader);
- ctx->PSSetSamplers(0, 1, &g_pFontSampler);
-
- // Setup render state
- const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
- ctx->OMSetBlendState(g_pBlendState, blend_factor, 0xffffffff);
- ctx->OMSetDepthStencilState(g_pDepthStencilState, 0);
- ctx->RSSetState(g_pRasterizerState);
+ // Setup desired DX state
+ ImGui_ImplDX10_SetupRenderState(draw_data, ctx);
// Render command lists
- int vtx_offset = 0;
- int idx_offset = 0;
+ // (Because we merged all buffers into a single one, we maintain our own offset into them)
+ int global_vtx_offset = 0;
+ int global_idx_offset = 0;
+ ImVec2 clip_off = draw_data->DisplayPos;
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
@@ -212,18 +224,27 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
- pcmd->UserCallback(cmd_list, pcmd);
+ // User callback, registered via ImDrawList::AddCallback()
+ // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
+ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
+ ImGui_ImplDX10_SetupRenderState(draw_data, ctx);
+ else
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
- const D3D10_RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
- ctx->PSSetShaderResources(0, 1, (ID3D10ShaderResourceView**)&pcmd->TextureId);
+ // Apply scissor/clipping rectangle
+ const D3D10_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y)};
ctx->RSSetScissorRects(1, &r);
- ctx->DrawIndexed(pcmd->ElemCount, idx_offset, vtx_offset);
+
+ // Bind texture, Draw
+ ID3D10ShaderResourceView* texture_srv = (ID3D10ShaderResourceView*)pcmd->TextureId;
+ ctx->PSSetShaderResources(0, 1, &texture_srv);
+ ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset);
}
- idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.Size;
+ global_idx_offset += cmd_list->IdxBuffer.Size;
+ global_vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -236,6 +257,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release();
ctx->PSSetShader(old.PS); if (old.PS) old.PS->Release();
ctx->VSSetShader(old.VS); if (old.VS) old.VS->Release();
+ ctx->GSSetShader(old.GS); if (old.GS) old.GS->Release();
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
@@ -243,120 +265,15 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
}
-static void ImGui_ImplWin32_UpdateMouseCursor()
-{
- ImGuiIO& io = ImGui::GetIO();
- ImGuiMouseCursor imgui_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
- if (imgui_cursor == ImGuiMouseCursor_None)
- {
- // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
- ::SetCursor(NULL);
- }
- else
- {
- // Hardware cursor type
- LPTSTR win32_cursor = IDC_ARROW;
- switch (imgui_cursor)
- {
- case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break;
- case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break;
- case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break;
- case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break;
- case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break;
- case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
- case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
- }
- ::SetCursor(::LoadCursor(NULL, win32_cursor));
- }
-}
-
-// Process Win32 mouse/keyboard inputs.
-// 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.
-// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
-// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
-IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (ImGui::GetCurrentContext() == NULL)
- return 0;
-
- ImGuiIO& io = ImGui::GetIO();
- switch (msg)
- {
- case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
- case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
- case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
- {
- int button = 0;
- if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) button = 0;
- if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) button = 1;
- if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) button = 2;
- if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
- ::SetCapture(hwnd);
- io.MouseDown[button] = true;
- return 0;
- }
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MBUTTONUP:
- {
- int button = 0;
- if (msg == WM_LBUTTONUP) button = 0;
- if (msg == WM_RBUTTONUP) button = 1;
- if (msg == WM_MBUTTONUP) button = 2;
- io.MouseDown[button] = false;
- if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
- ::ReleaseCapture();
- return 0;
- }
- case WM_MOUSEWHEEL:
- io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
- return 0;
- case WM_MOUSEHWHEEL:
- io.MouseWheelH += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
- return 0;
- case WM_MOUSEMOVE:
- io.MousePos.x = (signed short)(lParam);
- io.MousePos.y = (signed short)(lParam >> 16);
- return 0;
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- if (wParam < 256)
- io.KeysDown[wParam] = 1;
- return 0;
- case WM_KEYUP:
- case WM_SYSKEYUP:
- if (wParam < 256)
- io.KeysDown[wParam] = 0;
- return 0;
- case WM_CHAR:
- // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
- if (wParam > 0 && wParam < 0x10000)
- io.AddInputCharacter((unsigned short)wParam);
- return 0;
- case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- ImGui_ImplWin32_UpdateMouseCursor();
- return 1;
- }
- return 0;
- }
- return 0;
-}
-
static void ImGui_ImplDX10_CreateFontsTexture()
{
+ // Build texture atlas
ImGuiIO& io = ImGui::GetIO();
-
- // Build
unsigned char* pixels;
int width, height;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
- // Create DX10 texture
+ // Upload texture to graphics system
{
D3D10_TEXTURE2D_DESC desc;
ZeroMemory(&desc, sizeof(desc));
@@ -389,7 +306,7 @@ static void ImGui_ImplDX10_CreateFontsTexture()
}
// Store our identifier
- io.Fonts->TexID = (void *)g_pFontTextureView;
+ io.Fonts->TexID = (ImTextureID)g_pFontTextureView;
// Create texture sampler
{
@@ -405,10 +322,6 @@ static void ImGui_ImplDX10_CreateFontsTexture()
desc.MaxLOD = 0.f;
g_pd3dDevice->CreateSamplerState(&desc, &g_pFontSampler);
}
-
- // Cleanup (don't clear the input data if you want to append new fonts later)
- io.Fonts->ClearInputData();
- io.Fonts->ClearTexData();
}
bool ImGui_ImplDX10_CreateDeviceObjects()
@@ -419,9 +332,9 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
ImGui_ImplDX10_InvalidateDeviceObjects();
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
- // If you would like to use this DX11 sample code but remove this dependency you can:
+ // If you would like to use this DX10 sample code but remove this dependency you can:
// 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
- // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
+ // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
// Create the vertex shader
@@ -429,46 +342,53 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
static const char* vertexShader =
"cbuffer vertexBuffer : register(b0) \
{\
- float4x4 ProjectionMatrix; \
+ float4x4 ProjectionMatrix; \
};\
struct VS_INPUT\
{\
- float2 pos : POSITION;\
- float4 col : COLOR0;\
- float2 uv : TEXCOORD0;\
+ float2 pos : POSITION;\
+ float4 col : COLOR0;\
+ float2 uv : TEXCOORD0;\
};\
\
struct PS_INPUT\
{\
- float4 pos : SV_POSITION;\
- float4 col : COLOR0;\
- float2 uv : TEXCOORD0;\
+ float4 pos : SV_POSITION;\
+ float4 col : COLOR0;\
+ float2 uv : TEXCOORD0;\
};\
\
PS_INPUT main(VS_INPUT input)\
{\
- PS_INPUT output;\
- output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
- output.col = input.col;\
- output.uv = input.uv;\
- return output;\
+ PS_INPUT output;\
+ output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
+ output.col = input.col;\
+ output.uv = input.uv;\
+ return output;\
}";
- D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &g_pVertexShaderBlob, NULL);
- if (g_pVertexShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
- return false;
- if (g_pd3dDevice->CreateVertexShader((DWORD*)g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pVertexShader) != S_OK)
+ ID3DBlob* vertexShaderBlob;
+ if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &vertexShaderBlob, NULL)))
+ return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
+ if (g_pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &g_pVertexShader) != S_OK)
+ {
+ vertexShaderBlob->Release();
return false;
+ }
// Create the input layout
- D3D10_INPUT_ELEMENT_DESC local_layout[] =
+ D3D10_INPUT_ELEMENT_DESC local_layout[] =
{
- { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D10_INPUT_PER_VERTEX_DATA, 0 },
- { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D10_INPUT_PER_VERTEX_DATA, 0 },
- { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D10_INPUT_PER_VERTEX_DATA, 0 },
+ { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D10_INPUT_PER_VERTEX_DATA, 0 },
+ { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D10_INPUT_PER_VERTEX_DATA, 0 },
+ { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
- if (g_pd3dDevice->CreateInputLayout(local_layout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
+ if (g_pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
+ {
+ vertexShaderBlob->Release();
return false;
+ }
+ vertexShaderBlob->Release();
// Create the constant buffer
{
@@ -500,11 +420,15 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
return out_col; \
}";
- D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &g_pPixelShaderBlob, NULL);
- if (g_pPixelShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
- return false;
- if (g_pd3dDevice->CreatePixelShader((DWORD*)g_pPixelShaderBlob->GetBufferPointer(), g_pPixelShaderBlob->GetBufferSize(), &g_pPixelShader) != S_OK)
+ ID3DBlob* pixelShaderBlob;
+ if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &pixelShaderBlob, NULL)))
+ return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
+ if (g_pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize(), &g_pPixelShader) != S_OK)
+ {
+ pixelShaderBlob->Release();
return false;
+ }
+ pixelShaderBlob->Release();
}
// Create the blending setup
@@ -567,47 +491,33 @@ void ImGui_ImplDX10_InvalidateDeviceObjects()
if (g_pDepthStencilState) { g_pDepthStencilState->Release(); g_pDepthStencilState = NULL; }
if (g_pRasterizerState) { g_pRasterizerState->Release(); g_pRasterizerState = NULL; }
if (g_pPixelShader) { g_pPixelShader->Release(); g_pPixelShader = NULL; }
- if (g_pPixelShaderBlob) { g_pPixelShaderBlob->Release(); g_pPixelShaderBlob = NULL; }
if (g_pVertexConstantBuffer) { g_pVertexConstantBuffer->Release(); g_pVertexConstantBuffer = NULL; }
if (g_pInputLayout) { g_pInputLayout->Release(); g_pInputLayout = NULL; }
if (g_pVertexShader) { g_pVertexShader->Release(); g_pVertexShader = NULL; }
- if (g_pVertexShaderBlob) { g_pVertexShaderBlob->Release(); g_pVertexShaderBlob = NULL; }
}
-bool ImGui_ImplDX10_Init(void* hwnd, ID3D10Device* device)
+bool ImGui_ImplDX10_Init(ID3D10Device* device)
{
- g_hWnd = (HWND)hwnd;
- g_pd3dDevice = device;
-
- if (!QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
- return false;
- if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
- return false;
-
+ // Setup back-end capabilities flags
ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = VK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
- io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
- io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR;
- io.KeyMap[ImGuiKey_PageDown] = VK_NEXT;
- io.KeyMap[ImGuiKey_Home] = VK_HOME;
- io.KeyMap[ImGuiKey_End] = VK_END;
- io.KeyMap[ImGuiKey_Insert] = VK_INSERT;
- io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
- io.KeyMap[ImGuiKey_Space] = VK_SPACE;
- io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
- io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
- 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';
+ io.BackendRendererName = "imgui_impl_dx10";
+ io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
- io.ImeWindowHandle = g_hWnd;
+ // Get factory from device
+ IDXGIDevice* pDXGIDevice = NULL;
+ IDXGIAdapter* pDXGIAdapter = NULL;
+ IDXGIFactory* pFactory = NULL;
+
+ if (device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)) == S_OK)
+ if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK)
+ if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK)
+ {
+ g_pd3dDevice = device;
+ g_pFactory = pFactory;
+ }
+ if (pDXGIDevice) pDXGIDevice->Release();
+ if (pDXGIAdapter) pDXGIAdapter->Release();
+ g_pd3dDevice->AddRef();
return true;
}
@@ -615,54 +525,12 @@ bool ImGui_ImplDX10_Init(void* hwnd, ID3D10Device* device)
void ImGui_ImplDX10_Shutdown()
{
ImGui_ImplDX10_InvalidateDeviceObjects();
- g_pd3dDevice = NULL;
- g_hWnd = (HWND)0;
+ if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; }
+ if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
}
void ImGui_ImplDX10_NewFrame()
{
if (!g_pFontSampler)
ImGui_ImplDX10_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- RECT rect;
- GetClientRect(g_hWnd, &rect);
- io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
-
- // Setup time step
- INT64 current_time;
- QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
- io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
- g_Time = current_time;
-
- // Read keyboard modifiers inputs
- io.KeyCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
- io.KeyShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
- io.KeyAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;
- io.KeySuper = false;
- // io.KeysDown : filled by WM_KEYDOWN/WM_KEYUP events
- // io.MousePos : filled by WM_MOUSEMOVE events
- // io.MouseDown : filled by WM_*BUTTON* events
- // io.MouseWheel : filled by WM_MOUSEWHEEL events
-
- // Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
- if (io.WantMoveMouse)
- {
- POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
- ClientToScreen(g_hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
- }
-
- // Update OS mouse cursor with the cursor requested by imgui
- ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
- if (g_LastMouseCursor != mouse_cursor)
- {
- g_LastMouseCursor = mouse_cursor;
- ImGui_ImplWin32_UpdateMouseCursor();
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
}
diff --git a/third_party/imgui/examples/imgui_impl_dx10.h b/third_party/imgui/examples/imgui_impl_dx10.h
new file mode 100644
index 0000000000..d974ba8e34
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_dx10.h
@@ -0,0 +1,24 @@
+// dear imgui: Renderer for DirectX10
+// This needs to be used along with a Platform Binding (e.g. Win32)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+
+// 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
+#include "imgui.h" // IMGUI_IMPL_API
+
+struct ID3D10Device;
+
+IMGUI_IMPL_API bool ImGui_ImplDX10_Init(ID3D10Device* device);
+IMGUI_IMPL_API void ImGui_ImplDX10_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplDX10_NewFrame();
+IMGUI_IMPL_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data);
+
+// Use if you want to reset your rendering device without losing Dear ImGui state.
+IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects();
+IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects();
diff --git a/third_party/imgui/examples/directx11_example/imgui_impl_dx11.cpp b/third_party/imgui/examples/imgui_impl_dx11.cpp
similarity index 58%
rename from third_party/imgui/examples/directx11_example/imgui_impl_dx11.cpp
rename to third_party/imgui/examples/imgui_impl_dx11.cpp
index 84dcdbee49..26eb407f3e 100644
--- a/third_party/imgui/examples/directx11_example/imgui_impl_dx11.cpp
+++ b/third_party/imgui/examples/imgui_impl_dx11.cpp
@@ -1,53 +1,50 @@
-// ImGui Win32 + DirectX11 binding
+// dear imgui: Renderer for DirectX11
+// This needs to be used along with a Platform Binding (e.g. Win32)
// Implemented features:
-// [X] User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
+// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// 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)
-// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
+// 2019-08-01: DirectX11: Fixed code querying the Geometry Shader state (would generally error with Debug layer enabled).
+// 2019-07-21: DirectX11: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX10_RenderDrawData. Clearing Hull/Domain/Compute shaders without backup/restore.
+// 2019-05-29: DirectX11: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
+// 2019-04-30: DirectX11: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
+// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().
+// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
+// 2018-08-01: DirectX11: Querying for IDXGIFactory instead of IDXGIFactory1 to increase compatibility.
+// 2018-07-13: DirectX11: Fixed unreleased resources in Init and Shutdown functions.
+// 2018-06-08: Misc: Extracted imgui_impl_dx11.cpp/.h away from the old combined DX11+Win32 example.
+// 2018-06-08: DirectX11: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX11_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-// 2018-02-06: Inputs: Honoring the io.WantMoveMouse by repositioning the mouse by using navigation and ImGuiNavFlags_MoveMouse is set.
-// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
-// 2018-01-08: Inputs: Added mapping for ImGuiKey_Insert.
-// 2018-01-05: Inputs: Added WM_LBUTTONDBLCLK double-click handlers for window classes with the CS_DBLCLKS flag.
-// 2017-10-23: Inputs: Added WM_SYSKEYDOWN / WM_SYSKEYUP handlers so e.g. the VK_MENU key can be read.
-// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
-// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set.
// 2016-05-07: DirectX11: Disabling depth-write.
#include "imgui.h"
#include "imgui_impl_dx11.h"
// DirectX
+#include
#include
#include
-#define DIRECTINPUT_VERSION 0x0800
-#include
-
-// Win32 data
-static HWND g_hWnd = 0;
-static INT64 g_Time = 0;
-static INT64 g_TicksPerSecond = 0;
-static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_Count_;
+#ifdef _MSC_VER
+#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
+#endif
// DirectX data
static ID3D11Device* g_pd3dDevice = NULL;
static ID3D11DeviceContext* g_pd3dDeviceContext = NULL;
+static IDXGIFactory* g_pFactory = NULL;
static ID3D11Buffer* g_pVB = NULL;
static ID3D11Buffer* g_pIB = NULL;
-static ID3D10Blob * g_pVertexShaderBlob = NULL;
static ID3D11VertexShader* g_pVertexShader = NULL;
static ID3D11InputLayout* g_pInputLayout = NULL;
static ID3D11Buffer* g_pVertexConstantBuffer = NULL;
-static ID3D10Blob * g_pPixelShaderBlob = NULL;
static ID3D11PixelShader* g_pPixelShader = NULL;
static ID3D11SamplerState* g_pFontSampler = NULL;
static ID3D11ShaderResourceView*g_pFontTextureView = NULL;
@@ -58,13 +55,52 @@ static int g_VertexBufferSize = 5000, g_IndexBufferSize = 1
struct VERTEX_CONSTANT_BUFFER
{
- float mvp[4][4];
+ float mvp[4][4];
};
+static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
+{
+ // Setup viewport
+ D3D11_VIEWPORT vp;
+ memset(&vp, 0, sizeof(D3D11_VIEWPORT));
+ vp.Width = draw_data->DisplaySize.x;
+ vp.Height = draw_data->DisplaySize.y;
+ vp.MinDepth = 0.0f;
+ vp.MaxDepth = 1.0f;
+ vp.TopLeftX = vp.TopLeftY = 0;
+ ctx->RSSetViewports(1, &vp);
+
+ // Setup shader and vertex buffers
+ unsigned int stride = sizeof(ImDrawVert);
+ unsigned int offset = 0;
+ ctx->IASetInputLayout(g_pInputLayout);
+ ctx->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
+ ctx->IASetIndexBuffer(g_pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
+ ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ctx->VSSetShader(g_pVertexShader, NULL, 0);
+ ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
+ ctx->PSSetShader(g_pPixelShader, NULL, 0);
+ ctx->PSSetSamplers(0, 1, &g_pFontSampler);
+ ctx->GSSetShader(NULL, NULL, 0);
+ ctx->HSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
+ ctx->DSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
+ ctx->CSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
+
+ // Setup blend state
+ const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
+ ctx->OMSetBlendState(g_pBlendState, blend_factor, 0xffffffff);
+ ctx->OMSetDepthStencilState(g_pDepthStencilState, 0);
+ ctx->RSSetState(g_pRasterizerState);
+}
+
// Render function
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
{
+ // Avoid rendering when minimized
+ if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
+ return;
+
ID3D11DeviceContext* ctx = g_pd3dDeviceContext;
// Create and grow vertex/index buffers if needed
@@ -96,7 +132,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
return;
}
- // Copy and convert all vertices into a single contiguous buffer
+ // Upload vertex/index data into a single contiguous GPU buffer
D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource;
if (ctx->Map(g_pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK)
return;
@@ -116,15 +152,16 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
ctx->Unmap(g_pIB, 0);
// Setup orthographic projection matrix into our constant buffer
+ // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
{
D3D11_MAPPED_SUBRESOURCE mapped_resource;
if (ctx->Map(g_pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
return;
VERTEX_CONSTANT_BUFFER* constant_buffer = (VERTEX_CONSTANT_BUFFER*)mapped_resource.pData;
- float L = 0.0f;
- float R = ImGui::GetIO().DisplaySize.x;
- float B = ImGui::GetIO().DisplaySize.y;
- float T = 0.0f;
+ float L = draw_data->DisplayPos.x;
+ float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
+ float T = draw_data->DisplayPos.y;
+ float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
float mvp[4][4] =
{
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
@@ -152,8 +189,9 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
ID3D11SamplerState* PSSampler;
ID3D11PixelShader* PS;
ID3D11VertexShader* VS;
- UINT PSInstancesCount, VSInstancesCount;
- ID3D11ClassInstance* PSInstances[256], *VSInstances[256]; // 256 is max according to PSSetShader documentation
+ ID3D11GeometryShader* GS;
+ UINT PSInstancesCount, VSInstancesCount, GSInstancesCount;
+ ID3D11ClassInstance *PSInstances[256], *VSInstances[256], *GSInstances[256]; // 256 is max according to PSSetShader documentation
D3D11_PRIMITIVE_TOPOLOGY PrimitiveTopology;
ID3D11Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer;
UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset;
@@ -169,66 +207,54 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
ctx->OMGetDepthStencilState(&old.DepthStencilState, &old.StencilRef);
ctx->PSGetShaderResources(0, 1, &old.PSShaderResource);
ctx->PSGetSamplers(0, 1, &old.PSSampler);
- old.PSInstancesCount = old.VSInstancesCount = 256;
+ old.PSInstancesCount = old.VSInstancesCount = old.GSInstancesCount = 256;
ctx->PSGetShader(&old.PS, old.PSInstances, &old.PSInstancesCount);
ctx->VSGetShader(&old.VS, old.VSInstances, &old.VSInstancesCount);
ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
+ ctx->GSGetShader(&old.GS, old.GSInstances, &old.GSInstancesCount);
+
ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology);
ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
ctx->IAGetInputLayout(&old.InputLayout);
- // Setup viewport
- D3D11_VIEWPORT vp;
- memset(&vp, 0, sizeof(D3D11_VIEWPORT));
- vp.Width = ImGui::GetIO().DisplaySize.x;
- vp.Height = ImGui::GetIO().DisplaySize.y;
- vp.MinDepth = 0.0f;
- vp.MaxDepth = 1.0f;
- vp.TopLeftX = vp.TopLeftY = 0.0f;
- ctx->RSSetViewports(1, &vp);
-
- // Bind shader and vertex buffers
- unsigned int stride = sizeof(ImDrawVert);
- unsigned int offset = 0;
- ctx->IASetInputLayout(g_pInputLayout);
- ctx->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
- ctx->IASetIndexBuffer(g_pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
- ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
- ctx->VSSetShader(g_pVertexShader, NULL, 0);
- ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
- ctx->PSSetShader(g_pPixelShader, NULL, 0);
- ctx->PSSetSamplers(0, 1, &g_pFontSampler);
-
- // Setup render state
- const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
- ctx->OMSetBlendState(g_pBlendState, blend_factor, 0xffffffff);
- ctx->OMSetDepthStencilState(g_pDepthStencilState, 0);
- ctx->RSSetState(g_pRasterizerState);
+ // Setup desired DX state
+ ImGui_ImplDX11_SetupRenderState(draw_data, ctx);
// Render command lists
- int vtx_offset = 0;
- int idx_offset = 0;
+ // (Because we merged all buffers into a single one, we maintain our own offset into them)
+ int global_idx_offset = 0;
+ int global_vtx_offset = 0;
+ ImVec2 clip_off = draw_data->DisplayPos;
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
+ if (pcmd->UserCallback != NULL)
{
- pcmd->UserCallback(cmd_list, pcmd);
+ // User callback, registered via ImDrawList::AddCallback()
+ // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
+ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
+ ImGui_ImplDX11_SetupRenderState(draw_data, ctx);
+ else
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
- const D3D11_RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
- ctx->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->TextureId);
+ // Apply scissor/clipping rectangle
+ const D3D11_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
ctx->RSSetScissorRects(1, &r);
- ctx->DrawIndexed(pcmd->ElemCount, idx_offset, vtx_offset);
+
+ // Bind texture, Draw
+ ID3D11ShaderResourceView* texture_srv = (ID3D11ShaderResourceView*)pcmd->TextureId;
+ ctx->PSSetShaderResources(0, 1, &texture_srv);
+ ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset);
}
- idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.Size;
+ global_idx_offset += cmd_list->IdxBuffer.Size;
+ global_vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
@@ -243,6 +269,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
for (UINT i = 0; i < old.PSInstancesCount; i++) if (old.PSInstances[i]) old.PSInstances[i]->Release();
ctx->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount); if (old.VS) old.VS->Release();
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
+ ctx->GSSetShader(old.GS, old.GSInstances, old.GSInstancesCount); if (old.GS) old.GS->Release();
for (UINT i = 0; i < old.VSInstancesCount; i++) if (old.VSInstances[i]) old.VSInstances[i]->Release();
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
@@ -250,110 +277,6 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
}
-static void ImGui_ImplWin32_UpdateMouseCursor()
-{
- ImGuiIO& io = ImGui::GetIO();
- ImGuiMouseCursor imgui_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
- if (imgui_cursor == ImGuiMouseCursor_None)
- {
- // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
- ::SetCursor(NULL);
- }
- else
- {
- // Hardware cursor type
- LPTSTR win32_cursor = IDC_ARROW;
- switch (imgui_cursor)
- {
- case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break;
- case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break;
- case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break;
- case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break;
- case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break;
- case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
- case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
- }
- ::SetCursor(::LoadCursor(NULL, win32_cursor));
- }
-}
-
-// Process Win32 mouse/keyboard inputs.
-// 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.
-// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
-// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
-IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (ImGui::GetCurrentContext() == NULL)
- return 0;
-
- ImGuiIO& io = ImGui::GetIO();
- switch (msg)
- {
- case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
- case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
- case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
- {
- int button = 0;
- if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) button = 0;
- if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) button = 1;
- if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) button = 2;
- if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
- ::SetCapture(hwnd);
- io.MouseDown[button] = true;
- return 0;
- }
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MBUTTONUP:
- {
- int button = 0;
- if (msg == WM_LBUTTONUP) button = 0;
- if (msg == WM_RBUTTONUP) button = 1;
- if (msg == WM_MBUTTONUP) button = 2;
- io.MouseDown[button] = false;
- if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
- ::ReleaseCapture();
- return 0;
- }
- case WM_MOUSEWHEEL:
- io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
- return 0;
- case WM_MOUSEHWHEEL:
- io.MouseWheelH += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
- return 0;
- case WM_MOUSEMOVE:
- io.MousePos.x = (signed short)(lParam);
- io.MousePos.y = (signed short)(lParam >> 16);
- return 0;
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- if (wParam < 256)
- io.KeysDown[wParam] = 1;
- return 0;
- case WM_KEYUP:
- case WM_SYSKEYUP:
- if (wParam < 256)
- io.KeysDown[wParam] = 0;
- return 0;
- case WM_CHAR:
- // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
- if (wParam > 0 && wParam < 0x10000)
- io.AddInputCharacter((unsigned short)wParam);
- return 0;
- case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- ImGui_ImplWin32_UpdateMouseCursor();
- return 1;
- }
- return 0;
- }
- return 0;
-}
-
static void ImGui_ImplDX11_CreateFontsTexture()
{
// Build texture atlas
@@ -395,7 +318,7 @@ static void ImGui_ImplDX11_CreateFontsTexture()
}
// Store our identifier
- io.Fonts->TexID = (void *)g_pFontTextureView;
+ io.Fonts->TexID = (ImTextureID)g_pFontTextureView;
// Create texture sampler
{
@@ -421,9 +344,9 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
ImGui_ImplDX11_InvalidateDeviceObjects();
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
- // If you would like to use this DX11 sample code but remove this dependency you can:
+ // If you would like to use this DX11 sample code but remove this dependency you can:
// 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
- // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
+ // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
// Create the vertex shader
@@ -431,45 +354,53 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
static const char* vertexShader =
"cbuffer vertexBuffer : register(b0) \
{\
- float4x4 ProjectionMatrix; \
+ float4x4 ProjectionMatrix; \
};\
struct VS_INPUT\
{\
- float2 pos : POSITION;\
- float4 col : COLOR0;\
- float2 uv : TEXCOORD0;\
+ float2 pos : POSITION;\
+ float4 col : COLOR0;\
+ float2 uv : TEXCOORD0;\
};\
\
struct PS_INPUT\
{\
- float4 pos : SV_POSITION;\
- float4 col : COLOR0;\
- float2 uv : TEXCOORD0;\
+ float4 pos : SV_POSITION;\
+ float4 col : COLOR0;\
+ float2 uv : TEXCOORD0;\
};\
\
PS_INPUT main(VS_INPUT input)\
{\
- PS_INPUT output;\
- output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
- output.col = input.col;\
- output.uv = input.uv;\
- return output;\
+ PS_INPUT output;\
+ output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
+ output.col = input.col;\
+ output.uv = input.uv;\
+ return output;\
}";
- D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &g_pVertexShaderBlob, NULL);
- if (g_pVertexShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
- return false;
- if (g_pd3dDevice->CreateVertexShader((DWORD*)g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), NULL, &g_pVertexShader) != S_OK)
+ ID3DBlob* vertexShaderBlob;
+ if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &vertexShaderBlob, NULL)))
+ return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
+ if (g_pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), NULL, &g_pVertexShader) != S_OK)
+ {
+ vertexShaderBlob->Release();
return false;
+ }
// Create the input layout
- D3D11_INPUT_ELEMENT_DESC local_layout[] = {
- { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ D3D11_INPUT_ELEMENT_DESC local_layout[] =
+ {
+ { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
- if (g_pd3dDevice->CreateInputLayout(local_layout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
+ if (g_pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
+ {
+ vertexShaderBlob->Release();
return false;
+ }
+ vertexShaderBlob->Release();
// Create the constant buffer
{
@@ -501,11 +432,15 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
return out_col; \
}";
- D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &g_pPixelShaderBlob, NULL);
- if (g_pPixelShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
- return false;
- if (g_pd3dDevice->CreatePixelShader((DWORD*)g_pPixelShaderBlob->GetBufferPointer(), g_pPixelShaderBlob->GetBufferSize(), NULL, &g_pPixelShader) != S_OK)
+ ID3DBlob* pixelShaderBlob;
+ if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &pixelShaderBlob, NULL)))
+ return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
+ if (g_pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize(), NULL, &g_pPixelShader) != S_OK)
+ {
+ pixelShaderBlob->Release();
return false;
+ }
+ pixelShaderBlob->Release();
}
// Create the blending setup
@@ -568,48 +503,35 @@ void ImGui_ImplDX11_InvalidateDeviceObjects()
if (g_pDepthStencilState) { g_pDepthStencilState->Release(); g_pDepthStencilState = NULL; }
if (g_pRasterizerState) { g_pRasterizerState->Release(); g_pRasterizerState = NULL; }
if (g_pPixelShader) { g_pPixelShader->Release(); g_pPixelShader = NULL; }
- if (g_pPixelShaderBlob) { g_pPixelShaderBlob->Release(); g_pPixelShaderBlob = NULL; }
if (g_pVertexConstantBuffer) { g_pVertexConstantBuffer->Release(); g_pVertexConstantBuffer = NULL; }
if (g_pInputLayout) { g_pInputLayout->Release(); g_pInputLayout = NULL; }
if (g_pVertexShader) { g_pVertexShader->Release(); g_pVertexShader = NULL; }
- if (g_pVertexShaderBlob) { g_pVertexShaderBlob->Release(); g_pVertexShaderBlob = NULL; }
}
-bool ImGui_ImplDX11_Init(void* hwnd, ID3D11Device* device, ID3D11DeviceContext* device_context)
+bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
{
- g_hWnd = (HWND)hwnd;
- g_pd3dDevice = device;
- g_pd3dDeviceContext = device_context;
-
- if (!QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
- return false;
- if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
- return false;
-
+ // Setup back-end capabilities flags
ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = VK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
- io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
- io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR;
- io.KeyMap[ImGuiKey_PageDown] = VK_NEXT;
- io.KeyMap[ImGuiKey_Home] = VK_HOME;
- io.KeyMap[ImGuiKey_End] = VK_END;
- io.KeyMap[ImGuiKey_Insert] = VK_INSERT;
- io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
- io.KeyMap[ImGuiKey_Space] = VK_SPACE;
- io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
- io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
- 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';
+ io.BackendRendererName = "imgui_impl_dx11";
+ io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
- io.ImeWindowHandle = g_hWnd;
+ // Get factory from device
+ IDXGIDevice* pDXGIDevice = NULL;
+ IDXGIAdapter* pDXGIAdapter = NULL;
+ IDXGIFactory* pFactory = NULL;
+
+ if (device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)) == S_OK)
+ if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK)
+ if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK)
+ {
+ g_pd3dDevice = device;
+ g_pd3dDeviceContext = device_context;
+ g_pFactory = pFactory;
+ }
+ if (pDXGIDevice) pDXGIDevice->Release();
+ if (pDXGIAdapter) pDXGIAdapter->Release();
+ g_pd3dDevice->AddRef();
+ g_pd3dDeviceContext->AddRef();
return true;
}
@@ -617,55 +539,13 @@ bool ImGui_ImplDX11_Init(void* hwnd, ID3D11Device* device, ID3D11DeviceContex
void ImGui_ImplDX11_Shutdown()
{
ImGui_ImplDX11_InvalidateDeviceObjects();
- g_pd3dDevice = NULL;
- g_pd3dDeviceContext = NULL;
- g_hWnd = (HWND)0;
+ if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; }
+ if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
+ if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; }
}
void ImGui_ImplDX11_NewFrame()
{
if (!g_pFontSampler)
ImGui_ImplDX11_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- RECT rect;
- GetClientRect(g_hWnd, &rect);
- io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
-
- // Setup time step
- INT64 current_time;
- QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
- io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
- g_Time = current_time;
-
- // Read keyboard modifiers inputs
- io.KeyCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
- io.KeyShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
- io.KeyAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;
- io.KeySuper = false;
- // io.KeysDown : filled by WM_KEYDOWN/WM_KEYUP events
- // io.MousePos : filled by WM_MOUSEMOVE events
- // io.MouseDown : filled by WM_*BUTTON* events
- // io.MouseWheel : filled by WM_MOUSEWHEEL events
-
- // Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
- if (io.WantMoveMouse)
- {
- POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
- ClientToScreen(g_hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
- }
-
- // Update OS mouse cursor with the cursor requested by imgui
- ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
- if (g_LastMouseCursor != mouse_cursor)
- {
- g_LastMouseCursor = mouse_cursor;
- ImGui_ImplWin32_UpdateMouseCursor();
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
}
diff --git a/third_party/imgui/examples/imgui_impl_dx11.h b/third_party/imgui/examples/imgui_impl_dx11.h
new file mode 100644
index 0000000000..cccadcd2c7
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_dx11.h
@@ -0,0 +1,25 @@
+// dear imgui: Renderer for DirectX11
+// This needs to be used along with a Platform Binding (e.g. Win32)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+
+// 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
+#include "imgui.h" // IMGUI_IMPL_API
+
+struct ID3D11Device;
+struct ID3D11DeviceContext;
+
+IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context);
+IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame();
+IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
+
+// Use if you want to reset your rendering device without losing Dear ImGui state.
+IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects();
+IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();
diff --git a/third_party/imgui/examples/directx12_example/imgui_impl_dx12.cpp b/third_party/imgui/examples/imgui_impl_dx12.cpp
similarity index 56%
rename from third_party/imgui/examples/directx12_example/imgui_impl_dx12.cpp
rename to third_party/imgui/examples/imgui_impl_dx12.cpp
index beb48b9cb1..167a189b09 100644
--- a/third_party/imgui/examples/directx12_example/imgui_impl_dx12.cpp
+++ b/third_party/imgui/examples/imgui_impl_dx12.cpp
@@ -1,16 +1,27 @@
-// ImGui Win32 + DirectX12 binding
-// FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*))
+// dear imgui: Renderer for DirectX12
+// This needs to be used along with a Platform Binding (e.g. Win32)
// Implemented features:
-// [X] User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
+// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+// Issues:
+// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// 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-10-18: DirectX12: *BREAKING CHANGE* Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function.
+// 2019-05-29: DirectX12: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
+// 2019-04-30: DirectX12: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
+// 2019-03-29: Misc: Various minor tidying up.
+// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().
+// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
+// 2018-06-12: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from NewFrame() to RenderDrawData().
+// 2018-06-08: Misc: Extracted imgui_impl_dx12.cpp/.h away from the old combined DX12+Win32 example.
+// 2018-06-08: DirectX12: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle (to ease support for future multi-viewport).
// 2018-02-22: Merged into master with all Win32 code synchronized to other examples.
#include "imgui.h"
@@ -18,19 +29,14 @@
// DirectX
#include
+#include
#include
-
-// Win32 data
-static HWND g_hWnd = 0;
-static INT64 g_Time = 0;
-static INT64 g_TicksPerSecond = 0;
-static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_Count_;
+#ifdef _MSC_VER
+#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
+#endif
// DirectX data
static ID3D12Device* g_pd3dDevice = NULL;
-static ID3D12GraphicsCommandList* g_pd3dCommandList = NULL;
-static ID3D10Blob* g_pVertexShaderBlob = NULL;
-static ID3D10Blob* g_pPixelShaderBlob = NULL;
static ID3D12RootSignature* g_pRootSignature = NULL;
static ID3D12PipelineState* g_pPipelineState = NULL;
static DXGI_FORMAT g_RTVFormat = DXGI_FORMAT_UNKNOWN;
@@ -40,39 +46,101 @@ static D3D12_GPU_DESCRIPTOR_HANDLE g_hFontSrvGpuDescHandle = {};
struct FrameResources
{
- ID3D12Resource* IB;
- ID3D12Resource* VB;
- int VertexBufferSize;
- int IndexBufferSize;
+ ID3D12Resource* IndexBuffer;
+ ID3D12Resource* VertexBuffer;
+ int IndexBufferSize;
+ int VertexBufferSize;
};
-static FrameResources* g_pFrameResources = NULL;
-static UINT g_numFramesInFlight = 0;
-static UINT g_frameIndex = UINT_MAX;
+static FrameResources* g_pFrameResources = NULL;
+static UINT g_numFramesInFlight = 0;
+static UINT g_frameIndex = UINT_MAX;
+
+template
+static void SafeRelease(T*& res)
+{
+ if (res)
+ res->Release();
+ res = NULL;
+}
struct VERTEX_CONSTANT_BUFFER
{
- float mvp[4][4];
+ float mvp[4][4];
};
+static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, FrameResources* fr)
+{
+ // Setup orthographic projection matrix into our constant buffer
+ // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right).
+ VERTEX_CONSTANT_BUFFER vertex_constant_buffer;
+ {
+ float L = draw_data->DisplayPos.x;
+ float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
+ float T = draw_data->DisplayPos.y;
+ float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
+ float mvp[4][4] =
+ {
+ { 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
+ { 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
+ { 0.0f, 0.0f, 0.5f, 0.0f },
+ { (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
+ };
+ memcpy(&vertex_constant_buffer.mvp, mvp, sizeof(mvp));
+ }
+
+ // Setup viewport
+ D3D12_VIEWPORT vp;
+ memset(&vp, 0, sizeof(D3D12_VIEWPORT));
+ vp.Width = draw_data->DisplaySize.x;
+ vp.Height = draw_data->DisplaySize.y;
+ vp.MinDepth = 0.0f;
+ vp.MaxDepth = 1.0f;
+ vp.TopLeftX = vp.TopLeftY = 0.0f;
+ ctx->RSSetViewports(1, &vp);
+
+ // Bind shader and vertex buffers
+ unsigned int stride = sizeof(ImDrawVert);
+ unsigned int offset = 0;
+ D3D12_VERTEX_BUFFER_VIEW vbv;
+ memset(&vbv, 0, sizeof(D3D12_VERTEX_BUFFER_VIEW));
+ vbv.BufferLocation = fr->VertexBuffer->GetGPUVirtualAddress() + offset;
+ vbv.SizeInBytes = fr->VertexBufferSize * stride;
+ vbv.StrideInBytes = stride;
+ ctx->IASetVertexBuffers(0, 1, &vbv);
+ D3D12_INDEX_BUFFER_VIEW ibv;
+ memset(&ibv, 0, sizeof(D3D12_INDEX_BUFFER_VIEW));
+ ibv.BufferLocation = fr->IndexBuffer->GetGPUVirtualAddress();
+ ibv.SizeInBytes = fr->IndexBufferSize * sizeof(ImDrawIdx);
+ ibv.Format = sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
+ ctx->IASetIndexBuffer(&ibv);
+ ctx->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ctx->SetPipelineState(g_pPipelineState);
+ ctx->SetGraphicsRootSignature(g_pRootSignature);
+ ctx->SetGraphicsRoot32BitConstants(0, 16, &vertex_constant_buffer, 0);
+
+ // Setup blend factor
+ const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
+ ctx->OMSetBlendFactor(blend_factor);
+}
+
// Render function
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
-void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data)
+void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx)
{
- // NOTE: I'm assuming that this only get's called once per frame!
+ // Avoid rendering when minimized
+ if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
+ return;
+
+ // FIXME: I'm assuming that this only gets called once per frame!
// If not, we can't just re-allocate the IB or VB, we'll have to do a proper allocator.
g_frameIndex = g_frameIndex + 1;
- FrameResources* frameResources = &g_pFrameResources[g_frameIndex % g_numFramesInFlight];
- ID3D12Resource* g_pVB = frameResources->VB;
- ID3D12Resource* g_pIB = frameResources->IB;
- int g_VertexBufferSize = frameResources->VertexBufferSize;
- int g_IndexBufferSize = frameResources->IndexBufferSize;
- ID3D12GraphicsCommandList* ctx = g_pd3dCommandList;
+ FrameResources* fr = &g_pFrameResources[g_frameIndex % g_numFramesInFlight];
// Create and grow vertex/index buffers if needed
- if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
+ if (fr->VertexBuffer == NULL || fr->VertexBufferSize < draw_data->TotalVtxCount)
{
- if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
- g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
+ SafeRelease(fr->VertexBuffer);
+ fr->VertexBufferSize = draw_data->TotalVtxCount + 5000;
D3D12_HEAP_PROPERTIES props;
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
props.Type = D3D12_HEAP_TYPE_UPLOAD;
@@ -81,7 +149,7 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data)
D3D12_RESOURCE_DESC desc;
memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC));
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
- desc.Width = g_VertexBufferSize * sizeof(ImDrawVert);
+ desc.Width = fr->VertexBufferSize * sizeof(ImDrawVert);
desc.Height = 1;
desc.DepthOrArraySize = 1;
desc.MipLevels = 1;
@@ -89,16 +157,13 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data)
desc.SampleDesc.Count = 1;
desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
- if (g_pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE,
- &desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, IID_PPV_ARGS(&g_pVB)) < 0)
+ if (g_pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, IID_PPV_ARGS(&fr->VertexBuffer)) < 0)
return;
- frameResources->VB = g_pVB;
- frameResources->VertexBufferSize = g_VertexBufferSize;
}
- if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
+ if (fr->IndexBuffer == NULL || fr->IndexBufferSize < draw_data->TotalIdxCount)
{
- if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
- g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
+ SafeRelease(fr->IndexBuffer);
+ fr->IndexBufferSize = draw_data->TotalIdxCount + 10000;
D3D12_HEAP_PROPERTIES props;
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
props.Type = D3D12_HEAP_TYPE_UPLOAD;
@@ -107,7 +172,7 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data)
D3D12_RESOURCE_DESC desc;
memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC));
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
- desc.Width = g_IndexBufferSize * sizeof(ImDrawIdx);
+ desc.Width = fr->IndexBufferSize * sizeof(ImDrawIdx);
desc.Height = 1;
desc.DepthOrArraySize = 1;
desc.MipLevels = 1;
@@ -115,20 +180,17 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data)
desc.SampleDesc.Count = 1;
desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
- if (g_pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE,
- &desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, IID_PPV_ARGS(&g_pIB)) < 0)
+ if (g_pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, IID_PPV_ARGS(&fr->IndexBuffer)) < 0)
return;
- frameResources->IB = g_pIB;
- frameResources->IndexBufferSize = g_IndexBufferSize;
}
- // Copy and convert all vertices into a single contiguous buffer
+ // Upload vertex/index data into a single contiguous GPU buffer
void* vtx_resource, *idx_resource;
D3D12_RANGE range;
memset(&range, 0, sizeof(D3D12_RANGE));
- if (g_pVB->Map(0, &range, &vtx_resource) != S_OK)
+ if (fr->VertexBuffer->Map(0, &range, &vtx_resource) != S_OK)
return;
- if (g_pIB->Map(0, &range, &idx_resource) != S_OK)
+ if (fr->IndexBuffer->Map(0, &range, &idx_resource) != S_OK)
return;
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource;
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource;
@@ -140,191 +202,46 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data)
vtx_dst += cmd_list->VtxBuffer.Size;
idx_dst += cmd_list->IdxBuffer.Size;
}
- g_pVB->Unmap(0, &range);
- g_pIB->Unmap(0, &range);
+ fr->VertexBuffer->Unmap(0, &range);
+ fr->IndexBuffer->Unmap(0, &range);
- // Setup orthographic projection matrix into our constant buffer
- VERTEX_CONSTANT_BUFFER vertex_constant_buffer;
- {
- VERTEX_CONSTANT_BUFFER* constant_buffer = &vertex_constant_buffer;
- float L = 0.0f;
- float R = ImGui::GetIO().DisplaySize.x;
- float B = ImGui::GetIO().DisplaySize.y;
- float T = 0.0f;
- float mvp[4][4] =
- {
- { 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
- { 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
- { 0.0f, 0.0f, 0.5f, 0.0f },
- { (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
- };
- memcpy(&constant_buffer->mvp, mvp, sizeof(mvp));
- }
-
- // Setup viewport
- D3D12_VIEWPORT vp;
- memset(&vp, 0, sizeof(D3D12_VIEWPORT));
- vp.Width = ImGui::GetIO().DisplaySize.x;
- vp.Height = ImGui::GetIO().DisplaySize.y;
- vp.MinDepth = 0.0f;
- vp.MaxDepth = 1.0f;
- vp.TopLeftX = vp.TopLeftY = 0.0f;
- ctx->RSSetViewports(1, &vp);
-
- // Bind shader and vertex buffers
- unsigned int stride = sizeof(ImDrawVert);
- unsigned int offset = 0;
- D3D12_VERTEX_BUFFER_VIEW vbv;
- memset(&vbv, 0, sizeof(D3D12_VERTEX_BUFFER_VIEW));
- vbv.BufferLocation = g_pVB->GetGPUVirtualAddress() + offset;
- vbv.SizeInBytes = g_VertexBufferSize * stride;
- vbv.StrideInBytes = stride;
- ctx->IASetVertexBuffers(0, 1, &vbv);
- D3D12_INDEX_BUFFER_VIEW ibv;
- memset(&ibv, 0, sizeof(D3D12_INDEX_BUFFER_VIEW));
- ibv.BufferLocation = g_pIB->GetGPUVirtualAddress();
- ibv.SizeInBytes = g_IndexBufferSize * sizeof(ImDrawIdx);
- ibv.Format = sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
- ctx->IASetIndexBuffer(&ibv);
- ctx->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
- ctx->SetPipelineState(g_pPipelineState);
- ctx->SetGraphicsRootSignature(g_pRootSignature);
- ctx->SetGraphicsRoot32BitConstants(0, 16, &vertex_constant_buffer, 0);
-
- // Setup render state
- const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
- ctx->OMSetBlendFactor(blend_factor);
+ // Setup desired DX state
+ ImGui_ImplDX12_SetupRenderState(draw_data, ctx, fr);
// Render command lists
- int vtx_offset = 0;
- int idx_offset = 0;
+ // (Because we merged all buffers into a single one, we maintain our own offset into them)
+ int global_vtx_offset = 0;
+ int global_idx_offset = 0;
+ ImVec2 clip_off = draw_data->DisplayPos;
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
+ if (pcmd->UserCallback != NULL)
{
- pcmd->UserCallback(cmd_list, pcmd);
+ // User callback, registered via ImDrawList::AddCallback()
+ // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
+ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
+ ImGui_ImplDX12_SetupRenderState(draw_data, ctx, fr);
+ else
+ pcmd->UserCallback(cmd_list, pcmd);
}
else
{
- const D3D12_RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
+ // Apply Scissor, Bind texture, Draw
+ const D3D12_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
ctx->SetGraphicsRootDescriptorTable(1, *(D3D12_GPU_DESCRIPTOR_HANDLE*)&pcmd->TextureId);
ctx->RSSetScissorRects(1, &r);
- ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, idx_offset, vtx_offset, 0);
+ ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
}
- idx_offset += pcmd->ElemCount;
}
- vtx_offset += cmd_list->VtxBuffer.Size;
+ global_idx_offset += cmd_list->IdxBuffer.Size;
+ global_vtx_offset += cmd_list->VtxBuffer.Size;
}
}
-static void ImGui_ImplWin32_UpdateMouseCursor()
-{
- ImGuiIO& io = ImGui::GetIO();
- ImGuiMouseCursor imgui_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
- if (imgui_cursor == ImGuiMouseCursor_None)
- {
- // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
- ::SetCursor(NULL);
- }
- else
- {
- // Hardware cursor type
- LPTSTR win32_cursor = IDC_ARROW;
- switch (imgui_cursor)
- {
- case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break;
- case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break;
- case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break;
- case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break;
- case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break;
- case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
- case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
- }
- ::SetCursor(::LoadCursor(NULL, win32_cursor));
- }
-}
-
-// Process Win32 mouse/keyboard inputs.
-// 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.
-// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
-// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
-IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (ImGui::GetCurrentContext() == NULL)
- return 0;
-
- ImGuiIO& io = ImGui::GetIO();
- switch (msg)
- {
- case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
- case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
- case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
- {
- int button = 0;
- if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) button = 0;
- if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) button = 1;
- if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) button = 2;
- if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
- ::SetCapture(hwnd);
- io.MouseDown[button] = true;
- return 0;
- }
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MBUTTONUP:
- {
- int button = 0;
- if (msg == WM_LBUTTONUP) button = 0;
- if (msg == WM_RBUTTONUP) button = 1;
- if (msg == WM_MBUTTONUP) button = 2;
- io.MouseDown[button] = false;
- if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
- ::ReleaseCapture();
- return 0;
- }
- case WM_MOUSEWHEEL:
- io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
- return 0;
- case WM_MOUSEHWHEEL:
- io.MouseWheelH += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
- return 0;
- case WM_MOUSEMOVE:
- io.MousePos.x = (signed short)(lParam);
- io.MousePos.y = (signed short)(lParam >> 16);
- return 0;
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- if (wParam < 256)
- io.KeysDown[wParam] = 1;
- return 0;
- case WM_KEYUP:
- case WM_SYSKEYUP:
- if (wParam < 256)
- io.KeysDown[wParam] = 0;
- return 0;
- case WM_CHAR:
- // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
- if (wParam > 0 && wParam < 0x10000)
- io.AddInputCharacter((unsigned short)wParam);
- return 0;
- case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- ImGui_ImplWin32_UpdateMouseCursor();
- return 1;
- }
- return 0;
- }
- return 0;
-}
-
static void ImGui_ImplDX12_CreateFontsTexture()
{
// Build texture atlas
@@ -465,14 +382,13 @@ static void ImGui_ImplDX12_CreateFontsTexture()
srvDesc.Texture2D.MostDetailedMip = 0;
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, g_hFontSrvCpuDescHandle);
- if (g_pFontTextureResource != NULL)
- g_pFontTextureResource->Release();
+ SafeRelease(g_pFontTextureResource);
g_pFontTextureResource = pTexture;
}
// Store our identifier
- static_assert(sizeof(ImTextureID) >= sizeof(g_hFontSrvGpuDescHandle.ptr), "Can't pack descriptor handle into TexID");
- io.Fonts->TexID = (void *)g_hFontSrvGpuDescHandle.ptr;
+ static_assert(sizeof(ImTextureID) >= sizeof(g_hFontSrvGpuDescHandle.ptr), "Can't pack descriptor handle into TexID, 32-bit not supported yet.");
+ io.Fonts->TexID = (ImTextureID)g_hFontSrvGpuDescHandle.ptr;
}
bool ImGui_ImplDX12_CreateDeviceObjects()
@@ -539,9 +455,9 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
}
// By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
- // If you would like to use this DX12 sample code but remove this dependency you can:
+ // If you would like to use this DX12 sample code but remove this dependency you can:
// 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
- // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
+ // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc;
@@ -555,46 +471,48 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
psoDesc.SampleDesc.Count = 1;
psoDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
+ ID3DBlob* vertexShaderBlob;
+ ID3DBlob* pixelShaderBlob;
+
// Create the vertex shader
{
static const char* vertexShader =
"cbuffer vertexBuffer : register(b0) \
{\
- float4x4 ProjectionMatrix; \
+ float4x4 ProjectionMatrix; \
};\
struct VS_INPUT\
{\
- float2 pos : POSITION;\
- float4 col : COLOR0;\
- float2 uv : TEXCOORD0;\
+ float2 pos : POSITION;\
+ float4 col : COLOR0;\
+ float2 uv : TEXCOORD0;\
};\
\
struct PS_INPUT\
{\
- float4 pos : SV_POSITION;\
- float4 col : COLOR0;\
- float2 uv : TEXCOORD0;\
+ float4 pos : SV_POSITION;\
+ float4 col : COLOR0;\
+ float2 uv : TEXCOORD0;\
};\
\
PS_INPUT main(VS_INPUT input)\
{\
- PS_INPUT output;\
- output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
- output.col = input.col;\
- output.uv = input.uv;\
- return output;\
+ PS_INPUT output;\
+ output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
+ output.col = input.col;\
+ output.uv = input.uv;\
+ return output;\
}";
- D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_5_0", 0, 0, &g_pVertexShaderBlob, NULL);
- if (g_pVertexShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
- return false;
- psoDesc.VS = { g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize() };
+ if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_5_0", 0, 0, &vertexShaderBlob, NULL)))
+ return false; // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
+ psoDesc.VS = { vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize() };
// Create the input layout
static D3D12_INPUT_ELEMENT_DESC local_layout[] = {
- { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
- { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
- { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
+ { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
+ { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
+ { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
};
psoDesc.InputLayout = { local_layout, 3 };
}
@@ -604,23 +522,25 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
static const char* pixelShader =
"struct PS_INPUT\
{\
- float4 pos : SV_POSITION;\
- float4 col : COLOR0;\
- float2 uv : TEXCOORD0;\
+ float4 pos : SV_POSITION;\
+ float4 col : COLOR0;\
+ float2 uv : TEXCOORD0;\
};\
SamplerState sampler0 : register(s0);\
Texture2D texture0 : register(t0);\
\
float4 main(PS_INPUT input) : SV_Target\
{\
- float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \
- return out_col; \
+ float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \
+ return out_col; \
}";
- D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_5_0", 0, 0, &g_pPixelShaderBlob, NULL);
- if (g_pPixelShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
- return false;
- psoDesc.PS = { g_pPixelShaderBlob->GetBufferPointer(), g_pPixelShaderBlob->GetBufferSize() };
+ if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_5_0", 0, 0, &pixelShaderBlob, NULL)))
+ {
+ vertexShaderBlob->Release();
+ return false; // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
+ }
+ psoDesc.PS = { pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize() };
}
// Create the blending setup
@@ -665,7 +585,10 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
desc.BackFace = desc.FrontFace;
}
- if (g_pd3dDevice->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&g_pPipelineState)) != S_OK)
+ HRESULT result_pipeline_state = g_pd3dDevice->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&g_pPipelineState));
+ vertexShaderBlob->Release();
+ pixelShaderBlob->Release();
+ if (result_pipeline_state != S_OK)
return false;
ImGui_ImplDX12_CreateFontsTexture();
@@ -678,71 +601,48 @@ void ImGui_ImplDX12_InvalidateDeviceObjects()
if (!g_pd3dDevice)
return;
- if (g_pVertexShaderBlob) { g_pVertexShaderBlob->Release(); g_pVertexShaderBlob = NULL; }
- if (g_pPixelShaderBlob) { g_pPixelShaderBlob->Release(); g_pPixelShaderBlob = NULL; }
- if (g_pRootSignature) { g_pRootSignature->Release(); g_pRootSignature = NULL; }
- if (g_pPipelineState) { g_pPipelineState->Release(); g_pPipelineState = NULL; }
- if (g_pFontTextureResource) { g_pFontTextureResource->Release(); g_pFontTextureResource = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
+ SafeRelease(g_pRootSignature);
+ SafeRelease(g_pPipelineState);
+ SafeRelease(g_pFontTextureResource);
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.Fonts->TexID = NULL; // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
+
for (UINT i = 0; i < g_numFramesInFlight; i++)
{
- if (g_pFrameResources[i].IB) { g_pFrameResources[i].IB->Release(); g_pFrameResources[i].IB = NULL; }
- if (g_pFrameResources[i].VB) { g_pFrameResources[i].VB->Release(); g_pFrameResources[i].VB = NULL; }
+ FrameResources* fr = &g_pFrameResources[i];
+ SafeRelease(fr->IndexBuffer);
+ SafeRelease(fr->VertexBuffer);
}
}
-bool ImGui_ImplDX12_Init(void* hwnd, int num_frames_in_flight,
- ID3D12Device* device,
- DXGI_FORMAT rtv_format,
- D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle,
- D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle)
+bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
+ D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle)
{
- g_hWnd = (HWND)hwnd;
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendRendererName = "imgui_impl_dx12";
+ io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
+
g_pd3dDevice = device;
g_RTVFormat = rtv_format;
g_hFontSrvCpuDescHandle = font_srv_cpu_desc_handle;
g_hFontSrvGpuDescHandle = font_srv_gpu_desc_handle;
- g_pFrameResources = new FrameResources [num_frames_in_flight];
+ g_pFrameResources = new FrameResources[num_frames_in_flight];
g_numFramesInFlight = num_frames_in_flight;
g_frameIndex = UINT_MAX;
+ IM_UNUSED(cbv_srv_heap); // Unused in master branch (will be used by multi-viewports)
+ // Create buffers with a default size (they will later be grown as needed)
for (int i = 0; i < num_frames_in_flight; i++)
{
- g_pFrameResources[i].IB = NULL;
- g_pFrameResources[i].VB = NULL;
- g_pFrameResources[i].VertexBufferSize = 5000;
- g_pFrameResources[i].IndexBufferSize = 10000;
+ FrameResources* fr = &g_pFrameResources[i];
+ fr->IndexBuffer = NULL;
+ fr->VertexBuffer = NULL;
+ fr->IndexBufferSize = 10000;
+ fr->VertexBufferSize = 5000;
}
- if (!QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
- return false;
- if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
- return false;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = VK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
- io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
- io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR;
- io.KeyMap[ImGuiKey_PageDown] = VK_NEXT;
- io.KeyMap[ImGuiKey_Home] = VK_HOME;
- io.KeyMap[ImGuiKey_End] = VK_END;
- io.KeyMap[ImGuiKey_Insert] = VK_INSERT;
- io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
- io.KeyMap[ImGuiKey_Space] = VK_SPACE;
- io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
- io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
- 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';
-
- io.ImeWindowHandle = g_hWnd;
-
return true;
}
@@ -750,62 +650,16 @@ void ImGui_ImplDX12_Shutdown()
{
ImGui_ImplDX12_InvalidateDeviceObjects();
delete[] g_pFrameResources;
+ g_pFrameResources = NULL;
g_pd3dDevice = NULL;
- g_hWnd = (HWND)0;
- g_pd3dCommandList = NULL;
g_hFontSrvCpuDescHandle.ptr = 0;
g_hFontSrvGpuDescHandle.ptr = 0;
- g_pFrameResources = NULL;
g_numFramesInFlight = 0;
g_frameIndex = UINT_MAX;
}
-void ImGui_ImplDX12_NewFrame(ID3D12GraphicsCommandList* command_list)
+void ImGui_ImplDX12_NewFrame()
{
if (!g_pPipelineState)
ImGui_ImplDX12_CreateDeviceObjects();
-
- g_pd3dCommandList = command_list;
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- RECT rect;
- GetClientRect(g_hWnd, &rect);
- io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
-
- // Setup time step
- INT64 current_time;
- QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
- io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
- g_Time = current_time;
-
- // Read keyboard modifiers inputs
- io.KeyCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
- io.KeyShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
- io.KeyAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;
- io.KeySuper = false;
- // io.KeysDown : filled by WM_KEYDOWN/WM_KEYUP events
- // io.MousePos : filled by WM_MOUSEMOVE events
- // io.MouseDown : filled by WM_*BUTTON* events
- // io.MouseWheel : filled by WM_MOUSEWHEEL events
-
- // Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
- if (io.WantMoveMouse)
- {
- POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
- ClientToScreen(g_hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
- }
-
- // Update OS mouse cursor with the cursor requested by imgui
- ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
- if (g_LastMouseCursor != mouse_cursor)
- {
- g_LastMouseCursor = mouse_cursor;
- ImGui_ImplWin32_UpdateMouseCursor();
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
}
diff --git a/third_party/imgui/examples/imgui_impl_dx12.h b/third_party/imgui/examples/imgui_impl_dx12.h
new file mode 100644
index 0000000000..52dab0ba3a
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_dx12.h
@@ -0,0 +1,36 @@
+// dear imgui: Renderer for DirectX12
+// This needs to be used along with a Platform Binding (e.g. Win32)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+// Issues:
+// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
+
+// 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
+#include "imgui.h" // IMGUI_IMPL_API
+
+enum DXGI_FORMAT;
+struct ID3D12Device;
+struct ID3D12DescriptorHeap;
+struct ID3D12GraphicsCommandList;
+struct D3D12_CPU_DESCRIPTOR_HANDLE;
+struct D3D12_GPU_DESCRIPTOR_HANDLE;
+
+// cmd_list is the command list that the implementation will use to render imgui draw lists.
+// Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate
+// render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle.
+// font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture.
+IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
+ D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
+IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
+IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);
+
+// Use if you want to reset your rendering device without losing Dear ImGui state.
+IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
+IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
diff --git a/third_party/imgui/examples/imgui_impl_dx9.cpp b/third_party/imgui/examples/imgui_impl_dx9.cpp
new file mode 100644
index 0000000000..03114aa82f
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_dx9.cpp
@@ -0,0 +1,284 @@
+// dear imgui: Renderer for DirectX9
+// This needs to be used along with a Platform Binding (e.g. Win32)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+
+// 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-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
+// 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
+// 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects().
+// 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288.
+// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
+// 2018-06-08: Misc: Extracted imgui_impl_dx9.cpp/.h away from the old combined DX9+Win32 example.
+// 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
+// 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud.
+// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself.
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+
+#include "imgui.h"
+#include "imgui_impl_dx9.h"
+
+// DirectX
+#include
+#define DIRECTINPUT_VERSION 0x0800
+#include
+
+// DirectX data
+static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
+static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL;
+static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL;
+static LPDIRECT3DTEXTURE9 g_FontTexture = NULL;
+static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
+
+struct CUSTOMVERTEX
+{
+ float pos[3];
+ D3DCOLOR col;
+ float uv[2];
+};
+#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
+
+static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
+{
+ // Setup viewport
+ D3DVIEWPORT9 vp;
+ vp.X = vp.Y = 0;
+ vp.Width = (DWORD)draw_data->DisplaySize.x;
+ vp.Height = (DWORD)draw_data->DisplaySize.y;
+ vp.MinZ = 0.0f;
+ vp.MaxZ = 1.0f;
+ g_pd3dDevice->SetViewport(&vp);
+
+ // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient)
+ g_pd3dDevice->SetPixelShader(NULL);
+ g_pd3dDevice->SetVertexShader(NULL);
+ g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
+ g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
+ g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
+ g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
+ g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
+ g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
+ g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+ g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
+ g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+
+ // Setup orthographic projection matrix
+ // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
+ // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH()
+ {
+ float L = draw_data->DisplayPos.x + 0.5f;
+ float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f;
+ float T = draw_data->DisplayPos.y + 0.5f;
+ float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f;
+ D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } };
+ D3DMATRIX mat_projection =
+ { { {
+ 2.0f/(R-L), 0.0f, 0.0f, 0.0f,
+ 0.0f, 2.0f/(T-B), 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f
+ } } };
+ g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity);
+ g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity);
+ g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection);
+ }
+}
+
+// Render function.
+// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
+void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized
+ if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
+ return;
+
+ // Create and grow buffers if needed
+ if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
+ {
+ if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
+ g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
+ if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
+ return;
+ }
+ if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
+ {
+ if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
+ g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
+ if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0)
+ return;
+ }
+
+ // Backup the DX9 state
+ IDirect3DStateBlock9* d3d9_state_block = NULL;
+ if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0)
+ return;
+
+ // Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to)
+ D3DMATRIX last_world, last_view, last_projection;
+ g_pd3dDevice->GetTransform(D3DTS_WORLD, &last_world);
+ g_pd3dDevice->GetTransform(D3DTS_VIEW, &last_view);
+ g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection);
+
+ // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format.
+ // FIXME-OPT: This is a waste of resource, the ideal is to use imconfig.h and
+ // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR
+ // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; }
+ CUSTOMVERTEX* vtx_dst;
+ ImDrawIdx* idx_dst;
+ if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
+ return;
+ if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
+ return;
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
+ for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
+ {
+ vtx_dst->pos[0] = vtx_src->pos.x;
+ vtx_dst->pos[1] = vtx_src->pos.y;
+ vtx_dst->pos[2] = 0.0f;
+ vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000) >> 16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9
+ vtx_dst->uv[0] = vtx_src->uv.x;
+ vtx_dst->uv[1] = vtx_src->uv.y;
+ vtx_dst++;
+ vtx_src++;
+ }
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ idx_dst += cmd_list->IdxBuffer.Size;
+ }
+ g_pVB->Unlock();
+ g_pIB->Unlock();
+ g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
+ g_pd3dDevice->SetIndices(g_pIB);
+ g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
+
+ // Setup desired DX state
+ ImGui_ImplDX9_SetupRenderState(draw_data);
+
+ // Render command lists
+ // (Because we merged all buffers into a single one, we maintain our own offset into them)
+ int global_vtx_offset = 0;
+ int global_idx_offset = 0;
+ ImVec2 clip_off = draw_data->DisplayPos;
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback != NULL)
+ {
+ // User callback, registered via ImDrawList::AddCallback()
+ // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
+ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
+ ImGui_ImplDX9_SetupRenderState(draw_data);
+ else
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
+ const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId;
+ g_pd3dDevice->SetTexture(0, texture);
+ g_pd3dDevice->SetScissorRect(&r);
+ g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount/3);
+ }
+ }
+ global_idx_offset += cmd_list->IdxBuffer.Size;
+ global_vtx_offset += cmd_list->VtxBuffer.Size;
+ }
+
+ // Restore the DX9 transform
+ g_pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
+ g_pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
+ g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection);
+
+ // Restore the DX9 state
+ d3d9_state_block->Apply();
+ d3d9_state_block->Release();
+}
+
+bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
+{
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendRendererName = "imgui_impl_dx9";
+ io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
+
+ g_pd3dDevice = device;
+ g_pd3dDevice->AddRef();
+ return true;
+}
+
+void ImGui_ImplDX9_Shutdown()
+{
+ ImGui_ImplDX9_InvalidateDeviceObjects();
+ if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
+}
+
+static bool ImGui_ImplDX9_CreateFontsTexture()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height, bytes_per_pixel;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel);
+
+ // Upload texture to graphics system
+ g_FontTexture = NULL;
+ if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0)
+ return false;
+ D3DLOCKED_RECT tex_locked_rect;
+ if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
+ return false;
+ for (int y = 0; y < height; y++)
+ memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
+ g_FontTexture->UnlockRect(0);
+
+ // Store our identifier
+ io.Fonts->TexID = (ImTextureID)g_FontTexture;
+
+ return true;
+}
+
+bool ImGui_ImplDX9_CreateDeviceObjects()
+{
+ if (!g_pd3dDevice)
+ return false;
+ if (!ImGui_ImplDX9_CreateFontsTexture())
+ return false;
+ return true;
+}
+
+void ImGui_ImplDX9_InvalidateDeviceObjects()
+{
+ if (!g_pd3dDevice)
+ return;
+ if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
+ if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
+ if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
+}
+
+void ImGui_ImplDX9_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplDX9_CreateDeviceObjects();
+}
diff --git a/third_party/imgui/examples/imgui_impl_dx9.h b/third_party/imgui/examples/imgui_impl_dx9.h
new file mode 100644
index 0000000000..b93c89f7d4
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_dx9.h
@@ -0,0 +1,24 @@
+// dear imgui: Renderer for DirectX9
+// This needs to be used along with a Platform Binding (e.g. Win32)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+
+// 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
+#include "imgui.h" // IMGUI_IMPL_API
+
+struct IDirect3DDevice9;
+
+IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device);
+IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame();
+IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data);
+
+// Use if you want to reset your rendering device without losing Dear ImGui state.
+IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects();
+IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects();
diff --git a/third_party/imgui/examples/imgui_impl_glfw.cpp b/third_party/imgui/examples/imgui_impl_glfw.cpp
new file mode 100644
index 0000000000..ef63c81f97
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_glfw.cpp
@@ -0,0 +1,369 @@
+// dear imgui: Platform Binding for GLFW
+// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
+// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
+// (Requires: GLFW 3.1+)
+
+// Implemented features:
+// [X] Platform: Clipboard support.
+// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
+// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
+// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
+
+// 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)
+// 2020-01-17: Inputs: Disable error callback while assigning mouse cursors because some X11 setup don't have them and it generates errors.
+// 2019-12-05: Inputs: Added support for new mouse cursors added in GLFW 3.4+ (resizing cursors, not allowed cursor).
+// 2019-10-18: Misc: Previously installed user callbacks are now restored on shutdown.
+// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
+// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
+// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-11-07: Inputs: When installing our GLFW callbacks, we save user's previously installed ones - if any - and chain call them.
+// 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls.
+// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
+// 2018-06-08: Misc: Extracted imgui_impl_glfw.cpp/.h away from the old combined GLFW+OpenGL/Vulkan examples.
+// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
+// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value, passed to glfwSetCursor()).
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
+// 2018-01-25: Inputs: Added gamepad support if ImGuiConfigFlags_NavEnableGamepad is set.
+// 2018-01-25: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
+// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
+// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
+// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
+// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
+
+#include "imgui.h"
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#include
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#include // for glfwGetWin32Window
+#endif
+#define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ GLFW_FLOATING
+#define GLFW_HAS_WINDOW_HOVERED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ GLFW_HOVERED
+#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity
+#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale
+#define GLFW_HAS_VULKAN (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface
+#ifdef GLFW_RESIZE_NESW_CURSOR // let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
+#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
+#else
+#define GLFW_HAS_NEW_CURSORS (0)
+#endif
+
+// Data
+enum GlfwClientApi
+{
+ GlfwClientApi_Unknown,
+ GlfwClientApi_OpenGL,
+ GlfwClientApi_Vulkan
+};
+static GLFWwindow* g_Window = NULL; // Main window
+static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown;
+static double g_Time = 0.0;
+static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {};
+static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
+static bool g_InstalledCallbacks = false;
+
+// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
+static GLFWmousebuttonfun g_PrevUserCallbackMousebutton = NULL;
+static GLFWscrollfun g_PrevUserCallbackScroll = NULL;
+static GLFWkeyfun g_PrevUserCallbackKey = NULL;
+static GLFWcharfun g_PrevUserCallbackChar = NULL;
+
+static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data)
+{
+ return glfwGetClipboardString((GLFWwindow*)user_data);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text)
+{
+ glfwSetClipboardString((GLFWwindow*)user_data, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
+{
+ if (g_PrevUserCallbackMousebutton != NULL)
+ g_PrevUserCallbackMousebutton(window, button, action, mods);
+
+ if (action == GLFW_PRESS && button >= 0 && button < IM_ARRAYSIZE(g_MouseJustPressed))
+ g_MouseJustPressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
+{
+ if (g_PrevUserCallbackScroll != NULL)
+ g_PrevUserCallbackScroll(window, xoffset, yoffset);
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.MouseWheelH += (float)xoffset;
+ io.MouseWheel += (float)yoffset;
+}
+
+void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
+{
+ if (g_PrevUserCallbackKey != NULL)
+ g_PrevUserCallbackKey(window, key, scancode, action, mods);
+
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+#ifdef _WIN32
+ io.KeySuper = false;
+#else
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+#endif
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
+{
+ if (g_PrevUserCallbackChar != NULL)
+ g_PrevUserCallbackChar(window, c);
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.AddInputCharacter(c);
+}
+
+static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
+{
+ g_Window = window;
+ g_Time = 0.0;
+
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+ io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
+ io.BackendPlatformName = "imgui_impl_glfw";
+
+ // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB;
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+ io.ClipboardUserData = g_Window;
+#if defined(_WIN32)
+ io.ImeWindowHandle = (void*)glfwGetWin32Window(g_Window);
+#endif
+
+ // Create mouse cursors
+ // (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist,
+ // GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting.
+ // Missing cursors will return NULL and our _UpdateMouseCursor() function will use the Arrow cursor instead.)
+ GLFWerrorfun prev_error_callback = glfwSetErrorCallback(NULL);
+ g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
+#if GLFW_HAS_NEW_CURSORS
+ g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_RESIZE_ALL_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_RESIZE_NESW_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_NOT_ALLOWED_CURSOR);
+#else
+ g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
+#endif
+ glfwSetErrorCallback(prev_error_callback);
+
+ // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
+ g_PrevUserCallbackMousebutton = NULL;
+ g_PrevUserCallbackScroll = NULL;
+ g_PrevUserCallbackKey = NULL;
+ g_PrevUserCallbackChar = NULL;
+ if (install_callbacks)
+ {
+ g_InstalledCallbacks = true;
+ g_PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ g_PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ g_PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
+ g_PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ g_ClientApi = client_api;
+ return true;
+}
+
+bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks)
+{
+ return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL);
+}
+
+bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks)
+{
+ return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan);
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ if (g_InstalledCallbacks)
+ {
+ glfwSetMouseButtonCallback(g_Window, g_PrevUserCallbackMousebutton);
+ glfwSetScrollCallback(g_Window, g_PrevUserCallbackScroll);
+ glfwSetKeyCallback(g_Window, g_PrevUserCallbackKey);
+ glfwSetCharCallback(g_Window, g_PrevUserCallbackChar);
+ g_InstalledCallbacks = false;
+ }
+
+ for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
+ {
+ glfwDestroyCursor(g_MouseCursors[cursor_n]);
+ g_MouseCursors[cursor_n] = NULL;
+ }
+ g_ClientApi = GlfwClientApi_Unknown;
+}
+
+static void ImGui_ImplGlfw_UpdateMousePosAndButtons()
+{
+ // Update buttons
+ ImGuiIO& io = ImGui::GetIO();
+ for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++)
+ {
+ // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0;
+ g_MouseJustPressed[i] = false;
+ }
+
+ // Update mouse position
+ const ImVec2 mouse_pos_backup = io.MousePos;
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+#ifdef __EMSCRIPTEN__
+ const bool focused = true; // Emscripten
+#else
+ const bool focused = glfwGetWindowAttrib(g_Window, GLFW_FOCUSED) != 0;
+#endif
+ if (focused)
+ {
+ if (io.WantSetMousePos)
+ {
+ glfwSetCursorPos(g_Window, (double)mouse_pos_backup.x, (double)mouse_pos_backup.y);
+ }
+ else
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y);
+ }
+ }
+}
+
+static void ImGui_ImplGlfw_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) || glfwGetInputMode(g_Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
+ return;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
+ }
+ else
+ {
+ // Show OS mouse cursor
+ // FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
+ glfwSetCursor(g_Window, g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
+ glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
+ }
+}
+
+static void ImGui_ImplGlfw_UpdateGamepads()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ memset(io.NavInputs, 0, sizeof(io.NavInputs));
+ if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
+ return;
+
+ // Update gamepad inputs
+ #define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; }
+ #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; }
+ int axes_count = 0, buttons_count = 0;
+ const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count);
+ const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count);
+ MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A
+ MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B
+ MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X
+ MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y
+ MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left
+ MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right
+ MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up
+ MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down
+ MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB
+ MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB
+ MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB
+ MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB
+ MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f);
+ MAP_ANALOG(ImGuiNavInput_LStickRight,0, +0.3f, +0.9f);
+ MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f);
+ MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f);
+ #undef MAP_BUTTON
+ #undef MAP_ANALOG
+ if (axes_count > 0 && buttons_count > 0)
+ io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
+ else
+ io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ if (w > 0 && h > 0)
+ io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ ImGui_ImplGlfw_UpdateMousePosAndButtons();
+ ImGui_ImplGlfw_UpdateMouseCursor();
+
+ // Update game controllers (if enabled and available)
+ ImGui_ImplGlfw_UpdateGamepads();
+}
diff --git a/third_party/imgui/examples/imgui_impl_glfw.h b/third_party/imgui/examples/imgui_impl_glfw.h
new file mode 100644
index 0000000000..f62f44f31b
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_glfw.h
@@ -0,0 +1,35 @@
+// dear imgui: Platform Binding for GLFW
+// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
+// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
+
+// Implemented features:
+// [X] Platform: Clipboard support.
+// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
+// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW.
+// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
+
+// 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
+
+// About GLSL version:
+// The 'glsl_version' initialization parameter defaults to "#version 150" if NULL.
+// Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure!
+
+#pragma once
+#include "imgui.h" // IMGUI_IMPL_API
+
+struct GLFWwindow;
+
+IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
+IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
+IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
+
+// GLFW callbacks
+// - When calling Init with 'install_callbacks=true': GLFW callbacks will be installed for you. They will call user's previously installed callbacks, if any.
+// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call those function yourself from your own GLFW callbacks.
+IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/third_party/imgui/examples/imgui_impl_glut.cpp b/third_party/imgui/examples/imgui_impl_glut.cpp
new file mode 100644
index 0000000000..3c17bbfc1d
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_glut.cpp
@@ -0,0 +1,216 @@
+// 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 2020, you are being abused. Please show some resistance. !!!
+// !!! Nowadays, prefer using GLFW or SDL instead!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing mouse cursor shape/visibility support.
+// [ ] 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();
+
+#ifdef FREEGLUT
+ io.BackendPlatformName ="imgui_impl_glut (freeglut)";
+#else
+ io.BackendPlatformName ="imgui_impl_glut";
+#endif
+
+ 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_KeyPadEnter] = 13; // == CTRL+M
+ 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 int)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/third_party/imgui/examples/imgui_impl_glut.h b/third_party/imgui/examples/imgui_impl_glut.h
new file mode 100644
index 0000000000..9acb77fb4d
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_glut.h
@@ -0,0 +1,36 @@
+// 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 2020, you are being abused. Please show some resistance. !!!
+// !!! Nowadays, prefer using GLFW or SDL instead!
+
+// Issues:
+// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
+// [ ] Platform: Missing mouse cursor shape/visibility support.
+// [ ] 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
+#include "imgui.h" // IMGUI_IMPL_API
+
+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/third_party/imgui/examples/marmalade_example/imgui_impl_marmalade.cpp b/third_party/imgui/examples/imgui_impl_marmalade.cpp
similarity index 85%
rename from third_party/imgui/examples/marmalade_example/imgui_impl_marmalade.cpp
rename to third_party/imgui/examples/imgui_impl_marmalade.cpp
index 947bcbd6fb..0675c6b4f0 100644
--- a/third_party/imgui/examples/marmalade_example/imgui_impl_marmalade.cpp
+++ b/third_party/imgui/examples/imgui_impl_marmalade.cpp
@@ -1,18 +1,20 @@
-// ImGui Marmalade binding with IwGx
+// dear imgui: Renderer + Platform Binding for Marmalade + IwGx
+// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui)
// Implemented features:
-// [X] User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
+// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID!
+// Missing features:
+// [ ] Renderer: Clipping rectangles are not honored.
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
+// 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
-// Copyright (C) 2015 by Giovanni Zito
-// This file is part of ImGui
-
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
+// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
+// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
+// 2018-11-30: Misc: Setting up io.BackendPlatformName/io.BackendRendererName so they can be displayed in the About Window.
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_Marmalade_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
@@ -40,12 +42,12 @@ static ImVec2 g_RenderScale = ImVec2(1.0f,1.0f);
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data)
{
- // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
- ImGuiIO& io = ImGui::GetIO();
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+ // Avoid rendering when minimized
+ if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
+ return;
// Render command lists
- for(int n = 0; n < draw_data->CmdListsCount; n++)
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
@@ -54,9 +56,9 @@ void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data)
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
- for( int i=0; i < nVert; i++ )
+ for (int i = 0; i < nVert; i++)
{
- // TODO: optimize multiplication on gpu using vertex shader/projection matrix.
+ // FIXME-OPT: optimize multiplication on GPU using vertex shader/projection matrix.
pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x * g_RenderScale.x;
pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y * g_RenderScale.y;
pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x;
@@ -78,6 +80,7 @@ void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data)
}
else
{
+ // FIXME: Not honoring ClipRect fields.
CIwMaterial* pCurrentMaterial = IW_GX_ALLOC_MATERIAL();
pCurrentMaterial->SetShadeMode(CIwMaterial::SHADE_FLAT);
pCurrentMaterial->SetCullMode(CIwMaterial::CULL_NONE);
@@ -120,12 +123,12 @@ static void ImGui_Marmalade_SetClipboardText(void* /*user_data*/, const char* te
s3eClipboardSetText(text);
}
-int32 ImGui_Marmalade_PointerButtonEventCallback(void* SystemData, void* pUserData)
+int32 ImGui_Marmalade_PointerButtonEventCallback(void* system_data, void* user_data)
{
// pEvent->m_Button is of type s3ePointerButton and indicates which mouse
// button was pressed. For touchscreen this should always have the value
// S3E_POINTER_BUTTON_SELECT
- s3ePointerEvent* pEvent = (s3ePointerEvent*)SystemData;
+ s3ePointerEvent* pEvent = (s3ePointerEvent*)system_data;
if (pEvent->m_Pressed == 1)
{
@@ -144,10 +147,10 @@ int32 ImGui_Marmalade_PointerButtonEventCallback(void* SystemData, void* pUserDa
return 0;
}
-int32 ImGui_Marmalade_KeyCallback(void* SystemData, void* userData)
+int32 ImGui_Marmalade_KeyCallback(void* system_data, void* user_data)
{
ImGuiIO& io = ImGui::GetIO();
- s3eKeyboardEvent* e = (s3eKeyboardEvent*)SystemData;
+ s3eKeyboardEvent* e = (s3eKeyboardEvent*)system_data;
if (e->m_Pressed == 1)
io.KeysDown[e->m_Key] = true;
if (e->m_Pressed == 0)
@@ -161,12 +164,11 @@ int32 ImGui_Marmalade_KeyCallback(void* SystemData, void* userData)
return 0;
}
-int32 ImGui_Marmalade_CharCallback(void* SystemData, void* userData)
+int32 ImGui_Marmalade_CharCallback(void* system_data, void* user_data)
{
ImGuiIO& io = ImGui::GetIO();
- s3eKeyboardCharEvent* e = (s3eKeyboardCharEvent*)SystemData;
- if ((e->m_Char > 0 && e->m_Char < 0x10000))
- io.AddInputCharacter((unsigned short)e->m_Char);
+ s3eKeyboardCharEvent* e = (s3eKeyboardCharEvent*)system_data;
+ io.AddInputCharacter((unsigned int)e->m_Char);
return 0;
}
@@ -193,7 +195,7 @@ bool ImGui_Marmalade_CreateDeviceObjects()
g_FontTexture->Upload();
// Store our identifier
- io.Fonts->TexID = (void *)g_FontTexture;
+ io.Fonts->TexID = (ImTextureID)g_FontTexture;
return true;
}
@@ -217,7 +219,9 @@ void ImGui_Marmalade_InvalidateDeviceObjects()
bool ImGui_Marmalade_Init(bool install_callbacks)
{
ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = s3eKeyTab; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
+ io.BackendPlatformName = io.BackendRendererName = "imgui_impl_marmalade";
+
+ io.KeyMap[ImGuiKey_Tab] = s3eKeyTab; // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
io.KeyMap[ImGuiKey_LeftArrow] = s3eKeyLeft;
io.KeyMap[ImGuiKey_RightArrow] = s3eKeyRight;
io.KeyMap[ImGuiKey_UpArrow] = s3eKeyUp;
@@ -232,6 +236,7 @@ bool ImGui_Marmalade_Init(bool install_callbacks)
io.KeyMap[ImGuiKey_Space] = s3eKeySpace;
io.KeyMap[ImGuiKey_Enter] = s3eKeyEnter;
io.KeyMap[ImGuiKey_Escape] = s3eKeyEsc;
+ io.KeyMap[ImGuiKey_KeyPadEnter] = s3eKeyNumPadEnter;
io.KeyMap[ImGuiKey_A] = s3eKeyA;
io.KeyMap[ImGuiKey_C] = s3eKeyC;
io.KeyMap[ImGuiKey_V] = s3eKeyV;
@@ -289,9 +294,6 @@ void ImGui_Marmalade_NewFrame()
// TODO: Hide OS mouse cursor if ImGui is drawing it
// s3ePointerSetInt(S3E_POINTER_HIDE_CURSOR,(io.MouseDrawCursor ? 0 : 1));
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
-
// Show/hide OSD keyboard
if (io.WantTextInput)
{
diff --git a/third_party/imgui/examples/imgui_impl_marmalade.h b/third_party/imgui/examples/imgui_impl_marmalade.h
new file mode 100644
index 0000000000..9e92d899fb
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_marmalade.h
@@ -0,0 +1,27 @@
+// dear imgui: Renderer + Platform Binding for Marmalade + IwGx
+// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID!
+
+// 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
+#include "imgui.h" // IMGUI_IMPL_API
+
+IMGUI_IMPL_API bool ImGui_Marmalade_Init(bool install_callbacks);
+IMGUI_IMPL_API void ImGui_Marmalade_Shutdown();
+IMGUI_IMPL_API void ImGui_Marmalade_NewFrame();
+IMGUI_IMPL_API void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data);
+
+// Use if you want to reset your rendering device without losing Dear ImGui state.
+IMGUI_IMPL_API void ImGui_Marmalade_InvalidateDeviceObjects();
+IMGUI_IMPL_API bool ImGui_Marmalade_CreateDeviceObjects();
+
+// Callbacks (installed by default if you enable 'install_callbacks' during initialization)
+// You can also handle inputs yourself and use those as a reference.
+IMGUI_IMPL_API int32 ImGui_Marmalade_PointerButtonEventCallback(void* system_data, void* user_data);
+IMGUI_IMPL_API int32 ImGui_Marmalade_KeyCallback(void* system_data, void* user_data);
+IMGUI_IMPL_API int32 ImGui_Marmalade_CharCallback(void* system_data, void* user_data);
diff --git a/third_party/imgui/examples/imgui_impl_metal.h b/third_party/imgui/examples/imgui_impl_metal.h
new file mode 100644
index 0000000000..f6e8fd2bcb
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_metal.h
@@ -0,0 +1,28 @@
+// dear imgui: Renderer for Metal
+// This needs to be used along with a Platform Binding (e.g. OSX)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+
+// 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
+
+#include "imgui.h" // IMGUI_IMPL_API
+
+@class MTLRenderPassDescriptor;
+@protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder;
+
+IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id device);
+IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor);
+IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
+ id commandBuffer,
+ id commandEncoder);
+
+// Called by Init/NewFrame/Shutdown
+IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(id device);
+IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
+IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id device);
+IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
diff --git a/third_party/imgui/examples/imgui_impl_metal.mm b/third_party/imgui/examples/imgui_impl_metal.mm
new file mode 100644
index 0000000000..7cdda733e9
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_metal.mm
@@ -0,0 +1,550 @@
+// dear imgui: Renderer for Metal
+// This needs to be used along with a Platform Binding (e.g. OSX)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+
+// 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-05-29: Metal: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
+// 2019-04-30: Metal: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
+// 2019-02-11: Metal: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
+// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
+// 2018-07-05: Metal: Added new Metal backend implementation.
+
+#include "imgui.h"
+#include "imgui_impl_metal.h"
+
+#import
+// #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
+
+// A wrapper around a MTLBuffer object that knows the last time it was reused
+@interface MetalBuffer : NSObject
+@property (nonatomic, strong) id buffer;
+@property (nonatomic, assign) NSTimeInterval lastReuseTime;
+- (instancetype)initWithBuffer:(id)buffer;
+@end
+
+// An object that encapsulates the data necessary to uniquely identify a
+// render pipeline state. These are used as cache keys.
+@interface FramebufferDescriptor : NSObject
+@property (nonatomic, assign) unsigned long sampleCount;
+@property (nonatomic, assign) MTLPixelFormat colorPixelFormat;
+@property (nonatomic, assign) MTLPixelFormat depthPixelFormat;
+@property (nonatomic, assign) MTLPixelFormat stencilPixelFormat;
+- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor;
+@end
+
+// A singleton that stores long-lived objects that are needed by the Metal
+// renderer backend. Stores the render pipeline state cache and the default
+// font texture, and manages the reusable buffer cache.
+@interface MetalContext : NSObject
+@property (nonatomic, strong) id depthStencilState;
+@property (nonatomic, strong) FramebufferDescriptor *framebufferDescriptor; // framebuffer descriptor for current frame; transient
+@property (nonatomic, strong) NSMutableDictionary *renderPipelineStateCache; // pipeline cache; keyed on framebuffer descriptors
+@property (nonatomic, strong, nullable) id fontTexture;
+@property (nonatomic, strong) NSMutableArray *bufferCache;
+@property (nonatomic, assign) NSTimeInterval lastBufferCachePurge;
+- (void)makeDeviceObjectsWithDevice:(id)device;
+- (void)makeFontTextureWithDevice:(id)device;
+- (MetalBuffer *)dequeueReusableBufferOfLength:(NSUInteger)length device:(id)device;
+- (void)enqueueReusableBuffer:(MetalBuffer *)buffer;
+- (id)renderPipelineStateForFrameAndDevice:(id)device;
+- (void)emptyRenderPipelineStateCache;
+- (void)setupRenderState:(ImDrawData *)drawData
+ commandBuffer:(id)commandBuffer
+ commandEncoder:(id)commandEncoder
+ renderPipelineState:(id)renderPipelineState
+ vertexBuffer:(MetalBuffer *)vertexBuffer
+ vertexBufferOffset:(size_t)vertexBufferOffset;
+- (void)renderDrawData:(ImDrawData *)drawData
+ commandBuffer:(id)commandBuffer
+ commandEncoder:(id)commandEncoder;
+@end
+
+static MetalContext *g_sharedMetalContext = nil;
+
+#pragma mark - ImGui API implementation
+
+bool ImGui_ImplMetal_Init(id device)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendRendererName = "imgui_impl_metal";
+ io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
+
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ g_sharedMetalContext = [[MetalContext alloc] init];
+ });
+
+ ImGui_ImplMetal_CreateDeviceObjects(device);
+
+ return true;
+}
+
+void ImGui_ImplMetal_Shutdown()
+{
+ ImGui_ImplMetal_DestroyDeviceObjects();
+}
+
+void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor)
+{
+ IM_ASSERT(g_sharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init() ?");
+
+ g_sharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor];
+}
+
+// Metal Render function.
+void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id commandBuffer, id commandEncoder)
+{
+ [g_sharedMetalContext renderDrawData:draw_data commandBuffer:commandBuffer commandEncoder:commandEncoder];
+}
+
+bool ImGui_ImplMetal_CreateFontsTexture(id device)
+{
+ [g_sharedMetalContext makeFontTextureWithDevice:device];
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.Fonts->TexID = (__bridge void *)g_sharedMetalContext.fontTexture; // ImTextureID == void*
+
+ return (g_sharedMetalContext.fontTexture != nil);
+}
+
+void ImGui_ImplMetal_DestroyFontsTexture()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ g_sharedMetalContext.fontTexture = nil;
+ io.Fonts->TexID = nullptr;
+}
+
+bool ImGui_ImplMetal_CreateDeviceObjects(id device)
+{
+ [g_sharedMetalContext makeDeviceObjectsWithDevice:device];
+
+ ImGui_ImplMetal_CreateFontsTexture(device);
+
+ return true;
+}
+
+void ImGui_ImplMetal_DestroyDeviceObjects()
+{
+ ImGui_ImplMetal_DestroyFontsTexture();
+ [g_sharedMetalContext emptyRenderPipelineStateCache];
+}
+
+#pragma mark - MetalBuffer implementation
+
+@implementation MetalBuffer
+- (instancetype)initWithBuffer:(id)buffer
+{
+ if ((self = [super init]))
+ {
+ _buffer = buffer;
+ _lastReuseTime = [NSDate date].timeIntervalSince1970;
+ }
+ return self;
+}
+@end
+
+#pragma mark - FramebufferDescriptor implementation
+
+@implementation FramebufferDescriptor
+- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor
+{
+ if ((self = [super init]))
+ {
+ _sampleCount = renderPassDescriptor.colorAttachments[0].texture.sampleCount;
+ _colorPixelFormat = renderPassDescriptor.colorAttachments[0].texture.pixelFormat;
+ _depthPixelFormat = renderPassDescriptor.depthAttachment.texture.pixelFormat;
+ _stencilPixelFormat = renderPassDescriptor.stencilAttachment.texture.pixelFormat;
+ }
+ return self;
+}
+
+- (nonnull id)copyWithZone:(nullable NSZone *)zone
+{
+ FramebufferDescriptor *copy = [[FramebufferDescriptor allocWithZone:zone] init];
+ copy.sampleCount = self.sampleCount;
+ copy.colorPixelFormat = self.colorPixelFormat;
+ copy.depthPixelFormat = self.depthPixelFormat;
+ copy.stencilPixelFormat = self.stencilPixelFormat;
+ return copy;
+}
+
+- (NSUInteger)hash
+{
+ NSUInteger sc = _sampleCount & 0x3;
+ NSUInteger cf = _colorPixelFormat & 0x3FF;
+ NSUInteger df = _depthPixelFormat & 0x3FF;
+ NSUInteger sf = _stencilPixelFormat & 0x3FF;
+ NSUInteger hash = (sf << 22) | (df << 12) | (cf << 2) | sc;
+ return hash;
+}
+
+- (BOOL)isEqual:(id)object
+{
+ FramebufferDescriptor *other = object;
+ if (![other isKindOfClass:[FramebufferDescriptor class]])
+ return NO;
+ return other.sampleCount == self.sampleCount &&
+ other.colorPixelFormat == self.colorPixelFormat &&
+ other.depthPixelFormat == self.depthPixelFormat &&
+ other.stencilPixelFormat == self.stencilPixelFormat;
+}
+
+@end
+
+#pragma mark - MetalContext implementation
+
+@implementation MetalContext
+- (instancetype)init {
+ if ((self = [super init]))
+ {
+ _renderPipelineStateCache = [NSMutableDictionary dictionary];
+ _bufferCache = [NSMutableArray array];
+ _lastBufferCachePurge = [NSDate date].timeIntervalSince1970;
+ }
+ return self;
+}
+
+- (void)makeDeviceObjectsWithDevice:(id)device
+{
+ MTLDepthStencilDescriptor *depthStencilDescriptor = [[MTLDepthStencilDescriptor alloc] init];
+ depthStencilDescriptor.depthWriteEnabled = NO;
+ depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
+ self.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
+}
+
+// We are retrieving and uploading the font atlas as a 4-channels RGBA texture here.
+// In theory we could call GetTexDataAsAlpha8() and upload a 1-channel texture to save on memory access bandwidth.
+// However, using a shader designed for 1-channel texture would make it less obvious to use the ImTextureID facility to render users own textures.
+// You can make that change in your implementation.
+- (void)makeFontTextureWithDevice:(id)device
+{
+ ImGuiIO &io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
+ MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
+ width:width
+ height:height
+ mipmapped:NO];
+ textureDescriptor.usage = MTLTextureUsageShaderRead;
+#if TARGET_OS_OSX
+ textureDescriptor.storageMode = MTLStorageModeManaged;
+#else
+ textureDescriptor.storageMode = MTLStorageModeShared;
+#endif
+ id texture = [device newTextureWithDescriptor:textureDescriptor];
+ [texture replaceRegion:MTLRegionMake2D(0, 0, width, height) mipmapLevel:0 withBytes:pixels bytesPerRow:width * 4];
+ self.fontTexture = texture;
+}
+
+- (MetalBuffer *)dequeueReusableBufferOfLength:(NSUInteger)length device:(id)device
+{
+ NSTimeInterval now = [NSDate date].timeIntervalSince1970;
+
+ // Purge old buffers that haven't been useful for a while
+ if (now - self.lastBufferCachePurge > 1.0)
+ {
+ NSMutableArray *survivors = [NSMutableArray array];
+ for (MetalBuffer *candidate in self.bufferCache)
+ {
+ if (candidate.lastReuseTime > self.lastBufferCachePurge)
+ {
+ [survivors addObject:candidate];
+ }
+ }
+ self.bufferCache = [survivors mutableCopy];
+ self.lastBufferCachePurge = now;
+ }
+
+ // See if we have a buffer we can reuse
+ MetalBuffer *bestCandidate = nil;
+ for (MetalBuffer *candidate in self.bufferCache)
+ if (candidate.buffer.length >= length && (bestCandidate == nil || bestCandidate.lastReuseTime > candidate.lastReuseTime))
+ bestCandidate = candidate;
+
+ if (bestCandidate != nil)
+ {
+ [self.bufferCache removeObject:bestCandidate];
+ bestCandidate.lastReuseTime = now;
+ return bestCandidate;
+ }
+
+ // No luck; make a new buffer
+ id backing = [device newBufferWithLength:length options:MTLResourceStorageModeShared];
+ return [[MetalBuffer alloc] initWithBuffer:backing];
+}
+
+- (void)enqueueReusableBuffer:(MetalBuffer *)buffer
+{
+ [self.bufferCache addObject:buffer];
+}
+
+- (_Nullable id)renderPipelineStateForFrameAndDevice:(id)device
+{
+ // Try to retrieve a render pipeline state that is compatible with the framebuffer config for this frame
+ // The hit rate for this cache should be very near 100%.
+ id renderPipelineState = self.renderPipelineStateCache[self.framebufferDescriptor];
+
+ if (renderPipelineState == nil)
+ {
+ // No luck; make a new render pipeline state
+ renderPipelineState = [self _renderPipelineStateForFramebufferDescriptor:self.framebufferDescriptor device:device];
+ // Cache render pipeline state for later reuse
+ self.renderPipelineStateCache[self.framebufferDescriptor] = renderPipelineState;
+ }
+
+ return renderPipelineState;
+}
+
+- (id)_renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor *)descriptor device:(id)device
+{
+ NSError *error = nil;
+
+ NSString *shaderSource = @""
+ "#include \n"
+ "using namespace metal;\n"
+ "\n"
+ "struct Uniforms {\n"
+ " float4x4 projectionMatrix;\n"
+ "};\n"
+ "\n"
+ "struct VertexIn {\n"
+ " float2 position [[attribute(0)]];\n"
+ " float2 texCoords [[attribute(1)]];\n"
+ " uchar4 color [[attribute(2)]];\n"
+ "};\n"
+ "\n"
+ "struct VertexOut {\n"
+ " float4 position [[position]];\n"
+ " float2 texCoords;\n"
+ " float4 color;\n"
+ "};\n"
+ "\n"
+ "vertex VertexOut vertex_main(VertexIn in [[stage_in]],\n"
+ " constant Uniforms &uniforms [[buffer(1)]]) {\n"
+ " VertexOut out;\n"
+ " out.position = uniforms.projectionMatrix * float4(in.position, 0, 1);\n"
+ " out.texCoords = in.texCoords;\n"
+ " out.color = float4(in.color) / float4(255.0);\n"
+ " return out;\n"
+ "}\n"
+ "\n"
+ "fragment half4 fragment_main(VertexOut in [[stage_in]],\n"
+ " texture2d texture [[texture(0)]]) {\n"
+ " constexpr sampler linearSampler(coord::normalized, min_filter::linear, mag_filter::linear, mip_filter::linear);\n"
+ " half4 texColor = texture.sample(linearSampler, in.texCoords);\n"
+ " return half4(in.color) * texColor;\n"
+ "}\n";
+
+ id library = [device newLibraryWithSource:shaderSource options:nil error:&error];
+ if (library == nil)
+ {
+ NSLog(@"Error: failed to create Metal library: %@", error);
+ return nil;
+ }
+
+ id vertexFunction = [library newFunctionWithName:@"vertex_main"];
+ id fragmentFunction = [library newFunctionWithName:@"fragment_main"];
+
+ if (vertexFunction == nil || fragmentFunction == nil)
+ {
+ NSLog(@"Error: failed to find Metal shader functions in library: %@", error);
+ return nil;
+ }
+
+ MTLVertexDescriptor *vertexDescriptor = [MTLVertexDescriptor vertexDescriptor];
+ vertexDescriptor.attributes[0].offset = IM_OFFSETOF(ImDrawVert, pos);
+ vertexDescriptor.attributes[0].format = MTLVertexFormatFloat2; // position
+ vertexDescriptor.attributes[0].bufferIndex = 0;
+ vertexDescriptor.attributes[1].offset = IM_OFFSETOF(ImDrawVert, uv);
+ vertexDescriptor.attributes[1].format = MTLVertexFormatFloat2; // texCoords
+ vertexDescriptor.attributes[1].bufferIndex = 0;
+ vertexDescriptor.attributes[2].offset = IM_OFFSETOF(ImDrawVert, col);
+ vertexDescriptor.attributes[2].format = MTLVertexFormatUChar4; // color
+ vertexDescriptor.attributes[2].bufferIndex = 0;
+ vertexDescriptor.layouts[0].stepRate = 1;
+ vertexDescriptor.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex;
+ vertexDescriptor.layouts[0].stride = sizeof(ImDrawVert);
+
+ MTLRenderPipelineDescriptor *pipelineDescriptor = [[MTLRenderPipelineDescriptor alloc] init];
+ pipelineDescriptor.vertexFunction = vertexFunction;
+ pipelineDescriptor.fragmentFunction = fragmentFunction;
+ pipelineDescriptor.vertexDescriptor = vertexDescriptor;
+ pipelineDescriptor.sampleCount = self.framebufferDescriptor.sampleCount;
+ pipelineDescriptor.colorAttachments[0].pixelFormat = self.framebufferDescriptor.colorPixelFormat;
+ pipelineDescriptor.colorAttachments[0].blendingEnabled = YES;
+ pipelineDescriptor.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd;
+ pipelineDescriptor.colorAttachments[0].alphaBlendOperation = MTLBlendOperationAdd;
+ pipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
+ pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha;
+ pipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
+ pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
+ pipelineDescriptor.depthAttachmentPixelFormat = self.framebufferDescriptor.depthPixelFormat;
+ pipelineDescriptor.stencilAttachmentPixelFormat = self.framebufferDescriptor.stencilPixelFormat;
+
+ id renderPipelineState = [device newRenderPipelineStateWithDescriptor:pipelineDescriptor error:&error];
+ if (error != nil)
+ {
+ NSLog(@"Error: failed to create Metal pipeline state: %@", error);
+ }
+
+ return renderPipelineState;
+}
+
+- (void)emptyRenderPipelineStateCache
+{
+ [self.renderPipelineStateCache removeAllObjects];
+}
+
+- (void)setupRenderState:(ImDrawData *)drawData
+ commandBuffer:(id)commandBuffer
+ commandEncoder:(id)commandEncoder
+ renderPipelineState:(id)renderPipelineState
+ vertexBuffer:(MetalBuffer *)vertexBuffer
+ vertexBufferOffset:(size_t)vertexBufferOffset
+{
+ [commandEncoder setCullMode:MTLCullModeNone];
+ [commandEncoder setDepthStencilState:g_sharedMetalContext.depthStencilState];
+
+ // Setup viewport, orthographic projection matrix
+ // Our visible imgui space lies from draw_data->DisplayPos (top left) to
+ // draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps.
+ MTLViewport viewport =
+ {
+ .originX = 0.0,
+ .originY = 0.0,
+ .width = (double)(drawData->DisplaySize.x * drawData->FramebufferScale.x),
+ .height = (double)(drawData->DisplaySize.y * drawData->FramebufferScale.y),
+ .znear = 0.0,
+ .zfar = 1.0
+ };
+ [commandEncoder setViewport:viewport];
+
+ float L = drawData->DisplayPos.x;
+ float R = drawData->DisplayPos.x + drawData->DisplaySize.x;
+ float T = drawData->DisplayPos.y;
+ float B = drawData->DisplayPos.y + drawData->DisplaySize.y;
+ float N = viewport.znear;
+ float F = viewport.zfar;
+ const float ortho_projection[4][4] =
+ {
+ { 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
+ { 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
+ { 0.0f, 0.0f, 1/(F-N), 0.0f },
+ { (R+L)/(L-R), (T+B)/(B-T), N/(F-N), 1.0f },
+ };
+ [commandEncoder setVertexBytes:&ortho_projection length:sizeof(ortho_projection) atIndex:1];
+
+ [commandEncoder setRenderPipelineState:renderPipelineState];
+
+ [commandEncoder setVertexBuffer:vertexBuffer.buffer offset:0 atIndex:0];
+ [commandEncoder setVertexBufferOffset:vertexBufferOffset atIndex:0];
+}
+
+- (void)renderDrawData:(ImDrawData *)drawData
+ commandBuffer:(id)commandBuffer
+ commandEncoder:(id)commandEncoder
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ int fb_width = (int)(drawData->DisplaySize.x * drawData->FramebufferScale.x);
+ int fb_height = (int)(drawData->DisplaySize.y * drawData->FramebufferScale.y);
+ if (fb_width <= 0 || fb_height <= 0 || drawData->CmdListsCount == 0)
+ return;
+
+ id renderPipelineState = [self renderPipelineStateForFrameAndDevice:commandBuffer.device];
+
+ size_t vertexBufferLength = drawData->TotalVtxCount * sizeof(ImDrawVert);
+ size_t indexBufferLength = drawData->TotalIdxCount * sizeof(ImDrawIdx);
+ MetalBuffer* vertexBuffer = [self dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device];
+ MetalBuffer* indexBuffer = [self dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device];
+
+ [self setupRenderState:drawData commandBuffer:commandBuffer commandEncoder:commandEncoder renderPipelineState:renderPipelineState vertexBuffer:vertexBuffer vertexBufferOffset:0];
+
+ // Will project scissor/clipping rectangles into framebuffer space
+ ImVec2 clip_off = drawData->DisplayPos; // (0,0) unless using multi-viewports
+ ImVec2 clip_scale = drawData->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
+
+ // Render command lists
+ size_t vertexBufferOffset = 0;
+ size_t indexBufferOffset = 0;
+ for (int n = 0; n < drawData->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = drawData->CmdLists[n];
+
+ memcpy((char *)vertexBuffer.buffer.contents + vertexBufferOffset, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy((char *)indexBuffer.buffer.contents + indexBufferOffset, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ // User callback, registered via ImDrawList::AddCallback()
+ // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
+ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
+ [self setupRenderState:drawData commandBuffer:commandBuffer commandEncoder:commandEncoder renderPipelineState:renderPipelineState vertexBuffer:vertexBuffer vertexBufferOffset:vertexBufferOffset];
+ else
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ // Project scissor/clipping rectangles into framebuffer space
+ ImVec4 clip_rect;
+ clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
+ clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
+ clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
+ clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
+
+ if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
+ {
+ // Apply scissor/clipping rectangle
+ MTLScissorRect scissorRect =
+ {
+ .x = NSUInteger(clip_rect.x),
+ .y = NSUInteger(clip_rect.y),
+ .width = NSUInteger(clip_rect.z - clip_rect.x),
+ .height = NSUInteger(clip_rect.w - clip_rect.y)
+ };
+ [commandEncoder setScissorRect:scissorRect];
+
+
+ // Bind texture, Draw
+ if (pcmd->TextureId != NULL)
+ [commandEncoder setFragmentTexture:(__bridge id)(pcmd->TextureId) atIndex:0];
+
+ [commandEncoder setVertexBufferOffset:(vertexBufferOffset + pcmd->VtxOffset * sizeof(ImDrawVert)) atIndex:0];
+ [commandEncoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle
+ indexCount:pcmd->ElemCount
+ indexType:sizeof(ImDrawIdx) == 2 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32
+ indexBuffer:indexBuffer.buffer
+ indexBufferOffset:indexBufferOffset + pcmd->IdxOffset * sizeof(ImDrawIdx)];
+ }
+ }
+ }
+
+ vertexBufferOffset += cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
+ indexBufferOffset += cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx);
+ }
+
+ __weak id weakSelf = self;
+ [commandBuffer addCompletedHandler:^(id)
+ {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [weakSelf enqueueReusableBuffer:vertexBuffer];
+ [weakSelf enqueueReusableBuffer:indexBuffer];
+ });
+ }];
+}
+
+@end
diff --git a/third_party/imgui/examples/imgui_impl_opengl2.cpp b/third_party/imgui/examples/imgui_impl_opengl2.cpp
new file mode 100644
index 0000000000..b062697bcf
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_opengl2.cpp
@@ -0,0 +1,248 @@
+// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline)
+// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
+
+// 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
+
+// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
+// **Prefer using the code in imgui_impl_opengl3.cpp**
+// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
+// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
+// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
+// confuse your GPU driver.
+// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 2020-01-23: OpenGL: Explicitly backup, setup and restore GL_TEXTURE_ENV to increase compatibility with legacy OpenGL applications.
+// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
+// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
+// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
+// 2018-08-03: OpenGL: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications.
+// 2018-06-08: Misc: Extracted imgui_impl_opengl2.cpp/.h away from the old combined GLFW/SDL+OpenGL2 examples.
+// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
+// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplOpenGL2_RenderDrawData() in the .h file so you can call it yourself.
+// 2017-09-01: OpenGL: Save and restore current polygon mode.
+// 2016-09-10: OpenGL: Uploading font texture as RGBA32 to increase compatibility with users shaders (not ideal).
+// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
+
+#include "imgui.h"
+#include "imgui_impl_opengl2.h"
+#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
+#include // intptr_t
+#else
+#include // intptr_t
+#endif
+
+// Include OpenGL header (without an OpenGL loader) requires a bit of fiddling
+#if defined(_WIN32) && !defined(APIENTRY)
+#define APIENTRY __stdcall // It is customary to use APIENTRY for OpenGL function pointer declarations on all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
+#endif
+#if defined(_WIN32) && !defined(WINGDIAPI)
+#define WINGDIAPI __declspec(dllimport) // Some Windows OpenGL headers need this
+#endif
+#if defined(__APPLE__)
+#define GL_SILENCE_DEPRECATION
+#include
+#else
+#include
+#endif
+
+// OpenGL Data
+static GLuint g_FontTexture = 0;
+
+// Functions
+bool ImGui_ImplOpenGL2_Init()
+{
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendRendererName = "imgui_impl_opengl2";
+ return true;
+}
+
+void ImGui_ImplOpenGL2_Shutdown()
+{
+ ImGui_ImplOpenGL2_DestroyDeviceObjects();
+}
+
+void ImGui_ImplOpenGL2_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplOpenGL2_CreateDeviceObjects();
+}
+
+static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height)
+{
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
+ glEnable(GL_SCISSOR_TEST);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ // 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;
+ // glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
+ // glUseProgram(0);
+ // ImGui_ImplOpenGL2_RenderDrawData(...);
+ // glUseProgram(last_program)
+
+ // Setup viewport, orthographic projection matrix
+ // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(draw_data->DisplayPos.x, draw_data->DisplayPos.x + draw_data->DisplaySize.x, draw_data->DisplayPos.y + draw_data->DisplaySize.y, draw_data->DisplayPos.y, -1.0f, +1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+}
+
+// OpenGL2 Render function.
+// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
+// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
+void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
+ int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+
+ // Backup GL state
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ GLint last_tex_env_mode; glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &last_tex_env_mode);
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
+
+ // Setup desired GL state
+ ImGui_ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height);
+
+ // Will project scissor/clipping rectangles into framebuffer space
+ ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
+ ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
+
+ // Render command lists
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
+ glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos)));
+ glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv)));
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col)));
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ // User callback, registered via ImDrawList::AddCallback()
+ // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
+ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
+ ImGui_ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height);
+ else
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ // Project scissor/clipping rectangles into framebuffer space
+ ImVec4 clip_rect;
+ clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
+ clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
+ clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
+ clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
+
+ if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
+ {
+ // Apply scissor/clipping rectangle
+ glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
+
+ // Bind texture, Draw
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
+ }
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+
+ // Restore modified GL state
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopAttrib();
+ glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_tex_env_mode);
+}
+
+bool ImGui_ImplOpenGL2_CreateFontsTexture()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplOpenGL2_DestroyFontsTexture()
+{
+ if (g_FontTexture)
+ {
+ ImGuiIO& io = ImGui::GetIO();
+ glDeleteTextures(1, &g_FontTexture);
+ io.Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+bool ImGui_ImplOpenGL2_CreateDeviceObjects()
+{
+ return ImGui_ImplOpenGL2_CreateFontsTexture();
+}
+
+void ImGui_ImplOpenGL2_DestroyDeviceObjects()
+{
+ ImGui_ImplOpenGL2_DestroyFontsTexture();
+}
diff --git a/third_party/imgui/examples/imgui_impl_opengl2.h b/third_party/imgui/examples/imgui_impl_opengl2.h
new file mode 100644
index 0000000000..9b72cbba33
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_opengl2.h
@@ -0,0 +1,31 @@
+// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline)
+// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
+
+// 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
+
+// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
+// **Prefer using the code in imgui_impl_opengl3.cpp**
+// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
+// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
+// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
+// confuse your GPU driver.
+// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
+
+#pragma once
+#include "imgui.h" // IMGUI_IMPL_API
+
+IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init();
+IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplOpenGL2_NewFrame();
+IMGUI_IMPL_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data);
+
+// Called by Init/NewFrame/Shutdown
+IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateFontsTexture();
+IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyFontsTexture();
+IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects();
+IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects();
diff --git a/third_party/imgui/examples/imgui_impl_opengl3.cpp b/third_party/imgui/examples/imgui_impl_opengl3.cpp
new file mode 100644
index 0000000000..028a704bff
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_opengl3.cpp
@@ -0,0 +1,677 @@
+// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
+// - Desktop GL: 2.x 3.x 4.x
+// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
+// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
+// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
+
+// 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)
+// 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX.
+// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
+// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
+// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
+// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
+// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
+// 2019-09-22: OpenGL: Detect default GL loader using __has_include compiler facility.
+// 2019-09-16: OpenGL: Tweak initialization code to allow application calling ImGui_ImplOpenGL3_CreateFontsTexture() before the first NewFrame() call.
+// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
+// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
+// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
+// 2019-03-15: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
+// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
+// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
+// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
+// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
+// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
+// 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT) / GL_CLIP_ORIGIN.
+// 2018-08-29: OpenGL: Added support for more OpenGL loaders: glew and glad, with comments indicative that any loader can be used.
+// 2018-08-09: OpenGL: Default to OpenGL ES 3 on iOS and Android. GLSL version default to "#version 300 ES".
+// 2018-07-30: OpenGL: Support for GLSL 300 ES and 410 core. Fixes for Emscripten compilation.
+// 2018-07-10: OpenGL: Support for more GLSL versions (based on the GLSL version string). Added error output when shaders fail to compile/link.
+// 2018-06-08: Misc: Extracted imgui_impl_opengl3.cpp/.h away from the old combined GLFW/SDL+OpenGL3 examples.
+// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
+// 2018-05-25: OpenGL: Removed unnecessary backup/restore of GL_ELEMENT_ARRAY_BUFFER_BINDING since this is part of the VAO state.
+// 2018-05-14: OpenGL: Making the call to glBindSampler() optional so 3.2 context won't fail if the function is a NULL pointer.
+// 2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplOpenGL3_Init() so user can override the GLSL version e.g. "#version 150".
+// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
+// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself.
+// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150.
+// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
+// 2017-05-01: OpenGL: Fixed save and restore of current blend func state.
+// 2017-05-01: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE.
+// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
+// 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
+
+//----------------------------------------
+// OpenGL GLSL GLSL
+// version version string
+//----------------------------------------
+// 2.0 110 "#version 110"
+// 2.1 120 "#version 120"
+// 3.0 130 "#version 130"
+// 3.1 140 "#version 140"
+// 3.2 150 "#version 150"
+// 3.3 330 "#version 330 core"
+// 4.0 400 "#version 400 core"
+// 4.1 410 "#version 410 core"
+// 4.2 420 "#version 410 core"
+// 4.3 430 "#version 430 core"
+// ES 2.0 100 "#version 100" = WebGL 1.0
+// ES 3.0 300 "#version 300 es" = WebGL 2.0
+//----------------------------------------
+
+#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include "imgui.h"
+#include "imgui_impl_opengl3.h"
+#include
+#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
+#include // intptr_t
+#else
+#include // intptr_t
+#endif
+
+
+// GL includes
+#if defined(IMGUI_IMPL_OPENGL_ES2)
+#include
+#elif defined(IMGUI_IMPL_OPENGL_ES3)
+#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
+#include // Use GL ES 3
+#else
+#include // Use GL ES 3
+#endif
+#else
+// About Desktop OpenGL function loaders:
+// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
+// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
+// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
+#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
+#include // Needs to be initialized with gl3wInit() in user's code
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
+#include // Needs to be initialized with glewInit() in user's code.
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
+#include // Needs to be initialized with gladLoadGL() in user's code.
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
+#ifndef GLFW_INCLUDE_NONE
+#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
+#endif
+#include // Needs to be initialized with glbinding::Binding::initialize() in user's code.
+#include
+using namespace gl;
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
+#ifndef GLFW_INCLUDE_NONE
+#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
+#endif
+#include // Needs to be initialized with glbinding::initialize() in user's code.
+#include
+using namespace gl;
+#else
+#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
+#endif
+#endif
+
+// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
+#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2)
+#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 0
+#else
+#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 1
+#endif
+
+// OpenGL Data
+static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
+static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
+static GLuint g_FontTexture = 0;
+static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
+static GLint g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
+static GLuint g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location
+static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
+
+// Functions
+bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
+{
+ // Query for GL version (e.g. 320 for GL 3.2)
+#if !defined(IMGUI_IMPL_OPENGL_ES2)
+ GLint major, minor;
+ glGetIntegerv(GL_MAJOR_VERSION, &major);
+ glGetIntegerv(GL_MINOR_VERSION, &minor);
+ g_GlVersion = (GLuint)(major * 100 + minor * 10);
+#else
+ g_GlVersion = 200; // GLES 2
+#endif
+
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendRendererName = "imgui_impl_opengl3";
+#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
+ if (g_GlVersion >= 320)
+ io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
+#endif
+
+ // Store GLSL version string so we can refer to it later in case we recreate shaders.
+ // Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
+#if defined(IMGUI_IMPL_OPENGL_ES2)
+ if (glsl_version == NULL)
+ glsl_version = "#version 100";
+#elif defined(IMGUI_IMPL_OPENGL_ES3)
+ if (glsl_version == NULL)
+ glsl_version = "#version 300 es";
+#elif defined(__APPLE__)
+ if (glsl_version == NULL)
+ glsl_version = "#version 150";
+#else
+ if (glsl_version == NULL)
+ glsl_version = "#version 130";
+#endif
+ IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
+ strcpy(g_GlslVersionString, glsl_version);
+ strcat(g_GlslVersionString, "\n");
+
+ // Dummy construct to make it easily visible in the IDE and debugger which GL loader has been selected.
+ // The code actually never uses the 'gl_loader' variable! It is only here so you can read it!
+ // If auto-detection fails or doesn't select the same GL loader file as used by your application,
+ // you are likely to get a crash below.
+ // You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
+ const char* gl_loader = "Unknown";
+ IM_UNUSED(gl_loader);
+#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
+ gl_loader = "GL3W";
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
+ gl_loader = "GLEW";
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
+ gl_loader = "GLAD";
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
+ gl_loader = "glbinding2";
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
+ gl_loader = "glbinding3";
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
+ gl_loader = "custom";
+#else
+ gl_loader = "none";
+#endif
+
+ // Make a dummy GL call (we don't actually need the result)
+ // IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
+ // Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
+ GLint current_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
+
+ return true;
+}
+
+void ImGui_ImplOpenGL3_Shutdown()
+{
+ ImGui_ImplOpenGL3_DestroyDeviceObjects();
+}
+
+void ImGui_ImplOpenGL3_NewFrame()
+{
+ if (!g_ShaderHandle)
+ ImGui_ImplOpenGL3_CreateDeviceObjects();
+}
+
+static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
+{
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
+ glEnable(GL_BLEND);
+ glBlendEquation(GL_FUNC_ADD);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+#ifdef GL_POLYGON_MODE
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+#endif
+
+ // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
+ bool clip_origin_lower_left = true;
+#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
+ GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)¤t_clip_origin);
+ if (current_clip_origin == GL_UPPER_LEFT)
+ clip_origin_lower_left = false;
+#endif
+
+ // Setup viewport, orthographic projection matrix
+ // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ float L = draw_data->DisplayPos.x;
+ float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
+ float T = draw_data->DisplayPos.y;
+ float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
+ if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
+ const float ortho_projection[4][4] =
+ {
+ { 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
+ { 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
+ { 0.0f, 0.0f, -1.0f, 0.0f },
+ { (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f },
+ };
+ glUseProgram(g_ShaderHandle);
+ glUniform1i(g_AttribLocationTex, 0);
+ glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
+#ifdef GL_SAMPLER_BINDING
+ glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
+#endif
+
+ (void)vertex_array_object;
+#ifndef IMGUI_IMPL_OPENGL_ES2
+ glBindVertexArray(vertex_array_object);
+#endif
+
+ // Bind vertex/index buffers and setup attributes for ImDrawVert
+ glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
+ glEnableVertexAttribArray(g_AttribLocationVtxPos);
+ glEnableVertexAttribArray(g_AttribLocationVtxUV);
+ glEnableVertexAttribArray(g_AttribLocationVtxColor);
+ glVertexAttribPointer(g_AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
+ glVertexAttribPointer(g_AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
+ glVertexAttribPointer(g_AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
+}
+
+// OpenGL3 Render function.
+// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
+// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
+void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
+ int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
+ if (fb_width <= 0 || fb_height <= 0)
+ return;
+
+ // Backup GL state
+ GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
+ glActiveTexture(GL_TEXTURE0);
+ GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
+ GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
+#ifdef GL_SAMPLER_BINDING
+ GLuint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler);
+#endif
+ GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
+#ifndef IMGUI_IMPL_OPENGL_ES2
+ GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
+#endif
+#ifdef GL_POLYGON_MODE
+ GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
+#endif
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
+ GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
+ GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
+ GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
+ GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
+ GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
+ GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
+ GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
+ GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
+ GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
+
+ // Setup desired GL state
+ // Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
+ // The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound.
+ GLuint vertex_array_object = 0;
+#ifndef IMGUI_IMPL_OPENGL_ES2
+ glGenVertexArrays(1, &vertex_array_object);
+#endif
+ ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
+
+ // Will project scissor/clipping rectangles into framebuffer space
+ ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
+ ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
+
+ // Render command lists
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+
+ // Upload vertex/index buffers
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback != NULL)
+ {
+ // User callback, registered via ImDrawList::AddCallback()
+ // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
+ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
+ ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
+ else
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ // Project scissor/clipping rectangles into framebuffer space
+ ImVec4 clip_rect;
+ clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
+ clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
+ clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
+ clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
+
+ if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
+ {
+ // Apply scissor/clipping rectangle
+ glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
+
+ // Bind texture, Draw
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
+ if (g_GlVersion >= 320)
+ glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
+ else
+#endif
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)));
+ }
+ }
+ }
+ }
+
+ // Destroy the temporary VAO
+#ifndef IMGUI_IMPL_OPENGL_ES2
+ glDeleteVertexArrays(1, &vertex_array_object);
+#endif
+
+ // Restore modified GL state
+ glUseProgram(last_program);
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+#ifdef GL_SAMPLER_BINDING
+ glBindSampler(0, last_sampler);
+#endif
+ glActiveTexture(last_active_texture);
+#ifndef IMGUI_IMPL_OPENGL_ES2
+ glBindVertexArray(last_vertex_array_object);
+#endif
+ glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
+ glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
+ glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
+ if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
+ if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
+ if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
+ if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
+#ifdef GL_POLYGON_MODE
+ glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
+#endif
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+bool ImGui_ImplOpenGL3_CreateFontsTexture()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+#ifdef GL_UNPACK_ROW_LENGTH
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+#endif
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplOpenGL3_DestroyFontsTexture()
+{
+ if (g_FontTexture)
+ {
+ ImGuiIO& io = ImGui::GetIO();
+ glDeleteTextures(1, &g_FontTexture);
+ io.Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+// If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file.
+static bool CheckShader(GLuint handle, const char* desc)
+{
+ GLint status = 0, log_length = 0;
+ glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
+ glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
+ if ((GLboolean)status == GL_FALSE)
+ fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
+ if (log_length > 1)
+ {
+ ImVector buf;
+ buf.resize((int)(log_length + 1));
+ glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
+ fprintf(stderr, "%s\n", buf.begin());
+ }
+ return (GLboolean)status == GL_TRUE;
+}
+
+// If you get an error please report on GitHub. You may try different GL context version or GLSL version.
+static bool CheckProgram(GLuint handle, const char* desc)
+{
+ GLint status = 0, log_length = 0;
+ glGetProgramiv(handle, GL_LINK_STATUS, &status);
+ glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
+ if ((GLboolean)status == GL_FALSE)
+ fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
+ if (log_length > 1)
+ {
+ ImVector buf;
+ buf.resize((int)(log_length + 1));
+ glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
+ fprintf(stderr, "%s\n", buf.begin());
+ }
+ return (GLboolean)status == GL_TRUE;
+}
+
+bool ImGui_ImplOpenGL3_CreateDeviceObjects()
+{
+ // Backup GL state
+ GLint last_texture, last_array_buffer;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
+#ifndef IMGUI_IMPL_OPENGL_ES2
+ GLint last_vertex_array;
+ glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
+#endif
+
+ // Parse GLSL version string
+ int glsl_version = 130;
+ sscanf(g_GlslVersionString, "#version %d", &glsl_version);
+
+ const GLchar* vertex_shader_glsl_120 =
+ "uniform mat4 ProjMtx;\n"
+ "attribute vec2 Position;\n"
+ "attribute vec2 UV;\n"
+ "attribute vec4 Color;\n"
+ "varying vec2 Frag_UV;\n"
+ "varying vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
+ "}\n";
+
+ const GLchar* vertex_shader_glsl_130 =
+ "uniform mat4 ProjMtx;\n"
+ "in vec2 Position;\n"
+ "in vec2 UV;\n"
+ "in vec4 Color;\n"
+ "out vec2 Frag_UV;\n"
+ "out vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
+ "}\n";
+
+ const GLchar* vertex_shader_glsl_300_es =
+ "precision mediump float;\n"
+ "layout (location = 0) in vec2 Position;\n"
+ "layout (location = 1) in vec2 UV;\n"
+ "layout (location = 2) in vec4 Color;\n"
+ "uniform mat4 ProjMtx;\n"
+ "out vec2 Frag_UV;\n"
+ "out vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
+ "}\n";
+
+ const GLchar* vertex_shader_glsl_410_core =
+ "layout (location = 0) in vec2 Position;\n"
+ "layout (location = 1) in vec2 UV;\n"
+ "layout (location = 2) in vec4 Color;\n"
+ "uniform mat4 ProjMtx;\n"
+ "out vec2 Frag_UV;\n"
+ "out vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
+ "}\n";
+
+ const GLchar* fragment_shader_glsl_120 =
+ "#ifdef GL_ES\n"
+ " precision mediump float;\n"
+ "#endif\n"
+ "uniform sampler2D Texture;\n"
+ "varying vec2 Frag_UV;\n"
+ "varying vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
+ "}\n";
+
+ const GLchar* fragment_shader_glsl_130 =
+ "uniform sampler2D Texture;\n"
+ "in vec2 Frag_UV;\n"
+ "in vec4 Frag_Color;\n"
+ "out vec4 Out_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
+ "}\n";
+
+ const GLchar* fragment_shader_glsl_300_es =
+ "precision mediump float;\n"
+ "uniform sampler2D Texture;\n"
+ "in vec2 Frag_UV;\n"
+ "in vec4 Frag_Color;\n"
+ "layout (location = 0) out vec4 Out_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
+ "}\n";
+
+ const GLchar* fragment_shader_glsl_410_core =
+ "in vec2 Frag_UV;\n"
+ "in vec4 Frag_Color;\n"
+ "uniform sampler2D Texture;\n"
+ "layout (location = 0) out vec4 Out_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
+ "}\n";
+
+ // Select shaders matching our GLSL versions
+ const GLchar* vertex_shader = NULL;
+ const GLchar* fragment_shader = NULL;
+ if (glsl_version < 130)
+ {
+ vertex_shader = vertex_shader_glsl_120;
+ fragment_shader = fragment_shader_glsl_120;
+ }
+ else if (glsl_version >= 410)
+ {
+ vertex_shader = vertex_shader_glsl_410_core;
+ fragment_shader = fragment_shader_glsl_410_core;
+ }
+ else if (glsl_version == 300)
+ {
+ vertex_shader = vertex_shader_glsl_300_es;
+ fragment_shader = fragment_shader_glsl_300_es;
+ }
+ else
+ {
+ vertex_shader = vertex_shader_glsl_130;
+ fragment_shader = fragment_shader_glsl_130;
+ }
+
+ // Create shaders
+ const GLchar* vertex_shader_with_version[2] = { g_GlslVersionString, vertex_shader };
+ g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
+ glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL);
+ glCompileShader(g_VertHandle);
+ CheckShader(g_VertHandle, "vertex shader");
+
+ const GLchar* fragment_shader_with_version[2] = { g_GlslVersionString, fragment_shader };
+ g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
+ glShaderSource(g_FragHandle, 2, fragment_shader_with_version, NULL);
+ glCompileShader(g_FragHandle);
+ CheckShader(g_FragHandle, "fragment shader");
+
+ g_ShaderHandle = glCreateProgram();
+ glAttachShader(g_ShaderHandle, g_VertHandle);
+ glAttachShader(g_ShaderHandle, g_FragHandle);
+ glLinkProgram(g_ShaderHandle);
+ CheckProgram(g_ShaderHandle, "shader program");
+
+ g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
+ g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
+ g_AttribLocationVtxPos = (GLuint)glGetAttribLocation(g_ShaderHandle, "Position");
+ g_AttribLocationVtxUV = (GLuint)glGetAttribLocation(g_ShaderHandle, "UV");
+ g_AttribLocationVtxColor = (GLuint)glGetAttribLocation(g_ShaderHandle, "Color");
+
+ // Create buffers
+ glGenBuffers(1, &g_VboHandle);
+ glGenBuffers(1, &g_ElementsHandle);
+
+ ImGui_ImplOpenGL3_CreateFontsTexture();
+
+ // Restore modified GL state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+ glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
+#ifndef IMGUI_IMPL_OPENGL_ES2
+ glBindVertexArray(last_vertex_array);
+#endif
+
+ return true;
+}
+
+void ImGui_ImplOpenGL3_DestroyDeviceObjects()
+{
+ if (g_VboHandle) { glDeleteBuffers(1, &g_VboHandle); g_VboHandle = 0; }
+ if (g_ElementsHandle) { glDeleteBuffers(1, &g_ElementsHandle); g_ElementsHandle = 0; }
+ if (g_ShaderHandle && g_VertHandle) { glDetachShader(g_ShaderHandle, g_VertHandle); }
+ if (g_ShaderHandle && g_FragHandle) { glDetachShader(g_ShaderHandle, g_FragHandle); }
+ if (g_VertHandle) { glDeleteShader(g_VertHandle); g_VertHandle = 0; }
+ if (g_FragHandle) { glDeleteShader(g_FragHandle); g_FragHandle = 0; }
+ if (g_ShaderHandle) { glDeleteProgram(g_ShaderHandle); g_ShaderHandle = 0; }
+
+ ImGui_ImplOpenGL3_DestroyFontsTexture();
+}
diff --git a/third_party/imgui/examples/imgui_impl_opengl3.h b/third_party/imgui/examples/imgui_impl_opengl3.h
new file mode 100644
index 0000000000..07d3521969
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_opengl3.h
@@ -0,0 +1,84 @@
+// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
+// - Desktop GL: 2.x 3.x 4.x
+// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
+// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
+// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
+
+// 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
+
+// About Desktop OpenGL function loaders:
+// Modern Desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
+// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
+// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
+
+// About GLSL version:
+// The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string.
+// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
+// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
+
+#pragma once
+#include "imgui.h" // IMGUI_IMPL_API
+
+// Backend API
+IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
+
+// (Optional) Called by Init/NewFrame/Shutdown
+IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
+IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
+
+// Specific OpenGL ES versions
+//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
+//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
+
+// Attempt to auto-detect the default Desktop GL loader based on available header files.
+// If auto-detection fails or doesn't select the same GL loader file as used by your application,
+// you are likely to get a crash in ImGui_ImplOpenGL3_Init().
+// You can explicitly select a loader by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
+#if !defined(IMGUI_IMPL_OPENGL_ES2) \
+ && !defined(IMGUI_IMPL_OPENGL_ES3) \
+ && !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
+ && !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
+ && !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
+ && !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) \
+ && !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) \
+ && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
+
+// Try to detect GLES on matching platforms
+#if defined(__APPLE__)
+#include "TargetConditionals.h"
+#endif
+#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
+#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
+#elif defined(__EMSCRIPTEN__)
+#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
+
+// Otherwise try to detect supported Desktop OpenGL loaders..
+#elif defined(__has_include)
+#if __has_include()
+ #define IMGUI_IMPL_OPENGL_LOADER_GLEW
+#elif __has_include()
+ #define IMGUI_IMPL_OPENGL_LOADER_GLAD
+#elif __has_include()
+ #define IMGUI_IMPL_OPENGL_LOADER_GL3W
+#elif __has_include()
+ #define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
+#elif __has_include()
+ #define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
+#else
+ #error "Cannot detect OpenGL loader!"
+#endif
+#else
+ #define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W embedded in our repository
+#endif
+
+#endif
diff --git a/third_party/imgui/examples/imgui_impl_osx.h b/third_party/imgui/examples/imgui_impl_osx.h
new file mode 100644
index 0000000000..dae5c0cefd
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_osx.h
@@ -0,0 +1,19 @@
+// dear imgui: Platform Binding for OSX / Cocoa
+// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..)
+// [ALPHA] Early bindings, not well tested. If you want a portable application, prefer using the GLFW or SDL platform bindings on Mac.
+
+// Implemented features:
+// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
+// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this back-end).
+// Issues:
+// [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters]..
+
+#include "imgui.h" // IMGUI_IMPL_API
+
+@class NSEvent;
+@class NSView;
+
+IMGUI_IMPL_API bool ImGui_ImplOSX_Init();
+IMGUI_IMPL_API void ImGui_ImplOSX_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(NSView *_Nullable view);
+IMGUI_IMPL_API bool ImGui_ImplOSX_HandleEvent(NSEvent *_Nonnull event, NSView *_Nullable view);
diff --git a/third_party/imgui/examples/imgui_impl_osx.mm b/third_party/imgui/examples/imgui_impl_osx.mm
new file mode 100644
index 0000000000..9050162415
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_osx.mm
@@ -0,0 +1,318 @@
+// dear imgui: Platform Binding for OSX / Cocoa
+// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..)
+// [ALPHA] Early bindings, not well tested. If you want a portable application, prefer using the GLFW or SDL platform bindings on Mac.
+
+// Implemented features:
+// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
+// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this back-end).
+// Issues:
+// [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters]..
+
+#include "imgui.h"
+#include "imgui_impl_osx.h"
+#import
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 2020-05-25: Inputs: Added a fix for missing trackpad clicks when done with "soft tap".
+// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
+// 2019-10-11: Inputs: Fix using Backspace key.
+// 2019-07-21: Re-added clipboard handlers as they are not enabled by default in core imgui.cpp (reverted 2019-05-18 change).
+// 2019-05-28: Inputs: Added mouse cursor shape and visibility support.
+// 2019-05-18: Misc: Removed clipboard handlers as they are now supported by core imgui.cpp.
+// 2019-05-11: Inputs: Don't filter character values before calling AddInputCharacter() apart from 0xF700..0xFFFF range.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-07-07: Initial version.
+
+// Data
+static CFAbsoluteTime g_Time = 0.0;
+static NSCursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
+static bool g_MouseCursorHidden = false;
+static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {};
+static bool g_MouseDown[ImGuiMouseButton_COUNT] = {};
+
+// Undocumented methods for creating cursors.
+@interface NSCursor()
++ (id)_windowResizeNorthWestSouthEastCursor;
++ (id)_windowResizeNorthEastSouthWestCursor;
++ (id)_windowResizeNorthSouthCursor;
++ (id)_windowResizeEastWestCursor;
+@end
+
+// Functions
+bool ImGui_ImplOSX_Init()
+{
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup back-end capabilities flags
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+ //io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
+ //io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
+ //io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can set io.MouseHoveredViewport correctly (optional, not easy)
+ io.BackendPlatformName = "imgui_impl_osx";
+
+ // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeyDown[] array.
+ const int offset_for_function_keys = 256 - 0xF700;
+ io.KeyMap[ImGuiKey_Tab] = '\t';
+ io.KeyMap[ImGuiKey_LeftArrow] = NSLeftArrowFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_RightArrow] = NSRightArrowFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_UpArrow] = NSUpArrowFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_DownArrow] = NSDownArrowFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_PageUp] = NSPageUpFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_PageDown] = NSPageDownFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_Home] = NSHomeFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_End] = NSEndFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_Insert] = NSInsertFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_Delete] = NSDeleteFunctionKey + offset_for_function_keys;
+ io.KeyMap[ImGuiKey_Backspace] = 127;
+ io.KeyMap[ImGuiKey_Space] = 32;
+ io.KeyMap[ImGuiKey_Enter] = 13;
+ io.KeyMap[ImGuiKey_Escape] = 27;
+ io.KeyMap[ImGuiKey_KeyPadEnter] = 13;
+ 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';
+
+ // Load cursors. Some of them are undocumented.
+ g_MouseCursorHidden = false;
+ g_MouseCursors[ImGuiMouseCursor_Arrow] = [NSCursor arrowCursor];
+ g_MouseCursors[ImGuiMouseCursor_TextInput] = [NSCursor IBeamCursor];
+ g_MouseCursors[ImGuiMouseCursor_ResizeAll] = [NSCursor closedHandCursor];
+ g_MouseCursors[ImGuiMouseCursor_Hand] = [NSCursor pointingHandCursor];
+ g_MouseCursors[ImGuiMouseCursor_NotAllowed] = [NSCursor operationNotAllowedCursor];
+ g_MouseCursors[ImGuiMouseCursor_ResizeNS] = [NSCursor respondsToSelector:@selector(_windowResizeNorthSouthCursor)] ? [NSCursor _windowResizeNorthSouthCursor] : [NSCursor resizeUpDownCursor];
+ g_MouseCursors[ImGuiMouseCursor_ResizeEW] = [NSCursor respondsToSelector:@selector(_windowResizeEastWestCursor)] ? [NSCursor _windowResizeEastWestCursor] : [NSCursor resizeLeftRightCursor];
+ g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = [NSCursor respondsToSelector:@selector(_windowResizeNorthEastSouthWestCursor)] ? [NSCursor _windowResizeNorthEastSouthWestCursor] : [NSCursor closedHandCursor];
+ g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = [NSCursor respondsToSelector:@selector(_windowResizeNorthWestSouthEastCursor)] ? [NSCursor _windowResizeNorthWestSouthEastCursor] : [NSCursor closedHandCursor];
+
+ // Note that imgui.cpp also include default OSX clipboard handlers which can be enabled
+ // by adding '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h and adding '-framework ApplicationServices' to your linker command-line.
+ // Since we are already in ObjC land here, it is easy for us to add a clipboard handler using the NSPasteboard api.
+ io.SetClipboardTextFn = [](void*, const char* str) -> void
+ {
+ NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
+ [pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
+ [pasteboard setString:[NSString stringWithUTF8String:str] forType:NSPasteboardTypeString];
+ };
+
+ io.GetClipboardTextFn = [](void*) -> const char*
+ {
+ NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
+ NSString* available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:NSPasteboardTypeString]];
+ if (![available isEqualToString:NSPasteboardTypeString])
+ return NULL;
+
+ NSString* string = [pasteboard stringForType:NSPasteboardTypeString];
+ if (string == nil)
+ return NULL;
+
+ const char* string_c = (const char*)[string UTF8String];
+ size_t string_len = strlen(string_c);
+ static ImVector s_clipboard;
+ s_clipboard.resize((int)string_len + 1);
+ strcpy(s_clipboard.Data, string_c);
+ return s_clipboard.Data;
+ };
+
+ return true;
+}
+
+void ImGui_ImplOSX_Shutdown()
+{
+}
+
+static void ImGui_ImplOSX_UpdateMouseCursorAndButtons()
+{
+ // Update buttons
+ ImGuiIO& io = ImGui::GetIO();
+ for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++)
+ {
+ // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ io.MouseDown[i] = g_MouseJustPressed[i] || g_MouseDown[i];
+ g_MouseJustPressed[i] = false;
+ }
+
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
+ return;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ if (!g_MouseCursorHidden)
+ {
+ g_MouseCursorHidden = true;
+ [NSCursor hide];
+ }
+ }
+ else
+ {
+ // Show OS mouse cursor
+ [g_MouseCursors[g_MouseCursors[imgui_cursor] ? imgui_cursor : ImGuiMouseCursor_Arrow] set];
+ if (g_MouseCursorHidden)
+ {
+ g_MouseCursorHidden = false;
+ [NSCursor unhide];
+ }
+ }
+}
+
+void ImGui_ImplOSX_NewFrame(NSView* view)
+{
+ // Setup display size
+ ImGuiIO& io = ImGui::GetIO();
+ if (view)
+ {
+ const float dpi = [view.window backingScaleFactor];
+ io.DisplaySize = ImVec2((float)view.bounds.size.width, (float)view.bounds.size.height);
+ io.DisplayFramebufferScale = ImVec2(dpi, dpi);
+ }
+
+ // Setup time step
+ if (g_Time == 0.0)
+ g_Time = CFAbsoluteTimeGetCurrent();
+ CFAbsoluteTime current_time = CFAbsoluteTimeGetCurrent();
+ io.DeltaTime = current_time - g_Time;
+ g_Time = current_time;
+
+ ImGui_ImplOSX_UpdateMouseCursorAndButtons();
+}
+
+static int mapCharacterToKey(int c)
+{
+ if (c >= 'a' && c <= 'z')
+ return c - 'a' + 'A';
+ if (c == 25) // SHIFT+TAB -> TAB
+ return 9;
+ if (c >= 0 && c < 256)
+ return c;
+ if (c >= 0xF700 && c < 0xF700 + 256)
+ return c - 0xF700 + 256;
+ return -1;
+}
+
+static void resetKeys()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ for (int n = 0; n < IM_ARRAYSIZE(io.KeysDown); n++)
+ io.KeysDown[n] = false;
+}
+
+bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
+{
+ ImGuiIO& io = ImGui::GetIO();
+
+ if (event.type == NSEventTypeLeftMouseDown || event.type == NSEventTypeRightMouseDown || event.type == NSEventTypeOtherMouseDown)
+ {
+ int button = (int)[event buttonNumber];
+ if (button >= 0 && button < IM_ARRAYSIZE(g_MouseDown))
+ g_MouseDown[button] = g_MouseJustPressed[button] = true;
+ return io.WantCaptureMouse;
+ }
+
+ if (event.type == NSEventTypeLeftMouseUp || event.type == NSEventTypeRightMouseUp || event.type == NSEventTypeOtherMouseUp)
+ {
+ int button = (int)[event buttonNumber];
+ if (button >= 0 && button < IM_ARRAYSIZE(g_MouseDown))
+ g_MouseDown[button] = false;
+ return io.WantCaptureMouse;
+ }
+
+ if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged)
+ {
+ NSPoint mousePoint = event.locationInWindow;
+ mousePoint = [view convertPoint:mousePoint fromView:nil];
+ mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
+ io.MousePos = ImVec2(mousePoint.x, mousePoint.y);
+ }
+
+ if (event.type == NSEventTypeScrollWheel)
+ {
+ double wheel_dx = 0.0;
+ double wheel_dy = 0.0;
+
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
+ {
+ wheel_dx = [event scrollingDeltaX];
+ wheel_dy = [event scrollingDeltaY];
+ if ([event hasPreciseScrollingDeltas])
+ {
+ wheel_dx *= 0.1;
+ wheel_dy *= 0.1;
+ }
+ }
+ else
+ #endif // MAC_OS_X_VERSION_MAX_ALLOWED
+ {
+ wheel_dx = [event deltaX];
+ wheel_dy = [event deltaY];
+ }
+
+ if (fabs(wheel_dx) > 0.0)
+ io.MouseWheelH += wheel_dx * 0.1f;
+ if (fabs(wheel_dy) > 0.0)
+ io.MouseWheel += wheel_dy * 0.1f;
+ return io.WantCaptureMouse;
+ }
+
+ // FIXME: All the key handling is wrong and broken. Refer to GLFW's cocoa_init.mm and cocoa_window.mm.
+ if (event.type == NSEventTypeKeyDown)
+ {
+ NSString* str = [event characters];
+ int len = (int)[str length];
+ for (int i = 0; i < len; i++)
+ {
+ int c = [str characterAtIndex:i];
+ if (!io.KeyCtrl && !(c >= 0xF700 && c <= 0xFFFF) && c != 127)
+ io.AddInputCharacter((unsigned int)c);
+
+ // We must reset in case we're pressing a sequence of special keys while keeping the command pressed
+ int key = mapCharacterToKey(c);
+ if (key != -1 && key < 256 && !io.KeyCtrl)
+ resetKeys();
+ if (key != -1)
+ io.KeysDown[key] = true;
+ }
+ return io.WantCaptureKeyboard;
+ }
+
+ if (event.type == NSEventTypeKeyUp)
+ {
+ NSString* str = [event characters];
+ int len = (int)[str length];
+ for (int i = 0; i < len; i++)
+ {
+ int c = [str characterAtIndex:i];
+ int key = mapCharacterToKey(c);
+ if (key != -1)
+ io.KeysDown[key] = false;
+ }
+ return io.WantCaptureKeyboard;
+ }
+
+ if (event.type == NSEventTypeFlagsChanged)
+ {
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned int flags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
+
+ bool oldKeyCtrl = io.KeyCtrl;
+ bool oldKeyShift = io.KeyShift;
+ bool oldKeyAlt = io.KeyAlt;
+ bool oldKeySuper = io.KeySuper;
+ io.KeyCtrl = flags & NSEventModifierFlagControl;
+ io.KeyShift = flags & NSEventModifierFlagShift;
+ io.KeyAlt = flags & NSEventModifierFlagOption;
+ io.KeySuper = flags & NSEventModifierFlagCommand;
+
+ // We must reset them as we will not receive any keyUp event if they where pressed with a modifier
+ if ((oldKeyShift && !io.KeyShift) || (oldKeyCtrl && !io.KeyCtrl) || (oldKeyAlt && !io.KeyAlt) || (oldKeySuper && !io.KeySuper))
+ resetKeys();
+ return io.WantCaptureKeyboard;
+ }
+
+ return false;
+}
diff --git a/third_party/imgui/examples/imgui_impl_sdl.cpp b/third_party/imgui/examples/imgui_impl_sdl.cpp
new file mode 100644
index 0000000000..695ac810cb
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_sdl.cpp
@@ -0,0 +1,370 @@
+// dear imgui: Platform Binding for SDL2
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
+// (Requires: SDL 2.0. Prefer SDL 2.0.4+ for full feature support.)
+
+// Implemented features:
+// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
+// [X] Platform: Clipboard support.
+// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE).
+// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
+// Missing features:
+// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you 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)
+// 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends.
+// 2020-02-20: Inputs: Fixed mapping for ImGuiKey_KeyPadEnter (using SDL_SCANCODE_KP_ENTER instead of SDL_SCANCODE_RETURN2).
+// 2019-12-17: Inputs: On Wayland, use SDL_GetMouseState (because there is no global mouse state).
+// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
+// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
+// 2019-04-23: Inputs: Added support for SDL_GameController (if ImGuiConfigFlags_NavEnableGamepad is set by user application).
+// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized.
+// 2018-12-21: Inputs: Workaround for Android/iOS which don't seem to handle focus related calls.
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-11-14: Changed the signature of ImGui_ImplSDL2_ProcessEvent() to take a 'const SDL_Event*'.
+// 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls.
+// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
+// 2018-06-08: Misc: Extracted imgui_impl_sdl.cpp/.h away from the old combined SDL2+OpenGL/Vulkan examples.
+// 2018-06-08: Misc: ImGui_ImplSDL2_InitForOpenGL() now takes a SDL_GLContext parameter.
+// 2018-05-09: Misc: Fixed clipboard paste memory leak (we didn't call SDL_FreeMemory on the data returned by SDL_GetClipboardText).
+// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
+// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
+// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
+// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
+// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
+// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
+// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
+// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
+// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
+
+#include "imgui.h"
+#include "imgui_impl_sdl.h"
+
+// SDL
+#include
+#include
+#if defined(__APPLE__)
+#include "TargetConditionals.h"
+#endif
+
+#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE SDL_VERSION_ATLEAST(2,0,4)
+#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
+
+// Data
+static SDL_Window* g_Window = NULL;
+static Uint64 g_Time = 0;
+static bool g_MousePressed[3] = { false, false, false };
+static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
+static char* g_ClipboardTextData = NULL;
+static bool g_MouseCanUseGlobalState = true;
+
+static const char* ImGui_ImplSDL2_GetClipboardText(void*)
+{
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+ g_ClipboardTextData = SDL_GetClipboardText();
+ return g_ClipboardTextData;
+}
+
+static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
+{
+ SDL_SetClipboardText(text);
+}
+
+// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
+// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
+// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
+// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
+// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
+bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ switch (event->type)
+ {
+ case SDL_MOUSEWHEEL:
+ {
+ if (event->wheel.x > 0) io.MouseWheelH += 1;
+ if (event->wheel.x < 0) io.MouseWheelH -= 1;
+ if (event->wheel.y > 0) io.MouseWheel += 1;
+ if (event->wheel.y < 0) io.MouseWheel -= 1;
+ return true;
+ }
+ case SDL_MOUSEBUTTONDOWN:
+ {
+ if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
+ if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
+ if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
+ return true;
+ }
+ case SDL_TEXTINPUT:
+ {
+ io.AddInputCharactersUTF8(event->text.text);
+ return true;
+ }
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+ {
+ int key = event->key.keysym.scancode;
+ IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
+ io.KeysDown[key] = (event->type == SDL_KEYDOWN);
+ io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
+ io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
+ io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
+#ifdef _WIN32
+ io.KeySuper = false;
+#else
+ io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
+#endif
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool ImGui_ImplSDL2_Init(SDL_Window* window)
+{
+ g_Window = window;
+
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+ io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
+ io.BackendPlatformName = "imgui_impl_sdl";
+
+ // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
+ io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
+ io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
+ io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
+ io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
+ io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
+ io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
+ io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
+ io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
+ io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
+ io.KeyMap[ImGuiKey_KeyPadEnter] = SDL_SCANCODE_KP_ENTER;
+ io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
+ io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
+ io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
+ io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
+ io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
+ io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
+
+ io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
+ io.ClipboardUserData = NULL;
+
+ // Load mouse cursors
+ g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
+ g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
+ g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
+ g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
+ g_MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
+ g_MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
+
+ // Check and store if we are on Wayland
+ g_MouseCanUseGlobalState = strncmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0;
+
+#ifdef _WIN32
+ SDL_SysWMinfo wmInfo;
+ SDL_VERSION(&wmInfo.version);
+ SDL_GetWindowWMInfo(window, &wmInfo);
+ io.ImeWindowHandle = wmInfo.info.win.window;
+#else
+ (void)window;
+#endif
+
+ return true;
+}
+
+bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
+{
+ (void)sdl_gl_context; // Viewport branch will need this.
+ return ImGui_ImplSDL2_Init(window);
+}
+
+bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
+{
+#if !SDL_HAS_VULKAN
+ IM_ASSERT(0 && "Unsupported");
+#endif
+ return ImGui_ImplSDL2_Init(window);
+}
+
+bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
+{
+#if !defined(_WIN32)
+ IM_ASSERT(0 && "Unsupported");
+#endif
+ return ImGui_ImplSDL2_Init(window);
+}
+
+bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window)
+{
+ return ImGui_ImplSDL2_Init(window);
+}
+
+void ImGui_ImplSDL2_Shutdown()
+{
+ g_Window = NULL;
+
+ // Destroy last known clipboard data
+ if (g_ClipboardTextData)
+ SDL_free(g_ClipboardTextData);
+ g_ClipboardTextData = NULL;
+
+ // Destroy SDL mouse cursors
+ for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
+ SDL_FreeCursor(g_MouseCursors[cursor_n]);
+ memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
+}
+
+static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
+{
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
+ if (io.WantSetMousePos)
+ SDL_WarpMouseInWindow(g_Window, (int)io.MousePos.x, (int)io.MousePos.y);
+ else
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+
+ int mx, my;
+ Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
+ io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
+ io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
+ g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
+
+#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)
+ SDL_Window* focused_window = SDL_GetKeyboardFocus();
+ if (g_Window == focused_window)
+ {
+ if (g_MouseCanUseGlobalState)
+ {
+ // SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
+ // The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
+ // Won't use this workaround when on Wayland, as there is no global mouse position.
+ int wx, wy;
+ SDL_GetWindowPosition(focused_window, &wx, &wy);
+ SDL_GetGlobalMouseState(&mx, &my);
+ mx -= wx;
+ my -= wy;
+ }
+ io.MousePos = ImVec2((float)mx, (float)my);
+ }
+
+ // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger the OS window resize cursor.
+ // The function is only supported from SDL 2.0.4 (released Jan 2016)
+ bool any_mouse_button_down = ImGui::IsAnyMouseDown();
+ SDL_CaptureMouse(any_mouse_button_down ? SDL_TRUE : SDL_FALSE);
+#else
+ if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS)
+ io.MousePos = ImVec2((float)mx, (float)my);
+#endif
+}
+
+static void ImGui_ImplSDL2_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
+ return;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ SDL_ShowCursor(SDL_FALSE);
+ }
+ else
+ {
+ // Show OS mouse cursor
+ SDL_SetCursor(g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
+ SDL_ShowCursor(SDL_TRUE);
+ }
+}
+
+static void ImGui_ImplSDL2_UpdateGamepads()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ memset(io.NavInputs, 0, sizeof(io.NavInputs));
+ if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
+ return;
+
+ // Get gamepad
+ SDL_GameController* game_controller = SDL_GameControllerOpen(0);
+ if (!game_controller)
+ {
+ io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
+ return;
+ }
+
+ // Update gamepad inputs
+ #define MAP_BUTTON(NAV_NO, BUTTON_NO) { io.NavInputs[NAV_NO] = (SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0) ? 1.0f : 0.0f; }
+ #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GameControllerGetAxis(game_controller, AXIS_NO) - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
+ const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
+ MAP_BUTTON(ImGuiNavInput_Activate, SDL_CONTROLLER_BUTTON_A); // Cross / A
+ MAP_BUTTON(ImGuiNavInput_Cancel, SDL_CONTROLLER_BUTTON_B); // Circle / B
+ MAP_BUTTON(ImGuiNavInput_Menu, SDL_CONTROLLER_BUTTON_X); // Square / X
+ MAP_BUTTON(ImGuiNavInput_Input, SDL_CONTROLLER_BUTTON_Y); // Triangle / Y
+ MAP_BUTTON(ImGuiNavInput_DpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT); // D-Pad Left
+ MAP_BUTTON(ImGuiNavInput_DpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); // D-Pad Right
+ MAP_BUTTON(ImGuiNavInput_DpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP); // D-Pad Up
+ MAP_BUTTON(ImGuiNavInput_DpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN); // D-Pad Down
+ MAP_BUTTON(ImGuiNavInput_FocusPrev, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB
+ MAP_BUTTON(ImGuiNavInput_FocusNext, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB
+ MAP_BUTTON(ImGuiNavInput_TweakSlow, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB
+ MAP_BUTTON(ImGuiNavInput_TweakFast, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB
+ MAP_ANALOG(ImGuiNavInput_LStickLeft, SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768);
+ MAP_ANALOG(ImGuiNavInput_LStickRight, SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767);
+ MAP_ANALOG(ImGuiNavInput_LStickUp, SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32767);
+ MAP_ANALOG(ImGuiNavInput_LStickDown, SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767);
+
+ io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
+ #undef MAP_BUTTON
+ #undef MAP_ANALOG
+}
+
+void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ SDL_GetWindowSize(window, &w, &h);
+ if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
+ w = h = 0;
+ SDL_GL_GetDrawableSize(window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ if (w > 0 && h > 0)
+ io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
+
+ // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
+ static Uint64 frequency = SDL_GetPerformanceFrequency();
+ Uint64 current_time = SDL_GetPerformanceCounter();
+ io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
+ g_Time = current_time;
+
+ ImGui_ImplSDL2_UpdateMousePosAndButtons();
+ ImGui_ImplSDL2_UpdateMouseCursor();
+
+ // Update game controllers (if enabled and available)
+ ImGui_ImplSDL2_UpdateGamepads();
+}
diff --git a/third_party/imgui/examples/imgui_impl_sdl.h b/third_party/imgui/examples/imgui_impl_sdl.h
new file mode 100644
index 0000000000..bf207ba02b
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_sdl.h
@@ -0,0 +1,29 @@
+// dear imgui: Platform Binding for SDL2
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
+
+// Implemented features:
+// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
+// [X] Platform: Clipboard support.
+// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE).
+// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
+// Missing features:
+// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you 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
+#include "imgui.h" // IMGUI_IMPL_API
+
+struct SDL_Window;
+typedef union SDL_Event SDL_Event;
+
+IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
+IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
+IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
+IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
+IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
+IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
diff --git a/third_party/imgui/examples/imgui_impl_vulkan.cpp b/third_party/imgui/examples/imgui_impl_vulkan.cpp
new file mode 100644
index 0000000000..c65b2db044
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_vulkan.cpp
@@ -0,0 +1,1226 @@
+// dear imgui: Renderer for Vulkan
+// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
+
+// Implemented features:
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+// Missing features:
+// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
+
+// 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
+
+// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
+// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
+
+// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
+// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
+// You will use those if you want to use this rendering back-end in your engine/app.
+// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by
+// the back-end itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code.
+// Read comments in imgui_impl_vulkan.h.
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 2020-05-04: Vulkan: Fixed crash if initial frame has no vertices.
+// 2020-04-26: Vulkan: Fixed edge case where render callbacks wouldn't be called if the ImDrawData didn't have vertices.
+// 2019-08-01: Vulkan: Added support for specifying multisample count. Set ImGui_ImplVulkan_InitInfo::MSAASamples to one of the VkSampleCountFlagBits values to use, default is non-multisampled as before.
+// 2019-05-29: Vulkan: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
+// 2019-04-30: Vulkan: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
+// 2019-04-04: *BREAKING CHANGE*: Vulkan: Added ImageCount/MinImageCount fields in ImGui_ImplVulkan_InitInfo, required for initialization (was previously a hard #define IMGUI_VK_QUEUED_FRAMES 2). Added ImGui_ImplVulkan_SetMinImageCount().
+// 2019-04-04: Vulkan: Added VkInstance argument to ImGui_ImplVulkanH_CreateWindow() optional helper.
+// 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.
+// 2018-08-25: Vulkan: Fixed mishandled VkSurfaceCapabilitiesKHR::maxImageCount=0 case.
+// 2018-06-22: Inverted the parameters to ImGui_ImplVulkan_RenderDrawData() to be consistent with other bindings.
+// 2018-06-08: Misc: Extracted imgui_impl_vulkan.cpp/.h away from the old combined GLFW+Vulkan example.
+// 2018-06-08: Vulkan: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
+// 2018-03-03: Vulkan: Various refactor, created a couple of ImGui_ImplVulkanH_XXX helper that the example can use and that viewport support will use.
+// 2018-03-01: Vulkan: Renamed ImGui_ImplVulkan_Init_Info to ImGui_ImplVulkan_InitInfo and fields to match more closely Vulkan terminology.
+// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback, ImGui_ImplVulkan_Render() calls ImGui_ImplVulkan_RenderDrawData() itself.
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2017-05-15: Vulkan: Fix scissor offset being negative. Fix new Vulkan validation warnings. Set required depth member for buffer image copy.
+// 2016-11-13: Vulkan: Fix validation layer warnings and errors and redeclare gl_PerVertex.
+// 2016-10-18: Vulkan: Add location decorators & change to use structs as in/out in glsl, update embedded spv (produced with glslangValidator -x). Null the released resources.
+// 2016-08-27: Vulkan: Fix Vulkan example for use when a depth buffer is active.
+
+#include "imgui.h"
+#include "imgui_impl_vulkan.h"
+#include
+
+// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData()
+// [Please zero-clear before use!]
+struct ImGui_ImplVulkanH_FrameRenderBuffers
+{
+ VkDeviceMemory VertexBufferMemory;
+ VkDeviceMemory IndexBufferMemory;
+ VkDeviceSize VertexBufferSize;
+ VkDeviceSize IndexBufferSize;
+ VkBuffer VertexBuffer;
+ VkBuffer IndexBuffer;
+};
+
+// Each viewport will hold 1 ImGui_ImplVulkanH_WindowRenderBuffers
+// [Please zero-clear before use!]
+struct ImGui_ImplVulkanH_WindowRenderBuffers
+{
+ uint32_t Index;
+ uint32_t Count;
+ ImGui_ImplVulkanH_FrameRenderBuffers* FrameRenderBuffers;
+};
+
+// Vulkan data
+static ImGui_ImplVulkan_InitInfo g_VulkanInitInfo = {};
+static VkRenderPass g_RenderPass = VK_NULL_HANDLE;
+static VkDeviceSize g_BufferMemoryAlignment = 256;
+static VkPipelineCreateFlags g_PipelineCreateFlags = 0x00;
+static VkDescriptorSetLayout g_DescriptorSetLayout = VK_NULL_HANDLE;
+static VkPipelineLayout g_PipelineLayout = VK_NULL_HANDLE;
+static VkDescriptorSet g_DescriptorSet = VK_NULL_HANDLE;
+static VkPipeline g_Pipeline = VK_NULL_HANDLE;
+
+// Font data
+static VkSampler g_FontSampler = VK_NULL_HANDLE;
+static VkDeviceMemory g_FontMemory = VK_NULL_HANDLE;
+static VkImage g_FontImage = VK_NULL_HANDLE;
+static VkImageView g_FontView = VK_NULL_HANDLE;
+static VkDeviceMemory g_UploadBufferMemory = VK_NULL_HANDLE;
+static VkBuffer g_UploadBuffer = VK_NULL_HANDLE;
+
+// Render buffers
+static ImGui_ImplVulkanH_WindowRenderBuffers g_MainWindowRenderBuffers;
+
+// Forward Declarations
+bool ImGui_ImplVulkan_CreateDeviceObjects();
+void ImGui_ImplVulkan_DestroyDeviceObjects();
+void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
+void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator);
+void ImGui_ImplVulkanH_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkanH_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
+void ImGui_ImplVulkanH_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkanH_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
+void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
+void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator);
+
+//-----------------------------------------------------------------------------
+// SHADERS
+//-----------------------------------------------------------------------------
+
+// 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,
+ 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
+ 0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015,
+ 0x0000001b,0x0000001c,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
+ 0x00000000,0x00030005,0x00000009,0x00000000,0x00050006,0x00000009,0x00000000,0x6f6c6f43,
+ 0x00000072,0x00040006,0x00000009,0x00000001,0x00005655,0x00030005,0x0000000b,0x0074754f,
+ 0x00040005,0x0000000f,0x6c6f4361,0x0000726f,0x00030005,0x00000015,0x00565561,0x00060005,
+ 0x00000019,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x00000019,0x00000000,
+ 0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000001b,0x00000000,0x00040005,0x0000001c,
+ 0x736f5061,0x00000000,0x00060005,0x0000001e,0x73755075,0x6e6f4368,0x6e617473,0x00000074,
+ 0x00050006,0x0000001e,0x00000000,0x61635375,0x0000656c,0x00060006,0x0000001e,0x00000001,
+ 0x61725475,0x616c736e,0x00006574,0x00030005,0x00000020,0x00006370,0x00040047,0x0000000b,
+ 0x0000001e,0x00000000,0x00040047,0x0000000f,0x0000001e,0x00000002,0x00040047,0x00000015,
+ 0x0000001e,0x00000001,0x00050048,0x00000019,0x00000000,0x0000000b,0x00000000,0x00030047,
+ 0x00000019,0x00000002,0x00040047,0x0000001c,0x0000001e,0x00000000,0x00050048,0x0000001e,
+ 0x00000000,0x00000023,0x00000000,0x00050048,0x0000001e,0x00000001,0x00000023,0x00000008,
+ 0x00030047,0x0000001e,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,
+ 0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040017,
+ 0x00000008,0x00000006,0x00000002,0x0004001e,0x00000009,0x00000007,0x00000008,0x00040020,
+ 0x0000000a,0x00000003,0x00000009,0x0004003b,0x0000000a,0x0000000b,0x00000003,0x00040015,
+ 0x0000000c,0x00000020,0x00000001,0x0004002b,0x0000000c,0x0000000d,0x00000000,0x00040020,
+ 0x0000000e,0x00000001,0x00000007,0x0004003b,0x0000000e,0x0000000f,0x00000001,0x00040020,
+ 0x00000011,0x00000003,0x00000007,0x0004002b,0x0000000c,0x00000013,0x00000001,0x00040020,
+ 0x00000014,0x00000001,0x00000008,0x0004003b,0x00000014,0x00000015,0x00000001,0x00040020,
+ 0x00000017,0x00000003,0x00000008,0x0003001e,0x00000019,0x00000007,0x00040020,0x0000001a,
+ 0x00000003,0x00000019,0x0004003b,0x0000001a,0x0000001b,0x00000003,0x0004003b,0x00000014,
+ 0x0000001c,0x00000001,0x0004001e,0x0000001e,0x00000008,0x00000008,0x00040020,0x0000001f,
+ 0x00000009,0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000009,0x00040020,0x00000021,
+ 0x00000009,0x00000008,0x0004002b,0x00000006,0x00000028,0x00000000,0x0004002b,0x00000006,
+ 0x00000029,0x3f800000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,
+ 0x00000005,0x0004003d,0x00000007,0x00000010,0x0000000f,0x00050041,0x00000011,0x00000012,
+ 0x0000000b,0x0000000d,0x0003003e,0x00000012,0x00000010,0x0004003d,0x00000008,0x00000016,
+ 0x00000015,0x00050041,0x00000017,0x00000018,0x0000000b,0x00000013,0x0003003e,0x00000018,
+ 0x00000016,0x0004003d,0x00000008,0x0000001d,0x0000001c,0x00050041,0x00000021,0x00000022,
+ 0x00000020,0x0000000d,0x0004003d,0x00000008,0x00000023,0x00000022,0x00050085,0x00000008,
+ 0x00000024,0x0000001d,0x00000023,0x00050041,0x00000021,0x00000025,0x00000020,0x00000013,
+ 0x0004003d,0x00000008,0x00000026,0x00000025,0x00050081,0x00000008,0x00000027,0x00000024,
+ 0x00000026,0x00050051,0x00000006,0x0000002a,0x00000027,0x00000000,0x00050051,0x00000006,
+ 0x0000002b,0x00000027,0x00000001,0x00070050,0x00000007,0x0000002c,0x0000002a,0x0000002b,
+ 0x00000028,0x00000029,0x00050041,0x00000011,0x0000002d,0x0000001b,0x0000000d,0x0003003e,
+ 0x0000002d,0x0000002c,0x000100fd,0x00010038
+};
+
+// 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,
+ 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
+ 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000d,0x00030010,
+ 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
+ 0x00000000,0x00040005,0x00000009,0x6c6f4366,0x0000726f,0x00030005,0x0000000b,0x00000000,
+ 0x00050006,0x0000000b,0x00000000,0x6f6c6f43,0x00000072,0x00040006,0x0000000b,0x00000001,
+ 0x00005655,0x00030005,0x0000000d,0x00006e49,0x00050005,0x00000016,0x78655473,0x65727574,
+ 0x00000000,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x0000001e,
+ 0x00000000,0x00040047,0x00000016,0x00000022,0x00000000,0x00040047,0x00000016,0x00000021,
+ 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
+ 0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,
+ 0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040017,0x0000000a,0x00000006,
+ 0x00000002,0x0004001e,0x0000000b,0x00000007,0x0000000a,0x00040020,0x0000000c,0x00000001,
+ 0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040015,0x0000000e,0x00000020,
+ 0x00000001,0x0004002b,0x0000000e,0x0000000f,0x00000000,0x00040020,0x00000010,0x00000001,
+ 0x00000007,0x00090019,0x00000013,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,
+ 0x00000001,0x00000000,0x0003001b,0x00000014,0x00000013,0x00040020,0x00000015,0x00000000,
+ 0x00000014,0x0004003b,0x00000015,0x00000016,0x00000000,0x0004002b,0x0000000e,0x00000018,
+ 0x00000001,0x00040020,0x00000019,0x00000001,0x0000000a,0x00050036,0x00000002,0x00000004,
+ 0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000010,0x00000011,0x0000000d,
+ 0x0000000f,0x0004003d,0x00000007,0x00000012,0x00000011,0x0004003d,0x00000014,0x00000017,
+ 0x00000016,0x00050041,0x00000019,0x0000001a,0x0000000d,0x00000018,0x0004003d,0x0000000a,
+ 0x0000001b,0x0000001a,0x00050057,0x00000007,0x0000001c,0x00000017,0x0000001b,0x00050085,
+ 0x00000007,0x0000001d,0x00000012,0x0000001c,0x0003003e,0x00000009,0x0000001d,0x000100fd,
+ 0x00010038
+};
+
+//-----------------------------------------------------------------------------
+// FUNCTIONS
+//-----------------------------------------------------------------------------
+
+static uint32_t ImGui_ImplVulkan_MemoryType(VkMemoryPropertyFlags properties, uint32_t type_bits)
+{
+ ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
+ VkPhysicalDeviceMemoryProperties prop;
+ vkGetPhysicalDeviceMemoryProperties(v->PhysicalDevice, &prop);
+ for (uint32_t i = 0; i < prop.memoryTypeCount; i++)
+ if ((prop.memoryTypes[i].propertyFlags & properties) == properties && type_bits & (1<CheckVkResultFn)
+ v->CheckVkResultFn(err);
+}
+
+static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory, VkDeviceSize& p_buffer_size, size_t new_size, VkBufferUsageFlagBits usage)
+{
+ ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
+ VkResult err;
+ if (buffer != VK_NULL_HANDLE)
+ vkDestroyBuffer(v->Device, buffer, v->Allocator);
+ if (buffer_memory != VK_NULL_HANDLE)
+ vkFreeMemory(v->Device, buffer_memory, v->Allocator);
+
+ VkDeviceSize vertex_buffer_size_aligned = ((new_size - 1) / g_BufferMemoryAlignment + 1) * g_BufferMemoryAlignment;
+ VkBufferCreateInfo buffer_info = {};
+ buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ buffer_info.size = vertex_buffer_size_aligned;
+ buffer_info.usage = usage;
+ buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ err = vkCreateBuffer(v->Device, &buffer_info, v->Allocator, &buffer);
+ check_vk_result(err);
+
+ VkMemoryRequirements req;
+ vkGetBufferMemoryRequirements(v->Device, buffer, &req);
+ g_BufferMemoryAlignment = (g_BufferMemoryAlignment > req.alignment) ? g_BufferMemoryAlignment : req.alignment;
+ VkMemoryAllocateInfo alloc_info = {};
+ alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ alloc_info.allocationSize = req.size;
+ alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
+ err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &buffer_memory);
+ check_vk_result(err);
+
+ err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
+ check_vk_result(err);
+ p_buffer_size = new_size;
+}
+
+static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height)
+{
+ // Bind pipeline and descriptor sets:
+ {
+ vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_Pipeline);
+ VkDescriptorSet desc_set[1] = { g_DescriptorSet };
+ vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_PipelineLayout, 0, 1, desc_set, 0, NULL);
+ }
+
+ // Bind Vertex And Index Buffer:
+ if (draw_data->TotalVtxCount > 0)
+ {
+ VkBuffer vertex_buffers[1] = { rb->VertexBuffer };
+ VkDeviceSize vertex_offset[1] = { 0 };
+ vkCmdBindVertexBuffers(command_buffer, 0, 1, vertex_buffers, vertex_offset);
+ vkCmdBindIndexBuffer(command_buffer, rb->IndexBuffer, 0, sizeof(ImDrawIdx) == 2 ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32);
+ }
+
+ // Setup viewport:
+ {
+ VkViewport viewport;
+ viewport.x = 0;
+ viewport.y = 0;
+ viewport.width = (float)fb_width;
+ viewport.height = (float)fb_height;
+ viewport.minDepth = 0.0f;
+ viewport.maxDepth = 1.0f;
+ vkCmdSetViewport(command_buffer, 0, 1, &viewport);
+ }
+
+ // Setup scale and translation:
+ // Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
+ {
+ float scale[2];
+ scale[0] = 2.0f / draw_data->DisplaySize.x;
+ scale[1] = 2.0f / draw_data->DisplaySize.y;
+ float translate[2];
+ translate[0] = -1.0f - draw_data->DisplayPos.x * scale[0];
+ translate[1] = -1.0f - draw_data->DisplayPos.y * scale[1];
+ vkCmdPushConstants(command_buffer, g_PipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, sizeof(float) * 0, sizeof(float) * 2, scale);
+ vkCmdPushConstants(command_buffer, g_PipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, sizeof(float) * 2, sizeof(float) * 2, translate);
+ }
+}
+
+// Render function
+// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
+void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
+ int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
+ if (fb_width <= 0 || fb_height <= 0)
+ return;
+
+ ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
+
+ // Allocate array to store enough vertex/index buffers
+ ImGui_ImplVulkanH_WindowRenderBuffers* wrb = &g_MainWindowRenderBuffers;
+ if (wrb->FrameRenderBuffers == NULL)
+ {
+ wrb->Index = 0;
+ wrb->Count = v->ImageCount;
+ wrb->FrameRenderBuffers = (ImGui_ImplVulkanH_FrameRenderBuffers*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameRenderBuffers) * wrb->Count);
+ memset(wrb->FrameRenderBuffers, 0, sizeof(ImGui_ImplVulkanH_FrameRenderBuffers) * wrb->Count);
+ }
+ IM_ASSERT(wrb->Count == v->ImageCount);
+ wrb->Index = (wrb->Index + 1) % wrb->Count;
+ ImGui_ImplVulkanH_FrameRenderBuffers* rb = &wrb->FrameRenderBuffers[wrb->Index];
+
+ if (draw_data->TotalVtxCount > 0)
+ {
+ // Create or resize the vertex/index buffers
+ size_t vertex_size = draw_data->TotalVtxCount * sizeof(ImDrawVert);
+ size_t index_size = draw_data->TotalIdxCount * sizeof(ImDrawIdx);
+ if (rb->VertexBuffer == VK_NULL_HANDLE || rb->VertexBufferSize < vertex_size)
+ CreateOrResizeBuffer(rb->VertexBuffer, rb->VertexBufferMemory, rb->VertexBufferSize, vertex_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
+ if (rb->IndexBuffer == VK_NULL_HANDLE || rb->IndexBufferSize < index_size)
+ CreateOrResizeBuffer(rb->IndexBuffer, rb->IndexBufferMemory, rb->IndexBufferSize, index_size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
+
+ // Upload vertex/index data into a single contiguous GPU buffer
+ ImDrawVert* vtx_dst = NULL;
+ ImDrawIdx* idx_dst = NULL;
+ VkResult err = vkMapMemory(v->Device, rb->VertexBufferMemory, 0, vertex_size, 0, (void**)(&vtx_dst));
+ check_vk_result(err);
+ err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, index_size, 0, (void**)(&idx_dst));
+ check_vk_result(err);
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
+ memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
+ vtx_dst += cmd_list->VtxBuffer.Size;
+ idx_dst += cmd_list->IdxBuffer.Size;
+ }
+ VkMappedMemoryRange range[2] = {};
+ range[0].sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
+ range[0].memory = rb->VertexBufferMemory;
+ range[0].size = VK_WHOLE_SIZE;
+ range[1].sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
+ range[1].memory = rb->IndexBufferMemory;
+ range[1].size = VK_WHOLE_SIZE;
+ err = vkFlushMappedMemoryRanges(v->Device, 2, range);
+ check_vk_result(err);
+ vkUnmapMemory(v->Device, rb->VertexBufferMemory);
+ vkUnmapMemory(v->Device, rb->IndexBufferMemory);
+ }
+
+ // Setup desired Vulkan state
+ ImGui_ImplVulkan_SetupRenderState(draw_data, command_buffer, rb, fb_width, fb_height);
+
+ // Will project scissor/clipping rectangles into framebuffer space
+ ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
+ ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
+
+ // Render command lists
+ // (Because we merged all buffers into a single one, we maintain our own offset into them)
+ int global_vtx_offset = 0;
+ int global_idx_offset = 0;
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback != NULL)
+ {
+ // User callback, registered via ImDrawList::AddCallback()
+ // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
+ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
+ ImGui_ImplVulkan_SetupRenderState(draw_data, command_buffer, rb, fb_width, fb_height);
+ else
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ // Project scissor/clipping rectangles into framebuffer space
+ ImVec4 clip_rect;
+ clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
+ clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
+ clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
+ clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
+
+ 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);
+ scissor.offset.y = (int32_t)(clip_rect.y);
+ scissor.extent.width = (uint32_t)(clip_rect.z - clip_rect.x);
+ scissor.extent.height = (uint32_t)(clip_rect.w - clip_rect.y);
+ vkCmdSetScissor(command_buffer, 0, 1, &scissor);
+
+ // Draw
+ vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
+ }
+ }
+ }
+ global_idx_offset += cmd_list->IdxBuffer.Size;
+ global_vtx_offset += cmd_list->VtxBuffer.Size;
+ }
+}
+
+bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)
+{
+ ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
+ ImGuiIO& io = ImGui::GetIO();
+
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
+ size_t upload_size = width*height*4*sizeof(char);
+
+ VkResult err;
+
+ // Create the Image:
+ {
+ VkImageCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
+ info.imageType = VK_IMAGE_TYPE_2D;
+ info.format = VK_FORMAT_R8G8B8A8_UNORM;
+ info.extent.width = width;
+ info.extent.height = height;
+ info.extent.depth = 1;
+ info.mipLevels = 1;
+ info.arrayLayers = 1;
+ info.samples = VK_SAMPLE_COUNT_1_BIT;
+ info.tiling = VK_IMAGE_TILING_OPTIMAL;
+ info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+ info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ err = vkCreateImage(v->Device, &info, v->Allocator, &g_FontImage);
+ check_vk_result(err);
+ VkMemoryRequirements req;
+ vkGetImageMemoryRequirements(v->Device, g_FontImage, &req);
+ VkMemoryAllocateInfo alloc_info = {};
+ alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ alloc_info.allocationSize = req.size;
+ alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits);
+ err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &g_FontMemory);
+ check_vk_result(err);
+ err = vkBindImageMemory(v->Device, g_FontImage, g_FontMemory, 0);
+ check_vk_result(err);
+ }
+
+ // Create the Image View:
+ {
+ VkImageViewCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ info.image = g_FontImage;
+ info.viewType = VK_IMAGE_VIEW_TYPE_2D;
+ info.format = VK_FORMAT_R8G8B8A8_UNORM;
+ info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ info.subresourceRange.levelCount = 1;
+ info.subresourceRange.layerCount = 1;
+ err = vkCreateImageView(v->Device, &info, v->Allocator, &g_FontView);
+ check_vk_result(err);
+ }
+
+ // Update the Descriptor Set:
+ {
+ VkDescriptorImageInfo desc_image[1] = {};
+ desc_image[0].sampler = g_FontSampler;
+ desc_image[0].imageView = g_FontView;
+ desc_image[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+ VkWriteDescriptorSet write_desc[1] = {};
+ write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ write_desc[0].dstSet = g_DescriptorSet;
+ write_desc[0].descriptorCount = 1;
+ write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+ write_desc[0].pImageInfo = desc_image;
+ vkUpdateDescriptorSets(v->Device, 1, write_desc, 0, NULL);
+ }
+
+ // Create the Upload Buffer:
+ {
+ VkBufferCreateInfo buffer_info = {};
+ buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ buffer_info.size = upload_size;
+ buffer_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ err = vkCreateBuffer(v->Device, &buffer_info, v->Allocator, &g_UploadBuffer);
+ check_vk_result(err);
+ VkMemoryRequirements req;
+ vkGetBufferMemoryRequirements(v->Device, g_UploadBuffer, &req);
+ g_BufferMemoryAlignment = (g_BufferMemoryAlignment > req.alignment) ? g_BufferMemoryAlignment : req.alignment;
+ VkMemoryAllocateInfo alloc_info = {};
+ alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ alloc_info.allocationSize = req.size;
+ alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
+ err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &g_UploadBufferMemory);
+ check_vk_result(err);
+ err = vkBindBufferMemory(v->Device, g_UploadBuffer, g_UploadBufferMemory, 0);
+ check_vk_result(err);
+ }
+
+ // Upload to Buffer:
+ {
+ char* map = NULL;
+ err = vkMapMemory(v->Device, g_UploadBufferMemory, 0, upload_size, 0, (void**)(&map));
+ check_vk_result(err);
+ memcpy(map, pixels, upload_size);
+ VkMappedMemoryRange range[1] = {};
+ range[0].sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
+ range[0].memory = g_UploadBufferMemory;
+ range[0].size = upload_size;
+ err = vkFlushMappedMemoryRanges(v->Device, 1, range);
+ check_vk_result(err);
+ vkUnmapMemory(v->Device, g_UploadBufferMemory);
+ }
+
+ // Copy to Image:
+ {
+ VkImageMemoryBarrier copy_barrier[1] = {};
+ copy_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+ copy_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
+ copy_barrier[0].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ copy_barrier[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
+ copy_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ copy_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ copy_barrier[0].image = g_FontImage;
+ copy_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ copy_barrier[0].subresourceRange.levelCount = 1;
+ copy_barrier[0].subresourceRange.layerCount = 1;
+ vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, copy_barrier);
+
+ VkBufferImageCopy region = {};
+ region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ region.imageSubresource.layerCount = 1;
+ region.imageExtent.width = width;
+ region.imageExtent.height = height;
+ region.imageExtent.depth = 1;
+ vkCmdCopyBufferToImage(command_buffer, g_UploadBuffer, g_FontImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
+
+ VkImageMemoryBarrier use_barrier[1] = {};
+ use_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+ use_barrier[0].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
+ use_barrier[0].dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
+ use_barrier[0].oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
+ use_barrier[0].newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+ use_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ use_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ use_barrier[0].image = g_FontImage;
+ use_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ use_barrier[0].subresourceRange.levelCount = 1;
+ use_barrier[0].subresourceRange.layerCount = 1;
+ vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, use_barrier);
+ }
+
+ // Store our identifier
+ io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontImage;
+
+ return true;
+}
+
+bool ImGui_ImplVulkan_CreateDeviceObjects()
+{
+ ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
+ VkResult err;
+ VkShaderModule vert_module;
+ VkShaderModule frag_module;
+
+ // Create The Shader Modules:
+ {
+ VkShaderModuleCreateInfo vert_info = {};
+ vert_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
+ vert_info.codeSize = sizeof(__glsl_shader_vert_spv);
+ vert_info.pCode = (uint32_t*)__glsl_shader_vert_spv;
+ err = vkCreateShaderModule(v->Device, &vert_info, v->Allocator, &vert_module);
+ check_vk_result(err);
+ VkShaderModuleCreateInfo frag_info = {};
+ frag_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
+ frag_info.codeSize = sizeof(__glsl_shader_frag_spv);
+ frag_info.pCode = (uint32_t*)__glsl_shader_frag_spv;
+ err = vkCreateShaderModule(v->Device, &frag_info, v->Allocator, &frag_module);
+ check_vk_result(err);
+ }
+
+ if (!g_FontSampler)
+ {
+ VkSamplerCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
+ info.magFilter = VK_FILTER_LINEAR;
+ info.minFilter = VK_FILTER_LINEAR;
+ info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
+ info.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
+ info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
+ info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
+ info.minLod = -1000;
+ info.maxLod = 1000;
+ info.maxAnisotropy = 1.0f;
+ err = vkCreateSampler(v->Device, &info, v->Allocator, &g_FontSampler);
+ check_vk_result(err);
+ }
+
+ if (!g_DescriptorSetLayout)
+ {
+ VkSampler sampler[1] = {g_FontSampler};
+ VkDescriptorSetLayoutBinding binding[1] = {};
+ binding[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+ binding[0].descriptorCount = 1;
+ binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
+ binding[0].pImmutableSamplers = sampler;
+ VkDescriptorSetLayoutCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
+ info.bindingCount = 1;
+ info.pBindings = binding;
+ err = vkCreateDescriptorSetLayout(v->Device, &info, v->Allocator, &g_DescriptorSetLayout);
+ check_vk_result(err);
+ }
+
+ // Create Descriptor Set:
+ {
+ VkDescriptorSetAllocateInfo alloc_info = {};
+ alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
+ alloc_info.descriptorPool = v->DescriptorPool;
+ alloc_info.descriptorSetCount = 1;
+ alloc_info.pSetLayouts = &g_DescriptorSetLayout;
+ err = vkAllocateDescriptorSets(v->Device, &alloc_info, &g_DescriptorSet);
+ check_vk_result(err);
+ }
+
+ if (!g_PipelineLayout)
+ {
+ // Constants: we are using 'vec2 offset' and 'vec2 scale' instead of a full 3d projection matrix
+ VkPushConstantRange push_constants[1] = {};
+ push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
+ push_constants[0].offset = sizeof(float) * 0;
+ push_constants[0].size = sizeof(float) * 4;
+ VkDescriptorSetLayout set_layout[1] = { g_DescriptorSetLayout };
+ VkPipelineLayoutCreateInfo layout_info = {};
+ layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
+ layout_info.setLayoutCount = 1;
+ layout_info.pSetLayouts = set_layout;
+ layout_info.pushConstantRangeCount = 1;
+ layout_info.pPushConstantRanges = push_constants;
+ err = vkCreatePipelineLayout(v->Device, &layout_info, v->Allocator, &g_PipelineLayout);
+ check_vk_result(err);
+ }
+
+ VkPipelineShaderStageCreateInfo stage[2] = {};
+ stage[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+ stage[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
+ stage[0].module = vert_module;
+ stage[0].pName = "main";
+ stage[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+ stage[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
+ stage[1].module = frag_module;
+ stage[1].pName = "main";
+
+ VkVertexInputBindingDescription binding_desc[1] = {};
+ binding_desc[0].stride = sizeof(ImDrawVert);
+ binding_desc[0].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
+
+ VkVertexInputAttributeDescription attribute_desc[3] = {};
+ attribute_desc[0].location = 0;
+ attribute_desc[0].binding = binding_desc[0].binding;
+ attribute_desc[0].format = VK_FORMAT_R32G32_SFLOAT;
+ attribute_desc[0].offset = IM_OFFSETOF(ImDrawVert, pos);
+ attribute_desc[1].location = 1;
+ attribute_desc[1].binding = binding_desc[0].binding;
+ attribute_desc[1].format = VK_FORMAT_R32G32_SFLOAT;
+ attribute_desc[1].offset = IM_OFFSETOF(ImDrawVert, uv);
+ attribute_desc[2].location = 2;
+ attribute_desc[2].binding = binding_desc[0].binding;
+ attribute_desc[2].format = VK_FORMAT_R8G8B8A8_UNORM;
+ attribute_desc[2].offset = IM_OFFSETOF(ImDrawVert, col);
+
+ VkPipelineVertexInputStateCreateInfo vertex_info = {};
+ vertex_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
+ vertex_info.vertexBindingDescriptionCount = 1;
+ vertex_info.pVertexBindingDescriptions = binding_desc;
+ vertex_info.vertexAttributeDescriptionCount = 3;
+ vertex_info.pVertexAttributeDescriptions = attribute_desc;
+
+ VkPipelineInputAssemblyStateCreateInfo ia_info = {};
+ ia_info.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
+ ia_info.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
+
+ VkPipelineViewportStateCreateInfo viewport_info = {};
+ viewport_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
+ viewport_info.viewportCount = 1;
+ viewport_info.scissorCount = 1;
+
+ VkPipelineRasterizationStateCreateInfo raster_info = {};
+ raster_info.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
+ raster_info.polygonMode = VK_POLYGON_MODE_FILL;
+ raster_info.cullMode = VK_CULL_MODE_NONE;
+ raster_info.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
+ raster_info.lineWidth = 1.0f;
+
+ VkPipelineMultisampleStateCreateInfo ms_info = {};
+ ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
+ if (v->MSAASamples != 0)
+ ms_info.rasterizationSamples = v->MSAASamples;
+ else
+ ms_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
+
+ VkPipelineColorBlendAttachmentState color_attachment[1] = {};
+ color_attachment[0].blendEnable = VK_TRUE;
+ color_attachment[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
+ color_attachment[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
+ color_attachment[0].colorBlendOp = VK_BLEND_OP_ADD;
+ color_attachment[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
+ color_attachment[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
+ color_attachment[0].alphaBlendOp = VK_BLEND_OP_ADD;
+ color_attachment[0].colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
+
+ VkPipelineDepthStencilStateCreateInfo depth_info = {};
+ depth_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
+
+ VkPipelineColorBlendStateCreateInfo blend_info = {};
+ blend_info.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
+ blend_info.attachmentCount = 1;
+ blend_info.pAttachments = color_attachment;
+
+ VkDynamicState dynamic_states[2] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
+ VkPipelineDynamicStateCreateInfo dynamic_state = {};
+ dynamic_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
+ dynamic_state.dynamicStateCount = (uint32_t)IM_ARRAYSIZE(dynamic_states);
+ dynamic_state.pDynamicStates = dynamic_states;
+
+ VkGraphicsPipelineCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
+ info.flags = g_PipelineCreateFlags;
+ info.stageCount = 2;
+ info.pStages = stage;
+ info.pVertexInputState = &vertex_info;
+ info.pInputAssemblyState = &ia_info;
+ info.pViewportState = &viewport_info;
+ info.pRasterizationState = &raster_info;
+ info.pMultisampleState = &ms_info;
+ info.pDepthStencilState = &depth_info;
+ info.pColorBlendState = &blend_info;
+ info.pDynamicState = &dynamic_state;
+ info.layout = g_PipelineLayout;
+ info.renderPass = g_RenderPass;
+ err = vkCreateGraphicsPipelines(v->Device, v->PipelineCache, 1, &info, v->Allocator, &g_Pipeline);
+ check_vk_result(err);
+
+ vkDestroyShaderModule(v->Device, vert_module, v->Allocator);
+ vkDestroyShaderModule(v->Device, frag_module, v->Allocator);
+
+ return true;
+}
+
+void ImGui_ImplVulkan_DestroyFontUploadObjects()
+{
+ ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
+ if (g_UploadBuffer)
+ {
+ vkDestroyBuffer(v->Device, g_UploadBuffer, v->Allocator);
+ g_UploadBuffer = VK_NULL_HANDLE;
+ }
+ if (g_UploadBufferMemory)
+ {
+ vkFreeMemory(v->Device, g_UploadBufferMemory, v->Allocator);
+ g_UploadBufferMemory = VK_NULL_HANDLE;
+ }
+}
+
+void ImGui_ImplVulkan_DestroyDeviceObjects()
+{
+ ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
+ ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &g_MainWindowRenderBuffers, v->Allocator);
+ ImGui_ImplVulkan_DestroyFontUploadObjects();
+
+ if (g_FontView) { vkDestroyImageView(v->Device, g_FontView, v->Allocator); g_FontView = VK_NULL_HANDLE; }
+ if (g_FontImage) { vkDestroyImage(v->Device, g_FontImage, v->Allocator); g_FontImage = VK_NULL_HANDLE; }
+ if (g_FontMemory) { vkFreeMemory(v->Device, g_FontMemory, v->Allocator); g_FontMemory = VK_NULL_HANDLE; }
+ if (g_FontSampler) { vkDestroySampler(v->Device, g_FontSampler, v->Allocator); g_FontSampler = VK_NULL_HANDLE; }
+ if (g_DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, g_DescriptorSetLayout, v->Allocator); g_DescriptorSetLayout = VK_NULL_HANDLE; }
+ if (g_PipelineLayout) { vkDestroyPipelineLayout(v->Device, g_PipelineLayout, v->Allocator); g_PipelineLayout = VK_NULL_HANDLE; }
+ if (g_Pipeline) { vkDestroyPipeline(v->Device, g_Pipeline, v->Allocator); g_Pipeline = VK_NULL_HANDLE; }
+}
+
+bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass)
+{
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendRendererName = "imgui_impl_vulkan";
+ io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
+
+ IM_ASSERT(info->Instance != VK_NULL_HANDLE);
+ IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
+ IM_ASSERT(info->Device != VK_NULL_HANDLE);
+ IM_ASSERT(info->Queue != VK_NULL_HANDLE);
+ IM_ASSERT(info->DescriptorPool != VK_NULL_HANDLE);
+ IM_ASSERT(info->MinImageCount >= 2);
+ IM_ASSERT(info->ImageCount >= info->MinImageCount);
+ IM_ASSERT(render_pass != VK_NULL_HANDLE);
+
+ g_VulkanInitInfo = *info;
+ g_RenderPass = render_pass;
+ ImGui_ImplVulkan_CreateDeviceObjects();
+
+ return true;
+}
+
+void ImGui_ImplVulkan_Shutdown()
+{
+ ImGui_ImplVulkan_DestroyDeviceObjects();
+}
+
+void ImGui_ImplVulkan_NewFrame()
+{
+}
+
+void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
+{
+ IM_ASSERT(min_image_count >= 2);
+ if (g_VulkanInitInfo.MinImageCount == min_image_count)
+ return;
+
+ ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
+ VkResult err = vkDeviceWaitIdle(v->Device);
+ check_vk_result(err);
+ ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &g_MainWindowRenderBuffers, v->Allocator);
+ g_VulkanInitInfo.MinImageCount = min_image_count;
+}
+
+
+//-------------------------------------------------------------------------
+// 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:
+// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files.
+// 2) the upcoming multi-viewport feature will need them internally.
+// Generally we avoid exposing any kind of superfluous high-level helpers in the bindings,
+// but it is too much code to duplicate everywhere so we exceptionally expose them.
+//
+// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
+// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work.
+// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions)
+//-------------------------------------------------------------------------
+
+VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space)
+{
+ IM_ASSERT(request_formats != NULL);
+ IM_ASSERT(request_formats_count > 0);
+
+ // Per Spec Format and View Format are expected to be the same unless VK_IMAGE_CREATE_MUTABLE_BIT was set at image creation
+ // Assuming that the default behavior is without setting this bit, there is no need for separate Swapchain image and image view format
+ // Additionally several new color spaces were introduced with Vulkan Spec v1.0.40,
+ // hence we must make sure that a format with the mostly available color space, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, is found and used.
+ uint32_t avail_count;
+ vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &avail_count, NULL);
+ ImVector avail_format;
+ avail_format.resize((int)avail_count);
+ vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &avail_count, avail_format.Data);
+
+ // First check if only one format, VK_FORMAT_UNDEFINED, is available, which would imply that any format is available
+ if (avail_count == 1)
+ {
+ if (avail_format[0].format == VK_FORMAT_UNDEFINED)
+ {
+ VkSurfaceFormatKHR ret;
+ ret.format = request_formats[0];
+ ret.colorSpace = request_color_space;
+ return ret;
+ }
+ else
+ {
+ // No point in searching another format
+ return avail_format[0];
+ }
+ }
+ else
+ {
+ // Request several formats, the first found will be used
+ for (int request_i = 0; request_i < request_formats_count; request_i++)
+ for (uint32_t avail_i = 0; avail_i < avail_count; avail_i++)
+ if (avail_format[avail_i].format == request_formats[request_i] && avail_format[avail_i].colorSpace == request_color_space)
+ return avail_format[avail_i];
+
+ // If none of the requested image formats could be found, use the first available
+ return avail_format[0];
+ }
+}
+
+VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count)
+{
+ IM_ASSERT(request_modes != NULL);
+ IM_ASSERT(request_modes_count > 0);
+
+ // Request a certain mode and confirm that it is available. If not use VK_PRESENT_MODE_FIFO_KHR which is mandatory
+ uint32_t avail_count = 0;
+ vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device, surface, &avail_count, NULL);
+ ImVector avail_modes;
+ avail_modes.resize((int)avail_count);
+ vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device, surface, &avail_count, avail_modes.Data);
+ //for (uint32_t avail_i = 0; avail_i < avail_count; avail_i++)
+ // printf("[vulkan] avail_modes[%d] = %d\n", avail_i, avail_modes[avail_i]);
+
+ for (int request_i = 0; request_i < request_modes_count; request_i++)
+ for (uint32_t avail_i = 0; avail_i < avail_count; avail_i++)
+ if (request_modes[request_i] == avail_modes[avail_i])
+ return request_modes[request_i];
+
+ return VK_PRESENT_MODE_FIFO_KHR; // Always available
+}
+
+void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator)
+{
+ IM_ASSERT(physical_device != VK_NULL_HANDLE && device != VK_NULL_HANDLE);
+ (void)physical_device;
+ (void)allocator;
+
+ // Create Command Buffers
+ VkResult err;
+ for (uint32_t i = 0; i < wd->ImageCount; i++)
+ {
+ ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i];
+ ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[i];
+ {
+ VkCommandPoolCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+ info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
+ info.queueFamilyIndex = queue_family;
+ err = vkCreateCommandPool(device, &info, allocator, &fd->CommandPool);
+ check_vk_result(err);
+ }
+ {
+ VkCommandBufferAllocateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+ info.commandPool = fd->CommandPool;
+ info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
+ info.commandBufferCount = 1;
+ err = vkAllocateCommandBuffers(device, &info, &fd->CommandBuffer);
+ check_vk_result(err);
+ }
+ {
+ VkFenceCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
+ info.flags = VK_FENCE_CREATE_SIGNALED_BIT;
+ err = vkCreateFence(device, &info, allocator, &fd->Fence);
+ check_vk_result(err);
+ }
+ {
+ VkSemaphoreCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
+ err = vkCreateSemaphore(device, &info, allocator, &fsd->ImageAcquiredSemaphore);
+ check_vk_result(err);
+ err = vkCreateSemaphore(device, &info, allocator, &fsd->RenderCompleteSemaphore);
+ check_vk_result(err);
+ }
+ }
+}
+
+int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode)
+{
+ if (present_mode == VK_PRESENT_MODE_MAILBOX_KHR)
+ return 3;
+ if (present_mode == VK_PRESENT_MODE_FIFO_KHR || present_mode == VK_PRESENT_MODE_FIFO_RELAXED_KHR)
+ return 2;
+ if (present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR)
+ return 1;
+ IM_ASSERT(0);
+ return 1;
+}
+
+// Also destroy old swap chain and in-flight frames data, if any.
+void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count)
+{
+ VkResult err;
+ VkSwapchainKHR old_swapchain = wd->Swapchain;
+ wd->Swapchain = NULL;
+ err = vkDeviceWaitIdle(device);
+ check_vk_result(err);
+
+ // We don't use ImGui_ImplVulkanH_DestroyWindow() because we want to preserve the old swapchain to create the new one.
+ // Destroy old Framebuffer
+ for (uint32_t i = 0; i < wd->ImageCount; i++)
+ {
+ ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
+ ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
+ }
+ IM_FREE(wd->Frames);
+ IM_FREE(wd->FrameSemaphores);
+ wd->Frames = NULL;
+ wd->FrameSemaphores = NULL;
+ wd->ImageCount = 0;
+ if (wd->RenderPass)
+ vkDestroyRenderPass(device, wd->RenderPass, allocator);
+
+ // If min image count was not specified, request different count of images dependent on selected present mode
+ if (min_image_count == 0)
+ min_image_count = ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(wd->PresentMode);
+
+ // Create Swapchain
+ {
+ VkSwapchainCreateInfoKHR info = {};
+ info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
+ info.surface = wd->Surface;
+ info.minImageCount = min_image_count;
+ info.imageFormat = wd->SurfaceFormat.format;
+ info.imageColorSpace = wd->SurfaceFormat.colorSpace;
+ info.imageArrayLayers = 1;
+ info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
+ info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; // Assume that graphics family == present family
+ info.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
+ info.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
+ info.presentMode = wd->PresentMode;
+ info.clipped = VK_TRUE;
+ info.oldSwapchain = old_swapchain;
+ VkSurfaceCapabilitiesKHR cap;
+ 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;
+
+ if (cap.currentExtent.width == 0xffffffff)
+ {
+ info.imageExtent.width = wd->Width = w;
+ info.imageExtent.height = wd->Height = h;
+ }
+ else
+ {
+ info.imageExtent.width = wd->Width = cap.currentExtent.width;
+ info.imageExtent.height = wd->Height = cap.currentExtent.height;
+ }
+ err = vkCreateSwapchainKHR(device, &info, allocator, &wd->Swapchain);
+ check_vk_result(err);
+ err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, NULL);
+ check_vk_result(err);
+ VkImage backbuffers[16] = {};
+ IM_ASSERT(wd->ImageCount >= min_image_count);
+ IM_ASSERT(wd->ImageCount < IM_ARRAYSIZE(backbuffers));
+ err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, backbuffers);
+ check_vk_result(err);
+
+ IM_ASSERT(wd->Frames == NULL);
+ wd->Frames = (ImGui_ImplVulkanH_Frame*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_Frame) * wd->ImageCount);
+ wd->FrameSemaphores = (ImGui_ImplVulkanH_FrameSemaphores*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameSemaphores) * wd->ImageCount);
+ memset(wd->Frames, 0, sizeof(wd->Frames[0]) * wd->ImageCount);
+ memset(wd->FrameSemaphores, 0, sizeof(wd->FrameSemaphores[0]) * wd->ImageCount);
+ for (uint32_t i = 0; i < wd->ImageCount; i++)
+ wd->Frames[i].Backbuffer = backbuffers[i];
+ }
+ if (old_swapchain)
+ vkDestroySwapchainKHR(device, old_swapchain, allocator);
+
+ // Create the Render Pass
+ {
+ VkAttachmentDescription attachment = {};
+ attachment.format = wd->SurfaceFormat.format;
+ attachment.samples = VK_SAMPLE_COUNT_1_BIT;
+ attachment.loadOp = wd->ClearEnable ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
+ attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
+ attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
+ attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
+ attachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ attachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
+ VkAttachmentReference color_attachment = {};
+ color_attachment.attachment = 0;
+ color_attachment.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ VkSubpassDescription subpass = {};
+ subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
+ subpass.colorAttachmentCount = 1;
+ subpass.pColorAttachments = &color_attachment;
+ VkSubpassDependency dependency = {};
+ dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
+ dependency.dstSubpass = 0;
+ dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ dependency.srcAccessMask = 0;
+ dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+ VkRenderPassCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+ info.attachmentCount = 1;
+ info.pAttachments = &attachment;
+ info.subpassCount = 1;
+ info.pSubpasses = &subpass;
+ info.dependencyCount = 1;
+ info.pDependencies = &dependency;
+ err = vkCreateRenderPass(device, &info, allocator, &wd->RenderPass);
+ check_vk_result(err);
+ }
+
+ // Create The Image Views
+ {
+ VkImageViewCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ info.viewType = VK_IMAGE_VIEW_TYPE_2D;
+ info.format = wd->SurfaceFormat.format;
+ info.components.r = VK_COMPONENT_SWIZZLE_R;
+ info.components.g = VK_COMPONENT_SWIZZLE_G;
+ info.components.b = VK_COMPONENT_SWIZZLE_B;
+ info.components.a = VK_COMPONENT_SWIZZLE_A;
+ VkImageSubresourceRange image_range = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 };
+ info.subresourceRange = image_range;
+ for (uint32_t i = 0; i < wd->ImageCount; i++)
+ {
+ ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i];
+ info.image = fd->Backbuffer;
+ err = vkCreateImageView(device, &info, allocator, &fd->BackbufferView);
+ check_vk_result(err);
+ }
+ }
+
+ // Create Framebuffer
+ {
+ VkImageView attachment[1];
+ VkFramebufferCreateInfo info = {};
+ info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
+ info.renderPass = wd->RenderPass;
+ info.attachmentCount = 1;
+ info.pAttachments = attachment;
+ info.width = wd->Width;
+ info.height = wd->Height;
+ info.layers = 1;
+ for (uint32_t i = 0; i < wd->ImageCount; i++)
+ {
+ ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i];
+ attachment[0] = fd->BackbufferView;
+ err = vkCreateFramebuffer(device, &info, allocator, &fd->Framebuffer);
+ check_vk_result(err);
+ }
+ }
+}
+
+// Create or resize window
+void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int width, int height, uint32_t min_image_count)
+{
+ (void)instance;
+ ImGui_ImplVulkanH_CreateWindowSwapChain(physical_device, device, wd, allocator, width, height, min_image_count);
+ ImGui_ImplVulkanH_CreateWindowCommandBuffers(physical_device, device, wd, queue_family, allocator);
+}
+
+void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator)
+{
+ vkDeviceWaitIdle(device); // FIXME: We could wait on the Queue if we had the queue in wd-> (otherwise VulkanH functions can't use globals)
+ //vkQueueWaitIdle(g_Queue);
+
+ for (uint32_t i = 0; i < wd->ImageCount; i++)
+ {
+ ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
+ ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
+ }
+ IM_FREE(wd->Frames);
+ IM_FREE(wd->FrameSemaphores);
+ wd->Frames = NULL;
+ wd->FrameSemaphores = NULL;
+ vkDestroyRenderPass(device, wd->RenderPass, allocator);
+ vkDestroySwapchainKHR(device, wd->Swapchain, allocator);
+ vkDestroySurfaceKHR(instance, wd->Surface, allocator);
+
+ *wd = ImGui_ImplVulkanH_Window();
+}
+
+void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator)
+{
+ vkDestroyFence(device, fd->Fence, allocator);
+ vkFreeCommandBuffers(device, fd->CommandPool, 1, &fd->CommandBuffer);
+ vkDestroyCommandPool(device, fd->CommandPool, allocator);
+ fd->Fence = VK_NULL_HANDLE;
+ fd->CommandBuffer = VK_NULL_HANDLE;
+ fd->CommandPool = VK_NULL_HANDLE;
+
+ vkDestroyImageView(device, fd->BackbufferView, allocator);
+ vkDestroyFramebuffer(device, fd->Framebuffer, allocator);
+}
+
+void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator)
+{
+ vkDestroySemaphore(device, fsd->ImageAcquiredSemaphore, allocator);
+ vkDestroySemaphore(device, fsd->RenderCompleteSemaphore, allocator);
+ fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE;
+}
+
+void ImGui_ImplVulkanH_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkanH_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
+{
+ if (buffers->VertexBuffer) { vkDestroyBuffer(device, buffers->VertexBuffer, allocator); buffers->VertexBuffer = VK_NULL_HANDLE; }
+ if (buffers->VertexBufferMemory) { vkFreeMemory(device, buffers->VertexBufferMemory, allocator); buffers->VertexBufferMemory = VK_NULL_HANDLE; }
+ if (buffers->IndexBuffer) { vkDestroyBuffer(device, buffers->IndexBuffer, allocator); buffers->IndexBuffer = VK_NULL_HANDLE; }
+ if (buffers->IndexBufferMemory) { vkFreeMemory(device, buffers->IndexBufferMemory, allocator); buffers->IndexBufferMemory = VK_NULL_HANDLE; }
+ buffers->VertexBufferSize = 0;
+ buffers->IndexBufferSize = 0;
+}
+
+void ImGui_ImplVulkanH_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkanH_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
+{
+ for (uint32_t n = 0; n < buffers->Count; n++)
+ ImGui_ImplVulkanH_DestroyFrameRenderBuffers(device, &buffers->FrameRenderBuffers[n], allocator);
+ IM_FREE(buffers->FrameRenderBuffers);
+ buffers->FrameRenderBuffers = NULL;
+ buffers->Index = 0;
+ buffers->Count = 0;
+}
diff --git a/third_party/imgui/examples/imgui_impl_vulkan.h b/third_party/imgui/examples/imgui_impl_vulkan.h
new file mode 100644
index 0000000000..0eb772e7f6
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_vulkan.h
@@ -0,0 +1,126 @@
+// dear imgui: Renderer for Vulkan
+// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
+
+// Implemented features:
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
+// Missing features:
+// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
+
+// 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
+
+// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
+// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
+
+// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
+// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
+// You will use those if you want to use this rendering back-end in your engine/app.
+// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by
+// the back-end itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code.
+// Read comments in imgui_impl_vulkan.h.
+
+#pragma once
+#include "imgui.h" // IMGUI_IMPL_API
+#include
+
+// Initialization data, for ImGui_ImplVulkan_Init()
+// [Please zero-clear before use!]
+struct ImGui_ImplVulkan_InitInfo
+{
+ VkInstance Instance;
+ VkPhysicalDevice PhysicalDevice;
+ VkDevice Device;
+ uint32_t QueueFamily;
+ VkQueue Queue;
+ VkPipelineCache PipelineCache;
+ VkDescriptorPool DescriptorPool;
+ uint32_t MinImageCount; // >= 2
+ uint32_t ImageCount; // >= MinImageCount
+ VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT
+ const VkAllocationCallbacks* Allocator;
+ void (*CheckVkResultFn)(VkResult err);
+};
+
+// Called by user code
+IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
+IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
+IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer);
+IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
+IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
+IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
+
+
+//-------------------------------------------------------------------------
+// Internal / Miscellaneous Vulkan Helpers
+// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own engine/app.)
+//-------------------------------------------------------------------------
+// You probably do NOT need to use or care about those functions.
+// Those functions only exist because:
+// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files.
+// 2) the upcoming multi-viewport feature will need them internally.
+// Generally we avoid exposing any kind of superfluous high-level helpers in the bindings,
+// but it is too much code to duplicate everywhere so we exceptionally expose them.
+//
+// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
+// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work.
+// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions)
+//-------------------------------------------------------------------------
+
+struct ImGui_ImplVulkanH_Frame;
+struct ImGui_ImplVulkanH_Window;
+
+// Helpers
+IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
+IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator);
+IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
+IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
+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 engine/app.)
+// [Please zero-clear before use!]
+struct ImGui_ImplVulkanH_Frame
+{
+ VkCommandPool CommandPool;
+ VkCommandBuffer CommandBuffer;
+ VkFence Fence;
+ VkImage Backbuffer;
+ VkImageView BackbufferView;
+ VkFramebuffer Framebuffer;
+};
+
+struct ImGui_ImplVulkanH_FrameSemaphores
+{
+ VkSemaphore ImageAcquiredSemaphore;
+ VkSemaphore RenderCompleteSemaphore;
+};
+
+// 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 engine/app.)
+struct ImGui_ImplVulkanH_Window
+{
+ int Width;
+ int Height;
+ VkSwapchainKHR Swapchain;
+ VkSurfaceKHR Surface;
+ VkSurfaceFormatKHR SurfaceFormat;
+ VkPresentModeKHR PresentMode;
+ VkRenderPass RenderPass;
+ bool ClearEnable;
+ VkClearValue ClearValue;
+ uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
+ uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
+ uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
+ ImGui_ImplVulkanH_Frame* Frames;
+ ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
+
+ ImGui_ImplVulkanH_Window()
+ {
+ memset(this, 0, sizeof(*this));
+ PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
+ ClearEnable = true;
+ }
+};
+
diff --git a/third_party/imgui/examples/imgui_impl_win32.cpp b/third_party/imgui/examples/imgui_impl_win32.cpp
new file mode 100644
index 0000000000..57d6e3eda2
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_win32.cpp
@@ -0,0 +1,446 @@
+// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications)
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+
+// Implemented features:
+// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
+// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
+// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
+// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
+
+#include "imgui.h"
+#include "imgui_impl_win32.h"
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include
+#include
+
+// Using XInput library for gamepad (with recent Windows SDK this may leads to executables which won't run on Windows 7)
+#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
+#include
+#else
+#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT
+#endif
+#if defined(_MSC_VER) && !defined(IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT)
+#pragma comment(lib, "xinput")
+//#pragma comment(lib, "Xinput9_1_0")
+#endif
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 2020-03-03: Inputs: Calling AddInputCharacterUTF16() to support surrogate pairs leading to codepoint >= 0x10000 (for more complete CJK inputs)
+// 2020-02-17: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(), ImGui_ImplWin32_GetDpiScaleForMonitor() helper functions.
+// 2020-01-14: Inputs: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD/IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT.
+// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
+// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter().
+// 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent.
+// 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages.
+// 2019-01-15: Inputs: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is set by user application).
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
+// 2018-06-10: Inputs: Fixed handling of mouse wheel messages to support fine position messages (typically sent by track-pads).
+// 2018-06-08: Misc: Extracted imgui_impl_win32.cpp/.h away from the old combined DX9/DX10/DX11/DX12 examples.
+// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoMouseCursorChange flag.
+// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
+// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
+// 2018-02-06: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
+// 2018-01-08: Inputs: Added mapping for ImGuiKey_Insert.
+// 2018-01-05: Inputs: Added WM_LBUTTONDBLCLK double-click handlers for window classes with the CS_DBLCLKS flag.
+// 2017-10-23: Inputs: Added WM_SYSKEYDOWN / WM_SYSKEYUP handlers so e.g. the VK_MENU key can be read.
+// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
+// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set.
+
+// Win32 Data
+static HWND g_hWnd = NULL;
+static INT64 g_Time = 0;
+static INT64 g_TicksPerSecond = 0;
+static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_COUNT;
+static bool g_HasGamepad = false;
+static bool g_WantUpdateHasGamepad = true;
+
+// Functions
+bool ImGui_ImplWin32_Init(void* hwnd)
+{
+ if (!::QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
+ return false;
+ if (!::QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
+ return false;
+
+ // Setup back-end capabilities flags
+ g_hWnd = (HWND)hwnd;
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+ io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
+ io.BackendPlatformName = "imgui_impl_win32";
+ io.ImeWindowHandle = hwnd;
+
+ // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime.
+ io.KeyMap[ImGuiKey_Tab] = VK_TAB;
+ io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR;
+ io.KeyMap[ImGuiKey_PageDown] = VK_NEXT;
+ io.KeyMap[ImGuiKey_Home] = VK_HOME;
+ io.KeyMap[ImGuiKey_End] = VK_END;
+ io.KeyMap[ImGuiKey_Insert] = VK_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
+ io.KeyMap[ImGuiKey_Space] = VK_SPACE;
+ io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
+ io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
+ io.KeyMap[ImGuiKey_KeyPadEnter] = VK_RETURN;
+ 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_ImplWin32_Shutdown()
+{
+ g_hWnd = (HWND)0;
+}
+
+static bool ImGui_ImplWin32_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
+ return false;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ ::SetCursor(NULL);
+ }
+ else
+ {
+ // Show OS mouse cursor
+ LPTSTR win32_cursor = IDC_ARROW;
+ switch (imgui_cursor)
+ {
+ case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break;
+ case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break;
+ case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break;
+ case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break;
+ case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break;
+ case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
+ case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
+ case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break;
+ case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break;
+ }
+ ::SetCursor(::LoadCursor(NULL, win32_cursor));
+ }
+ return true;
+}
+
+static void ImGui_ImplWin32_UpdateMousePos()
+{
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
+ if (io.WantSetMousePos)
+ {
+ POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
+ ::ClientToScreen(g_hWnd, &pos);
+ ::SetCursorPos(pos.x, pos.y);
+ }
+
+ // Set mouse position
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+ POINT pos;
+ if (HWND active_window = ::GetForegroundWindow())
+ if (active_window == g_hWnd || ::IsChild(active_window, g_hWnd))
+ if (::GetCursorPos(&pos) && ::ScreenToClient(g_hWnd, &pos))
+ io.MousePos = ImVec2((float)pos.x, (float)pos.y);
+}
+
+// Gamepad navigation mapping
+static void ImGui_ImplWin32_UpdateGamepads()
+{
+#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
+ ImGuiIO& io = ImGui::GetIO();
+ memset(io.NavInputs, 0, sizeof(io.NavInputs));
+ if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
+ return;
+
+ // Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow.
+ // Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE.
+ if (g_WantUpdateHasGamepad)
+ {
+ XINPUT_CAPABILITIES caps;
+ g_HasGamepad = (XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS);
+ g_WantUpdateHasGamepad = false;
+ }
+
+ XINPUT_STATE xinput_state;
+ io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
+ if (g_HasGamepad && XInputGetState(0, &xinput_state) == ERROR_SUCCESS)
+ {
+ const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad;
+ io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
+
+ #define MAP_BUTTON(NAV_NO, BUTTON_ENUM) { io.NavInputs[NAV_NO] = (gamepad.wButtons & BUTTON_ENUM) ? 1.0f : 0.0f; }
+ #define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
+ MAP_BUTTON(ImGuiNavInput_Activate, XINPUT_GAMEPAD_A); // Cross / A
+ MAP_BUTTON(ImGuiNavInput_Cancel, XINPUT_GAMEPAD_B); // Circle / B
+ MAP_BUTTON(ImGuiNavInput_Menu, XINPUT_GAMEPAD_X); // Square / X
+ MAP_BUTTON(ImGuiNavInput_Input, XINPUT_GAMEPAD_Y); // Triangle / Y
+ MAP_BUTTON(ImGuiNavInput_DpadLeft, XINPUT_GAMEPAD_DPAD_LEFT); // D-Pad Left
+ MAP_BUTTON(ImGuiNavInput_DpadRight, XINPUT_GAMEPAD_DPAD_RIGHT); // D-Pad Right
+ MAP_BUTTON(ImGuiNavInput_DpadUp, XINPUT_GAMEPAD_DPAD_UP); // D-Pad Up
+ MAP_BUTTON(ImGuiNavInput_DpadDown, XINPUT_GAMEPAD_DPAD_DOWN); // D-Pad Down
+ MAP_BUTTON(ImGuiNavInput_FocusPrev, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
+ MAP_BUTTON(ImGuiNavInput_FocusNext, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
+ MAP_BUTTON(ImGuiNavInput_TweakSlow, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
+ MAP_BUTTON(ImGuiNavInput_TweakFast, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
+ MAP_ANALOG(ImGuiNavInput_LStickLeft, gamepad.sThumbLX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768);
+ MAP_ANALOG(ImGuiNavInput_LStickRight, gamepad.sThumbLX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
+ MAP_ANALOG(ImGuiNavInput_LStickUp, gamepad.sThumbLY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
+ MAP_ANALOG(ImGuiNavInput_LStickDown, gamepad.sThumbLY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32767);
+ #undef MAP_BUTTON
+ #undef MAP_ANALOG
+ }
+#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
+}
+
+void ImGui_ImplWin32_NewFrame()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
+
+ // Setup display size (every frame to accommodate for window resizing)
+ RECT rect;
+ ::GetClientRect(g_hWnd, &rect);
+ io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
+
+ // Setup time step
+ INT64 current_time;
+ ::QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
+ io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
+ g_Time = current_time;
+
+ // Read keyboard modifiers inputs
+ io.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ io.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ io.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ io.KeySuper = false;
+ // io.KeysDown[], io.MousePos, io.MouseDown[], io.MouseWheel: filled by the WndProc handler below.
+
+ // Update OS mouse position
+ ImGui_ImplWin32_UpdateMousePos();
+
+ // Update OS mouse cursor with the cursor requested by imgui
+ ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
+ if (g_LastMouseCursor != mouse_cursor)
+ {
+ g_LastMouseCursor = mouse_cursor;
+ ImGui_ImplWin32_UpdateMouseCursor();
+ }
+
+ // Update game controllers (if enabled and available)
+ ImGui_ImplWin32_UpdateGamepads();
+}
+
+// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions.
+#ifndef WM_MOUSEHWHEEL
+#define WM_MOUSEHWHEEL 0x020E
+#endif
+#ifndef DBT_DEVNODES_CHANGED
+#define DBT_DEVNODES_CHANGED 0x0007
+#endif
+
+// Win32 message handler (process Win32 mouse/keyboard inputs, etc.)
+// Call from your application's message handler.
+// When implementing your own back-end, 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.
+// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinates when dragging mouse outside of our window bounds.
+// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
+#if 0
+// Copy this line into your .cpp file to forward declare the function.
+extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+#endif
+IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ if (ImGui::GetCurrentContext() == NULL)
+ return 0;
+
+ ImGuiIO& io = ImGui::GetIO();
+ switch (msg)
+ {
+ case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
+ case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
+ case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
+ case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK:
+ {
+ int button = 0;
+ if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { button = 0; }
+ if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
+ if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
+ if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
+ if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
+ ::SetCapture(hwnd);
+ io.MouseDown[button] = true;
+ return 0;
+ }
+ case WM_LBUTTONUP:
+ case WM_RBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_XBUTTONUP:
+ {
+ int button = 0;
+ if (msg == WM_LBUTTONUP) { button = 0; }
+ if (msg == WM_RBUTTONUP) { button = 1; }
+ if (msg == WM_MBUTTONUP) { button = 2; }
+ if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
+ io.MouseDown[button] = false;
+ if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
+ ::ReleaseCapture();
+ return 0;
+ }
+ case WM_MOUSEWHEEL:
+ io.MouseWheel += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
+ return 0;
+ case WM_MOUSEHWHEEL:
+ io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
+ return 0;
+ case WM_KEYDOWN:
+ case WM_SYSKEYDOWN:
+ if (wParam < 256)
+ io.KeysDown[wParam] = 1;
+ return 0;
+ case WM_KEYUP:
+ case WM_SYSKEYUP:
+ if (wParam < 256)
+ io.KeysDown[wParam] = 0;
+ return 0;
+ case WM_CHAR:
+ // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
+ if (wParam > 0 && wParam < 0x10000)
+ io.AddInputCharacterUTF16((unsigned short)wParam);
+ return 0;
+ case WM_SETCURSOR:
+ if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor())
+ return 1;
+ return 0;
+ case WM_DEVICECHANGE:
+ if ((UINT)wParam == DBT_DEVNODES_CHANGED)
+ g_WantUpdateHasGamepad = true;
+ return 0;
+ }
+ return 0;
+}
+
+
+//--------------------------------------------------------------------------------------------------------
+// DPI-related helpers (optional)
+//--------------------------------------------------------------------------------------------------------
+// - Use to enable DPI awareness without having to create an application manifest.
+// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps.
+// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc.
+// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime,
+// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
+//---------------------------------------------------------------------------------------------------------
+// This is the scheme successfully used by GLFW (from which we borrowed some of the code) and other apps aiming to be highly portable.
+// ImGui_ImplWin32_EnableDpiAwareness() is just a helper called by main.cpp, we don't call it automatically.
+// If you are trying to implement your own back-end for your own engine, you may ignore that noise.
+//---------------------------------------------------------------------------------------------------------
+
+// Implement some of the functions and types normally declared in recent Windows SDK.
+#if !defined(_versionhelpers_H_INCLUDED_) && !defined(_INC_VERSIONHELPERS)
+static BOOL IsWindowsVersionOrGreater(WORD major, WORD minor, WORD sp)
+{
+ OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, { 0 }, sp, 0, 0, 0, 0 };
+ DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
+ ULONGLONG cond = ::VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ cond = ::VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
+ cond = ::VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
+ return ::VerifyVersionInfoW(&osvi, mask, cond);
+}
+#define IsWindows8Point1OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0602), LOBYTE(0x0602), 0) // _WIN32_WINNT_WINBLUE
+#endif
+
+#ifndef DPI_ENUMS_DECLARED
+typedef enum { PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 } PROCESS_DPI_AWARENESS;
+typedef enum { MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, MDT_RAW_DPI = 2, MDT_DEFAULT = MDT_EFFECTIVE_DPI } MONITOR_DPI_TYPE;
+#endif
+#ifndef _DPI_AWARENESS_CONTEXTS_
+DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
+#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE (DPI_AWARENESS_CONTEXT)-3
+#endif
+#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
+#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 (DPI_AWARENESS_CONTEXT)-4
+#endif
+typedef HRESULT(WINAPI* PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS); // Shcore.lib + dll, Windows 8.1+
+typedef HRESULT(WINAPI* PFN_GetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); // Shcore.lib + dll, Windows 8.1+
+typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); // User32.lib + dll, Windows 10 v1607+ (Creators Update)
+
+// Helper function to enable DPI awareness without setting up a manifest
+void ImGui_ImplWin32_EnableDpiAwareness()
+{
+ // if (IsWindows10OrGreater()) // This needs a manifest to succeed. Instead we try to grab the function pointer!
+ {
+ static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
+ if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext"))
+ {
+ SetThreadDpiAwarenessContextFn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
+ return;
+ }
+ }
+ if (IsWindows8Point1OrGreater())
+ {
+ static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
+ if (PFN_SetProcessDpiAwareness SetProcessDpiAwarenessFn = (PFN_SetProcessDpiAwareness)::GetProcAddress(shcore_dll, "SetProcessDpiAwareness"))
+ {
+ SetProcessDpiAwarenessFn(PROCESS_PER_MONITOR_DPI_AWARE);
+ return;
+ }
+ }
+#if _WIN32_WINNT >= 0x0600
+ ::SetProcessDPIAware();
+#endif
+}
+
+#if defined(_MSC_VER) && !defined(NOGDI)
+#pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps()
+#endif
+
+float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
+{
+ UINT xdpi = 96, ydpi = 96;
+ static BOOL bIsWindows8Point1OrGreater = IsWindows8Point1OrGreater();
+ if (bIsWindows8Point1OrGreater)
+ {
+ static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
+ if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor"))
+ GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
+ }
+#ifndef NOGDI
+ else
+ {
+ const HDC dc = ::GetDC(NULL);
+ xdpi = ::GetDeviceCaps(dc, LOGPIXELSX);
+ ydpi = ::GetDeviceCaps(dc, LOGPIXELSY);
+ ::ReleaseDC(NULL, dc);
+ }
+#endif
+ IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
+ return xdpi / 96.0f;
+}
+
+float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd)
+{
+ HMONITOR monitor = ::MonitorFromWindow((HWND)hwnd, MONITOR_DEFAULTTONEAREST);
+ return ImGui_ImplWin32_GetDpiScaleForMonitor(monitor);
+}
+
+//---------------------------------------------------------------------------------------------------------
diff --git a/third_party/imgui/examples/imgui_impl_win32.h b/third_party/imgui/examples/imgui_impl_win32.h
new file mode 100644
index 0000000000..8923bd6346
--- /dev/null
+++ b/third_party/imgui/examples/imgui_impl_win32.h
@@ -0,0 +1,37 @@
+// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications)
+// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
+
+// Implemented features:
+// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
+// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
+// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
+// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
+
+#pragma once
+#include "imgui.h" // IMGUI_IMPL_API
+
+IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
+IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
+
+// Configuration
+// - Disable gamepad support or linking with xinput.lib
+//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
+//#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT
+
+// Win32 message handler your application need to call.
+// - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper.
+// - You should COPY the line below into your .cpp code to forward declare the function and then you can call it.
+#if 0
+extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+#endif
+
+// DPI-related helpers (optional)
+// - Use to enable DPI awareness without having to create an application manifest.
+// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps.
+// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc.
+// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime,
+// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
+IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness();
+IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd
+IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor
diff --git a/third_party/imgui/examples/libs/usynergy/uSynergy.c b/third_party/imgui/examples/libs/usynergy/uSynergy.c
index a8d01da415..8dce47b8ab 100644
--- a/third_party/imgui/examples/libs/usynergy/uSynergy.c
+++ b/third_party/imgui/examples/libs/usynergy/uSynergy.c
@@ -1,636 +1,636 @@
-/*
-uSynergy client -- Implementation for the embedded Synergy client library
- version 1.0.0, July 7th, 2012
-
-Copyright (c) 2012 Alex Evans
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
- 3. This notice may not be removed or altered from any source
- distribution.
-*/
-#include "uSynergy.h"
-#include
-#include
-
-
-
-//---------------------------------------------------------------------------------------------------------------------
-// Internal helpers
-//---------------------------------------------------------------------------------------------------------------------
-
-
-
-/**
-@brief Read 16 bit integer in network byte order and convert to native byte order
-**/
-static int16_t sNetToNative16(const unsigned char *value)
-{
-#ifdef USYNERGY_LITTLE_ENDIAN
- return value[1] | (value[0] << 8);
-#else
- return value[0] | (value[1] << 8);
-#endif
-}
-
-
-
-/**
-@brief Read 32 bit integer in network byte order and convert to native byte order
-**/
-static int32_t sNetToNative32(const unsigned char *value)
-{
-#ifdef USYNERGY_LITTLE_ENDIAN
- return value[3] | (value[2] << 8) | (value[1] << 16) | (value[0] << 24);
-#else
- return value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
-#endif
-}
-
-
-
-/**
-@brief Trace text to client
-**/
-static void sTrace(uSynergyContext *context, const char* text)
-{
- // Don't trace if we don't have a trace function
- if (context->m_traceFunc != 0L)
- context->m_traceFunc(context->m_cookie, text);
-}
-
-
-
-/**
-@brief Add string to reply packet
-**/
-static void sAddString(uSynergyContext *context, const char *string)
-{
- size_t len = strlen(string);
- memcpy(context->m_replyCur, string, len);
- context->m_replyCur += len;
-}
-
-
-
-/**
-@brief Add uint8 to reply packet
-**/
-static void sAddUInt8(uSynergyContext *context, uint8_t value)
-{
- *context->m_replyCur++ = value;
-}
-
-
-
-/**
-@brief Add uint16 to reply packet
-**/
-static void sAddUInt16(uSynergyContext *context, uint16_t value)
-{
- uint8_t *reply = context->m_replyCur;
- *reply++ = (uint8_t)(value >> 8);
- *reply++ = (uint8_t)value;
- context->m_replyCur = reply;
-}
-
-
-
-/**
-@brief Add uint32 to reply packet
-**/
-static void sAddUInt32(uSynergyContext *context, uint32_t value)
-{
- uint8_t *reply = context->m_replyCur;
- *reply++ = (uint8_t)(value >> 24);
- *reply++ = (uint8_t)(value >> 16);
- *reply++ = (uint8_t)(value >> 8);
- *reply++ = (uint8_t)value;
- context->m_replyCur = reply;
-}
-
-
-
-/**
-@brief Send reply packet
-**/
-static uSynergyBool sSendReply(uSynergyContext *context)
-{
- // Set header size
- uint8_t *reply_buf = context->m_replyBuffer;
- uint32_t reply_len = (uint32_t)(context->m_replyCur - reply_buf); /* Total size of reply */
- uint32_t body_len = reply_len - 4; /* Size of body */
- uSynergyBool ret;
- reply_buf[0] = (uint8_t)(body_len >> 24);
- reply_buf[1] = (uint8_t)(body_len >> 16);
- reply_buf[2] = (uint8_t)(body_len >> 8);
- reply_buf[3] = (uint8_t)body_len;
-
- // Send reply
- ret = context->m_sendFunc(context->m_cookie, context->m_replyBuffer, reply_len);
-
- // Reset reply buffer write pointer
- context->m_replyCur = context->m_replyBuffer+4;
- return ret;
-}
-
-
-
-/**
-@brief Call mouse callback after a mouse event
-**/
-static void sSendMouseCallback(uSynergyContext *context)
-{
- // Skip if no callback is installed
- if (context->m_mouseCallback == 0L)
- return;
-
- // Send callback
- context->m_mouseCallback(context->m_cookie, context->m_mouseX, context->m_mouseY, context->m_mouseWheelX,
- context->m_mouseWheelY, context->m_mouseButtonLeft, context->m_mouseButtonRight, context->m_mouseButtonMiddle);
-}
-
-
-
-/**
-@brief Send keyboard callback when a key has been pressed or released
-**/
-static void sSendKeyboardCallback(uSynergyContext *context, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat)
-{
- // Skip if no callback is installed
- if (context->m_keyboardCallback == 0L)
- return;
-
- // Send callback
- context->m_keyboardCallback(context->m_cookie, key, modifiers, down, repeat);
-}
-
-
-
-/**
-@brief Send joystick callback
-**/
-static void sSendJoystickCallback(uSynergyContext *context, uint8_t joyNum)
-{
- int8_t *sticks;
-
- // Skip if no callback is installed
- if (context->m_joystickCallback == 0L)
- return;
-
- // Send callback
- sticks = context->m_joystickSticks[joyNum];
- context->m_joystickCallback(context->m_cookie, joyNum, context->m_joystickButtons[joyNum], sticks[0], sticks[1], sticks[2], sticks[3]);
-}
-
-
-
-/**
-@brief Parse a single client message, update state, send callbacks and send replies
-**/
-#define USYNERGY_IS_PACKET(pkt_id) memcmp(message+4, pkt_id, 4)==0
-static void sProcessMessage(uSynergyContext *context, const uint8_t *message)
-{
- // We have a packet!
- if (memcmp(message+4, "Synergy", 7)==0)
- {
- // Welcome message
- // kMsgHello = "Synergy%2i%2i"
- // kMsgHelloBack = "Synergy%2i%2i%s"
- sAddString(context, "Synergy");
- sAddUInt16(context, USYNERGY_PROTOCOL_MAJOR);
- sAddUInt16(context, USYNERGY_PROTOCOL_MINOR);
- sAddUInt32(context, (uint32_t)strlen(context->m_clientName));
- sAddString(context, context->m_clientName);
- if (!sSendReply(context))
- {
- // Send reply failed, let's try to reconnect
- sTrace(context, "SendReply failed, trying to reconnect in a second");
- context->m_connected = USYNERGY_FALSE;
- context->m_sleepFunc(context->m_cookie, 1000);
- }
- else
- {
- // Let's assume we're connected
- char buffer[256+1];
- sprintf(buffer, "Connected as client \"%s\"", context->m_clientName);
- sTrace(context, buffer);
- context->m_hasReceivedHello = USYNERGY_TRUE;
- }
- return;
- }
- else if (USYNERGY_IS_PACKET("QINF"))
- {
- // Screen info. Reply with DINF
- // kMsgQInfo = "QINF"
- // kMsgDInfo = "DINF%2i%2i%2i%2i%2i%2i%2i"
- uint16_t x = 0, y = 0, warp = 0;
- sAddString(context, "DINF");
- sAddUInt16(context, x);
- sAddUInt16(context, y);
- sAddUInt16(context, context->m_clientWidth);
- sAddUInt16(context, context->m_clientHeight);
- sAddUInt16(context, warp);
- sAddUInt16(context, 0); // mx?
- sAddUInt16(context, 0); // my?
- sSendReply(context);
- return;
- }
- else if (USYNERGY_IS_PACKET("CIAK"))
- {
- // Do nothing?
- // kMsgCInfoAck = "CIAK"
- return;
- }
- else if (USYNERGY_IS_PACKET("CROP"))
- {
- // Do nothing?
- // kMsgCResetOptions = "CROP"
- return;
- }
- else if (USYNERGY_IS_PACKET("CINN"))
- {
- // Screen enter. Reply with CNOP
- // kMsgCEnter = "CINN%2i%2i%4i%2i"
-
- // Obtain the Synergy sequence number
- context->m_sequenceNumber = sNetToNative32(message + 12);
- context->m_isCaptured = USYNERGY_TRUE;
-
- // Call callback
- if (context->m_screenActiveCallback != 0L)
- context->m_screenActiveCallback(context->m_cookie, USYNERGY_TRUE);
- }
- else if (USYNERGY_IS_PACKET("COUT"))
- {
- // Screen leave
- // kMsgCLeave = "COUT"
- context->m_isCaptured = USYNERGY_FALSE;
-
- // Call callback
- if (context->m_screenActiveCallback != 0L)
- context->m_screenActiveCallback(context->m_cookie, USYNERGY_FALSE);
- }
- else if (USYNERGY_IS_PACKET("DMDN"))
- {
- // Mouse down
- // kMsgDMouseDown = "DMDN%1i"
- char btn = message[8]-1;
- if (btn==2)
- context->m_mouseButtonRight = USYNERGY_TRUE;
- else if (btn==1)
- context->m_mouseButtonMiddle = USYNERGY_TRUE;
- else
- context->m_mouseButtonLeft = USYNERGY_TRUE;
- sSendMouseCallback(context);
- }
- else if (USYNERGY_IS_PACKET("DMUP"))
- {
- // Mouse up
- // kMsgDMouseUp = "DMUP%1i"
- char btn = message[8]-1;
- if (btn==2)
- context->m_mouseButtonRight = USYNERGY_FALSE;
- else if (btn==1)
- context->m_mouseButtonMiddle = USYNERGY_FALSE;
- else
- context->m_mouseButtonLeft = USYNERGY_FALSE;
- sSendMouseCallback(context);
- }
- else if (USYNERGY_IS_PACKET("DMMV"))
- {
- // Mouse move. Reply with CNOP
- // kMsgDMouseMove = "DMMV%2i%2i"
- context->m_mouseX = sNetToNative16(message+8);
- context->m_mouseY = sNetToNative16(message+10);
- sSendMouseCallback(context);
- }
- else if (USYNERGY_IS_PACKET("DMWM"))
- {
- // Mouse wheel
- // kMsgDMouseWheel = "DMWM%2i%2i"
- // kMsgDMouseWheel1_0 = "DMWM%2i"
- context->m_mouseWheelX += sNetToNative16(message+8);
- context->m_mouseWheelY += sNetToNative16(message+10);
- sSendMouseCallback(context);
- }
- else if (USYNERGY_IS_PACKET("DKDN"))
- {
- // Key down
- // kMsgDKeyDown = "DKDN%2i%2i%2i"
- // kMsgDKeyDown1_0 = "DKDN%2i%2i"
- //uint16_t id = sNetToNative16(message+8);
- uint16_t mod = sNetToNative16(message+10);
- uint16_t key = sNetToNative16(message+12);
- sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_FALSE);
- }
- else if (USYNERGY_IS_PACKET("DKRP"))
- {
- // Key repeat
- // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i"
- // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i"
- uint16_t mod = sNetToNative16(message+10);
-// uint16_t count = sNetToNative16(message+12);
- uint16_t key = sNetToNative16(message+14);
- sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_TRUE);
- }
- else if (USYNERGY_IS_PACKET("DKUP"))
- {
- // Key up
- // kMsgDKeyUp = "DKUP%2i%2i%2i"
- // kMsgDKeyUp1_0 = "DKUP%2i%2i"
- //uint16 id=Endian::sNetToNative(sbuf[4]);
- uint16_t mod = sNetToNative16(message+10);
- uint16_t key = sNetToNative16(message+12);
- sSendKeyboardCallback(context, key, mod, USYNERGY_FALSE, USYNERGY_FALSE);
- }
- else if (USYNERGY_IS_PACKET("DGBT"))
- {
- // Joystick buttons
- // kMsgDGameButtons = "DGBT%1i%2i";
- uint8_t joy_num = message[8];
- if (joy_numm_joystickButtons[joy_num] = (message[9] << 8) | message[10];
- sSendJoystickCallback(context, joy_num);
- }
- }
- else if (USYNERGY_IS_PACKET("DGST"))
- {
- // Joystick sticks
- // kMsgDGameSticks = "DGST%1i%1i%1i%1i%1i";
- uint8_t joy_num = message[8];
- if (joy_numm_joystickSticks[joy_num], message+9, 4);
- sSendJoystickCallback(context, joy_num);
- }
- }
- else if (USYNERGY_IS_PACKET("DSOP"))
- {
- // Set options
- // kMsgDSetOptions = "DSOP%4I"
- }
- else if (USYNERGY_IS_PACKET("CALV"))
- {
- // Keepalive, reply with CALV and then CNOP
- // kMsgCKeepAlive = "CALV"
- sAddString(context, "CALV");
- sSendReply(context);
- // now reply with CNOP
- }
- else if (USYNERGY_IS_PACKET("DCLP"))
- {
- // Clipboard message
- // kMsgDClipboard = "DCLP%1i%4i%s"
- //
- // The clipboard message contains:
- // 1 uint32: The size of the message
- // 4 chars: The identifier ("DCLP")
- // 1 uint8: The clipboard index
- // 1 uint32: The sequence number. It's zero, because this message is always coming from the server?
- // 1 uint32: The total size of the remaining 'string' (as per the Synergy %s string format (which is 1 uint32 for size followed by a char buffer (not necessarily null terminated)).
- // 1 uint32: The number of formats present in the message
- // And then 'number of formats' times the following:
- // 1 uint32: The format of the clipboard data
- // 1 uint32: The size n of the clipboard data
- // n uint8: The clipboard data
- const uint8_t * parse_msg = message+17;
- uint32_t num_formats = sNetToNative32(parse_msg);
- parse_msg += 4;
- for (; num_formats; num_formats--)
- {
- // Parse clipboard format header
- uint32_t format = sNetToNative32(parse_msg);
- uint32_t size = sNetToNative32(parse_msg+4);
- parse_msg += 8;
-
- // Call callback
- if (context->m_clipboardCallback)
- context->m_clipboardCallback(context->m_cookie, format, parse_msg, size);
-
- parse_msg += size;
- }
- }
- else
- {
- // Unknown packet, could be any of these
- // kMsgCNoop = "CNOP"
- // kMsgCClose = "CBYE"
- // kMsgCClipboard = "CCLP%1i%4i"
- // kMsgCScreenSaver = "CSEC%1i"
- // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i"
- // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i"
- // kMsgDMouseRelMove = "DMRM%2i%2i"
- // kMsgEIncompatible = "EICV%2i%2i"
- // kMsgEBusy = "EBSY"
- // kMsgEUnknown = "EUNK"
- // kMsgEBad = "EBAD"
- char buffer[64];
- sprintf(buffer, "Unknown packet '%c%c%c%c'", message[4], message[5], message[6], message[7]);
- sTrace(context, buffer);
- return;
- }
-
- // Reply with CNOP maybe?
- sAddString(context, "CNOP");
- sSendReply(context);
-}
-#undef USYNERGY_IS_PACKET
-
-
-
-/**
-@brief Mark context as being disconnected
-**/
-static void sSetDisconnected(uSynergyContext *context)
-{
- context->m_connected = USYNERGY_FALSE;
- context->m_hasReceivedHello = USYNERGY_FALSE;
- context->m_isCaptured = USYNERGY_FALSE;
- context->m_replyCur = context->m_replyBuffer + 4;
- context->m_sequenceNumber = 0;
-}
-
-
-
-/**
-@brief Update a connected context
-**/
-static void sUpdateContext(uSynergyContext *context)
-{
- /* Receive data (blocking) */
- int receive_size = USYNERGY_RECEIVE_BUFFER_SIZE - context->m_receiveOfs;
- int num_received = 0;
- int packlen = 0;
- if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer + context->m_receiveOfs, receive_size, &num_received) == USYNERGY_FALSE)
- {
- /* Receive failed, let's try to reconnect */
- char buffer[128];
- sprintf(buffer, "Receive failed (%d bytes asked, %d bytes received), trying to reconnect in a second", receive_size, num_received);
- sTrace(context, buffer);
- sSetDisconnected(context);
- context->m_sleepFunc(context->m_cookie, 1000);
- return;
- }
- context->m_receiveOfs += num_received;
-
- /* If we didn't receive any data then we're probably still polling to get connected and
- therefore not getting any data back. To avoid overloading the system with a Synergy
- thread that would hammer on polling, we let it rest for a bit if there's no data. */
- if (num_received == 0)
- context->m_sleepFunc(context->m_cookie, 500);
-
- /* Check for timeouts */
- if (context->m_hasReceivedHello)
- {
- uint32_t cur_time = context->m_getTimeFunc();
- if (num_received == 0)
- {
- /* Timeout after 2 secs of inactivity (we received no CALV) */
- if ((cur_time - context->m_lastMessageTime) > USYNERGY_IDLE_TIMEOUT)
- sSetDisconnected(context);
- }
- else
- context->m_lastMessageTime = cur_time;
- }
-
- /* Eat packets */
- for (;;)
- {
- /* Grab packet length and bail out if the packet goes beyond the end of the buffer */
- packlen = sNetToNative32(context->m_receiveBuffer);
- if (packlen+4 > context->m_receiveOfs)
- break;
-
- /* Process message */
- sProcessMessage(context, context->m_receiveBuffer);
-
- /* Move packet to front of buffer */
- memmove(context->m_receiveBuffer, context->m_receiveBuffer+packlen+4, context->m_receiveOfs-packlen-4);
- context->m_receiveOfs -= packlen+4;
- }
-
- /* Throw away over-sized packets */
- if (packlen > USYNERGY_RECEIVE_BUFFER_SIZE)
- {
- /* Oversized packet, ditch tail end */
- char buffer[128];
- sprintf(buffer, "Oversized packet: '%c%c%c%c' (length %d)", context->m_receiveBuffer[4], context->m_receiveBuffer[5], context->m_receiveBuffer[6], context->m_receiveBuffer[7], packlen);
- sTrace(context, buffer);
- num_received = context->m_receiveOfs-4; // 4 bytes for the size field
- while (num_received != packlen)
- {
- int buffer_left = packlen - num_received;
- int to_receive = buffer_left < USYNERGY_RECEIVE_BUFFER_SIZE ? buffer_left : USYNERGY_RECEIVE_BUFFER_SIZE;
- int ditch_received = 0;
- if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer, to_receive, &ditch_received) == USYNERGY_FALSE)
- {
- /* Receive failed, let's try to reconnect */
- sTrace(context, "Receive failed, trying to reconnect in a second");
- sSetDisconnected(context);
- context->m_sleepFunc(context->m_cookie, 1000);
- break;
- }
- else
- {
- num_received += ditch_received;
- }
- }
- context->m_receiveOfs = 0;
- }
-}
-
-
-//---------------------------------------------------------------------------------------------------------------------
-// Public interface
-//---------------------------------------------------------------------------------------------------------------------
-
-
-
-/**
-@brief Initialize uSynergy context
-**/
-void uSynergyInit(uSynergyContext *context)
-{
- /* Zero memory */
- memset(context, 0, sizeof(uSynergyContext));
-
- /* Initialize to default state */
- sSetDisconnected(context);
-}
-
-
-/**
-@brief Update uSynergy
-**/
-void uSynergyUpdate(uSynergyContext *context)
-{
- if (context->m_connected)
- {
- /* Update context, receive data, call callbacks */
- sUpdateContext(context);
- }
- else
- {
- /* Try to connect */
- if (context->m_connectFunc(context->m_cookie))
- context->m_connected = USYNERGY_TRUE;
- }
-}
-
-
-
-/**
-@brief Send clipboard data
-**/
-void uSynergySendClipboard(uSynergyContext *context, const char *text)
-{
- // Calculate maximum size that will fit in a reply packet
- uint32_t overhead_size = 4 + /* Message size */
- 4 + /* Message ID */
- 1 + /* Clipboard index */
- 4 + /* Sequence number */
- 4 + /* Rest of message size (because it's a Synergy string from here on) */
- 4 + /* Number of clipboard formats */
- 4 + /* Clipboard format */
- 4; /* Clipboard data length */
- uint32_t max_length = USYNERGY_REPLY_BUFFER_SIZE - overhead_size;
-
- // Clip text to max length
- uint32_t text_length = (uint32_t)strlen(text);
- if (text_length > max_length)
- {
- char buffer[128];
- sprintf(buffer, "Clipboard buffer too small, clipboard truncated at %d characters", max_length);
- sTrace(context, buffer);
- text_length = max_length;
- }
-
- // Assemble packet
- sAddString(context, "DCLP");
- sAddUInt8(context, 0); /* Clipboard index */
- sAddUInt32(context, context->m_sequenceNumber);
- sAddUInt32(context, 4+4+4+text_length); /* Rest of message size: numFormats, format, length, data */
- sAddUInt32(context, 1); /* Number of formats (only text for now) */
- sAddUInt32(context, USYNERGY_CLIPBOARD_FORMAT_TEXT);
- sAddUInt32(context, text_length);
- sAddString(context, text);
- sSendReply(context);
-}
+/*
+uSynergy client -- Implementation for the embedded Synergy client library
+ version 1.0.0, July 7th, 2012
+
+Copyright (c) 2012 Alex Evans
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source
+ distribution.
+*/
+#include "uSynergy.h"
+#include
+#include
+
+
+
+//---------------------------------------------------------------------------------------------------------------------
+// Internal helpers
+//---------------------------------------------------------------------------------------------------------------------
+
+
+
+/**
+@brief Read 16 bit integer in network byte order and convert to native byte order
+**/
+static int16_t sNetToNative16(const unsigned char *value)
+{
+#ifdef USYNERGY_LITTLE_ENDIAN
+ return value[1] | (value[0] << 8);
+#else
+ return value[0] | (value[1] << 8);
+#endif
+}
+
+
+
+/**
+@brief Read 32 bit integer in network byte order and convert to native byte order
+**/
+static int32_t sNetToNative32(const unsigned char *value)
+{
+#ifdef USYNERGY_LITTLE_ENDIAN
+ return value[3] | (value[2] << 8) | (value[1] << 16) | (value[0] << 24);
+#else
+ return value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
+#endif
+}
+
+
+
+/**
+@brief Trace text to client
+**/
+static void sTrace(uSynergyContext *context, const char* text)
+{
+ // Don't trace if we don't have a trace function
+ if (context->m_traceFunc != 0L)
+ context->m_traceFunc(context->m_cookie, text);
+}
+
+
+
+/**
+@brief Add string to reply packet
+**/
+static void sAddString(uSynergyContext *context, const char *string)
+{
+ size_t len = strlen(string);
+ memcpy(context->m_replyCur, string, len);
+ context->m_replyCur += len;
+}
+
+
+
+/**
+@brief Add uint8 to reply packet
+**/
+static void sAddUInt8(uSynergyContext *context, uint8_t value)
+{
+ *context->m_replyCur++ = value;
+}
+
+
+
+/**
+@brief Add uint16 to reply packet
+**/
+static void sAddUInt16(uSynergyContext *context, uint16_t value)
+{
+ uint8_t *reply = context->m_replyCur;
+ *reply++ = (uint8_t)(value >> 8);
+ *reply++ = (uint8_t)value;
+ context->m_replyCur = reply;
+}
+
+
+
+/**
+@brief Add uint32 to reply packet
+**/
+static void sAddUInt32(uSynergyContext *context, uint32_t value)
+{
+ uint8_t *reply = context->m_replyCur;
+ *reply++ = (uint8_t)(value >> 24);
+ *reply++ = (uint8_t)(value >> 16);
+ *reply++ = (uint8_t)(value >> 8);
+ *reply++ = (uint8_t)value;
+ context->m_replyCur = reply;
+}
+
+
+
+/**
+@brief Send reply packet
+**/
+static uSynergyBool sSendReply(uSynergyContext *context)
+{
+ // Set header size
+ uint8_t *reply_buf = context->m_replyBuffer;
+ uint32_t reply_len = (uint32_t)(context->m_replyCur - reply_buf); /* Total size of reply */
+ uint32_t body_len = reply_len - 4; /* Size of body */
+ uSynergyBool ret;
+ reply_buf[0] = (uint8_t)(body_len >> 24);
+ reply_buf[1] = (uint8_t)(body_len >> 16);
+ reply_buf[2] = (uint8_t)(body_len >> 8);
+ reply_buf[3] = (uint8_t)body_len;
+
+ // Send reply
+ ret = context->m_sendFunc(context->m_cookie, context->m_replyBuffer, reply_len);
+
+ // Reset reply buffer write pointer
+ context->m_replyCur = context->m_replyBuffer+4;
+ return ret;
+}
+
+
+
+/**
+@brief Call mouse callback after a mouse event
+**/
+static void sSendMouseCallback(uSynergyContext *context)
+{
+ // Skip if no callback is installed
+ if (context->m_mouseCallback == 0L)
+ return;
+
+ // Send callback
+ context->m_mouseCallback(context->m_cookie, context->m_mouseX, context->m_mouseY, context->m_mouseWheelX,
+ context->m_mouseWheelY, context->m_mouseButtonLeft, context->m_mouseButtonRight, context->m_mouseButtonMiddle);
+}
+
+
+
+/**
+@brief Send keyboard callback when a key has been pressed or released
+**/
+static void sSendKeyboardCallback(uSynergyContext *context, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat)
+{
+ // Skip if no callback is installed
+ if (context->m_keyboardCallback == 0L)
+ return;
+
+ // Send callback
+ context->m_keyboardCallback(context->m_cookie, key, modifiers, down, repeat);
+}
+
+
+
+/**
+@brief Send joystick callback
+**/
+static void sSendJoystickCallback(uSynergyContext *context, uint8_t joyNum)
+{
+ int8_t *sticks;
+
+ // Skip if no callback is installed
+ if (context->m_joystickCallback == 0L)
+ return;
+
+ // Send callback
+ sticks = context->m_joystickSticks[joyNum];
+ context->m_joystickCallback(context->m_cookie, joyNum, context->m_joystickButtons[joyNum], sticks[0], sticks[1], sticks[2], sticks[3]);
+}
+
+
+
+/**
+@brief Parse a single client message, update state, send callbacks and send replies
+**/
+#define USYNERGY_IS_PACKET(pkt_id) memcmp(message+4, pkt_id, 4)==0
+static void sProcessMessage(uSynergyContext *context, const uint8_t *message)
+{
+ // We have a packet!
+ if (memcmp(message+4, "Synergy", 7)==0)
+ {
+ // Welcome message
+ // kMsgHello = "Synergy%2i%2i"
+ // kMsgHelloBack = "Synergy%2i%2i%s"
+ sAddString(context, "Synergy");
+ sAddUInt16(context, USYNERGY_PROTOCOL_MAJOR);
+ sAddUInt16(context, USYNERGY_PROTOCOL_MINOR);
+ sAddUInt32(context, (uint32_t)strlen(context->m_clientName));
+ sAddString(context, context->m_clientName);
+ if (!sSendReply(context))
+ {
+ // Send reply failed, let's try to reconnect
+ sTrace(context, "SendReply failed, trying to reconnect in a second");
+ context->m_connected = USYNERGY_FALSE;
+ context->m_sleepFunc(context->m_cookie, 1000);
+ }
+ else
+ {
+ // Let's assume we're connected
+ char buffer[256+1];
+ sprintf(buffer, "Connected as client \"%s\"", context->m_clientName);
+ sTrace(context, buffer);
+ context->m_hasReceivedHello = USYNERGY_TRUE;
+ }
+ return;
+ }
+ else if (USYNERGY_IS_PACKET("QINF"))
+ {
+ // Screen info. Reply with DINF
+ // kMsgQInfo = "QINF"
+ // kMsgDInfo = "DINF%2i%2i%2i%2i%2i%2i%2i"
+ uint16_t x = 0, y = 0, warp = 0;
+ sAddString(context, "DINF");
+ sAddUInt16(context, x);
+ sAddUInt16(context, y);
+ sAddUInt16(context, context->m_clientWidth);
+ sAddUInt16(context, context->m_clientHeight);
+ sAddUInt16(context, warp);
+ sAddUInt16(context, 0); // mx?
+ sAddUInt16(context, 0); // my?
+ sSendReply(context);
+ return;
+ }
+ else if (USYNERGY_IS_PACKET("CIAK"))
+ {
+ // Do nothing?
+ // kMsgCInfoAck = "CIAK"
+ return;
+ }
+ else if (USYNERGY_IS_PACKET("CROP"))
+ {
+ // Do nothing?
+ // kMsgCResetOptions = "CROP"
+ return;
+ }
+ else if (USYNERGY_IS_PACKET("CINN"))
+ {
+ // Screen enter. Reply with CNOP
+ // kMsgCEnter = "CINN%2i%2i%4i%2i"
+
+ // Obtain the Synergy sequence number
+ context->m_sequenceNumber = sNetToNative32(message + 12);
+ context->m_isCaptured = USYNERGY_TRUE;
+
+ // Call callback
+ if (context->m_screenActiveCallback != 0L)
+ context->m_screenActiveCallback(context->m_cookie, USYNERGY_TRUE);
+ }
+ else if (USYNERGY_IS_PACKET("COUT"))
+ {
+ // Screen leave
+ // kMsgCLeave = "COUT"
+ context->m_isCaptured = USYNERGY_FALSE;
+
+ // Call callback
+ if (context->m_screenActiveCallback != 0L)
+ context->m_screenActiveCallback(context->m_cookie, USYNERGY_FALSE);
+ }
+ else if (USYNERGY_IS_PACKET("DMDN"))
+ {
+ // Mouse down
+ // kMsgDMouseDown = "DMDN%1i"
+ char btn = message[8]-1;
+ if (btn==2)
+ context->m_mouseButtonRight = USYNERGY_TRUE;
+ else if (btn==1)
+ context->m_mouseButtonMiddle = USYNERGY_TRUE;
+ else
+ context->m_mouseButtonLeft = USYNERGY_TRUE;
+ sSendMouseCallback(context);
+ }
+ else if (USYNERGY_IS_PACKET("DMUP"))
+ {
+ // Mouse up
+ // kMsgDMouseUp = "DMUP%1i"
+ char btn = message[8]-1;
+ if (btn==2)
+ context->m_mouseButtonRight = USYNERGY_FALSE;
+ else if (btn==1)
+ context->m_mouseButtonMiddle = USYNERGY_FALSE;
+ else
+ context->m_mouseButtonLeft = USYNERGY_FALSE;
+ sSendMouseCallback(context);
+ }
+ else if (USYNERGY_IS_PACKET("DMMV"))
+ {
+ // Mouse move. Reply with CNOP
+ // kMsgDMouseMove = "DMMV%2i%2i"
+ context->m_mouseX = sNetToNative16(message+8);
+ context->m_mouseY = sNetToNative16(message+10);
+ sSendMouseCallback(context);
+ }
+ else if (USYNERGY_IS_PACKET("DMWM"))
+ {
+ // Mouse wheel
+ // kMsgDMouseWheel = "DMWM%2i%2i"
+ // kMsgDMouseWheel1_0 = "DMWM%2i"
+ context->m_mouseWheelX += sNetToNative16(message+8);
+ context->m_mouseWheelY += sNetToNative16(message+10);
+ sSendMouseCallback(context);
+ }
+ else if (USYNERGY_IS_PACKET("DKDN"))
+ {
+ // Key down
+ // kMsgDKeyDown = "DKDN%2i%2i%2i"
+ // kMsgDKeyDown1_0 = "DKDN%2i%2i"
+ //uint16_t id = sNetToNative16(message+8);
+ uint16_t mod = sNetToNative16(message+10);
+ uint16_t key = sNetToNative16(message+12);
+ sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_FALSE);
+ }
+ else if (USYNERGY_IS_PACKET("DKRP"))
+ {
+ // Key repeat
+ // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i"
+ // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i"
+ uint16_t mod = sNetToNative16(message+10);
+// uint16_t count = sNetToNative16(message+12);
+ uint16_t key = sNetToNative16(message+14);
+ sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_TRUE);
+ }
+ else if (USYNERGY_IS_PACKET("DKUP"))
+ {
+ // Key up
+ // kMsgDKeyUp = "DKUP%2i%2i%2i"
+ // kMsgDKeyUp1_0 = "DKUP%2i%2i"
+ //uint16 id=Endian::sNetToNative(sbuf[4]);
+ uint16_t mod = sNetToNative16(message+10);
+ uint16_t key = sNetToNative16(message+12);
+ sSendKeyboardCallback(context, key, mod, USYNERGY_FALSE, USYNERGY_FALSE);
+ }
+ else if (USYNERGY_IS_PACKET("DGBT"))
+ {
+ // Joystick buttons
+ // kMsgDGameButtons = "DGBT%1i%2i";
+ uint8_t joy_num = message[8];
+ if (joy_numm_joystickButtons[joy_num] = (message[9] << 8) | message[10];
+ sSendJoystickCallback(context, joy_num);
+ }
+ }
+ else if (USYNERGY_IS_PACKET("DGST"))
+ {
+ // Joystick sticks
+ // kMsgDGameSticks = "DGST%1i%1i%1i%1i%1i";
+ uint8_t joy_num = message[8];
+ if (joy_numm_joystickSticks[joy_num], message+9, 4);
+ sSendJoystickCallback(context, joy_num);
+ }
+ }
+ else if (USYNERGY_IS_PACKET("DSOP"))
+ {
+ // Set options
+ // kMsgDSetOptions = "DSOP%4I"
+ }
+ else if (USYNERGY_IS_PACKET("CALV"))
+ {
+ // Keepalive, reply with CALV and then CNOP
+ // kMsgCKeepAlive = "CALV"
+ sAddString(context, "CALV");
+ sSendReply(context);
+ // now reply with CNOP
+ }
+ else if (USYNERGY_IS_PACKET("DCLP"))
+ {
+ // Clipboard message
+ // kMsgDClipboard = "DCLP%1i%4i%s"
+ //
+ // The clipboard message contains:
+ // 1 uint32: The size of the message
+ // 4 chars: The identifier ("DCLP")
+ // 1 uint8: The clipboard index
+ // 1 uint32: The sequence number. It's zero, because this message is always coming from the server?
+ // 1 uint32: The total size of the remaining 'string' (as per the Synergy %s string format (which is 1 uint32 for size followed by a char buffer (not necessarily null terminated)).
+ // 1 uint32: The number of formats present in the message
+ // And then 'number of formats' times the following:
+ // 1 uint32: The format of the clipboard data
+ // 1 uint32: The size n of the clipboard data
+ // n uint8: The clipboard data
+ const uint8_t * parse_msg = message+17;
+ uint32_t num_formats = sNetToNative32(parse_msg);
+ parse_msg += 4;
+ for (; num_formats; num_formats--)
+ {
+ // Parse clipboard format header
+ uint32_t format = sNetToNative32(parse_msg);
+ uint32_t size = sNetToNative32(parse_msg+4);
+ parse_msg += 8;
+
+ // Call callback
+ if (context->m_clipboardCallback)
+ context->m_clipboardCallback(context->m_cookie, format, parse_msg, size);
+
+ parse_msg += size;
+ }
+ }
+ else
+ {
+ // Unknown packet, could be any of these
+ // kMsgCNoop = "CNOP"
+ // kMsgCClose = "CBYE"
+ // kMsgCClipboard = "CCLP%1i%4i"
+ // kMsgCScreenSaver = "CSEC%1i"
+ // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i"
+ // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i"
+ // kMsgDMouseRelMove = "DMRM%2i%2i"
+ // kMsgEIncompatible = "EICV%2i%2i"
+ // kMsgEBusy = "EBSY"
+ // kMsgEUnknown = "EUNK"
+ // kMsgEBad = "EBAD"
+ char buffer[64];
+ sprintf(buffer, "Unknown packet '%c%c%c%c'", message[4], message[5], message[6], message[7]);
+ sTrace(context, buffer);
+ return;
+ }
+
+ // Reply with CNOP maybe?
+ sAddString(context, "CNOP");
+ sSendReply(context);
+}
+#undef USYNERGY_IS_PACKET
+
+
+
+/**
+@brief Mark context as being disconnected
+**/
+static void sSetDisconnected(uSynergyContext *context)
+{
+ context->m_connected = USYNERGY_FALSE;
+ context->m_hasReceivedHello = USYNERGY_FALSE;
+ context->m_isCaptured = USYNERGY_FALSE;
+ context->m_replyCur = context->m_replyBuffer + 4;
+ context->m_sequenceNumber = 0;
+}
+
+
+
+/**
+@brief Update a connected context
+**/
+static void sUpdateContext(uSynergyContext *context)
+{
+ /* Receive data (blocking) */
+ int receive_size = USYNERGY_RECEIVE_BUFFER_SIZE - context->m_receiveOfs;
+ int num_received = 0;
+ int packlen = 0;
+ if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer + context->m_receiveOfs, receive_size, &num_received) == USYNERGY_FALSE)
+ {
+ /* Receive failed, let's try to reconnect */
+ char buffer[128];
+ sprintf(buffer, "Receive failed (%d bytes asked, %d bytes received), trying to reconnect in a second", receive_size, num_received);
+ sTrace(context, buffer);
+ sSetDisconnected(context);
+ context->m_sleepFunc(context->m_cookie, 1000);
+ return;
+ }
+ context->m_receiveOfs += num_received;
+
+ /* If we didn't receive any data then we're probably still polling to get connected and
+ therefore not getting any data back. To avoid overloading the system with a Synergy
+ thread that would hammer on polling, we let it rest for a bit if there's no data. */
+ if (num_received == 0)
+ context->m_sleepFunc(context->m_cookie, 500);
+
+ /* Check for timeouts */
+ if (context->m_hasReceivedHello)
+ {
+ uint32_t cur_time = context->m_getTimeFunc();
+ if (num_received == 0)
+ {
+ /* Timeout after 2 secs of inactivity (we received no CALV) */
+ if ((cur_time - context->m_lastMessageTime) > USYNERGY_IDLE_TIMEOUT)
+ sSetDisconnected(context);
+ }
+ else
+ context->m_lastMessageTime = cur_time;
+ }
+
+ /* Eat packets */
+ for (;;)
+ {
+ /* Grab packet length and bail out if the packet goes beyond the end of the buffer */
+ packlen = sNetToNative32(context->m_receiveBuffer);
+ if (packlen+4 > context->m_receiveOfs)
+ break;
+
+ /* Process message */
+ sProcessMessage(context, context->m_receiveBuffer);
+
+ /* Move packet to front of buffer */
+ memmove(context->m_receiveBuffer, context->m_receiveBuffer+packlen+4, context->m_receiveOfs-packlen-4);
+ context->m_receiveOfs -= packlen+4;
+ }
+
+ /* Throw away over-sized packets */
+ if (packlen > USYNERGY_RECEIVE_BUFFER_SIZE)
+ {
+ /* Oversized packet, ditch tail end */
+ char buffer[128];
+ sprintf(buffer, "Oversized packet: '%c%c%c%c' (length %d)", context->m_receiveBuffer[4], context->m_receiveBuffer[5], context->m_receiveBuffer[6], context->m_receiveBuffer[7], packlen);
+ sTrace(context, buffer);
+ num_received = context->m_receiveOfs-4; // 4 bytes for the size field
+ while (num_received != packlen)
+ {
+ int buffer_left = packlen - num_received;
+ int to_receive = buffer_left < USYNERGY_RECEIVE_BUFFER_SIZE ? buffer_left : USYNERGY_RECEIVE_BUFFER_SIZE;
+ int ditch_received = 0;
+ if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer, to_receive, &ditch_received) == USYNERGY_FALSE)
+ {
+ /* Receive failed, let's try to reconnect */
+ sTrace(context, "Receive failed, trying to reconnect in a second");
+ sSetDisconnected(context);
+ context->m_sleepFunc(context->m_cookie, 1000);
+ break;
+ }
+ else
+ {
+ num_received += ditch_received;
+ }
+ }
+ context->m_receiveOfs = 0;
+ }
+}
+
+
+//---------------------------------------------------------------------------------------------------------------------
+// Public interface
+//---------------------------------------------------------------------------------------------------------------------
+
+
+
+/**
+@brief Initialize uSynergy context
+**/
+void uSynergyInit(uSynergyContext *context)
+{
+ /* Zero memory */
+ memset(context, 0, sizeof(uSynergyContext));
+
+ /* Initialize to default state */
+ sSetDisconnected(context);
+}
+
+
+/**
+@brief Update uSynergy
+**/
+void uSynergyUpdate(uSynergyContext *context)
+{
+ if (context->m_connected)
+ {
+ /* Update context, receive data, call callbacks */
+ sUpdateContext(context);
+ }
+ else
+ {
+ /* Try to connect */
+ if (context->m_connectFunc(context->m_cookie))
+ context->m_connected = USYNERGY_TRUE;
+ }
+}
+
+
+
+/**
+@brief Send clipboard data
+**/
+void uSynergySendClipboard(uSynergyContext *context, const char *text)
+{
+ // Calculate maximum size that will fit in a reply packet
+ uint32_t overhead_size = 4 + /* Message size */
+ 4 + /* Message ID */
+ 1 + /* Clipboard index */
+ 4 + /* Sequence number */
+ 4 + /* Rest of message size (because it's a Synergy string from here on) */
+ 4 + /* Number of clipboard formats */
+ 4 + /* Clipboard format */
+ 4; /* Clipboard data length */
+ uint32_t max_length = USYNERGY_REPLY_BUFFER_SIZE - overhead_size;
+
+ // Clip text to max length
+ uint32_t text_length = (uint32_t)strlen(text);
+ if (text_length > max_length)
+ {
+ char buffer[128];
+ sprintf(buffer, "Clipboard buffer too small, clipboard truncated at %d characters", max_length);
+ sTrace(context, buffer);
+ text_length = max_length;
+ }
+
+ // Assemble packet
+ sAddString(context, "DCLP");
+ sAddUInt8(context, 0); /* Clipboard index */
+ sAddUInt32(context, context->m_sequenceNumber);
+ sAddUInt32(context, 4+4+4+text_length); /* Rest of message size: numFormats, format, length, data */
+ sAddUInt32(context, 1); /* Number of formats (only text for now) */
+ sAddUInt32(context, USYNERGY_CLIPBOARD_FORMAT_TEXT);
+ sAddUInt32(context, text_length);
+ sAddString(context, text);
+ sSendReply(context);
+}
diff --git a/third_party/imgui/examples/marmalade_example/imgui_impl_marmalade.h b/third_party/imgui/examples/marmalade_example/imgui_impl_marmalade.h
deleted file mode 100644
index c41a5e8f26..0000000000
--- a/third_party/imgui/examples/marmalade_example/imgui_impl_marmalade.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// ImGui Marmalade binding with IwGx
-
-// Implemented features:
-// [X] User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-// Copyright (C) 2015 by Giovanni Zito
-// This file is part of ImGui
-
-IMGUI_API bool ImGui_Marmalade_Init(bool install_callbacks);
-IMGUI_API void ImGui_Marmalade_Shutdown();
-IMGUI_API void ImGui_Marmalade_NewFrame();
-IMGUI_API void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_Marmalade_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_Marmalade_CreateDeviceObjects();
-
-// callbacks (installed by default if you enable 'install_callbacks' during initialization)
-// You can also handle inputs yourself and use those as a reference.
-IMGUI_API int32 ImGui_Marmalade_PointerButtonEventCallback(void* SystemData, void* pUserData);
-IMGUI_API int32 ImGui_Marmalade_KeyCallback(void* SystemData, void* userData);
-IMGUI_API int32 ImGui_Marmalade_CharCallback(void* SystemData, void* userData);
diff --git a/third_party/imgui/examples/opengl2_example/Makefile b/third_party/imgui/examples/opengl2_example/Makefile
deleted file mode 100644
index b0ee3152de..0000000000
--- a/third_party/imgui/examples/opengl2_example/Makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
-#
-# You will need GLFW (http://www.glfw.org):
-# Linux:
-# apt-get install libglfw-dev
-# Mac OS X:
-# brew install glfw
-# MSYS2:
-# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw
-#
-
-#CXX = g++
-#CXX = clang++
-
-EXE = opengl2_example
-OBJS = main.o imgui_impl_glfw_gl2.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- #LIBS += -L/usr/local/lib -lglfw3
- LIBS += -L/usr/local/lib -lglfw
-
- CXXFLAGS = -I../../ -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
-
diff --git a/third_party/imgui/examples/opengl2_example/build_win32.bat b/third_party/imgui/examples/opengl2_example/build_win32.bat
deleted file mode 100644
index 28e6752fd1..0000000000
--- a/third_party/imgui/examples/opengl2_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\*.cpp /FeDebug/opengl2_example.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/third_party/imgui/examples/opengl2_example/imgui_impl_glfw_gl2.cpp b/third_party/imgui/examples/opengl2_example/imgui_impl_glfw_gl2.cpp
deleted file mode 100644
index f78b77be8e..0000000000
--- a/third_party/imgui/examples/opengl2_example/imgui_impl_glfw_gl2.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-// ImGui GLFW binding with OpenGL (legacy, fixed pipeline)
-// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-
-// Implemented features:
-// [X] User texture binding. Cast 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
-// **Prefer using the code in the opengl3_example/ folder**
-// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
-// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
-// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
-// confuse your GPU driver.
-// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-// CHANGELOG
-// (minor and older changes stripped away, please see git history for details)
-// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
-// 2018-02-20: Inputs: Renamed GLFW callbacks exposed in .h to not include GL2 in their name.
-// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplGlfwGL2_RenderDrawData() in the .h file so you can call it yourself.
-// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-// 2018-01-25: Inputs: Honoring the io.WantMoveMouse by repositioning the mouse by using navigation and ImGuiNavFlags_MoveMouse is set.
-// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
-// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
-// 2018-01-09: Misc: Renamed imgui_impl_glfw.* to imgui_impl_glfw_gl2.*.
-// 2017-09-01: OpenGL: Save and restore current polygon mode.
-// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
-// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
-// 2016-09-10: OpenGL: Uploading font texture as RGBA32 to increase compatibility with users shaders (not ideal).
-// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
-
-#include "imgui.h"
-#include "imgui_impl_glfw_gl2.h"
-
-// GLFW
-#include
-#ifdef _WIN32
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include
-#endif
-
-// GLFW data
-static GLFWwindow* g_Window = NULL;
-static double g_Time = 0.0f;
-static bool g_MouseJustPressed[3] = { false, false, false };
-static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
-
-// OpenGL data
-static GLuint g_FontTexture = 0;
-
-// OpenGL2 Render function.
-// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
-// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
-void ImGui_ImplGlfwGL2_RenderDrawData(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // We are using the OpenGL fixed pipeline to make the example code simpler to read!
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glEnable(GL_TEXTURE_2D);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Render command lists
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
- const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
- glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos)));
- glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv)));
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col)));
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
- }
- idx_buffer += pcmd->ElemCount;
- }
- }
-
- // Restore modified state
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glPopAttrib();
- glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
- glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
-}
-
-static const char* ImGui_ImplGlfwGL2_GetClipboardText(void* user_data)
-{
- return glfwGetClipboardString((GLFWwindow*)user_data);
-}
-
-static void ImGui_ImplGlfwGL2_SetClipboardText(void* user_data, const char* text)
-{
- glfwSetClipboardString((GLFWwindow*)user_data, text);
-}
-
-void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
- if (action == GLFW_PRESS && button >= 0 && button < 3)
- g_MouseJustPressed[button] = true;
-}
-
-void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double xoffset, double yoffset)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MouseWheelH += (float)xoffset;
- io.MouseWheel += (float)yoffset;
-}
-
-void ImGui_ImplGlfw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (action == GLFW_PRESS)
- io.KeysDown[key] = true;
- if (action == GLFW_RELEASE)
- io.KeysDown[key] = false;
-
- (void)mods; // Modifiers are not reliable across systems
- io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
- io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
- io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
- io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
-}
-
-void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (c > 0 && c < 0x10000)
- io.AddInputCharacter((unsigned short)c);
-}
-
-bool ImGui_ImplGlfwGL2_CreateDeviceObjects()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-
- return true;
-}
-
-void ImGui_ImplGlfwGL2_InvalidateDeviceObjects()
-{
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-static void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
-{
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
-}
-
-bool ImGui_ImplGlfwGL2_Init(GLFWwindow* window, bool install_callbacks)
-{
- g_Window = window;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
- io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
- io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
- io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
- io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
- io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
- io.SetClipboardTextFn = ImGui_ImplGlfwGL2_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplGlfwGL2_GetClipboardText;
- io.ClipboardUserData = g_Window;
-#ifdef _WIN32
- io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
- // Load cursors
- // FIXME: GLFW doesn't expose suitable cursors for ResizeAll, ResizeNESW, ResizeNWSE. We revert to arrow cursor for those.
- g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
-
- if (install_callbacks)
- ImGui_ImplGlfw_InstallCallbacks(window);
-
- return true;
-}
-
-void ImGui_ImplGlfwGL2_Shutdown()
-{
- // Destroy GLFW mouse cursors
- for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
- glfwDestroyCursor(g_MouseCursors[cursor_n]);
- memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
-
- // Destroy OpenGL objects
- ImGui_ImplGlfwGL2_InvalidateDeviceObjects();
-}
-
-void ImGui_ImplGlfwGL2_NewFrame()
-{
- if (!g_FontTexture)
- ImGui_ImplGlfwGL2_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- glfwGetWindowSize(g_Window, &w, &h);
- glfwGetFramebufferSize(g_Window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step
- double current_time = glfwGetTime();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
- if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
- {
- if (io.WantMoveMouse)
- {
- glfwSetCursorPos(g_Window, (double)io.MousePos.x, (double)io.MousePos.y); // Set mouse position if requested by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
- }
- else
- {
- double mouse_x, mouse_y;
- glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
- io.MousePos = ImVec2((float)mouse_x, (float)mouse_y);
- }
- }
- else
- {
- io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
- }
-
- for (int i = 0; i < 3; i++)
- {
- // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0;
- g_MouseJustPressed[i] = false;
- }
-
- // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
- ImGuiMouseCursor cursor = ImGui::GetMouseCursor();
- if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None)
- {
- glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
- }
- else
- {
- glfwSetCursor(g_Window, g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
- glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
-}
diff --git a/third_party/imgui/examples/opengl2_example/imgui_impl_glfw_gl2.h b/third_party/imgui/examples/opengl2_example/imgui_impl_glfw_gl2.h
deleted file mode 100644
index 4e0f393ccc..0000000000
--- a/third_party/imgui/examples/opengl2_example/imgui_impl_glfw_gl2.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// ImGui GLFW binding with OpenGL (legacy, fixed pipeline)
-// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-
-// Implemented features:
-// [X] User texture binding. Cast 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
-// **Prefer using the code in the opengl3_example/ folder**
-// See imgui_impl_glfw.cpp for details.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct GLFWwindow;
-
-IMGUI_API bool ImGui_ImplGlfwGL2_Init(GLFWwindow* window, bool install_callbacks);
-IMGUI_API void ImGui_ImplGlfwGL2_Shutdown();
-IMGUI_API void ImGui_ImplGlfwGL2_NewFrame();
-IMGUI_API void ImGui_ImplGlfwGL2_RenderDrawData(ImDrawData* draw_data);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplGlfwGL2_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplGlfwGL2_CreateDeviceObjects();
-
-// GLFW callbacks (registered by default to GLFW if you enable 'install_callbacks' during initialization)
-// Provided here if you want to chain callbacks yourself. You may also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/third_party/imgui/examples/opengl3_example/Makefile b/third_party/imgui/examples/opengl3_example/Makefile
deleted file mode 100644
index 133c0a64e0..0000000000
--- a/third_party/imgui/examples/opengl3_example/Makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
-#
-# You will need GLFW (http://www.glfw.org):
-# Linux:
-# apt-get install libglfw-dev
-# Mac OS X:
-# brew install glfw
-# MSYS2:
-# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw
-#
-
-#CXX = g++
-#CXX = clang++
-
-EXE = opengl3_example
-OBJS = main.o imgui_impl_glfw_gl3.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-OBJS += ../libs/gl3w/GL/gl3w.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL `pkg-config --static --libs glfw3`
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
- #LIBS += -L/usr/local/lib -lglfw3
- LIBS += -L/usr/local/lib -lglfw
-
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
- ECHO_MESSAGE = "Windows"
- LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
diff --git a/third_party/imgui/examples/opengl3_example/build_win32.bat b/third_party/imgui/examples/opengl3_example/build_win32.bat
deleted file mode 100644
index 9311591855..0000000000
--- a/third_party/imgui/examples/opengl3_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include /I ..\libs\gl3w *.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/opengl_example3.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
diff --git a/third_party/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/third_party/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
deleted file mode 100644
index ce8030b17f..0000000000
--- a/third_party/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ /dev/null
@@ -1,502 +0,0 @@
-// ImGui GLFW binding with OpenGL3 + shaders
-// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
-
-// Implemented features:
-// [X] User texture binding. Cast 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-// [X] Gamepad navigation mapping. Enable with 'io.NavFlags |= ImGuiNavFlags_EnableGamepad'.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-// CHANGELOG
-// (minor and older changes stripped away, please see git history for details)
-// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
-// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
-// 2018-02-20: Inputs: Renamed GLFW callbacks exposed in .h to not include GL3 in their name.
-// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplGlfwGL3_RenderDrawData() in the .h file so you can call it yourself.
-// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-// 2018-01-25: Inputs: Added gamepad support if ImGuiNavFlags_EnableGamepad is set.
-// 2018-01-25: Inputs: Honoring the io.WantMoveMouse by repositioning the mouse by using navigation and ImGuiNavFlags_MoveMouse is set.
-// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
-// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
-// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150. (Also changed GL context from 3.3 to 3.2 in example's main.cpp)
-// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
-// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
-// 2017-05-01: OpenGL: Fixed save and restore of current blend function state.
-// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
-// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
-// 2016-04-30: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE.
-
-#include "imgui.h"
-#include "imgui_impl_glfw_gl3.h"
-
-// GL3W/GLFW
-#include // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you.
-#include
-#ifdef _WIN32
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include
-#endif
-
-// GLFW data
-static GLFWwindow* g_Window = NULL;
-static double g_Time = 0.0f;
-static bool g_MouseJustPressed[3] = { false, false, false };
-static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
-
-// OpenGL3 data
-static GLuint g_FontTexture = 0;
-static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
-static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0;
-static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0;
-static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
-
-// OpenGL3 Render function.
-// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
-// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
-void ImGui_ImplGlfwGL3_RenderDrawData(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // Backup GL state
- GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
- glActiveTexture(GL_TEXTURE0);
- GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
- GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
- GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
- GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
- GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
- GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
- GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
- GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
- GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
- GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
- GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
- GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
- GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
- GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
- GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
-
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
- glEnable(GL_BLEND);
- glBlendEquation(GL_FUNC_ADD);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- const float ortho_projection[4][4] =
- {
- { 2.0f/io.DisplaySize.x, 0.0f, 0.0f, 0.0f },
- { 0.0f, 2.0f/-io.DisplaySize.y, 0.0f, 0.0f },
- { 0.0f, 0.0f, -1.0f, 0.0f },
- {-1.0f, 1.0f, 0.0f, 1.0f },
- };
- glUseProgram(g_ShaderHandle);
- glUniform1i(g_AttribLocationTex, 0);
- glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
- glBindSampler(0, 0); // Rely on combined texture/sampler state.
-
- // Recreate the VAO every time
- // (This is to easily allow multiple GL contexts. VAO are not shared among GL contexts, and we don't track creation/deletion of windows so we don't have an obvious key to use to cache them.)
- GLuint vao_handle = 0;
- glGenVertexArrays(1, &vao_handle);
- glBindVertexArray(vao_handle);
- glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glEnableVertexAttribArray(g_AttribLocationPosition);
- glEnableVertexAttribArray(g_AttribLocationUV);
- glEnableVertexAttribArray(g_AttribLocationColor);
- glVertexAttribPointer(g_AttribLocationPosition, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
- glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
- glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
-
- // Draw
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawIdx* idx_buffer_offset = 0;
-
- glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
- }
- idx_buffer_offset += pcmd->ElemCount;
- }
- }
- glDeleteVertexArrays(1, &vao_handle);
-
- // Restore modified GL state
- glUseProgram(last_program);
- glBindTexture(GL_TEXTURE_2D, last_texture);
- glBindSampler(0, last_sampler);
- glActiveTexture(last_active_texture);
- glBindVertexArray(last_vertex_array);
- glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, last_element_array_buffer);
- glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
- glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
- if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
- if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
- if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
- if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
- glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
- glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
-}
-
-static const char* ImGui_ImplGlfwGL3_GetClipboardText(void* user_data)
-{
- return glfwGetClipboardString((GLFWwindow*)user_data);
-}
-
-static void ImGui_ImplGlfwGL3_SetClipboardText(void* user_data, const char* text)
-{
- glfwSetClipboardString((GLFWwindow*)user_data, text);
-}
-
-void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
- if (action == GLFW_PRESS && button >= 0 && button < 3)
- g_MouseJustPressed[button] = true;
-}
-
-void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double xoffset, double yoffset)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MouseWheelH += (float)xoffset;
- io.MouseWheel += (float)yoffset;
-}
-
-void ImGui_ImplGlfw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (action == GLFW_PRESS)
- io.KeysDown[key] = true;
- if (action == GLFW_RELEASE)
- io.KeysDown[key] = false;
-
- (void)mods; // Modifiers are not reliable across systems
- io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
- io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
- io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
- io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
-}
-
-void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (c > 0 && c < 0x10000)
- io.AddInputCharacter((unsigned short)c);
-}
-
-bool ImGui_ImplGlfwGL3_CreateFontsTexture()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-
- return true;
-}
-
-bool ImGui_ImplGlfwGL3_CreateDeviceObjects()
-{
- // Backup GL state
- GLint last_texture, last_array_buffer, last_vertex_array;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
- glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
-
- const GLchar *vertex_shader =
- "#version 150\n"
- "uniform mat4 ProjMtx;\n"
- "in vec2 Position;\n"
- "in vec2 UV;\n"
- "in vec4 Color;\n"
- "out vec2 Frag_UV;\n"
- "out vec4 Frag_Color;\n"
- "void main()\n"
- "{\n"
- " Frag_UV = UV;\n"
- " Frag_Color = Color;\n"
- " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
- "}\n";
-
- const GLchar* fragment_shader =
- "#version 150\n"
- "uniform sampler2D Texture;\n"
- "in vec2 Frag_UV;\n"
- "in vec4 Frag_Color;\n"
- "out vec4 Out_Color;\n"
- "void main()\n"
- "{\n"
- " Out_Color = Frag_Color * texture( Texture, Frag_UV.st);\n"
- "}\n";
-
- g_ShaderHandle = glCreateProgram();
- g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
- g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
- glShaderSource(g_VertHandle, 1, &vertex_shader, 0);
- glShaderSource(g_FragHandle, 1, &fragment_shader, 0);
- glCompileShader(g_VertHandle);
- glCompileShader(g_FragHandle);
- glAttachShader(g_ShaderHandle, g_VertHandle);
- glAttachShader(g_ShaderHandle, g_FragHandle);
- glLinkProgram(g_ShaderHandle);
-
- g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
- g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
- g_AttribLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position");
- g_AttribLocationUV = glGetAttribLocation(g_ShaderHandle, "UV");
- g_AttribLocationColor = glGetAttribLocation(g_ShaderHandle, "Color");
-
- glGenBuffers(1, &g_VboHandle);
- glGenBuffers(1, &g_ElementsHandle);
-
- ImGui_ImplGlfwGL3_CreateFontsTexture();
-
- // Restore modified GL state
- glBindTexture(GL_TEXTURE_2D, last_texture);
- glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
- glBindVertexArray(last_vertex_array);
-
- return true;
-}
-
-void ImGui_ImplGlfwGL3_InvalidateDeviceObjects()
-{
- if (g_VboHandle) glDeleteBuffers(1, &g_VboHandle);
- if (g_ElementsHandle) glDeleteBuffers(1, &g_ElementsHandle);
- g_VboHandle = g_ElementsHandle = 0;
-
- if (g_ShaderHandle && g_VertHandle) glDetachShader(g_ShaderHandle, g_VertHandle);
- if (g_VertHandle) glDeleteShader(g_VertHandle);
- g_VertHandle = 0;
-
- if (g_ShaderHandle && g_FragHandle) glDetachShader(g_ShaderHandle, g_FragHandle);
- if (g_FragHandle) glDeleteShader(g_FragHandle);
- g_FragHandle = 0;
-
- if (g_ShaderHandle) glDeleteProgram(g_ShaderHandle);
- g_ShaderHandle = 0;
-
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-static void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
-{
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
-}
-
-bool ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks)
-{
- g_Window = window;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
- io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
- io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
- io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
- io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
- io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
- io.SetClipboardTextFn = ImGui_ImplGlfwGL3_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplGlfwGL3_GetClipboardText;
- io.ClipboardUserData = g_Window;
-#ifdef _WIN32
- io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
- // Load cursors
- // FIXME: GLFW doesn't expose suitable cursors for ResizeAll, ResizeNESW, ResizeNWSE. We revert to arrow cursor for those.
- g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
-
- if (install_callbacks)
- ImGui_ImplGlfw_InstallCallbacks(window);
-
- return true;
-}
-
-void ImGui_ImplGlfwGL3_Shutdown()
-{
- // Destroy GLFW mouse cursors
- for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
- glfwDestroyCursor(g_MouseCursors[cursor_n]);
- memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
-
- // Destroy OpenGL objects
- ImGui_ImplGlfwGL3_InvalidateDeviceObjects();
-}
-
-void ImGui_ImplGlfwGL3_NewFrame()
-{
- if (!g_FontTexture)
- ImGui_ImplGlfwGL3_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- glfwGetWindowSize(g_Window, &w, &h);
- glfwGetFramebufferSize(g_Window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step
- double current_time = glfwGetTime();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
- if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
- {
- if (io.WantMoveMouse)
- {
- glfwSetCursorPos(g_Window, (double)io.MousePos.x, (double)io.MousePos.y); // Set mouse position if requested by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
- }
- else
- {
- double mouse_x, mouse_y;
- glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
- io.MousePos = ImVec2((float)mouse_x, (float)mouse_y);
- }
- }
- else
- {
- io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
- }
-
- for (int i = 0; i < 3; i++)
- {
- // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0;
- g_MouseJustPressed[i] = false;
- }
-
- // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
- ImGuiMouseCursor cursor = ImGui::GetMouseCursor();
- if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None)
- {
- glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
- }
- else
- {
- glfwSetCursor(g_Window, g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
- glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
- }
-
- // Gamepad navigation mapping [BETA]
- memset(io.NavInputs, 0, sizeof(io.NavInputs));
- if (io.NavFlags & ImGuiNavFlags_EnableGamepad)
- {
- // Update gamepad inputs
- #define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; }
- #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; }
- int axes_count = 0, buttons_count = 0;
- const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count);
- const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count);
- MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A
- MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B
- MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X
- MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y
- MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left
- MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right
- MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up
- MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down
- MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB
- MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB
- MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB
- MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB
- MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f);
- MAP_ANALOG(ImGuiNavInput_LStickRight,0, +0.3f, +0.9f);
- MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f);
- MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f);
- #undef MAP_BUTTON
- #undef MAP_ANALOG
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
-}
diff --git a/third_party/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.h b/third_party/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.h
deleted file mode 100644
index 71ea4122c8..0000000000
--- a/third_party/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// ImGui GLFW binding with OpenGL3 + shaders
-// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
-
-// Implemented features:
-// [X] User texture binding. Cast 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-// [X] Gamepad navigation mapping. Enable with 'io.NavFlags |= ImGuiNavFlags_EnableGamepad'.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct GLFWwindow;
-
-IMGUI_API bool ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks);
-IMGUI_API void ImGui_ImplGlfwGL3_Shutdown();
-IMGUI_API void ImGui_ImplGlfwGL3_NewFrame();
-IMGUI_API void ImGui_ImplGlfwGL3_RenderDrawData(ImDrawData* draw_data);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplGlfwGL3_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplGlfwGL3_CreateDeviceObjects();
-
-// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
-// Provided here if you want to chain callbacks.
-// You can also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/third_party/imgui/examples/opengl3_example/main.cpp b/third_party/imgui/examples/opengl3_example/main.cpp
deleted file mode 100644
index a5f59e8aaf..0000000000
--- a/third_party/imgui/examples/opengl3_example/main.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-// ImGui - standalone example application for GLFW + OpenGL 3, using programmable pipeline
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
-
-#include "imgui.h"
-#include "imgui_impl_glfw_gl3.h"
-#include
-#include // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you.
-#include
-
-static void error_callback(int error, const char* description)
-{
- fprintf(stderr, "Error %d: %s\n", error, description);
-}
-
-int main(int, char**)
-{
- // Setup window
- glfwSetErrorCallback(error_callback);
- if (!glfwInit())
- return 1;
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
-#if __APPLE__
- glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
-#endif
- GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL3 example", NULL, NULL);
- glfwMakeContextCurrent(window);
- glfwSwapInterval(1); // Enable vsync
- gl3wInit();
-
- // Setup ImGui binding
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_ImplGlfwGL3_Init(window, true);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
- //io.NavFlags |= ImGuiNavFlags_EnableGamepad; // Enable Gamepad Controls
-
- // Setup style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // 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);
-
- bool show_demo_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
- // Main loop
- while (!glfwWindowShouldClose(window))
- {
- // 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.
- glfwPollEvents();
- ImGui_ImplGlfwGL3_NewFrame();
-
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
- {
- static float f = 0.0f;
- static int counter = 0;
- ImGui::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
-
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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);
- }
-
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
- // Rendering
- int display_w, display_h;
- glfwGetFramebufferSize(window, &display_w, &display_h);
- glViewport(0, 0, display_w, display_h);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- ImGui::Render();
- ImGui_ImplGlfwGL3_RenderDrawData(ImGui::GetDrawData());
- glfwSwapBuffers(window);
- }
-
- // Cleanup
- ImGui_ImplGlfwGL3_Shutdown();
- ImGui::DestroyContext();
- glfwTerminate();
-
- return 0;
-}
diff --git a/third_party/imgui/examples/sdl_opengl2_example/README.md b/third_party/imgui/examples/sdl_opengl2_example/README.md
deleted file mode 100644
index a1a44a5845..0000000000
--- a/third_party/imgui/examples/sdl_opengl2_example/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-# How to Build
-
-- On Windows with Visual Studio's CLI
-
-```
-set SDL2DIR=path_to_your_sdl2_folder
-cl /Zi /MD /I %SDL2DIR%\include /I ..\.. main.cpp imgui_impl_sdl_gl2.cpp ..\..\imgui*.cpp /link /LIBPATH:%SDL2DIR%\lib SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
-```
-
-- On Linux and similar Unixes
-
-```
-c++ `sdl2-config --cflags` -I ../.. main.cpp imgui_impl_sdl_gl2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL -o sdl2example
-```
-
-- On Mac OS X
-
-```
-brew install sdl2
-c++ `sdl2-config --cflags` -I ../.. main.cpp imgui_impl_sdl_gl2.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl -o sdl2example
-```
diff --git a/third_party/imgui/examples/sdl_opengl2_example/build_win32.bat b/third_party/imgui/examples/sdl_opengl2_example/build_win32.bat
deleted file mode 100644
index 6fe8cb9a7f..0000000000
--- a/third_party/imgui/examples/sdl_opengl2_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\gl3w /I %SDL2_DIR%\include main.cpp imgui_impl_sdl_gl2.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/sdl_opengl2_example.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
diff --git a/third_party/imgui/examples/sdl_opengl2_example/imgui_impl_sdl_gl2.cpp b/third_party/imgui/examples/sdl_opengl2_example/imgui_impl_sdl_gl2.cpp
deleted file mode 100644
index c7eeaa912b..0000000000
--- a/third_party/imgui/examples/sdl_opengl2_example/imgui_impl_sdl_gl2.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-// ImGui SDL2 binding with OpenGL (legacy, fixed pipeline)
-// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-
-// Implemented features:
-// [X] User texture binding. Cast 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
-// **Prefer using the code in the sdl_opengl3_example/ folder**
-// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
-// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
-// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
-// confuse your GPU driver.
-// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-// CHANGELOG
-// (minor and older changes stripped away, please see git history for details)
-// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
-// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL2_RenderDrawData() in the .h file so you can call it yourself.
-// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
-// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
-// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
-// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
-// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
-// 2017-09-01: OpenGL: Save and restore current polygon mode.
-// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
-// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
-// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
-// 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
-
-#include
-#include
-#include
-#include "imgui.h"
-#include "imgui_impl_sdl_gl2.h"
-
-// Data
-static Uint64 g_Time = 0;
-static bool g_MousePressed[3] = { false, false, false };
-static GLuint g_FontTexture = 0;
-static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
-
-// OpenGL2 Render function.
-// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
-// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
-void ImGui_ImplSdlGL2_RenderDrawData(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // We are using the OpenGL fixed pipeline to make the example code simpler to read!
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glEnable(GL_TEXTURE_2D);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // Render command lists
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
- const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
- glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos)));
- glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv)));
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col)));
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
- }
- idx_buffer += pcmd->ElemCount;
- }
- }
-
- // Restore modified state
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glPopAttrib();
- glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
- glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
-}
-
-static const char* ImGui_ImplSdlGL2_GetClipboardText(void*)
-{
- return SDL_GetClipboardText();
-}
-
-static void ImGui_ImplSdlGL2_SetClipboardText(void*, const char* text)
-{
- SDL_SetClipboardText(text);
-}
-
-// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
-// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
-// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
-// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
-bool ImGui_ImplSdlGL2_ProcessEvent(SDL_Event* event)
-{
- ImGuiIO& io = ImGui::GetIO();
- switch (event->type)
- {
- case SDL_MOUSEWHEEL:
- {
- if (event->wheel.x > 0) io.MouseWheelH += 1;
- if (event->wheel.x < 0) io.MouseWheelH -= 1;
- if (event->wheel.y > 0) io.MouseWheel += 1;
- if (event->wheel.y < 0) io.MouseWheel -= 1;
- return true;
- }
- case SDL_MOUSEBUTTONDOWN:
- {
- if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
- if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
- if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
- return true;
- }
- case SDL_TEXTINPUT:
- {
- io.AddInputCharactersUTF8(event->text.text);
- return true;
- }
- case SDL_KEYDOWN:
- case SDL_KEYUP:
- {
- int key = event->key.keysym.scancode;
- IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
- io.KeysDown[key] = (event->type == SDL_KEYDOWN);
- io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
- io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
- io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
- io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
- return true;
- }
- }
- return false;
-}
-
-bool ImGui_ImplSdlGL2_CreateDeviceObjects()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-
- return true;
-}
-
-void ImGui_ImplSdlGL2_InvalidateDeviceObjects()
-{
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-bool ImGui_ImplSdlGL2_Init(SDL_Window* window)
-{
- // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
- io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
- io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
- io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
- io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
- io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
- io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
- io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
- io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
- io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
- io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
- io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
- io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
- io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
- io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
- io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
- io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
-
- io.SetClipboardTextFn = ImGui_ImplSdlGL2_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplSdlGL2_GetClipboardText;
- io.ClipboardUserData = NULL;
-
- g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
- g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
- g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
- g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
- g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
- g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
- g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
-
-#ifdef _WIN32
- SDL_SysWMinfo wmInfo;
- SDL_VERSION(&wmInfo.version);
- SDL_GetWindowWMInfo(window, &wmInfo);
- io.ImeWindowHandle = wmInfo.info.win.window;
-#else
- (void)window;
-#endif
-
- return true;
-}
-
-void ImGui_ImplSdlGL2_Shutdown()
-{
- // Destroy SDL mouse cursors
- for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
- SDL_FreeCursor(g_MouseCursors[cursor_n]);
- memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
-
- // Destroy OpenGL objects
- ImGui_ImplSdlGL2_InvalidateDeviceObjects();
-}
-
-void ImGui_ImplSdlGL2_NewFrame(SDL_Window *window)
-{
- if (!g_FontTexture)
- ImGui_ImplSdlGL2_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- SDL_GetWindowSize(window, &w, &h);
- SDL_GL_GetDrawableSize(window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
- static Uint64 frequency = SDL_GetPerformanceFrequency();
- Uint64 current_time = SDL_GetPerformanceCounter();
- io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
- g_Time = current_time;
-
- // Setup mouse inputs (we already got mouse wheel, keyboard keys & characters from our event handler)
- int mx, my;
- Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
- io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
- io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
- io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
- g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
-
- // We need to use SDL_CaptureMouse() to easily retrieve mouse coordinates outside of the client area. This is only supported from SDL 2.0.4 (released Jan 2016)
-#if (SDL_MAJOR_VERSION >= 2) && (SDL_MINOR_VERSION >= 0) && (SDL_PATCHLEVEL >= 4)
- if ((SDL_GetWindowFlags(window) & (SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_MOUSE_CAPTURE)) != 0)
- io.MousePos = ImVec2((float)mx, (float)my);
- bool any_mouse_button_down = false;
- for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
- any_mouse_button_down |= io.MouseDown[n];
- if (any_mouse_button_down && (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE) == 0)
- SDL_CaptureMouse(SDL_TRUE);
- if (!any_mouse_button_down && (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE) != 0)
- SDL_CaptureMouse(SDL_FALSE);
-#else
- if ((SDL_GetWindowFlags(window) & SDL_WINDOW_INPUT_FOCUS) != 0)
- io.MousePos = ImVec2((float)mx, (float)my);
-#endif
-
- // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
- ImGuiMouseCursor cursor = ImGui::GetMouseCursor();
- if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None)
- {
- SDL_ShowCursor(0);
- }
- else
- {
- SDL_SetCursor(g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
- SDL_ShowCursor(1);
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
-}
diff --git a/third_party/imgui/examples/sdl_opengl2_example/imgui_impl_sdl_gl2.h b/third_party/imgui/examples/sdl_opengl2_example/imgui_impl_sdl_gl2.h
deleted file mode 100644
index 4df1c169c4..0000000000
--- a/third_party/imgui/examples/sdl_opengl2_example/imgui_impl_sdl_gl2.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// ImGui SDL2 binding with OpenGL (legacy, fixed pipeline)
-// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-
-// Implemented features:
-// [X] User texture binding. Cast 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
-// **Prefer using the code in the sdl_opengl3_example/ folder**
-// See imgui_impl_sdl.cpp for details.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct SDL_Window;
-typedef union SDL_Event SDL_Event;
-
-IMGUI_API bool ImGui_ImplSdlGL2_Init(SDL_Window* window);
-IMGUI_API void ImGui_ImplSdlGL2_Shutdown();
-IMGUI_API void ImGui_ImplSdlGL2_NewFrame(SDL_Window* window);
-IMGUI_API void ImGui_ImplSdlGL2_RenderDrawData(ImDrawData* draw_data);
-IMGUI_API bool ImGui_ImplSdlGL2_ProcessEvent(SDL_Event* event);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplSdlGL2_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplSdlGL2_CreateDeviceObjects();
diff --git a/third_party/imgui/examples/sdl_opengl3_example/Makefile b/third_party/imgui/examples/sdl_opengl3_example/Makefile
deleted file mode 100644
index 45f6a66314..0000000000
--- a/third_party/imgui/examples/sdl_opengl3_example/Makefile
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# Cross Platform Makefile
-# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
-#
-# You will need SDL2 (http://www.libsdl.org):
-# Linux:
-# apt-get install libsdl2-dev
-# Mac OS X:
-# brew install sdl2
-# MSYS2:
-# pacman -S mingw-w64-i686-SDL
-#
-
-#CXX = g++
-#CXX = clang++
-
-EXE = sdl_opengl3_example
-OBJS = main.o imgui_impl_sdl_gl3.o
-OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
-OBJS += ../libs/gl3w/GL/gl3w.o
-
-UNAME_S := $(shell uname -s)
-
-
-ifeq ($(UNAME_S), Linux) #LINUX
- ECHO_MESSAGE = "Linux"
- LIBS = -lGL -ldl `sdl2-config --libs`
-
- CXXFLAGS = -I../../ -I../libs/gl3w `sdl2-config --cflags`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(UNAME_S), Darwin) #APPLE
- ECHO_MESSAGE = "Mac OS X"
- LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
-
- CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/include `sdl2-config --cflags`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
- ECHO_MESSAGE = "Windows"
- LIBS = -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
-
- CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags sdl2`
- CXXFLAGS += -Wall -Wformat
- CFLAGS = $(CXXFLAGS)
-endif
-
-
-.cpp.o:
- $(CXX) $(CXXFLAGS) -c -o $@ $<
-
-all: $(EXE)
- @echo Build complete for $(ECHO_MESSAGE)
-
-$(EXE): $(OBJS)
- $(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
-
-clean:
- rm $(EXE) $(OBJS)
diff --git a/third_party/imgui/examples/sdl_opengl3_example/README.md b/third_party/imgui/examples/sdl_opengl3_example/README.md
deleted file mode 100644
index a982ff568d..0000000000
--- a/third_party/imgui/examples/sdl_opengl3_example/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-# How to Build
-
-- On Windows with Visual Studio's CLI
-
-```
-set SDL2DIR=path_to_your_sdl2_folder
-cl /Zi /MD /I ..\.. /I ..\libs\gl3w /I %SDL2DIR%\include main.cpp imgui_impl_sdl_gl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /link /libpath:%SDL2DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
-```
-
-- On Linux and similar Unixes
-
-```
-c++ `sdl2-config --cflags` -I ../.. -I ../libs/gl3w main.cpp imgui_impl_sdl_gl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -lGL -ldl -o sdl2example
-```
-
-- On Mac OS X
-
-```
-brew install sdl2
-c++ `sdl2-config --cflags` -I ../.. -I ../libs/gl3w main.cpp imgui_impl_sdl_gl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -framework OpenGl -framework CoreFoundation -o sdl2example
-```
diff --git a/third_party/imgui/examples/sdl_opengl3_example/build_win32.bat b/third_party/imgui/examples/sdl_opengl3_example/build_win32.bat
deleted file mode 100644
index aec9584e49..0000000000
--- a/third_party/imgui/examples/sdl_opengl3_example/build_win32.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
-mkdir Debug
-cl /nologo /Zi /MD /I ..\.. /I ..\libs\gl3w /I %SDL2_DIR%\include main.cpp imgui_impl_sdl_gl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/sdl_opengl3_example.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
diff --git a/third_party/imgui/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp b/third_party/imgui/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
deleted file mode 100644
index d5bd364cae..0000000000
--- a/third_party/imgui/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
+++ /dev/null
@@ -1,465 +0,0 @@
-// ImGui SDL2 binding with OpenGL3
-// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
-
-// Implemented features:
-// [X] User texture binding. Cast 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-// CHANGELOG
-// (minor and older changes stripped away, please see git history for details)
-// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
-// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
-// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself.
-// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
-// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
-// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
-// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
-// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
-// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150.
-// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
-// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
-// 2017-05-01: OpenGL: Fixed save and restore of current blend func state.
-// 2017-05-01: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE.
-// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
-// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
-// 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
-
-#include "imgui.h"
-#include "imgui_impl_sdl_gl3.h"
-
-// SDL,GL3W
-#include
-#include
-#include // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you.
-
-// SDL data
-static Uint64 g_Time = 0;
-static bool g_MousePressed[3] = { false, false, false };
-static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
-
-// OpenGL data
-static GLuint g_FontTexture = 0;
-static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
-static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0;
-static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0;
-static unsigned int g_VboHandle = 0,g_ElementsHandle = 0;
-
-// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
-// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
-// If text or lines are blurry when integrating ImGui in your engine: in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
-void ImGui_ImplSdlGL3_RenderDrawData(ImDrawData* draw_data)
-{
- // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
- ImGuiIO& io = ImGui::GetIO();
- int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
- int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
- if (fb_width == 0 || fb_height == 0)
- return;
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
-
- // Backup GL state
- GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
- glActiveTexture(GL_TEXTURE0);
- GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
- GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
- GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
- GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
- GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
- GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
- GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
- GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
- GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
- GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
- GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
- GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
- GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
- GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
- GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
- GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
- GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
- GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
-
- // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
- glEnable(GL_BLEND);
- glBlendEquation(GL_FUNC_ADD);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_SCISSOR_TEST);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-
- // Setup viewport, orthographic projection matrix
- glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
- const float ortho_projection[4][4] =
- {
- { 2.0f/io.DisplaySize.x, 0.0f, 0.0f, 0.0f },
- { 0.0f, 2.0f/-io.DisplaySize.y, 0.0f, 0.0f },
- { 0.0f, 0.0f, -1.0f, 0.0f },
- {-1.0f, 1.0f, 0.0f, 1.0f },
- };
- glUseProgram(g_ShaderHandle);
- glUniform1i(g_AttribLocationTex, 0);
- glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
- glBindSampler(0, 0); // Rely on combined texture/sampler state.
-
- // Recreate the VAO every time
- // (This is to easily allow multiple GL contexts. VAO are not shared among GL contexts, and we don't track creation/deletion of windows so we don't have an obvious key to use to cache them.)
- GLuint vao_handle = 0;
- glGenVertexArrays(1, &vao_handle);
- glBindVertexArray(vao_handle);
- glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glEnableVertexAttribArray(g_AttribLocationPosition);
- glEnableVertexAttribArray(g_AttribLocationUV);
- glEnableVertexAttribArray(g_AttribLocationColor);
- glVertexAttribPointer(g_AttribLocationPosition, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
- glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
- glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
-
- // Draw
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- const ImDrawIdx* idx_buffer_offset = 0;
-
- glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
- glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
-
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
- glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
- glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
- }
- idx_buffer_offset += pcmd->ElemCount;
- }
- }
- glDeleteVertexArrays(1, &vao_handle);
-
- // Restore modified GL state
- glUseProgram(last_program);
- glBindTexture(GL_TEXTURE_2D, last_texture);
- glBindSampler(0, last_sampler);
- glActiveTexture(last_active_texture);
- glBindVertexArray(last_vertex_array);
- glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, last_element_array_buffer);
- glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
- glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
- if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
- if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
- if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
- if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
- glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
- glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
- glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
-}
-
-static const char* ImGui_ImplSdlGL3_GetClipboardText(void*)
-{
- return SDL_GetClipboardText();
-}
-
-static void ImGui_ImplSdlGL3_SetClipboardText(void*, const char* text)
-{
- SDL_SetClipboardText(text);
-}
-
-// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
-// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
-// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
-// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
-bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event)
-{
- ImGuiIO& io = ImGui::GetIO();
- switch (event->type)
- {
- case SDL_MOUSEWHEEL:
- {
- if (event->wheel.x > 0) io.MouseWheelH += 1;
- if (event->wheel.x < 0) io.MouseWheelH -= 1;
- if (event->wheel.y > 0) io.MouseWheel += 1;
- if (event->wheel.y < 0) io.MouseWheel -= 1;
- return true;
- }
- case SDL_MOUSEBUTTONDOWN:
- {
- if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
- if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
- if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
- return true;
- }
- case SDL_TEXTINPUT:
- {
- io.AddInputCharactersUTF8(event->text.text);
- return true;
- }
- case SDL_KEYDOWN:
- case SDL_KEYUP:
- {
- int key = event->key.keysym.scancode;
- IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
- io.KeysDown[key] = (event->type == SDL_KEYDOWN);
- io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
- io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
- io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
- io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
- return true;
- }
- }
- return false;
-}
-
-void ImGui_ImplSdlGL3_CreateFontsTexture()
-{
- // Build texture atlas
- ImGuiIO& io = ImGui::GetIO();
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
-
- // Upload texture to graphics system
- GLint last_texture;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGenTextures(1, &g_FontTexture);
- glBindTexture(GL_TEXTURE_2D, g_FontTexture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
- // Restore state
- glBindTexture(GL_TEXTURE_2D, last_texture);
-}
-
-bool ImGui_ImplSdlGL3_CreateDeviceObjects()
-{
- // Backup GL state
- GLint last_texture, last_array_buffer, last_vertex_array;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
- glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
- glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
-
- const GLchar *vertex_shader =
- "#version 150\n"
- "uniform mat4 ProjMtx;\n"
- "in vec2 Position;\n"
- "in vec2 UV;\n"
- "in vec4 Color;\n"
- "out vec2 Frag_UV;\n"
- "out vec4 Frag_Color;\n"
- "void main()\n"
- "{\n"
- " Frag_UV = UV;\n"
- " Frag_Color = Color;\n"
- " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
- "}\n";
-
- const GLchar* fragment_shader =
- "#version 150\n"
- "uniform sampler2D Texture;\n"
- "in vec2 Frag_UV;\n"
- "in vec4 Frag_Color;\n"
- "out vec4 Out_Color;\n"
- "void main()\n"
- "{\n"
- " Out_Color = Frag_Color * texture( Texture, Frag_UV.st);\n"
- "}\n";
-
- g_ShaderHandle = glCreateProgram();
- g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
- g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
- glShaderSource(g_VertHandle, 1, &vertex_shader, 0);
- glShaderSource(g_FragHandle, 1, &fragment_shader, 0);
- glCompileShader(g_VertHandle);
- glCompileShader(g_FragHandle);
- glAttachShader(g_ShaderHandle, g_VertHandle);
- glAttachShader(g_ShaderHandle, g_FragHandle);
- glLinkProgram(g_ShaderHandle);
-
- g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
- g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
- g_AttribLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position");
- g_AttribLocationUV = glGetAttribLocation(g_ShaderHandle, "UV");
- g_AttribLocationColor = glGetAttribLocation(g_ShaderHandle, "Color");
-
- glGenBuffers(1, &g_VboHandle);
- glGenBuffers(1, &g_ElementsHandle);
-
- ImGui_ImplSdlGL3_CreateFontsTexture();
-
- // Restore modified GL state
- glBindTexture(GL_TEXTURE_2D, last_texture);
- glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
- glBindVertexArray(last_vertex_array);
-
- return true;
-}
-
-void ImGui_ImplSdlGL3_InvalidateDeviceObjects()
-{
- if (g_VboHandle) glDeleteBuffers(1, &g_VboHandle);
- if (g_ElementsHandle) glDeleteBuffers(1, &g_ElementsHandle);
- g_VboHandle = g_ElementsHandle = 0;
-
- if (g_ShaderHandle && g_VertHandle) glDetachShader(g_ShaderHandle, g_VertHandle);
- if (g_VertHandle) glDeleteShader(g_VertHandle);
- g_VertHandle = 0;
-
- if (g_ShaderHandle && g_FragHandle) glDetachShader(g_ShaderHandle, g_FragHandle);
- if (g_FragHandle) glDeleteShader(g_FragHandle);
- g_FragHandle = 0;
-
- if (g_ShaderHandle) glDeleteProgram(g_ShaderHandle);
- g_ShaderHandle = 0;
-
- if (g_FontTexture)
- {
- glDeleteTextures(1, &g_FontTexture);
- ImGui::GetIO().Fonts->TexID = 0;
- g_FontTexture = 0;
- }
-}
-
-bool ImGui_ImplSdlGL3_Init(SDL_Window* window)
-{
- // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
- io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
- io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
- io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
- io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
- io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
- io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
- io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
- io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
- io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
- io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
- io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
- io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
- io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
- io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
- io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
- io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
-
- io.SetClipboardTextFn = ImGui_ImplSdlGL3_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplSdlGL3_GetClipboardText;
- io.ClipboardUserData = NULL;
-
- g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
- g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
- g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
- g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
- g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
- g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
- g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
-
-#ifdef _WIN32
- SDL_SysWMinfo wmInfo;
- SDL_VERSION(&wmInfo.version);
- SDL_GetWindowWMInfo(window, &wmInfo);
- io.ImeWindowHandle = wmInfo.info.win.window;
-#else
- (void)window;
-#endif
-
- return true;
-}
-
-void ImGui_ImplSdlGL3_Shutdown()
-{
- // Destroy SDL mouse cursors
- for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
- SDL_FreeCursor(g_MouseCursors[cursor_n]);
- memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
-
- // Destroy OpenGL objects
- ImGui_ImplSdlGL3_InvalidateDeviceObjects();
-}
-
-void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window)
-{
- if (!g_FontTexture)
- ImGui_ImplSdlGL3_CreateDeviceObjects();
-
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- SDL_GetWindowSize(window, &w, &h);
- SDL_GL_GetDrawableSize(window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
- static Uint64 frequency = SDL_GetPerformanceFrequency();
- Uint64 current_time = SDL_GetPerformanceCounter();
- io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
- g_Time = current_time;
-
- // Setup mouse inputs (we already got mouse wheel, keyboard keys & characters from our event handler)
- int mx, my;
- Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
- io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
- io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
- io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
- g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
-
- // We need to use SDL_CaptureMouse() to easily retrieve mouse coordinates outside of the client area. This is only supported from SDL 2.0.4 (released Jan 2016)
-#if (SDL_MAJOR_VERSION >= 2) && (SDL_MINOR_VERSION >= 0) && (SDL_PATCHLEVEL >= 4)
- if ((SDL_GetWindowFlags(window) & (SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_MOUSE_CAPTURE)) != 0)
- io.MousePos = ImVec2((float)mx, (float)my);
- bool any_mouse_button_down = false;
- for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
- any_mouse_button_down |= io.MouseDown[n];
- if (any_mouse_button_down && (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE) == 0)
- SDL_CaptureMouse(SDL_TRUE);
- if (!any_mouse_button_down && (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE) != 0)
- SDL_CaptureMouse(SDL_FALSE);
-#else
- if ((SDL_GetWindowFlags(window) & SDL_WINDOW_INPUT_FOCUS) != 0)
- io.MousePos = ImVec2((float)mx, (float)my);
-#endif
-
- // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
- ImGuiMouseCursor cursor = ImGui::GetMouseCursor();
- if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None)
- {
- SDL_ShowCursor(0);
- }
- else
- {
- SDL_SetCursor(g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
- SDL_ShowCursor(1);
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
-}
diff --git a/third_party/imgui/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.h b/third_party/imgui/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.h
deleted file mode 100644
index fa111a1793..0000000000
--- a/third_party/imgui/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// ImGui SDL2 binding with OpenGL3
-// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
-
-// Implemented features:
-// [X] User texture binding. Cast 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct SDL_Window;
-typedef union SDL_Event SDL_Event;
-
-IMGUI_API bool ImGui_ImplSdlGL3_Init(SDL_Window* window);
-IMGUI_API void ImGui_ImplSdlGL3_Shutdown();
-IMGUI_API void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window);
-IMGUI_API void ImGui_ImplSdlGL3_RenderDrawData(ImDrawData* draw_data);
-IMGUI_API bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplSdlGL3_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplSdlGL3_CreateDeviceObjects();
diff --git a/third_party/imgui/examples/sdl_opengl3_example/main.cpp b/third_party/imgui/examples/sdl_opengl3_example/main.cpp
deleted file mode 100644
index a3fc625c25..0000000000
--- a/third_party/imgui/examples/sdl_opengl3_example/main.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-// ImGui - standalone example application for SDL2 + OpenGL
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
-// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
-
-#include "imgui.h"
-#include "imgui_impl_sdl_gl3.h"
-#include
-#include // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you.
-#include
-
-int main(int, char**)
-{
- // Setup SDL
- if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0)
- {
- printf("Error: %s\n", SDL_GetError());
- return -1;
- }
-
- // Setup window
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
- SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
- SDL_DisplayMode current;
- SDL_GetCurrentDisplayMode(0, ¤t);
- SDL_Window *window = SDL_CreateWindow("ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
- SDL_GLContext glcontext = SDL_GL_CreateContext(window);
- SDL_GL_SetSwapInterval(1); // Enable vsync
- gl3wInit();
-
- // Setup ImGui binding
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_ImplSdlGL3_Init(window);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard;
-
- // Setup style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // 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);
-
- bool show_demo_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
- // Main loop
- bool done = false;
- while (!done)
- {
- // 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.
- SDL_Event event;
- while (SDL_PollEvent(&event))
- {
- ImGui_ImplSdlGL3_ProcessEvent(&event);
- if (event.type == SDL_QUIT)
- done = true;
- }
- ImGui_ImplSdlGL3_NewFrame(window);
-
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
- {
- static float f = 0.0f;
- static int counter = 0;
- ImGui::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
-
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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);
- }
-
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
- // Rendering
- glViewport(0, 0, (int)ImGui::GetIO().DisplaySize.x, (int)ImGui::GetIO().DisplaySize.y);
- glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
- glClear(GL_COLOR_BUFFER_BIT);
- ImGui::Render();
- ImGui_ImplSdlGL3_RenderDrawData(ImGui::GetDrawData());
- SDL_GL_SwapWindow(window);
- }
-
- // Cleanup
- ImGui_ImplSdlGL3_Shutdown();
- ImGui::DestroyContext();
-
- SDL_GL_DeleteContext(glcontext);
- SDL_DestroyWindow(window);
- SDL_Quit();
-
- return 0;
-}
diff --git a/third_party/imgui/examples/vulkan_example/imgui_impl_glfw_vulkan.cpp b/third_party/imgui/examples/vulkan_example/imgui_impl_glfw_vulkan.cpp
deleted file mode 100644
index 8f9fa654a0..0000000000
--- a/third_party/imgui/examples/vulkan_example/imgui_impl_glfw_vulkan.cpp
+++ /dev/null
@@ -1,890 +0,0 @@
-// ImGui GLFW binding with Vulkan + shaders
-
-// Missing features:
-// [ ] User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 5 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXX_CreateFontsTexture(), ImGui_ImplXXXX_NewFrame(), ImGui_ImplXXXX_Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-// CHANGELOG
-// (minor and older changes stripped away, please see git history for details)
-// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
-// 2018-02-20: Inputs: Renamed GLFW callbacks exposed in .h to not include Vulkan in their name.
-// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback, ImGui_ImplGlfwVulkan_Render() calls ImGui_ImplGlfwVulkan_RenderDrawData() itself.
-// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
-// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
-// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
-// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
-// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
-// 2017-05-15: Vulkan: Fix scissor offset being negative. Fix new Vulkan validation warnings. Set required depth member for buffer image copy.
-// 2016-11-13: Vulkan: Fix validation layer warnings and errors and redeclare gl_PerVertex.
-// 2016-10-18: Vulkan: Add location decorators & change to use structs as in/out in glsl, update embedded spv (produced with glslangValidator -x). Null the released resources.
-// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
-// 2016-08-27: Vulkan: Fix Vulkan example for use when a depth buffer is active.
-
-#include "imgui.h"
-#include "imgui_impl_glfw_vulkan.h"
-
-// GLFW
-#define GLFW_INCLUDE_NONE
-#define GLFW_INCLUDE_VULKAN
-#include
-#ifdef _WIN32
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include
-#endif
-
-// GLFW data
-static GLFWwindow* g_Window = NULL;
-static double g_Time = 0.0f;
-static bool g_MouseJustPressed[3] = { false, false, false };
-static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_Count_] = { 0 };
-
-// Vulkan data
-static VkAllocationCallbacks* g_Allocator = NULL;
-static VkPhysicalDevice g_Gpu = VK_NULL_HANDLE;
-static VkDevice g_Device = VK_NULL_HANDLE;
-static VkRenderPass g_RenderPass = VK_NULL_HANDLE;
-static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE;
-static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
-static void (*g_CheckVkResult)(VkResult err) = NULL;
-
-static VkCommandBuffer g_CommandBuffer = VK_NULL_HANDLE;
-static VkDeviceSize g_BufferMemoryAlignment = 256;
-static VkPipelineCreateFlags g_PipelineCreateFlags = 0;
-static int g_FrameIndex = 0;
-
-static VkDescriptorSetLayout g_DescriptorSetLayout = VK_NULL_HANDLE;
-static VkPipelineLayout g_PipelineLayout = VK_NULL_HANDLE;
-static VkDescriptorSet g_DescriptorSet = VK_NULL_HANDLE;
-static VkPipeline g_Pipeline = VK_NULL_HANDLE;
-
-static VkSampler g_FontSampler = VK_NULL_HANDLE;
-static VkDeviceMemory g_FontMemory = VK_NULL_HANDLE;
-static VkImage g_FontImage = VK_NULL_HANDLE;
-static VkImageView g_FontView = VK_NULL_HANDLE;
-
-static VkDeviceMemory g_VertexBufferMemory[IMGUI_VK_QUEUED_FRAMES] = {};
-static VkDeviceMemory g_IndexBufferMemory[IMGUI_VK_QUEUED_FRAMES] = {};
-static VkDeviceSize g_VertexBufferSize[IMGUI_VK_QUEUED_FRAMES] = {};
-static VkDeviceSize g_IndexBufferSize[IMGUI_VK_QUEUED_FRAMES] = {};
-static VkBuffer g_VertexBuffer[IMGUI_VK_QUEUED_FRAMES] = {};
-static VkBuffer g_IndexBuffer[IMGUI_VK_QUEUED_FRAMES] = {};
-
-static VkDeviceMemory g_UploadBufferMemory = VK_NULL_HANDLE;
-static VkBuffer g_UploadBuffer = VK_NULL_HANDLE;
-
-static uint32_t __glsl_shader_vert_spv[] =
-{
- 0x07230203,0x00010000,0x00080001,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b,
- 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
- 0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015,
- 0x0000001b,0x0000001c,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
- 0x00000000,0x00030005,0x00000009,0x00000000,0x00050006,0x00000009,0x00000000,0x6f6c6f43,
- 0x00000072,0x00040006,0x00000009,0x00000001,0x00005655,0x00030005,0x0000000b,0x0074754f,
- 0x00040005,0x0000000f,0x6c6f4361,0x0000726f,0x00030005,0x00000015,0x00565561,0x00060005,
- 0x00000019,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x00000019,0x00000000,
- 0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000001b,0x00000000,0x00040005,0x0000001c,
- 0x736f5061,0x00000000,0x00060005,0x0000001e,0x73755075,0x6e6f4368,0x6e617473,0x00000074,
- 0x00050006,0x0000001e,0x00000000,0x61635375,0x0000656c,0x00060006,0x0000001e,0x00000001,
- 0x61725475,0x616c736e,0x00006574,0x00030005,0x00000020,0x00006370,0x00040047,0x0000000b,
- 0x0000001e,0x00000000,0x00040047,0x0000000f,0x0000001e,0x00000002,0x00040047,0x00000015,
- 0x0000001e,0x00000001,0x00050048,0x00000019,0x00000000,0x0000000b,0x00000000,0x00030047,
- 0x00000019,0x00000002,0x00040047,0x0000001c,0x0000001e,0x00000000,0x00050048,0x0000001e,
- 0x00000000,0x00000023,0x00000000,0x00050048,0x0000001e,0x00000001,0x00000023,0x00000008,
- 0x00030047,0x0000001e,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,
- 0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040017,
- 0x00000008,0x00000006,0x00000002,0x0004001e,0x00000009,0x00000007,0x00000008,0x00040020,
- 0x0000000a,0x00000003,0x00000009,0x0004003b,0x0000000a,0x0000000b,0x00000003,0x00040015,
- 0x0000000c,0x00000020,0x00000001,0x0004002b,0x0000000c,0x0000000d,0x00000000,0x00040020,
- 0x0000000e,0x00000001,0x00000007,0x0004003b,0x0000000e,0x0000000f,0x00000001,0x00040020,
- 0x00000011,0x00000003,0x00000007,0x0004002b,0x0000000c,0x00000013,0x00000001,0x00040020,
- 0x00000014,0x00000001,0x00000008,0x0004003b,0x00000014,0x00000015,0x00000001,0x00040020,
- 0x00000017,0x00000003,0x00000008,0x0003001e,0x00000019,0x00000007,0x00040020,0x0000001a,
- 0x00000003,0x00000019,0x0004003b,0x0000001a,0x0000001b,0x00000003,0x0004003b,0x00000014,
- 0x0000001c,0x00000001,0x0004001e,0x0000001e,0x00000008,0x00000008,0x00040020,0x0000001f,
- 0x00000009,0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000009,0x00040020,0x00000021,
- 0x00000009,0x00000008,0x0004002b,0x00000006,0x00000028,0x00000000,0x0004002b,0x00000006,
- 0x00000029,0x3f800000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,
- 0x00000005,0x0004003d,0x00000007,0x00000010,0x0000000f,0x00050041,0x00000011,0x00000012,
- 0x0000000b,0x0000000d,0x0003003e,0x00000012,0x00000010,0x0004003d,0x00000008,0x00000016,
- 0x00000015,0x00050041,0x00000017,0x00000018,0x0000000b,0x00000013,0x0003003e,0x00000018,
- 0x00000016,0x0004003d,0x00000008,0x0000001d,0x0000001c,0x00050041,0x00000021,0x00000022,
- 0x00000020,0x0000000d,0x0004003d,0x00000008,0x00000023,0x00000022,0x00050085,0x00000008,
- 0x00000024,0x0000001d,0x00000023,0x00050041,0x00000021,0x00000025,0x00000020,0x00000013,
- 0x0004003d,0x00000008,0x00000026,0x00000025,0x00050081,0x00000008,0x00000027,0x00000024,
- 0x00000026,0x00050051,0x00000006,0x0000002a,0x00000027,0x00000000,0x00050051,0x00000006,
- 0x0000002b,0x00000027,0x00000001,0x00070050,0x00000007,0x0000002c,0x0000002a,0x0000002b,
- 0x00000028,0x00000029,0x00050041,0x00000011,0x0000002d,0x0000001b,0x0000000d,0x0003003e,
- 0x0000002d,0x0000002c,0x000100fd,0x00010038
-};
-
-static uint32_t __glsl_shader_frag_spv[] =
-{
- 0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b,
- 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
- 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000d,0x00030010,
- 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
- 0x00000000,0x00040005,0x00000009,0x6c6f4366,0x0000726f,0x00030005,0x0000000b,0x00000000,
- 0x00050006,0x0000000b,0x00000000,0x6f6c6f43,0x00000072,0x00040006,0x0000000b,0x00000001,
- 0x00005655,0x00030005,0x0000000d,0x00006e49,0x00050005,0x00000016,0x78655473,0x65727574,
- 0x00000000,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x0000001e,
- 0x00000000,0x00040047,0x00000016,0x00000022,0x00000000,0x00040047,0x00000016,0x00000021,
- 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
- 0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,
- 0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040017,0x0000000a,0x00000006,
- 0x00000002,0x0004001e,0x0000000b,0x00000007,0x0000000a,0x00040020,0x0000000c,0x00000001,
- 0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040015,0x0000000e,0x00000020,
- 0x00000001,0x0004002b,0x0000000e,0x0000000f,0x00000000,0x00040020,0x00000010,0x00000001,
- 0x00000007,0x00090019,0x00000013,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,
- 0x00000001,0x00000000,0x0003001b,0x00000014,0x00000013,0x00040020,0x00000015,0x00000000,
- 0x00000014,0x0004003b,0x00000015,0x00000016,0x00000000,0x0004002b,0x0000000e,0x00000018,
- 0x00000001,0x00040020,0x00000019,0x00000001,0x0000000a,0x00050036,0x00000002,0x00000004,
- 0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000010,0x00000011,0x0000000d,
- 0x0000000f,0x0004003d,0x00000007,0x00000012,0x00000011,0x0004003d,0x00000014,0x00000017,
- 0x00000016,0x00050041,0x00000019,0x0000001a,0x0000000d,0x00000018,0x0004003d,0x0000000a,
- 0x0000001b,0x0000001a,0x00050057,0x00000007,0x0000001c,0x00000017,0x0000001b,0x00050085,
- 0x00000007,0x0000001d,0x00000012,0x0000001c,0x0003003e,0x00000009,0x0000001d,0x000100fd,
- 0x00010038
-};
-
-static uint32_t ImGui_ImplGlfwVulkan_MemoryType(VkMemoryPropertyFlags properties, uint32_t type_bits)
-{
- VkPhysicalDeviceMemoryProperties prop;
- vkGetPhysicalDeviceMemoryProperties(g_Gpu, &prop);
- for (uint32_t i = 0; i < prop.memoryTypeCount; i++)
- if ((prop.memoryTypes[i].propertyFlags & properties) == properties && type_bits & (1<TotalVtxCount == 0)
- return;
-
- // Create the Vertex Buffer:
- size_t vertex_size = draw_data->TotalVtxCount * sizeof(ImDrawVert);
- if (!g_VertexBuffer[g_FrameIndex] || g_VertexBufferSize[g_FrameIndex] < vertex_size)
- {
- if (g_VertexBuffer[g_FrameIndex])
- vkDestroyBuffer(g_Device, g_VertexBuffer[g_FrameIndex], g_Allocator);
- if (g_VertexBufferMemory[g_FrameIndex])
- vkFreeMemory(g_Device, g_VertexBufferMemory[g_FrameIndex], g_Allocator);
- VkDeviceSize vertex_buffer_size = ((vertex_size-1) / g_BufferMemoryAlignment+1) * g_BufferMemoryAlignment;
- VkBufferCreateInfo buffer_info = {};
- buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
- buffer_info.size = vertex_buffer_size;
- buffer_info.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
- buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
- err = vkCreateBuffer(g_Device, &buffer_info, g_Allocator, &g_VertexBuffer[g_FrameIndex]);
- ImGui_ImplGlfwVulkan_VkResult(err);
- VkMemoryRequirements req;
- vkGetBufferMemoryRequirements(g_Device, g_VertexBuffer[g_FrameIndex], &req);
- g_BufferMemoryAlignment = (g_BufferMemoryAlignment > req.alignment) ? g_BufferMemoryAlignment : req.alignment;
- VkMemoryAllocateInfo alloc_info = {};
- alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
- alloc_info.allocationSize = req.size;
- alloc_info.memoryTypeIndex = ImGui_ImplGlfwVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
- err = vkAllocateMemory(g_Device, &alloc_info, g_Allocator, &g_VertexBufferMemory[g_FrameIndex]);
- ImGui_ImplGlfwVulkan_VkResult(err);
- err = vkBindBufferMemory(g_Device, g_VertexBuffer[g_FrameIndex], g_VertexBufferMemory[g_FrameIndex], 0);
- ImGui_ImplGlfwVulkan_VkResult(err);
- g_VertexBufferSize[g_FrameIndex] = vertex_buffer_size;
- }
-
- // Create the Index Buffer:
- size_t index_size = draw_data->TotalIdxCount * sizeof(ImDrawIdx);
- if (!g_IndexBuffer[g_FrameIndex] || g_IndexBufferSize[g_FrameIndex] < index_size)
- {
- if (g_IndexBuffer[g_FrameIndex])
- vkDestroyBuffer(g_Device, g_IndexBuffer[g_FrameIndex], g_Allocator);
- if (g_IndexBufferMemory[g_FrameIndex])
- vkFreeMemory(g_Device, g_IndexBufferMemory[g_FrameIndex], g_Allocator);
- VkDeviceSize index_buffer_size = ((index_size-1) / g_BufferMemoryAlignment+1) * g_BufferMemoryAlignment;
- VkBufferCreateInfo buffer_info = {};
- buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
- buffer_info.size = index_buffer_size;
- buffer_info.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
- buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
- err = vkCreateBuffer(g_Device, &buffer_info, g_Allocator, &g_IndexBuffer[g_FrameIndex]);
- ImGui_ImplGlfwVulkan_VkResult(err);
- VkMemoryRequirements req;
- vkGetBufferMemoryRequirements(g_Device, g_IndexBuffer[g_FrameIndex], &req);
- g_BufferMemoryAlignment = (g_BufferMemoryAlignment > req.alignment) ? g_BufferMemoryAlignment : req.alignment;
- VkMemoryAllocateInfo alloc_info = {};
- alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
- alloc_info.allocationSize = req.size;
- alloc_info.memoryTypeIndex = ImGui_ImplGlfwVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
- err = vkAllocateMemory(g_Device, &alloc_info, g_Allocator, &g_IndexBufferMemory[g_FrameIndex]);
- ImGui_ImplGlfwVulkan_VkResult(err);
- err = vkBindBufferMemory(g_Device, g_IndexBuffer[g_FrameIndex], g_IndexBufferMemory[g_FrameIndex], 0);
- ImGui_ImplGlfwVulkan_VkResult(err);
- g_IndexBufferSize[g_FrameIndex] = index_buffer_size;
- }
-
- // Upload Vertex and index Data:
- {
- ImDrawVert* vtx_dst;
- ImDrawIdx* idx_dst;
- err = vkMapMemory(g_Device, g_VertexBufferMemory[g_FrameIndex], 0, vertex_size, 0, (void**)(&vtx_dst));
- ImGui_ImplGlfwVulkan_VkResult(err);
- err = vkMapMemory(g_Device, g_IndexBufferMemory[g_FrameIndex], 0, index_size, 0, (void**)(&idx_dst));
- ImGui_ImplGlfwVulkan_VkResult(err);
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
- memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
- vtx_dst += cmd_list->VtxBuffer.Size;
- idx_dst += cmd_list->IdxBuffer.Size;
- }
- VkMappedMemoryRange range[2] = {};
- range[0].sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
- range[0].memory = g_VertexBufferMemory[g_FrameIndex];
- range[0].size = VK_WHOLE_SIZE;
- range[1].sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
- range[1].memory = g_IndexBufferMemory[g_FrameIndex];
- range[1].size = VK_WHOLE_SIZE;
- err = vkFlushMappedMemoryRanges(g_Device, 2, range);
- ImGui_ImplGlfwVulkan_VkResult(err);
- vkUnmapMemory(g_Device, g_VertexBufferMemory[g_FrameIndex]);
- vkUnmapMemory(g_Device, g_IndexBufferMemory[g_FrameIndex]);
- }
-
- // Bind pipeline and descriptor sets:
- {
- vkCmdBindPipeline(g_CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_Pipeline);
- VkDescriptorSet desc_set[1] = {g_DescriptorSet};
- vkCmdBindDescriptorSets(g_CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_PipelineLayout, 0, 1, desc_set, 0, NULL);
- }
-
- // Bind Vertex And Index Buffer:
- {
- VkBuffer vertex_buffers[1] = {g_VertexBuffer[g_FrameIndex]};
- VkDeviceSize vertex_offset[1] = {0};
- vkCmdBindVertexBuffers(g_CommandBuffer, 0, 1, vertex_buffers, vertex_offset);
- vkCmdBindIndexBuffer(g_CommandBuffer, g_IndexBuffer[g_FrameIndex], 0, VK_INDEX_TYPE_UINT16);
- }
-
- // Setup viewport:
- {
- VkViewport viewport;
- viewport.x = 0;
- viewport.y = 0;
- viewport.width = ImGui::GetIO().DisplaySize.x;
- viewport.height = ImGui::GetIO().DisplaySize.y;
- viewport.minDepth = 0.0f;
- viewport.maxDepth = 1.0f;
- vkCmdSetViewport(g_CommandBuffer, 0, 1, &viewport);
- }
-
- // Setup scale and translation:
- {
- float scale[2];
- scale[0] = 2.0f/io.DisplaySize.x;
- scale[1] = 2.0f/io.DisplaySize.y;
- float translate[2];
- translate[0] = -1.0f;
- translate[1] = -1.0f;
- vkCmdPushConstants(g_CommandBuffer, g_PipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, sizeof(float) * 0, sizeof(float) * 2, scale);
- vkCmdPushConstants(g_CommandBuffer, g_PipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, sizeof(float) * 2, sizeof(float) * 2, translate);
- }
-
- // Render the command lists:
- int vtx_offset = 0;
- int idx_offset = 0;
- for (int n = 0; n < draw_data->CmdListsCount; n++)
- {
- const ImDrawList* cmd_list = draw_data->CmdLists[n];
- for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
- {
- const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
- if (pcmd->UserCallback)
- {
- pcmd->UserCallback(cmd_list, pcmd);
- }
- else
- {
- VkRect2D scissor;
- scissor.offset.x = (int32_t)(pcmd->ClipRect.x) > 0 ? (int32_t)(pcmd->ClipRect.x) : 0;
- scissor.offset.y = (int32_t)(pcmd->ClipRect.y) > 0 ? (int32_t)(pcmd->ClipRect.y) : 0;
- scissor.extent.width = (uint32_t)(pcmd->ClipRect.z - pcmd->ClipRect.x);
- scissor.extent.height = (uint32_t)(pcmd->ClipRect.w - pcmd->ClipRect.y + 1); // FIXME: Why +1 here?
- vkCmdSetScissor(g_CommandBuffer, 0, 1, &scissor);
- vkCmdDrawIndexed(g_CommandBuffer, pcmd->ElemCount, 1, idx_offset, vtx_offset, 0);
- }
- idx_offset += pcmd->ElemCount;
- }
- vtx_offset += cmd_list->VtxBuffer.Size;
- }
-}
-
-static const char* ImGui_ImplGlfwVulkan_GetClipboardText(void* user_data)
-{
- return glfwGetClipboardString((GLFWwindow*)user_data);
-}
-
-static void ImGui_ImplGlfwVulkan_SetClipboardText(void* user_data, const char* text)
-{
- glfwSetClipboardString((GLFWwindow*)user_data, text);
-}
-
-void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
- if (action == GLFW_PRESS && button >= 0 && button < 3)
- g_MouseJustPressed[button] = true;
-}
-
-void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double xoffset, double yoffset)
-{
- ImGuiIO& io = ImGui::GetIO();
- io.MouseWheelH += (float)xoffset;
- io.MouseWheel += (float)yoffset;
-}
-
-void ImGui_ImplGlfw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (action == GLFW_PRESS)
- io.KeysDown[key] = true;
- if (action == GLFW_RELEASE)
- io.KeysDown[key] = false;
-
- (void)mods; // Modifiers are not reliable across systems
- io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
- io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
- io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
- io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
-}
-
-void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
-{
- ImGuiIO& io = ImGui::GetIO();
- if (c > 0 && c < 0x10000)
- io.AddInputCharacter((unsigned short)c);
-}
-
-bool ImGui_ImplGlfwVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)
-{
- ImGuiIO& io = ImGui::GetIO();
-
- unsigned char* pixels;
- int width, height;
- io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
- size_t upload_size = width*height*4*sizeof(char);
-
- VkResult err;
-
- // Create the Image:
- {
- VkImageCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
- info.imageType = VK_IMAGE_TYPE_2D;
- info.format = VK_FORMAT_R8G8B8A8_UNORM;
- info.extent.width = width;
- info.extent.height = height;
- info.extent.depth = 1;
- info.mipLevels = 1;
- info.arrayLayers = 1;
- info.samples = VK_SAMPLE_COUNT_1_BIT;
- info.tiling = VK_IMAGE_TILING_OPTIMAL;
- info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
- info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
- info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- err = vkCreateImage(g_Device, &info, g_Allocator, &g_FontImage);
- ImGui_ImplGlfwVulkan_VkResult(err);
- VkMemoryRequirements req;
- vkGetImageMemoryRequirements(g_Device, g_FontImage, &req);
- VkMemoryAllocateInfo alloc_info = {};
- alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
- alloc_info.allocationSize = req.size;
- alloc_info.memoryTypeIndex = ImGui_ImplGlfwVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits);
- err = vkAllocateMemory(g_Device, &alloc_info, g_Allocator, &g_FontMemory);
- ImGui_ImplGlfwVulkan_VkResult(err);
- err = vkBindImageMemory(g_Device, g_FontImage, g_FontMemory, 0);
- ImGui_ImplGlfwVulkan_VkResult(err);
- }
-
- // Create the Image View:
- {
- VkImageViewCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
- info.image = g_FontImage;
- info.viewType = VK_IMAGE_VIEW_TYPE_2D;
- info.format = VK_FORMAT_R8G8B8A8_UNORM;
- info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- info.subresourceRange.levelCount = 1;
- info.subresourceRange.layerCount = 1;
- err = vkCreateImageView(g_Device, &info, g_Allocator, &g_FontView);
- ImGui_ImplGlfwVulkan_VkResult(err);
- }
-
- // Update the Descriptor Set:
- {
- VkDescriptorImageInfo desc_image[1] = {};
- desc_image[0].sampler = g_FontSampler;
- desc_image[0].imageView = g_FontView;
- desc_image[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
- VkWriteDescriptorSet write_desc[1] = {};
- write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
- write_desc[0].dstSet = g_DescriptorSet;
- write_desc[0].descriptorCount = 1;
- write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
- write_desc[0].pImageInfo = desc_image;
- vkUpdateDescriptorSets(g_Device, 1, write_desc, 0, NULL);
- }
-
- // Create the Upload Buffer:
- {
- VkBufferCreateInfo buffer_info = {};
- buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
- buffer_info.size = upload_size;
- buffer_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
- buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
- err = vkCreateBuffer(g_Device, &buffer_info, g_Allocator, &g_UploadBuffer);
- ImGui_ImplGlfwVulkan_VkResult(err);
- VkMemoryRequirements req;
- vkGetBufferMemoryRequirements(g_Device, g_UploadBuffer, &req);
- g_BufferMemoryAlignment = (g_BufferMemoryAlignment > req.alignment) ? g_BufferMemoryAlignment : req.alignment;
- VkMemoryAllocateInfo alloc_info = {};
- alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
- alloc_info.allocationSize = req.size;
- alloc_info.memoryTypeIndex = ImGui_ImplGlfwVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
- err = vkAllocateMemory(g_Device, &alloc_info, g_Allocator, &g_UploadBufferMemory);
- ImGui_ImplGlfwVulkan_VkResult(err);
- err = vkBindBufferMemory(g_Device, g_UploadBuffer, g_UploadBufferMemory, 0);
- ImGui_ImplGlfwVulkan_VkResult(err);
- }
-
- // Upload to Buffer:
- {
- char* map = NULL;
- err = vkMapMemory(g_Device, g_UploadBufferMemory, 0, upload_size, 0, (void**)(&map));
- ImGui_ImplGlfwVulkan_VkResult(err);
- memcpy(map, pixels, upload_size);
- VkMappedMemoryRange range[1] = {};
- range[0].sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
- range[0].memory = g_UploadBufferMemory;
- range[0].size = upload_size;
- err = vkFlushMappedMemoryRanges(g_Device, 1, range);
- ImGui_ImplGlfwVulkan_VkResult(err);
- vkUnmapMemory(g_Device, g_UploadBufferMemory);
- }
- // Copy to Image:
- {
- VkImageMemoryBarrier copy_barrier[1] = {};
- copy_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
- copy_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
- copy_barrier[0].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- copy_barrier[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
- copy_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
- copy_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
- copy_barrier[0].image = g_FontImage;
- copy_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- copy_barrier[0].subresourceRange.levelCount = 1;
- copy_barrier[0].subresourceRange.layerCount = 1;
- vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, copy_barrier);
-
- VkBufferImageCopy region = {};
- region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- region.imageSubresource.layerCount = 1;
- region.imageExtent.width = width;
- region.imageExtent.height = height;
- region.imageExtent.depth = 1;
- vkCmdCopyBufferToImage(command_buffer, g_UploadBuffer, g_FontImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
-
- VkImageMemoryBarrier use_barrier[1] = {};
- use_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
- use_barrier[0].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
- use_barrier[0].dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
- use_barrier[0].oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
- use_barrier[0].newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
- use_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
- use_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
- use_barrier[0].image = g_FontImage;
- use_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- use_barrier[0].subresourceRange.levelCount = 1;
- use_barrier[0].subresourceRange.layerCount = 1;
- vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, use_barrier);
- }
-
- // Store our identifier
- io.Fonts->TexID = (void *)(intptr_t)g_FontImage;
-
- return true;
-}
-
-bool ImGui_ImplGlfwVulkan_CreateDeviceObjects()
-{
- VkResult err;
- VkShaderModule vert_module;
- VkShaderModule frag_module;
-
- // Create The Shader Modules:
- {
- VkShaderModuleCreateInfo vert_info = {};
- vert_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
- vert_info.codeSize = sizeof(__glsl_shader_vert_spv);
- vert_info.pCode = (uint32_t*)__glsl_shader_vert_spv;
- err = vkCreateShaderModule(g_Device, &vert_info, g_Allocator, &vert_module);
- ImGui_ImplGlfwVulkan_VkResult(err);
- VkShaderModuleCreateInfo frag_info = {};
- frag_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
- frag_info.codeSize = sizeof(__glsl_shader_frag_spv);
- frag_info.pCode = (uint32_t*)__glsl_shader_frag_spv;
- err = vkCreateShaderModule(g_Device, &frag_info, g_Allocator, &frag_module);
- ImGui_ImplGlfwVulkan_VkResult(err);
- }
-
- if (!g_FontSampler)
- {
- VkSamplerCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
- info.magFilter = VK_FILTER_LINEAR;
- info.minFilter = VK_FILTER_LINEAR;
- info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
- info.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
- info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
- info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
- info.minLod = -1000;
- info.maxLod = 1000;
- info.maxAnisotropy = 1.0f;
- err = vkCreateSampler(g_Device, &info, g_Allocator, &g_FontSampler);
- ImGui_ImplGlfwVulkan_VkResult(err);
- }
-
- if (!g_DescriptorSetLayout)
- {
- VkSampler sampler[1] = {g_FontSampler};
- VkDescriptorSetLayoutBinding binding[1] = {};
- binding[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
- binding[0].descriptorCount = 1;
- binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
- binding[0].pImmutableSamplers = sampler;
- VkDescriptorSetLayoutCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
- info.bindingCount = 1;
- info.pBindings = binding;
- err = vkCreateDescriptorSetLayout(g_Device, &info, g_Allocator, &g_DescriptorSetLayout);
- ImGui_ImplGlfwVulkan_VkResult(err);
- }
-
- // Create Descriptor Set:
- {
- VkDescriptorSetAllocateInfo alloc_info = {};
- alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
- alloc_info.descriptorPool = g_DescriptorPool;
- alloc_info.descriptorSetCount = 1;
- alloc_info.pSetLayouts = &g_DescriptorSetLayout;
- err = vkAllocateDescriptorSets(g_Device, &alloc_info, &g_DescriptorSet);
- ImGui_ImplGlfwVulkan_VkResult(err);
- }
-
- if (!g_PipelineLayout)
- {
- VkPushConstantRange push_constants[1] = {};
- push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
- push_constants[0].offset = sizeof(float) * 0;
- push_constants[0].size = sizeof(float) * 4;
- VkDescriptorSetLayout set_layout[1] = {g_DescriptorSetLayout};
- VkPipelineLayoutCreateInfo layout_info = {};
- layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
- layout_info.setLayoutCount = 1;
- layout_info.pSetLayouts = set_layout;
- layout_info.pushConstantRangeCount = 1;
- layout_info.pPushConstantRanges = push_constants;
- err = vkCreatePipelineLayout(g_Device, &layout_info, g_Allocator, &g_PipelineLayout);
- ImGui_ImplGlfwVulkan_VkResult(err);
- }
-
- VkPipelineShaderStageCreateInfo stage[2] = {};
- stage[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
- stage[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
- stage[0].module = vert_module;
- stage[0].pName = "main";
- stage[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
- stage[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
- stage[1].module = frag_module;
- stage[1].pName = "main";
-
- VkVertexInputBindingDescription binding_desc[1] = {};
- binding_desc[0].stride = sizeof(ImDrawVert);
- binding_desc[0].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
-
- VkVertexInputAttributeDescription attribute_desc[3] = {};
- attribute_desc[0].location = 0;
- attribute_desc[0].binding = binding_desc[0].binding;
- attribute_desc[0].format = VK_FORMAT_R32G32_SFLOAT;
- attribute_desc[0].offset = (size_t)(&((ImDrawVert*)0)->pos);
- attribute_desc[1].location = 1;
- attribute_desc[1].binding = binding_desc[0].binding;
- attribute_desc[1].format = VK_FORMAT_R32G32_SFLOAT;
- attribute_desc[1].offset = (size_t)(&((ImDrawVert*)0)->uv);
- attribute_desc[2].location = 2;
- attribute_desc[2].binding = binding_desc[0].binding;
- attribute_desc[2].format = VK_FORMAT_R8G8B8A8_UNORM;
- attribute_desc[2].offset = (size_t)(&((ImDrawVert*)0)->col);
-
- VkPipelineVertexInputStateCreateInfo vertex_info = {};
- vertex_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
- vertex_info.vertexBindingDescriptionCount = 1;
- vertex_info.pVertexBindingDescriptions = binding_desc;
- vertex_info.vertexAttributeDescriptionCount = 3;
- vertex_info.pVertexAttributeDescriptions = attribute_desc;
-
- VkPipelineInputAssemblyStateCreateInfo ia_info = {};
- ia_info.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
- ia_info.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
-
- VkPipelineViewportStateCreateInfo viewport_info = {};
- viewport_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
- viewport_info.viewportCount = 1;
- viewport_info.scissorCount = 1;
-
- VkPipelineRasterizationStateCreateInfo raster_info = {};
- raster_info.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
- raster_info.polygonMode = VK_POLYGON_MODE_FILL;
- raster_info.cullMode = VK_CULL_MODE_NONE;
- raster_info.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
- raster_info.lineWidth = 1.0f;
-
- VkPipelineMultisampleStateCreateInfo ms_info = {};
- ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
- ms_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
-
- VkPipelineColorBlendAttachmentState color_attachment[1] = {};
- color_attachment[0].blendEnable = VK_TRUE;
- color_attachment[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
- color_attachment[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
- color_attachment[0].colorBlendOp = VK_BLEND_OP_ADD;
- color_attachment[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
- color_attachment[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
- color_attachment[0].alphaBlendOp = VK_BLEND_OP_ADD;
- color_attachment[0].colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
-
- VkPipelineDepthStencilStateCreateInfo depth_info = {};
- depth_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
-
- VkPipelineColorBlendStateCreateInfo blend_info = {};
- blend_info.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
- blend_info.attachmentCount = 1;
- blend_info.pAttachments = color_attachment;
-
- VkDynamicState dynamic_states[2] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
- VkPipelineDynamicStateCreateInfo dynamic_state = {};
- dynamic_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
- dynamic_state.dynamicStateCount = 2;
- dynamic_state.pDynamicStates = dynamic_states;
-
- VkGraphicsPipelineCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
- info.flags = g_PipelineCreateFlags;
- info.stageCount = 2;
- info.pStages = stage;
- info.pVertexInputState = &vertex_info;
- info.pInputAssemblyState = &ia_info;
- info.pViewportState = &viewport_info;
- info.pRasterizationState = &raster_info;
- info.pMultisampleState = &ms_info;
- info.pDepthStencilState = &depth_info;
- info.pColorBlendState = &blend_info;
- info.pDynamicState = &dynamic_state;
- info.layout = g_PipelineLayout;
- info.renderPass = g_RenderPass;
- err = vkCreateGraphicsPipelines(g_Device, g_PipelineCache, 1, &info, g_Allocator, &g_Pipeline);
- ImGui_ImplGlfwVulkan_VkResult(err);
-
- vkDestroyShaderModule(g_Device, vert_module, g_Allocator);
- vkDestroyShaderModule(g_Device, frag_module, g_Allocator);
-
- return true;
-}
-
-void ImGui_ImplGlfwVulkan_InvalidateFontUploadObjects()
-{
- if (g_UploadBuffer)
- {
- vkDestroyBuffer(g_Device, g_UploadBuffer, g_Allocator);
- g_UploadBuffer = VK_NULL_HANDLE;
- }
- if (g_UploadBufferMemory)
- {
- vkFreeMemory(g_Device, g_UploadBufferMemory, g_Allocator);
- g_UploadBufferMemory = VK_NULL_HANDLE;
- }
-}
-
-void ImGui_ImplGlfwVulkan_InvalidateDeviceObjects()
-{
- ImGui_ImplGlfwVulkan_InvalidateFontUploadObjects();
-
- for (int i = 0; i < IMGUI_VK_QUEUED_FRAMES; i++)
- {
- if (g_VertexBuffer[i]) { vkDestroyBuffer(g_Device, g_VertexBuffer[i], g_Allocator); g_VertexBuffer[i] = VK_NULL_HANDLE; }
- if (g_VertexBufferMemory[i]) { vkFreeMemory(g_Device, g_VertexBufferMemory[i], g_Allocator); g_VertexBufferMemory[i] = VK_NULL_HANDLE; }
- if (g_IndexBuffer[i]) { vkDestroyBuffer(g_Device, g_IndexBuffer[i], g_Allocator); g_IndexBuffer[i] = VK_NULL_HANDLE; }
- if (g_IndexBufferMemory[i]) { vkFreeMemory(g_Device, g_IndexBufferMemory[i], g_Allocator); g_IndexBufferMemory[i] = VK_NULL_HANDLE; }
- }
-
- if (g_FontView) { vkDestroyImageView(g_Device, g_FontView, g_Allocator); g_FontView = VK_NULL_HANDLE; }
- if (g_FontImage) { vkDestroyImage(g_Device, g_FontImage, g_Allocator); g_FontImage = VK_NULL_HANDLE; }
- if (g_FontMemory) { vkFreeMemory(g_Device, g_FontMemory, g_Allocator); g_FontMemory = VK_NULL_HANDLE; }
- if (g_FontSampler) { vkDestroySampler(g_Device, g_FontSampler, g_Allocator); g_FontSampler = VK_NULL_HANDLE; }
- if (g_DescriptorSetLayout) { vkDestroyDescriptorSetLayout(g_Device, g_DescriptorSetLayout, g_Allocator); g_DescriptorSetLayout = VK_NULL_HANDLE; }
- if (g_PipelineLayout) { vkDestroyPipelineLayout(g_Device, g_PipelineLayout, g_Allocator); g_PipelineLayout = VK_NULL_HANDLE; }
- if (g_Pipeline) { vkDestroyPipeline(g_Device, g_Pipeline, g_Allocator); g_Pipeline = VK_NULL_HANDLE; }
-}
-
-static void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
-{
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
-}
-
-bool ImGui_ImplGlfwVulkan_Init(GLFWwindow* window, bool install_callbacks, ImGui_ImplGlfwVulkan_Init_Data *init_data)
-{
- g_Allocator = init_data->allocator;
- g_Gpu = init_data->gpu;
- g_Device = init_data->device;
- g_RenderPass = init_data->render_pass;
- g_PipelineCache = init_data->pipeline_cache;
- g_DescriptorPool = init_data->descriptor_pool;
- g_CheckVkResult = init_data->check_vk_result;
-
- g_Window = window;
-
- ImGuiIO& io = ImGui::GetIO();
- io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
- io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
- io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
- io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
- io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
- io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
- io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
- io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
- io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
- io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT;
- io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
- io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
- io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
- io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
- io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
- io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
- io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
- io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
- io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
- io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
- io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
- io.SetClipboardTextFn = ImGui_ImplGlfwVulkan_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplGlfwVulkan_GetClipboardText;
- io.ClipboardUserData = g_Window;
-#ifdef _WIN32
- io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
- // Load cursors
- // FIXME: GLFW doesn't expose suitable cursors for ResizeAll, ResizeNESW, ResizeNWSE. We revert to arrow cursor for those.
- g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
- g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
-
- if (install_callbacks)
- ImGui_ImplGlfw_InstallCallbacks(window);
-
- ImGui_ImplGlfwVulkan_CreateDeviceObjects();
-
- return true;
-}
-
-void ImGui_ImplGlfwVulkan_Shutdown()
-{
- // Destroy GLFW mouse cursors
- for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++)
- glfwDestroyCursor(g_MouseCursors[cursor_n]);
- memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
-
- // Destroy Vulkan objects
- ImGui_ImplGlfwVulkan_InvalidateDeviceObjects();
-}
-
-void ImGui_ImplGlfwVulkan_NewFrame()
-{
- ImGuiIO& io = ImGui::GetIO();
-
- // Setup display size (every frame to accommodate for window resizing)
- int w, h;
- int display_w, display_h;
- glfwGetWindowSize(g_Window, &w, &h);
- glfwGetFramebufferSize(g_Window, &display_w, &display_h);
- io.DisplaySize = ImVec2((float)w, (float)h);
- io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
-
- // Setup time step
- double current_time = glfwGetTime();
- io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
- g_Time = current_time;
-
- // Setup inputs
- // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
- if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
- {
- double mouse_x, mouse_y;
- glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
- io.MousePos = ImVec2((float)mouse_x, (float)mouse_y);
- }
- else
- {
- io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
- }
-
- for (int i = 0; i < 3; i++)
- {
- io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
- g_MouseJustPressed[i] = false;
- }
-
- // Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
- ImGuiMouseCursor cursor = ImGui::GetMouseCursor();
- if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None)
- {
- glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
- }
- else
- {
- glfwSetCursor(g_Window, g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
- glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
- }
-
- // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
- ImGui::NewFrame();
-}
-
-void ImGui_ImplGlfwVulkan_Render(VkCommandBuffer command_buffer)
-{
- g_CommandBuffer = command_buffer;
- ImGui::Render();
- ImGui_ImplGlfwVulkan_RenderDrawData(ImGui::GetDrawData());
- g_CommandBuffer = VK_NULL_HANDLE;
- g_FrameIndex = (g_FrameIndex + 1) % IMGUI_VK_QUEUED_FRAMES;
-}
diff --git a/third_party/imgui/examples/vulkan_example/imgui_impl_glfw_vulkan.h b/third_party/imgui/examples/vulkan_example/imgui_impl_glfw_vulkan.h
deleted file mode 100644
index 5d2b63cc18..0000000000
--- a/third_party/imgui/examples/vulkan_example/imgui_impl_glfw_vulkan.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// ImGui GLFW binding with Vulkan + shaders
-
-// Missing features:
-// [ ] User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
-
-// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
-// If you use this binding you'll need to call 5 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXX_CreateFontsTexture(), ImGui_ImplXXXX_NewFrame(), ImGui_ImplXXXX_Render() and ImGui_ImplXXXX_Shutdown().
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-// https://github.com/ocornut/imgui
-
-struct GLFWwindow;
-
-#include
-
-#define IMGUI_VK_QUEUED_FRAMES 2
-
-struct ImGui_ImplGlfwVulkan_Init_Data
-{
- VkAllocationCallbacks* allocator;
- VkPhysicalDevice gpu;
- VkDevice device;
- VkRenderPass render_pass;
- VkPipelineCache pipeline_cache;
- VkDescriptorPool descriptor_pool;
- void (*check_vk_result)(VkResult err);
-};
-
-IMGUI_API bool ImGui_ImplGlfwVulkan_Init(GLFWwindow* window, bool install_callbacks, ImGui_ImplGlfwVulkan_Init_Data *init_data);
-IMGUI_API void ImGui_ImplGlfwVulkan_Shutdown();
-IMGUI_API void ImGui_ImplGlfwVulkan_NewFrame();
-IMGUI_API void ImGui_ImplGlfwVulkan_Render(VkCommandBuffer command_buffer);
-
-// Use if you want to reset your rendering device without losing ImGui state.
-IMGUI_API void ImGui_ImplGlfwVulkan_InvalidateFontUploadObjects();
-IMGUI_API void ImGui_ImplGlfwVulkan_InvalidateDeviceObjects();
-IMGUI_API bool ImGui_ImplGlfwVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
-IMGUI_API bool ImGui_ImplGlfwVulkan_CreateDeviceObjects();
-
-// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
-// Provided here if you want to chain callbacks.
-// You can also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
-
diff --git a/third_party/imgui/examples/vulkan_example/main.cpp b/third_party/imgui/examples/vulkan_example/main.cpp
deleted file mode 100644
index be5fe52849..0000000000
--- a/third_party/imgui/examples/vulkan_example/main.cpp
+++ /dev/null
@@ -1,754 +0,0 @@
-// ImGui - standalone example application for Glfw + Vulkan, using programmable pipeline
-// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
-
-#include "imgui.h"
-#include "imgui_impl_glfw_vulkan.h"
-
-#include // printf, fprintf
-#include // abort
-#define GLFW_INCLUDE_NONE
-#define GLFW_INCLUDE_VULKAN
-#include
-
-#define IMGUI_MAX_POSSIBLE_BACK_BUFFERS 16
-#define IMGUI_UNLIMITED_FRAME_RATE
-//#ifdef _DEBUG
-//#define IMGUI_VULKAN_DEBUG_REPORT
-//#endif
-
-static VkAllocationCallbacks* g_Allocator = NULL;
-static VkInstance g_Instance = VK_NULL_HANDLE;
-static VkSurfaceKHR g_Surface = VK_NULL_HANDLE;
-static VkPhysicalDevice g_Gpu = VK_NULL_HANDLE;
-static VkDevice g_Device = VK_NULL_HANDLE;
-static VkSwapchainKHR g_Swapchain = VK_NULL_HANDLE;
-static VkRenderPass g_RenderPass = VK_NULL_HANDLE;
-static uint32_t g_QueueFamily = 0;
-static VkQueue g_Queue = VK_NULL_HANDLE;
-static VkDebugReportCallbackEXT g_Debug_Report = VK_NULL_HANDLE;
-
-static VkSurfaceFormatKHR g_SurfaceFormat;
-static VkImageSubresourceRange g_ImageRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
-static VkPresentModeKHR g_PresentMode;
-
-static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE;
-static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
-
-static int fb_width, fb_height;
-static uint32_t g_BackbufferIndices[IMGUI_VK_QUEUED_FRAMES]; // keep track of recently rendered swapchain frame indices
-static uint32_t g_BackBufferCount = 0;
-static VkImage g_BackBuffer[IMGUI_MAX_POSSIBLE_BACK_BUFFERS] = {};
-static VkImageView g_BackBufferView[IMGUI_MAX_POSSIBLE_BACK_BUFFERS] = {};
-static VkFramebuffer g_Framebuffer[IMGUI_MAX_POSSIBLE_BACK_BUFFERS] = {};
-
-static uint32_t g_FrameIndex = 0;
-static VkCommandPool g_CommandPool[IMGUI_VK_QUEUED_FRAMES];
-static VkCommandBuffer g_CommandBuffer[IMGUI_VK_QUEUED_FRAMES];
-static VkFence g_Fence[IMGUI_VK_QUEUED_FRAMES];
-static VkSemaphore g_PresentCompleteSemaphore[IMGUI_VK_QUEUED_FRAMES];
-static VkSemaphore g_RenderCompleteSemaphore[IMGUI_VK_QUEUED_FRAMES];
-
-static VkClearValue g_ClearValue = {};
-
-static void check_vk_result(VkResult err)
-{
- if (err == 0) return;
- printf("VkResult %d\n", err);
- if (err < 0)
- abort();
-}
-
-static void resize_vulkan(GLFWwindow* /*window*/, int w, int h)
-{
- VkResult err;
- VkSwapchainKHR old_swapchain = g_Swapchain;
- err = vkDeviceWaitIdle(g_Device);
- check_vk_result(err);
-
- // Destroy old Framebuffer:
- for (uint32_t i = 0; i < g_BackBufferCount; i++)
- if (g_BackBufferView[i])
- vkDestroyImageView(g_Device, g_BackBufferView[i], g_Allocator);
- for (uint32_t i = 0; i < g_BackBufferCount; i++)
- if (g_Framebuffer[i])
- vkDestroyFramebuffer(g_Device, g_Framebuffer[i], g_Allocator);
- if (g_RenderPass)
- vkDestroyRenderPass(g_Device, g_RenderPass, g_Allocator);
-
- // Create Swapchain:
- {
- VkSwapchainCreateInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
- info.surface = g_Surface;
- info.imageFormat = g_SurfaceFormat.format;
- info.imageColorSpace = g_SurfaceFormat.colorSpace;
- info.imageArrayLayers = 1;
- info.imageUsage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
- info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
- info.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
- info.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
- info.presentMode = g_PresentMode;
- info.clipped = VK_TRUE;
- info.oldSwapchain = old_swapchain;
- VkSurfaceCapabilitiesKHR cap;
- err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(g_Gpu, g_Surface, &cap);
- check_vk_result(err);
- if (cap.maxImageCount > 0)
- info.minImageCount = (cap.minImageCount + 2 < cap.maxImageCount) ? (cap.minImageCount + 2) : cap.maxImageCount;
- else
- info.minImageCount = cap.minImageCount + 2;
-
- if (cap.currentExtent.width == 0xffffffff)
- {
- fb_width = w;
- fb_height = h;
- info.imageExtent.width = fb_width;
- info.imageExtent.height = fb_height;
- }
- else
- {
- fb_width = cap.currentExtent.width;
- fb_height = cap.currentExtent.height;
- info.imageExtent.width = fb_width;
- info.imageExtent.height = fb_height;
- }
- err = vkCreateSwapchainKHR(g_Device, &info, g_Allocator, &g_Swapchain);
- check_vk_result(err);
- err = vkGetSwapchainImagesKHR(g_Device, g_Swapchain, &g_BackBufferCount, NULL);
- check_vk_result(err);
- err = vkGetSwapchainImagesKHR(g_Device, g_Swapchain, &g_BackBufferCount, g_BackBuffer);
- check_vk_result(err);
- }
- if (old_swapchain)
- vkDestroySwapchainKHR(g_Device, old_swapchain, g_Allocator);
-
- // Create the Render Pass:
- {
- VkAttachmentDescription attachment = {};
- attachment.format = g_SurfaceFormat.format;
- attachment.samples = VK_SAMPLE_COUNT_1_BIT;
- attachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
- attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
- attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
- attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
- attachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
- attachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
- VkAttachmentReference color_attachment = {};
- color_attachment.attachment = 0;
- color_attachment.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- VkSubpassDescription subpass = {};
- subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
- subpass.colorAttachmentCount = 1;
- subpass.pColorAttachments = &color_attachment;
- VkRenderPassCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
- info.attachmentCount = 1;
- info.pAttachments = &attachment;
- info.subpassCount = 1;
- info.pSubpasses = &subpass;
- err = vkCreateRenderPass(g_Device, &info, g_Allocator, &g_RenderPass);
- check_vk_result(err);
- }
-
- // Create The Image Views
- {
- VkImageViewCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
- info.viewType = VK_IMAGE_VIEW_TYPE_2D;
- info.format = g_SurfaceFormat.format;
- info.components.r = VK_COMPONENT_SWIZZLE_R;
- info.components.g = VK_COMPONENT_SWIZZLE_G;
- info.components.b = VK_COMPONENT_SWIZZLE_B;
- info.components.a = VK_COMPONENT_SWIZZLE_A;
- info.subresourceRange = g_ImageRange;
- for (uint32_t i = 0; i < g_BackBufferCount; i++)
- {
- info.image = g_BackBuffer[i];
- err = vkCreateImageView(g_Device, &info, g_Allocator, &g_BackBufferView[i]);
- check_vk_result(err);
- }
- }
-
- // Create Framebuffer:
- {
- VkImageView attachment[1];
- VkFramebufferCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
- info.renderPass = g_RenderPass;
- info.attachmentCount = 1;
- info.pAttachments = attachment;
- info.width = fb_width;
- info.height = fb_height;
- info.layers = 1;
- for (uint32_t i = 0; i < g_BackBufferCount; i++)
- {
- attachment[0] = g_BackBufferView[i];
- err = vkCreateFramebuffer(g_Device, &info, g_Allocator, &g_Framebuffer[i]);
- check_vk_result(err);
- }
- }
-}
-
-#ifdef IMGUI_VULKAN_DEBUG_REPORT
-static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(
- VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
-{
- printf("[vulkan] ObjectType: %i\nMessage: %s\n\n", objectType, pMessage );
- return VK_FALSE;
-}
-#endif // IMGUI_VULKAN_DEBUG_REPORT
-
-static void setup_vulkan(GLFWwindow* window)
-{
- VkResult err;
-
- // Create Vulkan Instance
- {
- uint32_t extensions_count;
- const char** glfw_extensions = glfwGetRequiredInstanceExtensions(&extensions_count);
-
- VkInstanceCreateInfo create_info = {};
- create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
- create_info.enabledExtensionCount = extensions_count;
- create_info.ppEnabledExtensionNames = glfw_extensions;
-
-#ifdef IMGUI_VULKAN_DEBUG_REPORT
- // enabling multiple validation layers grouped as lunarg standard validation
- const char* layers[] = {"VK_LAYER_LUNARG_standard_validation"};
- create_info.enabledLayerCount = 1;
- create_info.ppEnabledLayerNames = layers;
-
- // need additional storage for char pointer to debug report extension
- const char** extensions = (const char**)malloc(sizeof(const char*) * (extensions_count + 1));
- for (size_t i = 0; i < extensions_count; i++)
- extensions[i] = glfw_extensions[i];
- extensions[ extensions_count ] = "VK_EXT_debug_report";
- create_info.enabledExtensionCount = extensions_count+1;
- create_info.ppEnabledExtensionNames = extensions;
-#endif // IMGUI_VULKAN_DEBUG_REPORT
-
- err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
- check_vk_result(err);
-
-#ifdef IMGUI_VULKAN_DEBUG_REPORT
- free(extensions);
-
- // create the debug report callback
- VkDebugReportCallbackCreateInfoEXT debug_report_ci ={};
- debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
- debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
- debug_report_ci.pfnCallback = debug_report;
- debug_report_ci.pUserData = NULL;
-
- // get the proc address of the function pointer, required for used extensions
- PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT =
- (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
-
- err = vkCreateDebugReportCallbackEXT( g_Instance, &debug_report_ci, g_Allocator, &g_Debug_Report );
- check_vk_result(err);
-#endif // IMGUI_VULKAN_DEBUG_REPORT
- }
-
- // Create Window Surface
- {
- err = glfwCreateWindowSurface(g_Instance, window, g_Allocator, &g_Surface);
- check_vk_result(err);
- }
-
- // Get GPU
- {
- uint32_t gpu_count;
- err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, NULL);
- check_vk_result(err);
-
- VkPhysicalDevice* gpus = (VkPhysicalDevice*)malloc(sizeof(VkPhysicalDevice) * gpu_count);
- err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus);
- check_vk_result(err);
-
- // If a number >1 of GPUs got reported, you should find the best fit GPU for your purpose
- // e.g. VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU if available, or with the greatest memory available, etc.
- // for sake of simplicity we'll just take the first one, assuming it has a graphics queue family.
- g_Gpu = gpus[0];
- free(gpus);
- }
-
- // Get queue
- {
- uint32_t count;
- vkGetPhysicalDeviceQueueFamilyProperties(g_Gpu, &count, NULL);
- VkQueueFamilyProperties* queues = (VkQueueFamilyProperties*)malloc(sizeof(VkQueueFamilyProperties) * count);
- vkGetPhysicalDeviceQueueFamilyProperties(g_Gpu, &count, queues);
- for (uint32_t i = 0; i < count; i++)
- {
- if (queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
- {
- g_QueueFamily = i;
- break;
- }
- }
- free(queues);
- }
-
- // Check for WSI support
- {
- VkBool32 res;
- vkGetPhysicalDeviceSurfaceSupportKHR(g_Gpu, g_QueueFamily, g_Surface, &res);
- if (res != VK_TRUE)
- {
- fprintf(stderr, "Error no WSI support on physical device 0\n");
- exit(-1);
- }
- }
-
- // Get Surface Format
- {
- // Per Spec Format and View Format are expected to be the same unless VK_IMAGE_CREATE_MUTABLE_BIT was set at image creation
- // Assuming that the default behavior is without setting this bit, there is no need for separate Spawchain image and image view format
- // additionally several new color spaces were introduced with Vulkan Spec v1.0.40
- // hence we must make sure that a format with the mostly available color space, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, is found and used
- uint32_t count;
- vkGetPhysicalDeviceSurfaceFormatsKHR(g_Gpu, g_Surface, &count, NULL);
- VkSurfaceFormatKHR *formats = (VkSurfaceFormatKHR*)malloc(sizeof(VkSurfaceFormatKHR) * count);
- vkGetPhysicalDeviceSurfaceFormatsKHR(g_Gpu, g_Surface, &count, formats);
-
- // first check if only one format, VK_FORMAT_UNDEFINED, is available, which would imply that any format is available
- if (count == 1)
- {
- if( formats[0].format == VK_FORMAT_UNDEFINED )
- {
- g_SurfaceFormat.format = VK_FORMAT_B8G8R8A8_UNORM;
- g_SurfaceFormat.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
- }
- else
- { // no point in searching another format
- g_SurfaceFormat = formats[0];
- }
- }
- else
- {
- // request several formats, the first found will be used
- VkFormat requestSurfaceImageFormat[] = {VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM};
- VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
- bool requestedFound = false;
- for (size_t i = 0; i < sizeof(requestSurfaceImageFormat) / sizeof(requestSurfaceImageFormat[0]); i++)
- {
- if( requestedFound ) {
- break;
- }
- for (uint32_t j = 0; j < count; j++)
- {
- if (formats[j].format == requestSurfaceImageFormat[i] && formats[j].colorSpace == requestSurfaceColorSpace)
- {
- g_SurfaceFormat = formats[j];
- requestedFound = true;
- }
- }
- }
-
- // if none of the requested image formats could be found, use the first available
- if (!requestedFound)
- g_SurfaceFormat = formats[0];
- }
- free(formats);
- }
-
-
- // Get Present Mode
- {
- // Requst a certain mode and confirm that it is available. If not use VK_PRESENT_MODE_FIFO_KHR which is mandatory
-#ifdef IMGUI_UNLIMITED_FRAME_RATE
- g_PresentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
-#else
- g_PresentMode = VK_PRESENT_MODE_FIFO_KHR;
-#endif
- uint32_t count = 0;
- vkGetPhysicalDeviceSurfacePresentModesKHR(g_Gpu, g_Surface, &count, nullptr);
- VkPresentModeKHR* presentModes = (VkPresentModeKHR*)malloc(sizeof(VkQueueFamilyProperties) * count);
- vkGetPhysicalDeviceSurfacePresentModesKHR(g_Gpu, g_Surface, &count, presentModes);
- bool presentModeAvailable = false;
- for (size_t i = 0; i < count; i++)
- {
- if (presentModes[i] == g_PresentMode)
- {
- presentModeAvailable = true;
- break;
- }
- }
- if( !presentModeAvailable )
- g_PresentMode = VK_PRESENT_MODE_FIFO_KHR; // always available
- }
-
-
- // Create Logical Device
- {
- int device_extension_count = 1;
- const char* device_extensions[] = {"VK_KHR_swapchain"};
- const uint32_t queue_index = 0;
- const uint32_t queue_count = 1;
- const float queue_priority[] = {1.0f};
- VkDeviceQueueCreateInfo queue_info[1] = {};
- queue_info[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
- queue_info[0].queueFamilyIndex = g_QueueFamily;
- queue_info[0].queueCount = queue_count;
- queue_info[0].pQueuePriorities = queue_priority;
- VkDeviceCreateInfo create_info = {};
- create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
- create_info.queueCreateInfoCount = sizeof(queue_info)/sizeof(queue_info[0]);
- create_info.pQueueCreateInfos = queue_info;
- create_info.enabledExtensionCount = device_extension_count;
- create_info.ppEnabledExtensionNames = device_extensions;
- err = vkCreateDevice(g_Gpu, &create_info, g_Allocator, &g_Device);
- check_vk_result(err);
- vkGetDeviceQueue(g_Device, g_QueueFamily, queue_index, &g_Queue);
- }
-
- // Create Framebuffers
- {
- int w, h;
- glfwGetFramebufferSize(window, &w, &h);
- resize_vulkan(window, w, h);
- glfwSetFramebufferSizeCallback(window, resize_vulkan);
- }
-
- // Create Command Buffers
- for (int i = 0; i < IMGUI_VK_QUEUED_FRAMES; i++)
- {
- {
- VkCommandPoolCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
- info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
- info.queueFamilyIndex = g_QueueFamily;
- err = vkCreateCommandPool(g_Device, &info, g_Allocator, &g_CommandPool[i]);
- check_vk_result(err);
- }
- {
- VkCommandBufferAllocateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
- info.commandPool = g_CommandPool[i];
- info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
- info.commandBufferCount = 1;
- err = vkAllocateCommandBuffers(g_Device, &info, &g_CommandBuffer[i]);
- check_vk_result(err);
- }
- {
- VkFenceCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
- info.flags = VK_FENCE_CREATE_SIGNALED_BIT;
- err = vkCreateFence(g_Device, &info, g_Allocator, &g_Fence[i]);
- check_vk_result(err);
- }
- {
- VkSemaphoreCreateInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
- err = vkCreateSemaphore(g_Device, &info, g_Allocator, &g_PresentCompleteSemaphore[i]);
- check_vk_result(err);
- err = vkCreateSemaphore(g_Device, &info, g_Allocator, &g_RenderCompleteSemaphore[i]);
- check_vk_result(err);
- }
- }
-
- // Create Descriptor Pool
- {
- VkDescriptorPoolSize pool_size[11] =
- {
- { VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
- { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 },
- { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 },
- { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
- { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 },
- { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 },
- { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 },
- { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 },
- { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
- { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
- { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 }
- };
- VkDescriptorPoolCreateInfo pool_info = {};
- pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
- pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
- pool_info.maxSets = 1000 * 11;
- pool_info.poolSizeCount = 11;
- pool_info.pPoolSizes = pool_size;
- err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
- check_vk_result(err);
- }
-}
-
-static void cleanup_vulkan()
-{
- vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
- for (int i = 0; i < IMGUI_VK_QUEUED_FRAMES; i++)
- {
- vkDestroyFence(g_Device, g_Fence[i], g_Allocator);
- vkFreeCommandBuffers(g_Device, g_CommandPool[i], 1, &g_CommandBuffer[i]);
- vkDestroyCommandPool(g_Device, g_CommandPool[i], g_Allocator);
- vkDestroySemaphore(g_Device, g_PresentCompleteSemaphore[i], g_Allocator);
- vkDestroySemaphore(g_Device, g_RenderCompleteSemaphore[i], g_Allocator);
- }
- for (uint32_t i = 0; i < g_BackBufferCount; i++)
- {
- vkDestroyImageView(g_Device, g_BackBufferView[i], g_Allocator);
- vkDestroyFramebuffer(g_Device, g_Framebuffer[i], g_Allocator);
- }
- vkDestroyRenderPass(g_Device, g_RenderPass, g_Allocator);
- vkDestroySwapchainKHR(g_Device, g_Swapchain, g_Allocator);
- vkDestroySurfaceKHR(g_Instance, g_Surface, g_Allocator);
-
-#ifdef IMGUI_VULKAN_DEBUG_REPORT
- // get the proc address of the function pointer, required for used extensions
- auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
- vkDestroyDebugReportCallbackEXT(g_Instance, g_Debug_Report, g_Allocator);
-#endif // IMGUI_VULKAN_DEBUG_REPORT
-
- vkDestroyDevice(g_Device, g_Allocator);
- vkDestroyInstance(g_Instance, g_Allocator);
-}
-
-static void frame_begin()
-{
- VkResult err;
- for (;;)
- {
- err = vkWaitForFences(g_Device, 1, &g_Fence[g_FrameIndex], VK_TRUE, 100);
- if (err == VK_SUCCESS) break;
- if (err == VK_TIMEOUT) continue;
- check_vk_result(err);
- }
- {
- err = vkAcquireNextImageKHR(g_Device, g_Swapchain, UINT64_MAX, g_PresentCompleteSemaphore[g_FrameIndex], VK_NULL_HANDLE, &g_BackbufferIndices[g_FrameIndex]);
- check_vk_result(err);
- }
- {
- err = vkResetCommandPool(g_Device, g_CommandPool[g_FrameIndex], 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(g_CommandBuffer[g_FrameIndex], &info);
- check_vk_result(err);
- }
- {
- VkRenderPassBeginInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- info.renderPass = g_RenderPass;
- info.framebuffer = g_Framebuffer[g_BackbufferIndices[g_FrameIndex]];
- info.renderArea.extent.width = fb_width;
- info.renderArea.extent.height = fb_height;
- info.clearValueCount = 1;
- info.pClearValues = &g_ClearValue;
- vkCmdBeginRenderPass(g_CommandBuffer[g_FrameIndex], &info, VK_SUBPASS_CONTENTS_INLINE);
- }
-}
-
-static void frame_end()
-{
- VkResult err;
- vkCmdEndRenderPass(g_CommandBuffer[g_FrameIndex]);
- {
- VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- VkSubmitInfo info = {};
- info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &g_PresentCompleteSemaphore[g_FrameIndex];
- info.pWaitDstStageMask = &wait_stage;
- info.commandBufferCount = 1;
- info.pCommandBuffers = &g_CommandBuffer[g_FrameIndex];
- info.signalSemaphoreCount = 1;
- info.pSignalSemaphores = &g_RenderCompleteSemaphore[g_FrameIndex];
-
- err = vkEndCommandBuffer(g_CommandBuffer[g_FrameIndex]);
- check_vk_result(err);
- err = vkResetFences(g_Device, 1, &g_Fence[g_FrameIndex]);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &info, g_Fence[g_FrameIndex]);
- check_vk_result(err);
- }
-}
-
-static void frame_present()
-{
- VkResult err;
- // If IMGUI_UNLIMITED_FRAME_RATE is defined we present the latest but one frame. Otherwise we present the latest rendered frame
-#ifdef IMGUI_UNLIMITED_FRAME_RATE
- uint32_t PresentIndex = (g_FrameIndex + IMGUI_VK_QUEUED_FRAMES - 1) % IMGUI_VK_QUEUED_FRAMES;
-#else
- uint32_t PresentIndex = g_FrameIndex;
-#endif // IMGUI_UNLIMITED_FRAME_RATE
-
- VkSwapchainKHR swapchains[1] = {g_Swapchain};
- uint32_t indices[1] = {g_BackbufferIndices[PresentIndex]};
- VkPresentInfoKHR info = {};
- info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
- info.waitSemaphoreCount = 1;
- info.pWaitSemaphores = &g_RenderCompleteSemaphore[PresentIndex];
- info.swapchainCount = 1;
- info.pSwapchains = swapchains;
- info.pImageIndices = indices;
- err = vkQueuePresentKHR(g_Queue, &info);
- check_vk_result(err);
-
- g_FrameIndex = (g_FrameIndex + 1) % IMGUI_VK_QUEUED_FRAMES;
-}
-
-static void error_callback(int error, const char* description)
-{
- fprintf(stderr, "Error %d: %s\n", error, description);
-}
-
-int main(int, char**)
-{
- // Setup window
- glfwSetErrorCallback(error_callback);
- if (!glfwInit())
- return 1;
-
- glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
- GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui Vulkan example", NULL, NULL);
-
- // Setup Vulkan
- if (!glfwVulkanSupported())
- {
- printf("GLFW: Vulkan Not Supported\n");
- return 1;
- }
- setup_vulkan(window);
-
- // Setup ImGui binding
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- ImGui_ImplGlfwVulkan_Init_Data init_data = {};
- init_data.allocator = g_Allocator;
- init_data.gpu = g_Gpu;
- init_data.device = g_Device;
- init_data.render_pass = g_RenderPass;
- init_data.pipeline_cache = g_PipelineCache;
- init_data.descriptor_pool = g_DescriptorPool;
- init_data.check_vk_result = check_vk_result;
- ImGui_ImplGlfwVulkan_Init(window, true, &init_data);
- //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
-
- // Setup style
- ImGui::StyleColorsDark();
- //ImGui::StyleColorsClassic();
-
- // 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);
-
- // Upload Fonts
- {
- VkResult err;
- err = vkResetCommandPool(g_Device, g_CommandPool[g_FrameIndex], 0);
- check_vk_result(err);
- VkCommandBufferBeginInfo begin_info = {};
- begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- begin_info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
- err = vkBeginCommandBuffer(g_CommandBuffer[g_FrameIndex], &begin_info);
- check_vk_result(err);
-
- ImGui_ImplGlfwVulkan_CreateFontsTexture(g_CommandBuffer[g_FrameIndex]);
-
- VkSubmitInfo end_info = {};
- end_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
- end_info.commandBufferCount = 1;
- end_info.pCommandBuffers = &g_CommandBuffer[g_FrameIndex];
- err = vkEndCommandBuffer(g_CommandBuffer[g_FrameIndex]);
- check_vk_result(err);
- err = vkQueueSubmit(g_Queue, 1, &end_info, VK_NULL_HANDLE);
- check_vk_result(err);
-
- err = vkDeviceWaitIdle(g_Device);
- check_vk_result(err);
- ImGui_ImplGlfwVulkan_InvalidateFontUploadObjects();
- }
-
- bool show_demo_window = true;
- bool show_another_window = false;
- ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
-
- // When IMGUI_UNLIMITED_FRAME_RATE is defined we render into latest image acquired from the swapchain but we display the image which was rendered before.
- // Hence we must render once and increase the g_FrameIndex without presenting, which we do before entering the render loop.
- // This is also the reason why frame_end() is split into frame_end() and frame_present(), the later one not being called here.
-#ifdef IMGUI_UNLIMITED_FRAME_RATE
- ImGui_ImplGlfwVulkan_NewFrame();
- frame_begin();
- ImGui_ImplGlfwVulkan_Render(g_CommandBuffer[g_FrameIndex]);
- frame_end();
- g_FrameIndex = (g_FrameIndex + 1) % IMGUI_VK_QUEUED_FRAMES;
-#endif // IMGUI_UNLIMITED_FRAME_RATE
-
- // Main loop
- while (!glfwWindowShouldClose(window))
- {
- // 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.
- glfwPollEvents();
- ImGui_ImplGlfwVulkan_NewFrame();
-
- // 1. Show a simple window.
- // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
- {
- static float f = 0.0f;
- static int counter = 0;
- ImGui::Text("Hello, world!"); // Display some text (you can use a format string too)
- 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
-
- ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state
- ImGui::Checkbox("Another Window", &show_another_window);
-
- if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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);
- }
-
- // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
- if (show_another_window)
- {
- ImGui::Begin("Another Window", &show_another_window);
- ImGui::Text("Hello from another window!");
- if (ImGui::Button("Close Me"))
- show_another_window = false;
- ImGui::End();
- }
-
- // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
- if (show_demo_window)
- {
- ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
- ImGui::ShowDemoWindow(&show_demo_window);
- }
-
- memcpy(&g_ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
- frame_begin();
- ImGui_ImplGlfwVulkan_Render(g_CommandBuffer[g_FrameIndex]);
- frame_end();
- frame_present();
- }
-
- // Cleanup
- VkResult err = vkDeviceWaitIdle(g_Device);
- check_vk_result(err);
- ImGui_ImplGlfwVulkan_Shutdown();
- ImGui::DestroyContext();
- cleanup_vulkan();
- glfwTerminate();
-
- return 0;
-}
diff --git a/third_party/imgui/imconfig.h b/third_party/imgui/imconfig.h
new file mode 100644
index 0000000000..c6817de7cc
--- /dev/null
+++ b/third_party/imgui/imconfig.h
@@ -0,0 +1,108 @@
+//-----------------------------------------------------------------------------
+// COMPILE-TIME OPTIONS FOR DEAR IMGUI
+// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
+// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
+//-----------------------------------------------------------------------------
+// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/branch with your modifications to imconfig.h)
+// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
+// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include
+// the imgui*.cpp files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
+// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
+// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
+//-----------------------------------------------------------------------------
+
+#pragma once
+
+//---- Define assertion handler. Defaults to calling assert().
+// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
+//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
+//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
+
+//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
+// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
+//#define IMGUI_API __declspec( dllexport )
+//#define IMGUI_API __declspec( dllimport )
+
+//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
+//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+
+//---- Disable all of Dear ImGui or don't implement standard windows.
+// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
+//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
+//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
+//#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty.
+
+//---- Don't implement some functions to reduce linkage requirements.
+//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
+//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
+//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
+//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
+//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
+//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
+//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
+//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
+
+//---- Include imgui_user.h at the end of imgui.h as a convenience
+//#define IMGUI_INCLUDE_IMGUI_USER_H
+
+//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
+//#define IMGUI_USE_BGRA_PACKED_COLOR
+
+//---- Use 32-bit for ImWchar (default is 16-bit) to support full unicode code points.
+//#define IMGUI_USE_WCHAR32
+
+//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
+// By default the embedded implementations are declared static and not available outside of imgui cpp files.
+//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
+//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
+//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
+//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
+
+//---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library.
+// Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
+// #define IMGUI_USE_STB_SPRINTF
+
+//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
+// This will be inlined as part of ImVec2 and ImVec4 class declarations.
+/*
+#define IM_VEC2_CLASS_EXTRA \
+ ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
+ operator MyVec2() const { return MyVec2(x,y); }
+
+#define IM_VEC4_CLASS_EXTRA \
+ ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
+ operator MyVec4() const { return MyVec4(x,y,z,w); }
+*/
+
+//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
+// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices).
+// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
+// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
+//#define ImDrawIdx unsigned int
+
+//---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly)
+//struct ImDrawList;
+//struct ImDrawCmd;
+//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
+//#define ImDrawCallback MyImDrawCallback
+
+//---- Debug Tools: Macro to break in Debugger
+// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
+//#define IM_DEBUG_BREAK IM_ASSERT(0)
+//#define IM_DEBUG_BREAK __debugbreak()
+
+//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
+// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
+// This adds a small runtime cost which is why it is not enabled by default.
+//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
+
+//---- Debug Tools: Enable slower asserts
+//#define IMGUI_DEBUG_PARANOID
+
+//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
+/*
+namespace ImGui
+{
+ void MyFunction(const char* name, const MyMatrix44& v);
+}
+*/
diff --git a/third_party/imgui/imgui.cpp b/third_party/imgui/imgui.cpp
index 3a6d681ecd..2b5983a382 100644
--- a/third_party/imgui/imgui.cpp
+++ b/third_party/imgui/imgui.cpp
@@ -1,60 +1,107 @@
-// dear imgui, v1.60 WIP
+// dear imgui, v1.77
// (main code and documentation)
-// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
-// Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase.
-// Get latest version at https://github.com/ocornut/imgui
-// Releases change-log at https://github.com/ocornut/imgui/releases
-// Gallery (please post your screenshots/video there!): https://github.com/ocornut/imgui/issues/1269
+// Help:
+// - Read FAQ at http://dearimgui.org/faq
+// - Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase.
+// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that.
+// Read imgui.cpp for details, links and comments.
+
+// Resources:
+// - FAQ http://dearimgui.org/faq
+// - Homepage & latest https://github.com/ocornut/imgui
+// - Releases & changelog https://github.com/ocornut/imgui/releases
+// - Gallery https://github.com/ocornut/imgui/issues/3075 (please post your screenshots/video there!)
+// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
+// - Wiki https://github.com/ocornut/imgui/wiki
+// - Issues & support https://github.com/ocornut/imgui/issues
+
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
-// This library is free but I need your support to sustain development and maintenance.
-// If you work for a company, please consider financial support, see Readme. For individuals: https://www.patreon.com/imgui
+// See LICENSE.txt for copyright and licensing details (standard MIT License).
+// This library is free but needs your support to sustain development and maintenance.
+// Businesses: you can support continued development via invoiced technical support, maintenance and sponsoring contracts. Please reach out to "contact AT dearimgui.org".
+// Individuals: you can support continued development via donations. See docs/README or web page.
+
+// It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library.
+// Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without
+// modifying imgui.h or imgui.cpp. You may include imgui_internal.h to access internal data structures, but it doesn't
+// come with any guarantee of forward compatibility. Discussing your changes on the GitHub Issue Tracker may lead you
+// to a better solution or official support for them.
/*
- Index
- - MISSION STATEMENT
- - END-USER GUIDE
- - PROGRAMMER GUIDE (read me!)
- - Read first
- - How to update to a newer version of Dear ImGui
- - Getting started with integrating Dear ImGui in your code/engine
- - Using gamepad/keyboard navigation [BETA]
- - API BREAKING CHANGES (read me when you update!)
- - ISSUES & TODO LIST
- - FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
- - How can I help?
- - How can I display an image? What is ImTextureID, how does it works?
- - How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels and the ID stack.
- - How can I tell when Dear ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?
- - How can I load a different font than the default?
- - How can I easily use icons in my application?
- - How can I load multiple fonts?
- - How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
- - How can I preserve my Dear ImGui context across reloading a DLL? (loss of the global/static variables)
- - How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
- - I integrated Dear ImGui in my engine and the text or lines are blurry..
- - I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
- - ISSUES & TODO-LIST
- - CODE
+Index of this file:
+DOCUMENTATION
+
+- MISSION STATEMENT
+- END-USER GUIDE
+- PROGRAMMER GUIDE
+ - READ FIRST
+ - HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI
+ - GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE
+ - HOW A SIMPLE APPLICATION MAY LOOK LIKE
+ - HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE
+ - USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS
+- API BREAKING CHANGES (read me when you update!)
+- FREQUENTLY ASKED QUESTIONS (FAQ)
+ - Read all answers online: https://www.dearimgui.org/faq, or in docs/FAQ.md (with a Markdown viewer)
+
+CODE
+(search for "[SECTION]" in the code to find them)
+
+// [SECTION] INCLUDES
+// [SECTION] FORWARD DECLARATIONS
+// [SECTION] CONTEXT AND MEMORY ALLOCATORS
+// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
+// [SECTION] MISC HELPERS/UTILITIES (Geometry functions)
+// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions)
+// [SECTION] MISC HELPERS/UTILITIES (File functions)
+// [SECTION] MISC HELPERS/UTILITIES (ImText* functions)
+// [SECTION] MISC HELPERS/UTILITIES (Color functions)
+// [SECTION] ImGuiStorage
+// [SECTION] ImGuiTextFilter
+// [SECTION] ImGuiTextBuffer
+// [SECTION] ImGuiListClipper
+// [SECTION] STYLING
+// [SECTION] RENDER HELPERS
+// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
+// [SECTION] ERROR CHECKING
+// [SECTION] LAYOUT
+// [SECTION] SCROLLING
+// [SECTION] TOOLTIPS
+// [SECTION] POPUPS
+// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
+// [SECTION] DRAG AND DROP
+// [SECTION] LOGGING/CAPTURING
+// [SECTION] SETTINGS
+// [SECTION] PLATFORM DEPENDENT HELPERS
+// [SECTION] METRICS/DEBUG WINDOW
+
+*/
+
+//-----------------------------------------------------------------------------
+// DOCUMENTATION
+//-----------------------------------------------------------------------------
+
+/*
MISSION STATEMENT
=================
- - Easy to use to create code-driven and data-driven tools
- - Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools
- - Easy to hack and improve
- - Minimize screen real-estate usage
- - Minimize setup and maintenance
- - Minimize state storage on user side
- - Portable, minimize dependencies, run on target (consoles, phones, etc.)
- - Efficient runtime and memory consumption (NB- we do allocate when "growing" content e.g. creating a window, opening a tree node
- for the first time, etc. but a typical frame won't allocate anything)
+ - Easy to use to create code-driven and data-driven tools.
+ - Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools.
+ - Easy to hack and improve.
+ - Minimize screen real-estate usage.
+ - Minimize setup and maintenance.
+ - Minimize state storage on user side.
+ - Portable, minimize dependencies, run on target (consoles, phones, etc.).
+ - Efficient runtime and memory consumption (NB- we do allocate when "growing" content e.g. creating a window,.
+ opening a tree node for the first time, etc. but a typical frame should not allocate anything).
Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes:
- - Doesn't look fancy, doesn't animate
- - Limited layout features, intricate layouts are typically crafted in code
+ - Doesn't look fancy, doesn't animate.
+ - Limited layout features, intricate layouts are typically crafted in code.
END-USER GUIDE
@@ -77,109 +124,174 @@
- ESCAPE to revert text to its original value.
- You can apply arithmetic operators +,*,/ on numerical values. Use +- to subtract (because - would set a negative value!)
- Controls are automatically adjusted for OSX to match standard OSX text editing operations.
- - Gamepad navigation: see suggested mappings in imgui.h ImGuiNavInput_
+ - General Keyboard controls: enable with ImGuiConfigFlags_NavEnableKeyboard.
+ - General Gamepad controls: enable with ImGuiConfigFlags_NavEnableGamepad. See suggested mappings in imgui.h ImGuiNavInput_ + download PNG/PSD at http://goo.gl/9LgVZW
PROGRAMMER GUIDE
================
READ FIRST
-
- - Read the FAQ below this section!
- - Your code creates the UI, if your code doesn't run the UI is gone! == very dynamic UI, no construction/destructions steps, less data retention
- on your side, no state duplication, less sync, less bugs.
+ ----------
+ - Remember to read the FAQ (https://www.dearimgui.org/faq)
+ - Your code creates the UI, if your code doesn't run the UI is gone! The UI can be highly dynamic, there are no construction
+ or destruction steps, less superfluous data retention on your side, less state duplication, less state synchronization, less bugs.
- Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features.
- - You can learn about immediate-mode gui principles at http://www.johno.se/book/imgui.html or watch http://mollyrocket.com/861
+ - The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build.
+ - Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori).
+ You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links in the FAQ.
+ - Dear ImGui is a "single pass" rasterizing implementation of the IMGUI paradigm, aimed at ease of use and high-performances.
+ For every application frame your UI code will be called only once. This is in contrast to e.g. Unity's own implementation of an IMGUI,
+ where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches.
+ - Our origin are on the top-left. In axis aligned bounding boxes, Min = top-left, Max = bottom-right.
+ - This codebase is also optimized to yield decent performances with typical "Debug" builds settings.
+ - Please make sure you have asserts enabled (IM_ASSERT redirects to assert() by default, but can be redirected).
+ If you get an assert, read the messages and comments around the assert.
+ - C++: this is a very C-ish codebase: we don't rely on C++11, we don't include any C++ headers, and ImGui:: is a namespace.
+ - C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types.
+ See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that.
+ However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase.
+ - C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!).
+
HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI
-
+ ----------------------------------------------
- Overwrite all the sources files except for imconfig.h (if you have made modification to your copy of imconfig.h)
- - Read the "API BREAKING CHANGES" section (below). This is where we list occasional API breaking changes.
- If a function/type has been renamed / or marked obsolete, try to fix the name in your code before it is permanently removed from the public API.
- If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it.
- Please report any issue to the GitHub page!
+ - Or maintain your own branch where you have imconfig.h modified.
+ - Read the "API BREAKING CHANGES" section (below). This is where we list occasional API breaking changes.
+ If a function/type has been renamed / or marked obsolete, try to fix the name in your code before it is permanently removed
+ from the public API. If you have a problem with a missing function/symbols, search for its name in the code, there will
+ likely be a comment about it. Please report any issue to the GitHub page!
- Try to keep your copy of dear imgui reasonably up to date.
+
GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE
-
- - Add the Dear ImGui source files to your projects, using your preferred build system.
- It is recommended you build the .cpp files as part of your project and not as a library.
- - You can later customize the imconfig.h file to tweak some compilation time behavior, such as integrating imgui types with your own maths types.
- - See examples/ folder for standalone sample applications.
- - You may be able to grab and copy a ready made imgui_impl_*** file from the examples/.
+ ---------------------------------------------------------------
+ - Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library.
+ - In the majority of cases you should be able to use unmodified back-ends files available in the examples/ folder.
+ - Add the Dear ImGui source files + selected back-end source files to your projects or using your preferred build system.
+ It is recommended you build and statically link the .cpp files as part of your project and NOT as shared library (DLL).
+ - You can later customize the imconfig.h file to tweak some compile-time behavior, such as integrating Dear ImGui types with your own maths types.
- When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them.
+ - Dear ImGui never touches or knows about your GPU state. The only function that knows about GPU is the draw function that you provide.
+ Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render"
+ phases of your own application. All rendering information are stored into command-lists that you will retrieve after calling ImGui::Render().
+ - Refer to the bindings and demo applications in the examples/ folder for instruction on how to setup your code.
+ - If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder.
- - Init: retrieve the ImGuiIO structure with ImGui::GetIO() and fill the fields marked 'Settings': at minimum you need to set io.DisplaySize
- (application resolution). Later on you will fill your keyboard mapping, clipboard handlers, and other advanced features but for a basic
- integration you don't need to worry about it all.
- - Init: call io.Fonts->GetTexDataAsRGBA32(...), it will build the font atlas texture, then load the texture pixels into graphics memory.
- - Every frame:
- - In your main loop as early a possible, fill the IO fields marked 'Input' (e.g. mouse position, buttons, keyboard info, etc.)
- - Call ImGui::NewFrame() to begin the frame
- - You can use any ImGui function you want between NewFrame() and Render()
- - Call ImGui::Render() as late as you can to end the frame and finalize render data. it will call your io.RenderDrawListFn handler.
- (Even if you don't render, call Render() and ignore the callback, or call EndFrame() instead. Otherwhise some features will break)
- - All rendering information are stored into command-lists until ImGui::Render() is called.
- - Dear ImGui never touches or knows about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you provide.
- - Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases
- of your own application.
- - Refer to the examples applications in the examples/ folder for instruction on how to setup your code.
- - A minimal application skeleton may be:
- // Application init
+ HOW A SIMPLE APPLICATION MAY LOOK LIKE
+ --------------------------------------
+ EXHIBIT 1: USING THE EXAMPLE BINDINGS (= imgui_impl_XXX.cpp files from the examples/ folder).
+ The sub-folders in examples/ contains examples applications following this structure.
+
+ // Application init: create a dear imgui context, setup some options, load fonts
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
- io.DisplaySize.x = 1920.0f;
- io.DisplaySize.y = 1280.0f;
- // TODO: Fill others settings of the io structure later.
+ // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls.
+ // TODO: Fill optional fields of the io structure later.
+ // TODO: Load TTF/OTF fonts if you don't want to use the default font.
- // Load texture atlas (there is a default font so you don't need to care about choosing a font yet)
- unsigned char* pixels;
+ // Initialize helper Platform and Renderer bindings (here we are using imgui_impl_win32.cpp and imgui_impl_dx11.cpp)
+ ImGui_ImplWin32_Init(hwnd);
+ ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
+
+ // Application main loop
+ while (true)
+ {
+ // Feed inputs to dear imgui, start new frame
+ ImGui_ImplDX11_NewFrame();
+ ImGui_ImplWin32_NewFrame();
+ ImGui::NewFrame();
+
+ // Any application code here
+ ImGui::Text("Hello, world!");
+
+ // Render dear imgui into screen
+ ImGui::Render();
+ ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
+ g_pSwapChain->Present(1, 0);
+ }
+
+ // Shutdown
+ ImGui_ImplDX11_Shutdown();
+ ImGui_ImplWin32_Shutdown();
+ ImGui::DestroyContext();
+
+ EXHIBIT 2: IMPLEMENTING CUSTOM BINDING / CUSTOM ENGINE
+
+ // Application init: create a dear imgui context, setup some options, load fonts
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO();
+ // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls.
+ // TODO: Fill optional fields of the io structure later.
+ // TODO: Load TTF/OTF fonts if you don't want to use the default font.
+
+ // Build and load the texture atlas into a texture
+ // (In the examples/ app this is usually done within the ImGui_ImplXXX_Init() function from one of the demo Renderer)
int width, height;
- io.Fonts->GetTexDataAsRGBA32(pixels, &width, &height);
- // TODO: At this points you've got the texture data and you need to upload that your your graphic system:
- MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA)
- // TODO: Store your texture pointer/identifier (whatever your engine uses) in 'io.Fonts->TexID'. This will be passed back to your via the renderer.
+ unsigned char* pixels = NULL;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
+
+ // At this point you've got the texture data and you need to upload that your your graphic system:
+ // After we have created the texture, store its pointer/identifier (_in whichever format your engine uses_) in 'io.Fonts->TexID'.
+ // This will be passed back to your via the renderer. Basically ImTextureID == void*. Read FAQ for details about ImTextureID.
+ MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA32)
io.Fonts->TexID = (void*)texture;
// Application main loop
while (true)
{
- // Setup low-level inputs (e.g. on Win32, GetKeyboardState(), or write to those fields from your Windows message loop handlers, etc.)
- ImGuiIO& io = ImGui::GetIO();
- io.DeltaTime = 1.0f/60.0f;
- io.MousePos = mouse_pos;
- io.MouseDown[0] = mouse_button_0;
- io.MouseDown[1] = mouse_button_1;
+ // Setup low-level inputs, e.g. on Win32: calling GetKeyboardState(), or write to those fields from your Windows message handlers, etc.
+ // (In the examples/ app this is usually done within the ImGui_ImplXXX_NewFrame() function from one of the demo Platform bindings)
+ io.DeltaTime = 1.0f/60.0f; // set the time elapsed since the previous frame (in seconds)
+ io.DisplaySize.x = 1920.0f; // set the current display width
+ io.DisplaySize.y = 1280.0f; // set the current display height here
+ io.MousePos = my_mouse_pos; // set the mouse position
+ io.MouseDown[0] = my_mouse_buttons[0]; // set the mouse button states
+ io.MouseDown[1] = my_mouse_buttons[1];
// Call NewFrame(), after this point you can use ImGui::* functions anytime
+ // (So you want to try calling NewFrame() as early as you can in your mainloop to be able to use Dear ImGui everywhere)
ImGui::NewFrame();
// Most of your application code here
- MyGameUpdate(); // may use any ImGui functions, e.g. ImGui::Begin("My window"); ImGui::Text("Hello, world!"); ImGui::End();
- MyGameRender(); // may use any ImGui functions as well!
-
- // Render & swap video buffers
+ ImGui::Text("Hello, world!");
+ MyGameUpdate(); // may use any Dear ImGui functions, e.g. ImGui::Begin("My window"); ImGui::Text("Hello, world!"); ImGui::End();
+ MyGameRender(); // may use any Dear ImGui functions as well!
+
+ // Render dear imgui, swap buffers
+ // (You want to try calling EndFrame/Render as late as you can, to be able to use Dear ImGui in your own game rendering code)
+ ImGui::EndFrame();
ImGui::Render();
- MyImGuiRenderFunction(ImGui::GetDrawData());
+ ImDrawData* draw_data = ImGui::GetDrawData();
+ MyImGuiRenderFunction(draw_data);
SwapBuffers();
}
// Shutdown
ImGui::DestroyContext();
+ To decide whether to dispatch mouse/keyboard inputs to Dear ImGui to the rest your application,
+ you should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
+ Please read the FAQ and example applications for details about this!
- - A minimal render function skeleton may be:
- void void MyRenderFunction(ImDrawData* draw_data)
+ HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE
+ ---------------------------------------------
+ The bindings in impl_impl_XXX.cpp files contains many working implementations of a rendering function.
+
+ void void MyImGuiRenderFunction(ImDrawData* draw_data)
{
// TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
- // TODO: Setup viewport, orthographic projection matrix
+ // TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
+ // TODO: Setup orthographic projection matrix cover draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
// TODO: Setup shader: vertex { float2 pos, float2 uv, u32 color }, fragment shader sample color from 1 texture, multiply by vertex color.
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
- const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by ImGui
- const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by ImGui
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by Dear ImGui
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by Dear ImGui
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
@@ -189,16 +301,23 @@
}
else
{
- // The texture for the draw call is specified by pcmd->TextureId.
- // The vast majority of draw calls with use the imgui texture atlas, which value you have set yourself during initialization.
- MyEngineBindTexture(pcmd->TextureId);
+ // The texture for the draw call is specified by pcmd->TextureId.
+ // The vast majority of draw calls will use the Dear ImGui texture atlas, which value you have set yourself during initialization.
+ MyEngineBindTexture((MyTexture*)pcmd->TextureId);
- // We are using scissoring to clip some objects. All low-level graphics API supports it.
- // If your engine doesn't support scissoring yet, you will get some small glitches (some elements outside their bounds) which you can fix later.
- MyEngineScissor((int)pcmd->ClipRect.x, (int)pcmd->ClipRect.y, (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ // We are using scissoring to clip some objects. All low-level graphics API should supports it.
+ // - If your engine doesn't support scissoring yet, you may ignore this at first. You will get some small glitches
+ // (some elements visible outside their bounds) but you can fix that once everything else works!
+ // - Clipping coordinates are provided in imgui coordinates space (from draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize)
+ // In a single viewport application, draw_data->DisplayPos will always be (0,0) and draw_data->DisplaySize will always be == io.DisplaySize.
+ // However, in the interest of supporting multi-viewport applications in the future (see 'viewport' branch on github),
+ // always subtract draw_data->DisplayPos from clipping bounds to convert them to your viewport space.
+ // - Note that pcmd->ClipRect contains Min+Max bounds. Some graphics API may use Min+Max, other may use Min+Size (size being Max-Min)
+ ImVec2 pos = draw_data->DisplayPos;
+ MyEngineScissor((int)(pcmd->ClipRect.x - pos.x), (int)(pcmd->ClipRect.y - pos.y), (int)(pcmd->ClipRect.z - pos.x), (int)(pcmd->ClipRect.w - pos.y));
// Render 'pcmd->ElemCount/3' indexed triangles.
- // By default the indices ImDrawIdx are 16-bits, you can change them to 32-bits if your engine doesn't support 16-bits indices.
+ // By default the indices ImDrawIdx are 16-bit, you can change them to 32-bit in imconfig.h if your engine doesn't support 16-bit indices.
MyEngineDrawIndexedTriangles(pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer, vtx_buffer);
}
idx_buffer += pcmd->ElemCount;
@@ -206,39 +325,41 @@
}
}
- - The examples/ folders contains many functional implementation of the pseudo-code above.
- - When calling NewFrame(), the 'io.WantCaptureMouse'/'io.WantCaptureKeyboard'/'io.WantTextInput' flags are updated.
- They tell you if ImGui intends to use your inputs. So for example, if 'io.WantCaptureMouse' is set you would typically want to hide
- mouse inputs from the rest of your application. Read the FAQ below for more information about those flags.
- USING GAMEPAD/KEYBOARD NAVIGATION [BETA]
-
- - Ask questions and report issues at https://github.com/ocornut/imgui/issues/787
+ USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS
+ ------------------------------------------
+ - The gamepad/keyboard navigation is fairly functional and keeps being improved.
+ - Gamepad support is particularly useful to use Dear ImGui on a console system (e.g. PS4, Switch, XB1) without a mouse!
+ - You can ask questions and report issues at https://github.com/ocornut/imgui/issues/787
- The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable.
- Keyboard:
- - Set io.NavFlags |= ImGuiNavFlags_EnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeyDown[] + io.KeyMap[] arrays.
- - When keyboard navigation is active (io.NavActive + NavFlags_EnableKeyboard), the io.WantCaptureKeyboard flag will be set.
- For more advanced uses, you may want to read from:
+ - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable.
+ NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
+ - When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag
+ will be set. For more advanced uses, you may want to read from:
- io.NavActive: true when a window is focused and it doesn't have the ImGuiWindowFlags_NoNavInputs flag set.
- io.NavVisible: true when the navigation cursor is visible (and usually goes false when mouse is used).
- - or query focus information with e.g. IsWindowFocused(), IsItemFocused() etc. functions.
+ - or query focus information with e.g. IsWindowFocused(ImGuiFocusedFlags_AnyWindow), IsItemFocused() etc. functions.
Please reach out if you think the game vs navigation input sharing could be improved.
- Gamepad:
- - Set io.NavFlags |= ImGuiNavFlags_EnableGamepad to enable. Fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
+ - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable.
+ - Backend: Set io.BackendFlags |= ImGuiBackendFlags_HasGamepad + fill the io.NavInputs[] fields before calling NewFrame().
+ Note that io.NavInputs[] is cleared by EndFrame().
- See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. For each entry of io.NavInputs[], set the following values:
0.0f= not held. 1.0f= fully held. Pass intermediate 0.0f..1.0f values for analog triggers/sticks.
- We uses a simple >0.0f test for activation testing, and won't attempt to test for a dead-zone.
- Your code will probably need to transform your raw inputs (such as e.g. remapping your 0.2..0.9 raw input range to 0.0..1.0 imgui range, maybe a power curve, etc.).
- - If you need to share inputs between your game and the imgui parts, the easiest approach is to go all-or-nothing, with a buttons combo to toggle the target.
- Please reach out if you think the game vs navigation input sharing could be improved.
+ Your code will probably need to transform your raw inputs (such as e.g. remapping your 0.2..0.9 raw input range to 0.0..1.0 imgui range, etc.).
+ - You can download PNG/PSD files depicting the gamepad controls for common controllers at: http://goo.gl/9LgVZW.
+ - If you need to share inputs between your game and the imgui parts, the easiest approach is to go all-or-nothing, with a buttons combo
+ to toggle the target. Please reach out if you think the game vs navigation input sharing could be improved.
- Mouse:
- PS4 users: Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback.
- - Consoles/Tablet/Phone users: Consider using Synergy host (on your computer) + uSynergy.c (in your console/tablet/phone app) to use your PC mouse/keyboard.
- - On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiNavFlags_MoveMouse flag in io.NavFlags.
- Enabling ImGuiNavFlags_MoveMouse instructs dear imgui to move your mouse cursor along with navigation movements.
- When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantMoveMouse' to notify you that it wants the mouse cursor to be moved.
+ - Consoles/Tablet/Phone users: Consider using a Synergy 1.x server (on your PC) + uSynergy.c (on your console/tablet/phone app) to share your PC mouse/keyboard.
+ - On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag.
+ Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements.
+ When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantSetMousePos' to notify you that it wants the mouse cursor to be moved.
When that happens your back-end NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the binding in examples/ do that.
- (If you set the ImGuiNavFlags_MoveMouse flag but don't honor 'io.WantMoveMouse' properly, imgui will misbehave as it will see your mouse as moving back and forth.)
+ (If you set the NavEnableSetMousePos flag but don't honor 'io.WantSetMousePos' properly, imgui will misbehave as it will see your mouse as moving back and forth!)
(In a setup when you may not have easy control over the mouse cursor, e.g. uSynergy.c doesn't expose moving remote mouse cursor, you may want
to set a boolean to ignore your other external mouse positions until the external source is moved again.)
@@ -246,16 +367,100 @@
API BREAKING CHANGES
====================
- Occasionally introducing changes that are breaking the API. The breakage are generally minor and easy to fix.
- Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
- Also read releases logs https://github.com/ocornut/imgui/releases for more details.
+ Occasionally introducing changes that are breaking the API. We try to make the breakage minor and easy to fix.
+ Below is a change-log of API breaking changes only. If you are using one of the functions listed, expect to have to fix some code.
+ When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
+ You can read releases logs https://github.com/ocornut/imgui/releases for more details.
- - 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
+ - 2020/06/23 (1.77) - removed BeginPopupContextWindow(const char*, int mouse_button, bool also_over_items) in favor of BeginPopupContextWindow(const char*, ImGuiPopupFlags flags) with ImGuiPopupFlags_NoOverItems.
+ - 2020/06/15 (1.77) - renamed OpenPopupOnItemClick() to OpenPopupContextItem(). Kept inline redirection function (will obsolete).
+ - 2020/06/15 (1.77) - removed CalcItemRectClosestPoint() entry point which was made obsolete and asserting in December 2017.
+ - 2020/04/23 (1.77) - removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular().
+ - 2020/01/22 (1.75) - ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius any more.
+ - 2019/12/17 (1.75) - [undid this change in 1.76] made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead.
+ - 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value.
+ - 2019/12/08 (1.75) - removed redirecting functions/enums that were marked obsolete in 1.53 (December 2017):
+ - ShowTestWindow() -> use ShowDemoWindow()
+ - IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow)
+ - IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows)
+ - SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f)
+ - GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing()
+ - ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg
+ - ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding
+ - ImGuiTreeNodeFlags_AllowOverlapMode -> use ImGuiTreeNodeFlags_AllowItemOverlap
+ - IMGUI_DISABLE_TEST_WINDOWS -> use IMGUI_DISABLE_DEMO_WINDOWS
+ - 2019/12/08 (1.75) - obsoleted calling ImDrawList::PrimReserve() with a negative count (which was the vaguely documented and rarely if ever used). Instead we added an explicit PrimUnreserve() API.
+ - 2019/12/06 (1.75) - removed implicit default parameter to IsMouseDragging(int button = 0) to be consistent with other mouse functions (none of the other functions have it).
+ - 2019/11/21 (1.74) - ImFontAtlas::AddCustomRectRegular() now requires an ID larger than 0x110000 (instead of 0x10000) to conform with supporting Unicode planes 1-16 in a future update. ID below 0x110000 will now assert.
+ - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS to IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS for consistency.
+ - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_MATH_FUNCTIONS to IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS for consistency.
+ - 2019/10/22 (1.74) - removed redirecting functions/enums that were marked obsolete in 1.52 (October 2017):
+ - Begin() [old 5 args version] -> use Begin() [3 args], use SetNextWindowSize() SetNextWindowBgAlpha() if needed
+ - IsRootWindowOrAnyChildHovered() -> use IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows)
+ - AlignFirstTextHeightToWidgets() -> use AlignTextToFramePadding()
+ - SetNextWindowPosCenter() -> use SetNextWindowPos() with a pivot of (0.5f, 0.5f)
+ - ImFont::Glyph -> use ImFontGlyph
+ - 2019/10/14 (1.74) - inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function.
+ if you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can add +io.KeyRepeatDelay to it to compensate for the fix.
+ The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0). Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay).
+ If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you.
+ - 2019/07/15 (1.72) - removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()). Kept redirection function (will obsolete).
+ - 2019/07/12 (1.72) - renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete).
+ - 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names, or see how they were implemented until 1.71.
+ - 2019/06/07 (1.71) - rendering of child window outer decorations (bg color, border, scrollbars) is now performed as part of the parent window. If you have
+ overlapping child windows in a same parent, and relied on their relative z-order to be mapped to their submission order, this will affect your rendering.
+ This optimization is disabled if the parent window has no visual output, because it appears to be the most common situation leading to the creation of overlapping child windows.
+ Please reach out if you are affected.
+ - 2019/05/13 (1.71) - renamed SetNextTreeNodeOpen() to SetNextItemOpen(). Kept inline redirection function (will obsolete).
+ - 2019/05/11 (1.71) - changed io.AddInputCharacter(unsigned short c) signature to io.AddInputCharacter(unsigned int c).
+ - 2019/04/29 (1.70) - improved ImDrawList thick strokes (>1.0f) preserving correct thickness up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines, they will appear thicker now.
+ - 2019/04/29 (1.70) - removed GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. Kept inline redirection function (will obsolete).
+ - 2019/03/04 (1.69) - renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete).
+ - 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete).
+ - 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with a dummy small value!
+ - 2019/02/01 (1.68) - removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
+ - 2019/01/06 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead!
+ - 2019/01/06 (1.67) - renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
+ - 2018/12/20 (1.67) - made it illegal to call Begin("") with an empty string. This somehow half-worked before but had various undesirable side-effects.
+ - 2018/12/10 (1.67) - renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges as we are doing a large pass on configuration flags.
+ - 2018/10/12 (1.66) - renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files.
+ - 2018/09/28 (1.66) - renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete).
+ - 2018/09/06 (1.65) - renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and stb_rect_pack.h to imstb_rectpack.h.
+ If you were conveniently using the imgui copy of those STB headers in your project you will have to update your include paths.
+ - 2018/09/05 (1.65) - renamed io.OptCursorBlink/io.ConfigCursorBlink to io.ConfigInputTextCursorBlink. (#1427)
+ - 2018/08/31 (1.64) - added imgui_widgets.cpp file, extracted and moved widgets code out of imgui.cpp into imgui_widgets.cpp. Re-ordered some of the code remaining in imgui.cpp.
+ NONE OF THE FUNCTIONS HAVE CHANGED. THE CODE IS SEMANTICALLY 100% IDENTICAL, BUT _EVERY_ FUNCTION HAS BEEN MOVED.
+ Because of this, any local modifications to imgui.cpp will likely conflict when you update. Read docs/CHANGELOG.txt for suggestions.
+ - 2018/08/22 (1.63) - renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API. Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent).
+ - 2018/08/21 (1.63) - renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData for consistency. Kept redirection types (will obsolete).
+ - 2018/08/21 (1.63) - removed ImGuiInputTextCallbackData::ReadOnly since it is a duplication of (ImGuiInputTextCallbackData::Flags & ImGuiInputTextFlags_ReadOnly).
+ - 2018/08/01 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.ConfigResizeWindowsFromEdges [update 1.67 renamed to ConfigWindowsResizeFromEdges] to enable the feature.
+ - 2018/08/01 (1.63) - renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency.
+ - 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time.
+ - 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
+ - 2018/06/08 (1.62) - examples: the imgui_impl_xxx files have been split to separate platform (Win32, Glfw, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.).
+ old bindings will still work as is, however prefer using the separated bindings as they will be updated to support multi-viewports.
+ when adopting new bindings follow the main.cpp code of your preferred examples/ folder to know which functions to call.
+ in particular, note that old bindings called ImGui::NewFrame() at the end of their ImGui_ImplXXXX_NewFrame() function.
+ - 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set.
+ - 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details.
+ - 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more.
+ If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
+ To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code.
+ If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to help you find them.
+ - 2018/04/28 (1.61) - obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format",
+ consistent with other functions. Kept redirection functions (will obsolete).
+ - 2018/04/09 (1.61) - IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value.
+ - 2018/03/20 (1.60) - renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some binding ahead of merging the Nav branch).
+ - 2018/03/12 (1.60) - removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now.
+ - 2018/03/08 (1.60) - changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically.
+ - 2018/03/03 (1.60) - renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
+ - 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
- 2018/02/16 (1.60) - obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display.
- 2018/02/07 (1.60) - reorganized context handling to be more explicit,
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
- removed Shutdown() function, as DestroyContext() serve this purpose.
- - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwhise CreateContext() will create its own font atlas instance.
+ - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance.
- removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
- removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts.
- 2018/01/31 (1.60) - moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths.
@@ -283,23 +488,27 @@
- 2017/10/20 (1.52) - changed IsWindowHovered() default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it.
- 2017/10/20 (1.52) - marked IsItemHoveredRect()/IsMouseHoveringWindow() as obsolete, in favor of using the newly introduced flags for IsItemHovered() and IsWindowHovered(). See https://github.com/ocornut/imgui/issues/1382 for details.
removed the IsItemRectHovered()/IsWindowRectHovered() names introduced in 1.51 since they were merely more consistent names for the two functions we are now obsoleting.
+ IsItemHoveredRect() --> IsItemHovered(ImGuiHoveredFlags_RectOnly)
+ IsMouseHoveringAnyWindow() --> IsWindowHovered(ImGuiHoveredFlags_AnyWindow)
+ IsMouseHoveringWindow() --> IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) [weird, old behavior]
- 2017/10/17 (1.52) - marked the old 5-parameters version of Begin() as obsolete (still available). Use SetNextWindowSize()+Begin() instead!
- 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete).
- - 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete).
+ - 2017/09/26 (1.52) - renamed ImFont::Glyph to ImFontGlyph. Kept redirection typedef (will obsolete).
+ - 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete).
- 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your binding if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)".
- - 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete). -> (1.52) use IsItemHovered(ImGuiHoveredFlags_RectOnly)!
+ - 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete). -> (1.52) use IsItemHovered(ImGuiHoveredFlags_RectOnly)!
- renamed IsMouseHoveringAnyWindow() to IsAnyWindowHovered() for consistency. Kept inline redirection function (will obsolete).
- renamed IsMouseHoveringWindow() to IsWindowRectHovered() for consistency. Kept inline redirection function (will obsolete).
- 2017/08/20 (1.51) - renamed GetStyleColName() to GetStyleColorName() for consistency.
- 2017/08/20 (1.51) - added PushStyleColor(ImGuiCol idx, ImU32 col) overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicily to fix.
- - 2017/08/15 (1.51) - marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame.
+ - 2017/08/15 (1.51) - marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame type.
- 2017/08/15 (1.51) - changed parameter order for BeginPopupContextWindow() from (const char*,int buttons,bool also_over_items) to (const char*,int buttons,bool also_over_items). Note that most calls relied on default parameters completely.
- - 2017/08/13 (1.51) - renamed ImGuiCol_Columns*** to ImGuiCol_Separator***. Kept redirection enums (will obsolete).
- - 2017/08/11 (1.51) - renamed ImGuiSetCond_*** types and flags to ImGuiCond_***. Kept redirection enums (will obsolete).
+ - 2017/08/13 (1.51) - renamed ImGuiCol_Column to ImGuiCol_Separator, ImGuiCol_ColumnHovered to ImGuiCol_SeparatorHovered, ImGuiCol_ColumnActive to ImGuiCol_SeparatorActive. Kept redirection enums (will obsolete).
+ - 2017/08/11 (1.51) - renamed ImGuiSetCond_Always to ImGuiCond_Always, ImGuiSetCond_Once to ImGuiCond_Once, ImGuiSetCond_FirstUseEver to ImGuiCond_FirstUseEver, ImGuiSetCond_Appearing to ImGuiCond_Appearing. Kept redirection enums (will obsolete).
- 2017/08/09 (1.51) - removed ValueColor() helpers, they are equivalent to calling Text(label) + SameLine() + ColorButton().
- 2017/08/08 (1.51) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to the various Color*() functions. The SetColorEditOptions() allows to initialize default but the user can still change them with right-click context menu.
- changed prototype of 'ColorEdit4(const char* label, float col[4], bool show_alpha = true)' to 'ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)', where passing flags = 0x01 is a safe no-op (hello dodgy backward compatibility!). - check and run the demo window, under "Color/Picker Widgets", to understand the various new options.
- - changed prototype of rarely used 'ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)' to 'ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0))'
+ - changed prototype of rarely used 'ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)' to 'ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0, 0))'
- 2017/07/20 (1.51) - removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse
- 2017/05/26 (1.50) - removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset.
- 2017/05/01 (1.50) - renamed ImDrawList::PathFill() (rarely used directly) to ImDrawList::PathFillConvex() for clarity.
@@ -307,20 +516,15 @@
- 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it.
- 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
- 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
- - 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore.
- If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you.
- However if your TitleBg/TitleBgActive alpha was <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar.
- This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color.
- ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col)
- {
- float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a;
- return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a);
- }
+ - 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore.
+ If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you, otherwise if <1.0f you need tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar.
+ This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color:
+ ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col) { float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a; return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a); }
If this is confusing, pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color.
- 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext().
- 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection.
- 2016/05/01 (1.49) - obsoleted old signature of CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false) as extra parameters were badly designed and rarely used. You can replace the "default_open = true" flag in new API with CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen).
- - 2016/04/26 (1.49) - changed ImDrawList::PushClipRect(ImVec4 rect) to ImDraw::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false). Note that higher-level ImGui::PushClipRect() is preferable because it will clip at logic/widget level, whereas ImDrawList::PushClipRect() only affect your renderer.
+ - 2016/04/26 (1.49) - changed ImDrawList::PushClipRect(ImVec4 rect) to ImDrawList::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false). Note that higher-level ImGui::PushClipRect() is preferable because it will clip at logic/widget level, whereas ImDrawList::PushClipRect() only affect your renderer.
- 2016/04/03 (1.48) - removed style.WindowFillAlphaDefault setting which was redundant. Bake default BG alpha inside style.Colors[ImGuiCol_WindowBg] and all other Bg color values. (ref github issue #337).
- 2016/04/03 (1.48) - renamed ImGuiCol_TooltipBg to ImGuiCol_PopupBg, used by popups/menus and tooltips. popups/menus were previously using ImGuiCol_WindowBg. (ref github issue #337)
- 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete).
@@ -342,7 +546,7 @@
- the signature of the io.RenderDrawListsFn handler has changed!
old: ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
new: ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data).
- argument: 'cmd_lists' becomes 'draw_data->CmdLists', 'cmd_lists_count' becomes 'draw_data->CmdListsCount'
+ parameters: 'cmd_lists' becomes 'draw_data->CmdLists', 'cmd_lists_count' becomes 'draw_data->CmdListsCount'
ImDrawList: 'commands' becomes 'CmdBuffer', 'vtx_buffer' becomes 'VtxBuffer', 'IdxBuffer' is new.
ImDrawCmd: 'vtx_count' becomes 'ElemCount', 'clip_rect' becomes 'ClipRect', 'user_callback' becomes 'UserCallback', 'texture_id' becomes 'TextureId'.
- each ImDrawList now contains both a vertex buffer and an index buffer. For each command, render ElemCount/3 triangles using indices from the index buffer.
@@ -374,14 +578,13 @@
- 2015/02/01 (1.31) - removed IO.MemReallocFn (unused)
- 2015/01/19 (1.30) - renamed ImGuiStorage::GetIntPtr()/GetFloatPtr() to GetIntRef()/GetIntRef() because Ptr was conflicting with actual pointer storage functions.
- 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader.
- (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels.
- font init: const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); <..Upload texture to GPU..>
- became: unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); <..Upload texture to GPU>; io.Fonts->TexId = YourTextureIdentifier;
- you now more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs.
- it is now recommended that you sample the font texture with bilinear interpolation.
- (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID.
- (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix)
- (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets
+ - 2015/01/11 (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels.
+ - old: const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); [..Upload texture to GPU..];
+ - new: unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); [..Upload texture to GPU..]; io.Fonts->TexId = YourTexIdentifier;
+ you now have more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs. It is now recommended that you sample the font texture with bilinear interpolation.
+ - 2015/01/11 (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID.
+ - 2015/01/11 (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix)
+ - 2015/01/11 (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets
- 2014/12/10 (1.18) - removed SetNewWindowDefaultPos() in favor of new generic API SetNextWindowPos(pos, ImGuiSetCondition_FirstUseEver)
- 2014/11/28 (1.17) - moved IO.Font*** options to inside the IO.Font-> structure (FontYOffset, FontTexUvForWhite, FontBaseScale, FontFallbackGlyph)
- 2014/11/26 (1.17) - reworked syntax of IMGUI_ONCE_UPON_A_FRAME helper macro to increase compiler compatibility
@@ -395,247 +598,119 @@
- 2014/08/28 (1.09) - changed the behavior of IO.PixelCenterOffset following various rendering fixes
- ISSUES & TODO-LIST
- ==================
- See TODO.txt
+ FREQUENTLY ASKED QUESTIONS (FAQ)
+ ================================
+ Read all answers online:
+ https://www.dearimgui.org/faq or https://github.com/ocornut/imgui/blob/master/docs/FAQ.md (same url)
+ Read all answers locally (with a text editor or ideally a Markdown viewer):
+ docs/FAQ.md
+ Some answers are copied down here to facilitate searching in code.
- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
- ======================================
+ Q&A: Basics
+ ===========
+
+ Q: Where is the documentation?
+ A: This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.
+ - Run the examples/ and explore them.
+ - See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function.
+ - The demo covers most features of Dear ImGui, so you can read the code and see its output.
+ - See documentation and comments at the top of imgui.cpp + effectively imgui.h.
+ - Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the
+ examples/ folder to explain how to integrate Dear ImGui with your own engine/application.
+ - The Wiki (https://github.com/ocornut/imgui/wiki) has many resources and links.
+ - The Glossary (https://github.com/ocornut/imgui/wiki/Glossary) page also may be useful.
+ - Your programming IDE is your friend, find the type or function declaration to find comments
+ associated to it.
+
+ Q: What is this library called?
+ Q: Which version should I get?
+ >> This library is called "Dear ImGui", please don't call it "ImGui" :)
+ >> See https://www.dearimgui.org/faq for details.
+
+ Q&A: Integration
+ ================
+
+ Q: How to get started?
+ A: Read 'PROGRAMMER GUIDE' above. Read examples/README.txt.
+
+ Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?
+ A: You should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
+ >> See https://www.dearimgui.org/faq for fully detailed answer. You really want to read this.
+
+ Q. How can I enable keyboard controls?
+ Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)
+ Q: I integrated Dear ImGui in my engine and little squares are showing instead of text..
+ Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
+ Q: I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries..
+ >> See https://www.dearimgui.org/faq
+
+ Q&A: Usage
+ ----------
+
+ Q: How can I have widgets with an empty label?
+ Q: How can I have multiple widgets with the same label?
+ Q: Why are multiple widgets reacting when I interact with one?
+ Q: How can I display an image? What is ImTextureID, how does it works?
+ Q: How can I use my own math types instead of ImVec2/ImVec4?
+ Q: How can I interact with standard C++ types (such as std::string and std::vector)?
+ Q: How can I display custom shapes? (using low-level ImDrawList API)
+ >> See https://www.dearimgui.org/faq
+
+ Q&A: Fonts, Text
+ ================
+
+ Q: How should I handle DPI in my application?
+ Q: How can I load a different font than the default?
+ Q: How can I easily use icons in my application?
+ Q: How can I load multiple fonts?
+ Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
+ >> See https://www.dearimgui.org/faq and https://github.com/ocornut/imgui/edit/master/docs/FONTS.md
+
+ Q&A: Concerns
+ =============
+
+ Q: Who uses Dear ImGui?
+ Q: Can you create elaborate/serious tools with Dear ImGui?
+ Q: Can you reskin the look of Dear ImGui?
+ Q: Why using C++ (as opposed to C)?
+ >> See https://www.dearimgui.org/faq
+
+ Q&A: Community
+ ==============
Q: How can I help?
- A: - If you are experienced with Dear ImGui and C++, look at the github issues, or TODO.txt and see how you want/can help!
- - Convince your company to fund development time! Individual users: you can also become a Patron (patreon.com/imgui) or donate on PayPal! See README.
- - Disclose your usage of dear imgui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
- You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/1269). Visuals are ideal as they inspire other programmers.
+ A: - Businesses: please reach out to "contact AT dearimgui.org" if you work in a place using Dear ImGui!
+ We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts.
+ This is among the most useful thing you can do for Dear ImGui. With increased funding we can hire more people working on this project.
+ - Individuals: you can support continued development via PayPal donations. See README.
+ - If you are experienced with Dear ImGui and C++, look at the github issues, look at the Wiki, read docs/TODO.txt
+ and see how you want to help and can help!
+ - Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
+ You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/3075). Visuals are ideal as they inspire other programmers.
But even without visuals, disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues (on github or privately).
- Q: How can I display an image? What is ImTextureID, how does it works?
- A: ImTextureID is a void* used to pass renderer-agnostic texture references around until it hits your render function.
- Dear ImGui knows nothing about what those bits represent, it just passes them around. It is up to you to decide what you want the void* to carry!
- It could be an identifier to your OpenGL texture (cast GLuint to void*), a pointer to your custom engine material (cast MyMaterial* to void*), etc.
- At the end of the chain, your renderer takes this void* to cast it back into whatever it needs to select a current texture to render.
- Refer to examples applications, where each renderer (in a imgui_impl_xxxx.cpp file) is treating ImTextureID as a different thing.
- (c++ tip: OpenGL uses integers to identify textures. You can safely store an integer into a void*, just cast it to void*, don't take it's address!)
- To display a custom image/texture within an ImGui window, you may use ImGui::Image(), ImGui::ImageButton(), ImDrawList::AddImage() functions.
- Dear ImGui will generate the geometry and draw calls using the ImTextureID that you passed and which your renderer can use.
- You may call ImGui::ShowMetricsWindow() to explore active draw lists and visualize/understand how the draw data is generated.
- It is your responsibility to get textures uploaded to your GPU.
-
- Q: Can I have multiple widgets with the same label? Can I have widget without a label?
- A: Yes. A primer on labels and the ID stack...
-
- - Elements that are typically not clickable, such as Text() items don't need an ID.
-
- - Interactive widgets require state to be carried over multiple frames (most typically Dear ImGui often needs to remember what is
- the "active" widget). to do so they need a unique ID. unique ID are typically derived from a string label, an integer index or a pointer.
-
- Button("OK"); // Label = "OK", ID = hash of "OK"
- Button("Cancel"); // Label = "Cancel", ID = hash of "Cancel"
-
- - ID are uniquely scoped within windows, tree nodes, etc. so no conflict can happen if you have two buttons called "OK"
- in two different windows or in two different locations of a tree.
-
- - If you have a same ID twice in the same location, you'll have a conflict:
-
- Button("OK");
- Button("OK"); // ID collision! Both buttons will be treated as the same.
-
- Fear not! this is easy to solve and there are many ways to solve it!
-
- - When passing a label you can optionally specify extra unique ID information within string itself.
- Use "##" to pass a complement to the ID that won't be visible to the end-user.
- This helps solving the simple collision cases when you know which items are going to be created.
-
- Button("Play"); // Label = "Play", ID = hash of "Play"
- Button("Play##foo1"); // Label = "Play", ID = hash of "Play##foo1" (different from above)
- Button("Play##foo2"); // Label = "Play", ID = hash of "Play##foo2" (different from above)
-
- - If you want to completely hide the label, but still need an ID:
-
- Checkbox("##On", &b); // Label = "", ID = hash of "##On" (no label!)
-
- - Occasionally/rarely you might want change a label while preserving a constant ID. This allows you to animate labels.
- For example you may want to include varying information in a window title bar, but windows are uniquely identified by their ID..
- Use "###" to pass a label that isn't part of ID:
-
- Button("Hello###ID"; // Label = "Hello", ID = hash of "ID"
- Button("World###ID"; // Label = "World", ID = hash of "ID" (same as above)
-
- sprintf(buf, "My game (%f FPS)###MyGame", fps);
- Begin(buf); // Variable label, ID = hash of "MyGame"
-
- - Use PushID() / PopID() to create scopes and avoid ID conflicts within the same Window.
- This is the most convenient way of distinguishing ID if you are iterating and creating many UI elements.
- You can push a pointer, a string or an integer value. Remember that ID are formed from the concatenation of _everything_ in the ID stack!
-
- for (int i = 0; i < 100; i++)
- {
- PushID(i);
- Button("Click"); // Label = "Click", ID = hash of integer + "label" (unique)
- PopID();
- }
-
- for (int i = 0; i < 100; i++)
- {
- MyObject* obj = Objects[i];
- PushID(obj);
- Button("Click"); // Label = "Click", ID = hash of pointer + "label" (unique)
- PopID();
- }
-
- for (int i = 0; i < 100; i++)
- {
- MyObject* obj = Objects[i];
- PushID(obj->Name);
- Button("Click"); // Label = "Click", ID = hash of string + "label" (unique)
- PopID();
- }
-
- - More example showing that you can stack multiple prefixes into the ID stack:
-
- Button("Click"); // Label = "Click", ID = hash of "Click"
- PushID("node");
- Button("Click"); // Label = "Click", ID = hash of "node" + "Click"
- PushID(my_ptr);
- Button("Click"); // Label = "Click", ID = hash of "node" + ptr + "Click"
- PopID();
- PopID();
-
- - Tree nodes implicitly creates a scope for you by calling PushID().
-
- Button("Click"); // Label = "Click", ID = hash of "Click"
- if (TreeNode("node"))
- {
- Button("Click"); // Label = "Click", ID = hash of "node" + "Click"
- TreePop();
- }
-
- - When working with trees, ID are used to preserve the open/close state of each tree node.
- Depending on your use cases you may want to use strings, indices or pointers as ID.
- e.g. when displaying a single object that may change over time (dynamic 1-1 relationship), using a static string as ID will preserve your
- node open/closed state when the targeted object change.
- e.g. when displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state differently.
- experiment and see what makes more sense!
-
- Q: How can I tell when Dear ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?
- A: You can read the 'io.WantCaptureMouse'/'io.WantCaptureKeyboard'/'ioWantTextInput' flags from the ImGuiIO structure.
- - When 'io.WantCaptureMouse' or 'io.WantCaptureKeyboard' flags are set you may want to discard/hide the inputs from the rest of your application.
- - When 'io.WantTextInput' is set to may want to notify your OS to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS).
- Preferably read the flags after calling ImGui::NewFrame() to avoid them lagging by one frame. But reading those flags before calling NewFrame() is
- also generally ok, as the bool toggles fairly rarely and you don't generally expect to interact with either Dear ImGui or your application during
- the same frame when that transition occurs. Dear ImGui is tracking dragging and widget activity that may occur outside the boundary of a window,
- so 'io.WantCaptureMouse' is more accurate and correct than checking if a window is hovered.
- (Advanced note: text input releases focus on Return 'KeyDown', so the following Return 'KeyUp' event that your application receive will typically
- have 'io.WantCaptureKeyboard=false'. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs
- were for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
-
- Q: How can I load a different font than the default? (default is an embedded version of ProggyClean.ttf, rendered at size 13)
- A: Use the font atlas to load the TTF/OTF file you want:
- ImGuiIO& io = ImGui::GetIO();
- io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
- io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
-
- New programmers: remember that in C/C++ and most programming languages if you want to use a backslash \ in a string literal you need to write a double backslash "\\":
- io.Fonts->AddFontFromFileTTF("MyDataFolder\MyFontFile.ttf", size_in_pixels); // WRONG
- io.Fonts->AddFontFromFileTTF("MyDataFolder\\MyFontFile.ttf", size_in_pixels); // CORRECT
- io.Fonts->AddFontFromFileTTF("MyDataFolder/MyFontFile.ttf", size_in_pixels); // ALSO CORRECT
-
- Q: How can I easily use icons in my application?
- A: The most convenient and practical way is to merge an icon font such as FontAwesome inside you main font. Then you can refer to icons within your
- strings. Read 'How can I load multiple fonts?' and the file 'misc/fonts/README.txt' for instructions and useful header files.
-
- Q: How can I load multiple fonts?
- A: Use the font atlas to pack them into a single texture:
- (Read misc/fonts/README.txt and the code in ImFontAtlas for more details.)
-
- ImGuiIO& io = ImGui::GetIO();
- ImFont* font0 = io.Fonts->AddFontDefault();
- ImFont* font1 = io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
- ImFont* font2 = io.Fonts->AddFontFromFileTTF("myfontfile2.ttf", size_in_pixels);
- io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
- // the first loaded font gets used by default
- // use ImGui::PushFont()/ImGui::PopFont() to change the font at runtime
-
- // Options
- ImFontConfig config;
- config.OversampleH = 3;
- config.OversampleV = 1;
- config.GlyphOffset.y -= 2.0f; // Move everything by 2 pixels up
- config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters
- io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, &config);
-
- // Combine multiple fonts into one (e.g. for icon fonts)
- ImWchar ranges[] = { 0xf000, 0xf3ff, 0 };
- ImFontConfig config;
- config.MergeMode = true;
- io.Fonts->AddFontDefault();
- io.Fonts->LoadFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font
- io.Fonts->LoadFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs
-
- Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
- A: When loading a font, pass custom Unicode ranges to specify the glyphs to load.
-
- // Add default Japanese ranges
- io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, io.Fonts->GetGlyphRangesJapanese());
-
- // Or create your own custom ranges (e.g. for a game you can feed your entire game script and only build the characters the game need)
- ImVector ranges;
- ImFontAtlas::GlyphRangesBuilder builder;
- builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters)
- builder.AddChar(0x7262); // Add a specific character
- builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges
- builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted)
- io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, ranges.Data);
-
- All your strings needs to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax.
- Specifying literal in your source code using a local code page (such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
- Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
-
- Text input: it is up to your application to pass the right character code to io.AddInputCharacter(). The applications in examples/ are doing that.
- For languages using IME, on Windows you can copy the Hwnd of your application to io.ImeWindowHandle.
- The default implementation of io.ImeSetInputScreenPosFn() on Windows will set your IME position correctly.
-
- Q: How can I preserve my Dear ImGui context across reloading a DLL? (loss of the global/static variables)
- A: Create your own context 'ctx = CreateContext()' + 'SetCurrentContext(ctx)' and your own font atlas 'ctx->GetIO().Fonts = new ImFontAtlas()'
- so you don't rely on the default globals.
-
- Q: How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
- A: - You can create a dummy window. Call Begin() with NoTitleBar|NoResize|NoMove|NoScrollbar|NoSavedSettings|NoInputs flag,
- push a ImGuiCol_WindowBg with zero alpha, then retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
- - You can call ImGui::GetOverlayDrawList() and use this draw list to display contents over every other imgui windows.
- - You can create your own ImDrawList instance. You'll need to initialize them ImGui::GetDrawListSharedData(), or create your own ImDrawListSharedData.
-
- Q: I integrated Dear ImGui in my engine and the text or lines are blurry..
- A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
- Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
-
- Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
- A: You are probably mishandling the clipping rectangles in your render function.
- Rectangles provided by ImGui are defined as (x1=left,y1=top,x2=right,y2=bottom) and NOT as (x1,y1,width,height).
-
-
- - tip: you can call Begin() multiple times with the same name during the same frame, it will keep appending to the same window.
- this is also useful to set yourself in the context of another window (to get/set other settings)
- - tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug".
- - tip: the ImGuiOnceUponAFrame helper will allow run the block of code only once a frame. You can use it to quickly add custom UI in the middle
- of a deep nested inner loop in your code.
- - tip: you can call Render() multiple times (e.g for VR renders).
- - tip: call and read the ShowDemoWindow() code in imgui_demo.cpp for more example of how to use ImGui!
-
*/
+//-------------------------------------------------------------------------
+// [SECTION] INCLUDES
+//-------------------------------------------------------------------------
+
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "imgui.h"
+#ifndef IMGUI_DISABLE
+
+#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
+#endif
#include "imgui_internal.h"
-#include