diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..c6dc600a
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,24 @@
+# See http://editorconfig.org to read about the EditorConfig format.
+# - In theory automatically supported by VS2017+ and most common IDE or text editors.
+# - In practice VS2019 stills gets trailing whitespaces wrong :(
+# - Suggest install to trim whitespaces: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TrailingWhitespaceVisualizer
+# - Alternative for older VS2010 to VS2015: 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/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..d48470ee
--- /dev/null
+++ b/.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/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 00000000..2aa08b44
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1 @@
+custom: ['https://github.com/ocornut/imgui/wiki/Sponsors']
diff --git a/.github/issue_template.md b/.github/issue_template.md
new file mode 100644
index 00000000..fdd09439
--- /dev/null
+++ b/.github/issue_template.md
@@ -0,0 +1,46 @@
+(Click "Preview" above ^ to turn URL into clickable links)
+
+1. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions).
+
+2. PLEASE CAREFULLY READ: [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md)
+
+3. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261)
+
+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 links above.
+
+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/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 00000000..187d7105
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,6 @@
+(Click "Preview" to turn any http URL into a clickable link)
+
+1. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261)
+
+2. Clear this template before submitting your PR.
+
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 00000000..f01bff87
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,516 @@
+name: build
+
+on:
+ push:
+ pull_request:
+ workflow_run:
+ # Use a workflow as a trigger of scheduled builds. Forked repositories can disable scheduled builds by disabling
+ # "scheduled" workflow, while maintaining ability to perform local CI builds.
+ workflows:
+ - scheduled
+ branches:
+ - master
+ - docking
+ types:
+ - requested
+
+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\
+ steps:
+ - uses: actions/checkout@v2
+
+ - 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
+ echo "SDL2_DIR=$(pwd)\SDL2-devel-2.0.10-VC\SDL2-2.0.10\" >>${env:GITHUB_ENV}
+
+ 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
+ echo "VULKAN_SDK=$(pwd)\vulkan-sdk-1.1.121.2\" >>${env:GITHUB_ENV}
+
+ - 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
+ call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat"
+ .\build_win32.bat /W4
+
+ - name: Build example_null (single file build)
+ shell: bash
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp -limm32
+
+ - name: Build example_null (with IMGUI_DISABLE_WIN32_FUNCTIONS)
+ shell: bash
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_DISABLE_WIN32_FUNCTIONS
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp -limm32
+
+ - name: Build example_null (as DLL)
+ shell: cmd
+ run: |
+ call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat"
+
+ 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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-20.04
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Install Dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y libglfw3-dev libsdl2-dev gcc-multilib g++-multilib libfreetype6-dev libvulkan-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 (extra warnings, empty IM_ASSERT)
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IM_ASSERT(x)
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -Wextra -Werror -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros -Wno-empty-body -o example_single_file example_single_file.cpp
+
+ - 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: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with ImWchar32)
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_USE_WCHAR32
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with large ImDrawIdx + pointer ImTextureID)
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define ImTextureID void*
+ #define ImDrawIdx unsigned int
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with IMGUI_DISABLE_OBSOLETE_FUNCTIONS)
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ 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: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_DISABLE_DEMO_WINDOWS
+ #define IMGUI_DISABLE_METRICS_WINDOW
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with IMGUI_DISABLE_FILE_FUNCTIONS)
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_DISABLE_FILE_FUNCTIONS
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (with IMGUI_USE_BGRA_PACKED_COLOR)
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_USE_BGRA_PACKED_COLOR
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ 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: |
+ cat > example_single_file.cpp <<'EOF'
+
+ struct MyVec2 { float x; float y; MyVec2(float x, float y) : x(x), y(y) { } };
+ struct MyVec4 { float x; float y; float z; float w;
+ MyVec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } };
+ #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); }
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (without c++ runtime, Clang)
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_IMPLEMENTATION
+ #define IMGUI_DISABLE_DEMO_WINDOWS
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ 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 == 'workflow_run'
+
+ - name: Build example_sdl_opengl2
+ run: make -C examples/example_sdl_opengl2
+ if: github.event_name == 'workflow_run'
+
+ - name: Build example_sdl_opengl3
+ run: make -C examples/example_sdl_opengl3
+
+ - name: Build with IMGUI_IMPL_VULKAN_NO_PROTOTYPES
+ run: g++ -c -I. -DIMGUI_IMPL_VULKAN_NO_PROTOTYPES=1 backends/imgui_impl_vulkan.cpp
+
+ MacOS:
+ runs-on: macos-latest
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Install Dependencies
+ run: |
+ brew install glfw3 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: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ clang++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
+
+ - name: Build example_null (without c++ runtime)
+ run: |
+ cat > example_single_file.cpp <<'EOF'
+
+ #define IMGUI_IMPLEMENTATION
+ #include "misc/single_file/imgui_single_file.h"
+ #include "examples/example_null/main.cpp"
+
+ EOF
+ 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 == 'workflow_run'
+
+ - 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 == 'workflow_run'
+
+ - 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@v2
+
+ - 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@v2
+
+ - 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
+ emsdk-master/emsdk activate latest
+
+ - name: Build example_emscripten_opengl3
+ run: |
+ pushd emsdk-master
+ source ./emsdk_env.sh
+ popd
+ make -C examples/example_emscripten_opengl3
+
+ - name: Build example_emscripten_wgpu
+ run: |
+ pushd emsdk-master
+ source ./emsdk_env.sh
+ popd
+ make -C examples/example_emscripten_wgpu
+
+ Android:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Build example_android_opengl3
+ run: |
+ cd examples/example_android_opengl3/android
+ gradle assembleDebug
+
+ Discord-CI:
+ runs-on: ubuntu-18.04
+ if: always()
+ needs: [Windows, Linux, MacOS, iOS, Emscripten, Android]
+ steps:
+ - uses: dearimgui/github_discord_notifier@latest
+ with:
+ discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }}
+ github-token: ${{ github.token }}
+ action-task: discord-jobs
+ discord-filter: "'{{ github.branch }}'.match(/master|docking/g) != null && '{{ run.conclusion }}' != '{{ last_run.conclusion }}'"
+ discord-username: GitHub Actions
+ discord-job-new-failure-message: ''
+ discord-job-fixed-failure-message: ''
+ discord-job-new-failure-embed: |
+ {
+ "title": "`{{ job.name }}` job is failing on `{{ github.branch }}`!",
+ "description": "Commit [{{ github.context.payload.head_commit.title }}]({{ github.context.payload.head_commit.url }}) pushed to [{{ github.branch }}]({{ github.branch_url }}) broke [{{ job.name }}]({{ job.url }}) build job.\nFailing steps: {{ failing_steps }}",
+ "url": "{{ job.url }}",
+ "color": "0xFF0000",
+ "timestamp": "{{ run.updated_at }}"
+ }
+ discord-job-fixed-failure-embed: |
+ {
+ "title": "`{{ github.branch }}` branch is no longer failing!",
+ "description": "Build failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.",
+ "color": "0x00FF00",
+ "url": "{{ github.context.payload.head_commit.url }}",
+ "timestamp": "{{ run.completed_at }}"
+ }
diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml
new file mode 100644
index 00000000..2a08578f
--- /dev/null
+++ b/.github/workflows/scheduled.yml
@@ -0,0 +1,15 @@
+#
+# This is a dummy workflow used to trigger scheduled builds. Forked repositories most likely should disable this
+# workflow to avoid daily builds of inactive repositories.
+#
+name: scheduled
+
+on:
+ schedule:
+ - cron: '0 9 * * *'
+
+jobs:
+ scheduled:
+ runs-on: ubuntu-latest
+ steps:
+ - run: exit 0
diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml
new file mode 100644
index 00000000..f3e6b2d1
--- /dev/null
+++ b/.github/workflows/static-analysis.yml
@@ -0,0 +1,77 @@
+name: static-analysis
+
+on:
+ workflow_run:
+ # Perform static analysis together with build workflow. Build triggers of "build" workflow do not need to be repeated here.
+ workflows:
+ - build
+ types:
+ - requested
+
+jobs:
+ PVS-Studio:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v1
+ with:
+ fetch-depth: 1
+
+ - name: Install Dependencies
+ env:
+ # The Secret variable setup in GitHub must be in format: "name_or_email key", on a single line
+ PVS_STUDIO_LICENSE: ${{ secrets.PVS_STUDIO_LICENSE }}
+ run: |
+ if [[ "$PVS_STUDIO_LICENSE" != "" ]];
+ then
+ 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
+ pvs-studio-analyzer credentials -o pvs-studio.lic $PVS_STUDIO_LICENSE
+ 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' -d V1071 -t errorfile -w pvs-studio.log
+
+ Discord-CI:
+ runs-on: ubuntu-18.04
+ needs: [PVS-Studio]
+ if: always()
+ steps:
+ - uses: dearimgui/github_discord_notifier@latest
+ with:
+ discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }}
+ github-token: ${{ github.token }}
+ action-task: discord-jobs
+ discord-filter: "'{{ github.branch }}'.match(/master|docking/g) != null && '{{ run.conclusion }}' != '{{ last_run.conclusion }}'"
+ discord-username: GitHub Actions
+ discord-job-new-failure-message: ''
+ discord-job-fixed-failure-message: ''
+ discord-job-new-failure-embed: |
+ {
+ "title": "`{{ job.name }}` job is failing on `{{ github.branch }}`!",
+ "description": "Commit [{{ github.context.payload.head_commit.title }}]({{ github.context.payload.head_commit.url }}) pushed to [{{ github.branch }}]({{ github.branch_url }}) broke static analysis [{{ job.name }}]({{ job.url }}) job.\nFailing steps: {{ failing_steps }}",
+ "url": "{{ job.url }}",
+ "color": "0xFF0000",
+ "timestamp": "{{ run.updated_at }}"
+ }
+ discord-job-fixed-failure-embed: |
+ {
+ "title": "`{{ github.branch }}` branch is no longer failing!",
+ "description": "Static analysis failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.",
+ "color": "0x00FF00",
+ "url": "{{ github.context.payload.head_commit.url }}",
+ "timestamp": "{{ run.completed_at }}"
+ }
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..86bed609
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,53 @@
+## 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
+
+## Commonly used CMake directories
+/build*/
+
+## Xcode artifacts
+project.xcworkspace
+xcuserdata
+
+## Emscripten artifacts
+examples/*.o.tmp
+examples/*.out.js
+examples/*.out.wasm
+examples/example_emscripten_opengl3/web/*
+examples/example_emscripten_wgpu/web/*
+
+## 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/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 00000000..780533dc
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014-2021 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
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/backends/imgui_impl_allegro5.cpp b/backends/imgui_impl_allegro5.cpp
new file mode 100644
index 00000000..ccb1396d
--- /dev/null
+++ b/backends/imgui_impl_allegro5.cpp
@@ -0,0 +1,478 @@
+// dear imgui: Renderer + Platform Backend 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 use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
+// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
+// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
+// Read online: https://github.com/ocornut/imgui/tree/master/docs
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 2021-08-17: Calling io.AddFocusEvent() on ALLEGRO_EVENT_DISPLAY_SWITCH_OUT/ALLEGRO_EVENT_DISPLAY_SWITCH_IN events.
+// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
+// 2021-05-19: Renderer: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
+// 2021-02-18: Change blending equation to preserve alpha in output buffer.
+// 2020-08-10: Inputs: Fixed horizontal mouse wheel direction.
+// 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
+
+// Allegro Data
+struct ImGui_ImplAllegro5_Data
+{
+ ALLEGRO_DISPLAY* Display;
+ ALLEGRO_BITMAP* Texture;
+ double Time;
+ ALLEGRO_MOUSE_CURSOR* MouseCursorInvisible;
+ ALLEGRO_VERTEX_DECL* VertexDecl;
+ char* ClipboardTextData;
+
+ ImGui_ImplAllegro5_Data() { memset(this, 0, sizeof(*this)); }
+};
+
+// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts
+// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
+// FIXME: multi-context support is not well tested and probably dysfunctional in this backend.
+static ImGui_ImplAllegro5_Data* ImGui_ImplAllegro5_GetBackendData() { return ImGui::GetCurrentContext() ? (ImGui_ImplAllegro5_Data*)ImGui::GetIO().BackendPlatformUserData : NULL; }
+
+struct ImDrawVertAllegro
+{
+ ImVec2 pos;
+ ImVec2 uv;
+ ALLEGRO_COLOR col;
+};
+
+static void ImGui_ImplAllegro5_SetupRenderState(ImDrawData* draw_data)
+{
+ // Setup blending
+ al_set_separate_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, ALLEGRO_ADD, ALLEGRO_ONE, 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.
+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
+ ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+ 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
+ {
+ // Project scissor/clipping rectangles into framebuffer space
+ ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y);
+ ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y);
+ if (clip_max.x < clip_min.x || clip_max.y < clip_min.y)
+ continue;
+
+ // Apply scissor/clipping rectangle, Draw
+ ALLEGRO_BITMAP* texture = (ALLEGRO_BITMAP*)pcmd->GetTexID();
+ al_set_clipping_rectangle(clip_min.x, clip_min.y, clip_max.x - clip_min.x, clip_max.y - clip_min.y);
+ al_draw_prim(&vertices[0], bd->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
+ ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+ 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->SetTexID((void*)cloned_img);
+ bd->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);
+ bd->MouseCursorInvisible = al_create_mouse_cursor(mouse_cursor, 0, 0);
+ al_destroy_bitmap(mouse_cursor);
+
+ return true;
+}
+
+void ImGui_ImplAllegro5_InvalidateDeviceObjects()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+ if (bd->Texture)
+ {
+ io.Fonts->SetTexID(NULL);
+ al_destroy_bitmap(bd->Texture);
+ bd->Texture = NULL;
+ }
+ if (bd->MouseCursorInvisible)
+ {
+ al_destroy_mouse_cursor(bd->MouseCursorInvisible);
+ bd->MouseCursorInvisible = NULL;
+ }
+}
+
+#if ALLEGRO_HAS_CLIPBOARD
+static const char* ImGui_ImplAllegro5_GetClipboardText(void*)
+{
+ ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+ if (bd->ClipboardTextData)
+ al_free(bd->ClipboardTextData);
+ bd->ClipboardTextData = al_get_clipboard_text(bd->Display);
+ return bd->ClipboardTextData;
+}
+
+static void ImGui_ImplAllegro5_SetClipboardText(void*, const char* text)
+{
+ ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+ al_set_clipboard_text(bd->Display, text);
+}
+#endif
+
+bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!");
+
+ // Setup backend capabilities flags
+ ImGui_ImplAllegro5_Data* bd = IM_NEW(ImGui_ImplAllegro5_Data)();
+ io.BackendPlatformUserData = (void*)bd;
+ io.BackendPlatformName = io.BackendRendererName = "imgui_impl_allegro5";
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+
+ bd->Display = display;
+
+ // 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 }
+ };
+ bd->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_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+ IM_ASSERT(bd != NULL && "No platform backend to shutdown, or already shutdown?");
+ ImGuiIO& io = ImGui::GetIO();
+
+ ImGui_ImplAllegro5_InvalidateDeviceObjects();
+ if (bd->VertexDecl)
+ al_destroy_vertex_decl(bd->VertexDecl);
+ if (bd->ClipboardTextData)
+ al_free(bd->ClipboardTextData);
+
+ io.BackendPlatformUserData = NULL;
+ io.BackendPlatformName = io.BackendRendererName = NULL;
+ IM_DELETE(bd);
+}
+
+// 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();
+ ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+
+ switch (ev->type)
+ {
+ case ALLEGRO_EVENT_MOUSE_AXES:
+ if (ev->mouse.display == bd->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 == bd->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 == bd->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 == bd->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 == bd->Display)
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+ return true;
+ case ALLEGRO_EVENT_KEY_CHAR:
+ if (ev->keyboard.display == bd->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 == bd->Display)
+ io.KeysDown[ev->keyboard.keycode] = (ev->type == ALLEGRO_EVENT_KEY_DOWN);
+ return true;
+ case ALLEGRO_EVENT_DISPLAY_SWITCH_OUT:
+ if (ev->display.source == bd->Display)
+ io.AddFocusEvent(false);
+ return true;
+ case ALLEGRO_EVENT_DISPLAY_SWITCH_IN:
+ if (ev->display.source == bd->Display)
+ {
+ io.AddFocusEvent(true);
+#if defined(ALLEGRO_UNSTABLE)
+ al_clear_keyboard_state(bd->Display);
+#endif
+ }
+ return true;
+ }
+ return false;
+}
+
+static void ImGui_ImplAllegro5_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
+ return;
+
+ ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+ 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(bd->Display, bd->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(bd->Display, cursor_id);
+ }
+}
+
+void ImGui_ImplAllegro5_NewFrame()
+{
+ ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
+ IM_ASSERT(bd != NULL && "Did you call ImGui_ImplAllegro5_Init()?");
+
+ if (!bd->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(bd->Display);
+ h = al_get_display_height(bd->Display);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+
+ // Setup time step
+ double current_time = al_get_time();
+ io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
+ bd->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/backends/imgui_impl_allegro5.h b/backends/imgui_impl_allegro5.h
new file mode 100644
index 00000000..06c7120b
--- /dev/null
+++ b/backends/imgui_impl_allegro5.h
@@ -0,0 +1,31 @@
+// dear imgui: Renderer + Platform Backend 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 use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
+// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
+// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
+// Read online: https://github.com/ocornut/imgui/tree/master/docs
+
+#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/backends/imgui_impl_android.cpp b/backends/imgui_impl_android.cpp
new file mode 100644
index 00000000..aae8e6b8
--- /dev/null
+++ b/backends/imgui_impl_android.cpp
@@ -0,0 +1,187 @@
+// dear imgui: Platform Binding for Android native app
+// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
+
+// Implemented features:
+// [X] Platform: Keyboard arrays indexed using AKEYCODE_* codes, e.g. ImGui::IsKeyPressed(AKEYCODE_SPACE).
+// Missing features:
+// [ ] Platform: Clipboard support.
+// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
+// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
+// Important:
+// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
+// - FIXME: Unicode character inputs needs to be passed by Dear ImGui by the application (see examples/ and issue #3446)
+
+// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
+// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
+// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
+// Read online: https://github.com/ocornut/imgui/tree/master/docs
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 2021-03-04: Initial version.
+
+#include "imgui.h"
+#include "imgui_impl_android.h"
+#include
+#include