mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-06 06:25:54 +01:00
Compare commits
No commits in common. "master" and "v1.92.7" have entirely different histories.
1
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
1
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
@ -14,7 +14,6 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
value: |
|
value: |
|
||||||
**Prerequisites:**
|
**Prerequisites:**
|
||||||
- I am not using a LLM to think or write for me. Please distill information to what's necessary and meaningful.
|
|
||||||
- I have read [Frequently Asked Questions](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md).
|
- I have read [Frequently Asked Questions](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md).
|
||||||
- I have read [Contributing Guidelines -> General Advices](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md#getting-started--general-advice).
|
- I have read [Contributing Guidelines -> General Advices](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md#getting-started--general-advice).
|
||||||
- I have read [Contributing Guidelines -> How to open an Issue](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md#how-to-open-an-issue).
|
- I have read [Contributing Guidelines -> How to open an Issue](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md#how-to-open-an-issue).
|
||||||
|
|||||||
6
.github/pull_request_template.md
vendored
6
.github/pull_request_template.md
vendored
@ -1,12 +1,10 @@
|
|||||||
(Click "Preview" to turn any http URL into a clickable link)
|
(Click "Preview" to turn any http URL into a clickable link)
|
||||||
|
|
||||||
1. PLEASE CAREFULLY READ: [Contributing Guidelines](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md). By submitting a PR you are agreeing with the [CLA](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md#copyright--contributor-license-agreement).
|
1. PLEASE CAREFULLY READ: [Contributing Guidelines](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md)
|
||||||
|
|
||||||
2. **Make sure you're using a special branch just for this pull request**. (In git, 1 PR = 1 branch. If you update the branch the PR will be updated.)
|
2. **Make sure you're using a special branch just for this pull request**. (In git, 1 PR = 1 branch. If you update the branch the PR will be updated.)
|
||||||
|
|
||||||
3. Consider running the [imgui_test_suite](https://github.com/ocornut/imgui_test_engine) or adding new tests to test for expected behaviors.
|
3. Consider running the [imgui_test_suite](https://github.com/ocornut/imgui_test_engine) or adding new tests to test for expected behaviors.
|
||||||
|
|
||||||
4. PLEASE DO NOT SUBMIT AI-GENERATED PROSE. ONLY SUBMIT CODE THAT YOU REVIEWED AND UNDERSTAND. Submissions that are lacking proper human review/judgement before being passed to us are not welcome.
|
4. Clear this template before submitting your PR.
|
||||||
|
|
||||||
5. Clear this template before submitting your PR.
|
|
||||||
|
|
||||||
|
|||||||
67
.github/workflows/build.yml
vendored
67
.github/workflows/build.yml
vendored
@ -25,8 +25,8 @@ jobs:
|
|||||||
working-directory: ${{ github.workspace }}/imgui
|
working-directory: ${{ github.workspace }}/imgui
|
||||||
|
|
||||||
env:
|
env:
|
||||||
VS_PATH: C:\Program Files\Microsoft Visual Studio\18\Enterprise
|
VS_PATH: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\
|
||||||
MSBUILD_PATH: C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Current\Bin\
|
MSBUILD_PATH: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
@ -77,7 +77,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd examples\example_null
|
cd examples\example_null
|
||||||
call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat"
|
call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
.\build_win.bat /W4
|
.\build_win32.bat /W4
|
||||||
|
|
||||||
- name: Build example_null (single file build)
|
- name: Build example_null (single file build)
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -116,7 +116,7 @@ jobs:
|
|||||||
cl.exe /D_USRDLL /D_WINDLL /I. example_single_file.cpp /LD /FeImGui.dll /link
|
cl.exe /D_USRDLL /D_WINDLL /I. example_single_file.cpp /LD /FeImGui.dll /link
|
||||||
cl.exe /DIMGUI_API=__declspec(dllimport) -DIMGUI_IMPL_API= /I. ImGui.lib /Feexample_null.exe examples/example_null/main.cpp
|
cl.exe /DIMGUI_API=__declspec(dllimport) -DIMGUI_IMPL_API= /I. ImGui.lib /Feexample_null.exe examples/example_null/main.cpp
|
||||||
|
|
||||||
# Win64 examples are more frequently compiled than the Win32 examples.
|
# Win64 examples are more frequently compilted than the Win32 examples.
|
||||||
# More of the Win32 examples requires 'workflow_run' to reduce waste.
|
# More of the Win32 examples requires 'workflow_run' to reduce waste.
|
||||||
- name: Build Win32 example_glfw_opengl2
|
- name: Build Win32 example_glfw_opengl2
|
||||||
shell: cmd
|
shell: cmd
|
||||||
@ -160,7 +160,6 @@ jobs:
|
|||||||
- name: Build Win32 example_sdl3_opengl3
|
- name: Build Win32 example_sdl3_opengl3
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
|
||||||
|
|
||||||
- name: Build Win32 example_sdl3_sdlgpu3
|
- name: Build Win32 example_sdl3_sdlgpu3
|
||||||
shell: cmd
|
shell: cmd
|
||||||
@ -201,7 +200,6 @@ jobs:
|
|||||||
- name: Build Win64 example_glfw_opengl3
|
- name: Build Win64 example_glfw_opengl3
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
|
||||||
|
|
||||||
- name: Build Win64 example_glfw_vulkan
|
- name: Build Win64 example_glfw_vulkan
|
||||||
shell: cmd
|
shell: cmd
|
||||||
@ -230,7 +228,6 @@ jobs:
|
|||||||
- name: Build Win64 example_sdl2_directx11
|
- name: Build Win64 example_sdl2_directx11
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
|
||||||
|
|
||||||
- name: Build Win64 example_sdl3_opengl3
|
- name: Build Win64 example_sdl3_opengl3
|
||||||
shell: cmd
|
shell: cmd
|
||||||
@ -268,39 +265,6 @@ jobs:
|
|||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
Build-Windows-ARM64:
|
|
||||||
runs-on: windows-11-arm
|
|
||||||
name: Build - Windows ARM64
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: ${{ github.workspace }}/imgui
|
|
||||||
|
|
||||||
env:
|
|
||||||
VS_PATH: C:\Program Files\Microsoft Visual Studio\18\Enterprise
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
with:
|
|
||||||
path: ${{ github.workspace }}/imgui
|
|
||||||
|
|
||||||
- name: Build example_null (extra warnings, msvc arm64)
|
|
||||||
shell: cmd
|
|
||||||
run: |
|
|
||||||
cd examples\example_null
|
|
||||||
call "%VS_PATH%\VC\Auxiliary\Build\vcvarsarm64.bat"
|
|
||||||
.\build_win.bat /W4
|
|
||||||
|
|
||||||
- name: Run example_null (msvc arm64)
|
|
||||||
shell: cmd
|
|
||||||
run: examples\example_null\Debug\example_null.exe
|
|
||||||
|
|
||||||
- name: Build example_win32_directx11 (msvc arm64)
|
|
||||||
shell: cmd
|
|
||||||
run: |
|
|
||||||
cd examples\example_win32_directx11
|
|
||||||
call "%VS_PATH%\VC\Auxiliary\Build\vcvarsarm64.bat"
|
|
||||||
.\build_win.bat
|
|
||||||
|
|
||||||
Build-Linux:
|
Build-Linux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Build - Linux
|
name: Build - Linux
|
||||||
@ -542,7 +506,7 @@ jobs:
|
|||||||
run: g++ -c -I. -std=c++11 -DIMGUI_IMPL_VULKAN_NO_PROTOTYPES=1 backends/imgui_impl_vulkan.cpp
|
run: g++ -c -I. -std=c++11 -DIMGUI_IMPL_VULKAN_NO_PROTOTYPES=1 backends/imgui_impl_vulkan.cpp
|
||||||
|
|
||||||
Build-MacOS:
|
Build-MacOS:
|
||||||
runs-on: macos-26
|
runs-on: macos-latest
|
||||||
name: Build - MacOS
|
name: Build - MacOS
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
@ -556,7 +520,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
brew install glfw sdl2 sdl3
|
brew install glfw3 sdl2 sdl3
|
||||||
|
|
||||||
- name: Build example_null (extra warnings, clang 64-bit)
|
- name: Build example_null (extra warnings, clang 64-bit)
|
||||||
run: make -C examples/example_null WITH_EXTRA_WARNINGS=1
|
run: make -C examples/example_null WITH_EXTRA_WARNINGS=1
|
||||||
@ -608,9 +572,6 @@ jobs:
|
|||||||
- name: Build macOS example_sdl2_metal
|
- name: Build macOS example_sdl2_metal
|
||||||
run: make -C examples/example_sdl2_metal
|
run: make -C examples/example_sdl2_metal
|
||||||
|
|
||||||
- name: Build macOS example_sdl3_metal4
|
|
||||||
run: make -C examples/example_sdl3_metal4
|
|
||||||
|
|
||||||
- name: Build macOS example_sdl2_opengl2
|
- name: Build macOS example_sdl2_opengl2
|
||||||
run: make -C examples/example_sdl2_opengl2
|
run: make -C examples/example_sdl2_opengl2
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
@ -626,18 +587,10 @@ jobs:
|
|||||||
run: xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos
|
run: xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build macOS example_apple_metal4
|
|
||||||
run: xcodebuild -project examples/example_apple_metal4/example_apple_metal4.xcodeproj -target example_apple_metal_macos
|
|
||||||
if: github.event_name == 'workflow_run'
|
|
||||||
|
|
||||||
- name: Build macOS example_apple_opengl2
|
- name: Build macOS example_apple_opengl2
|
||||||
run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
|
run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build macOS example_apple_opengl3
|
|
||||||
run: xcodebuild -project examples/example_apple_opengl3/example_apple_opengl3.xcodeproj -target example_osx_opengl3
|
|
||||||
if: github.event_name == 'workflow_run'
|
|
||||||
|
|
||||||
Build-iOS:
|
Build-iOS:
|
||||||
runs-on: macos-14
|
runs-on: macos-14
|
||||||
name: Build - iOS
|
name: Build - iOS
|
||||||
@ -698,12 +651,8 @@ jobs:
|
|||||||
name: Build - Android
|
name: Build - Android
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Gradle 9.4.1
|
|
||||||
uses: gradle/actions/setup-gradle@v6
|
|
||||||
with:
|
|
||||||
gradle-version: '9.4.1'
|
|
||||||
|
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Build example_android_opengl3
|
- name: Build example_android_opengl3
|
||||||
run: |
|
run: |
|
||||||
cd examples/example_android_opengl3/android
|
cd examples/example_android_opengl3/android
|
||||||
@ -718,7 +667,7 @@ jobs:
|
|||||||
working-directory: ${{ github.workspace }}/imgui
|
working-directory: ${{ github.workspace }}/imgui
|
||||||
|
|
||||||
env:
|
env:
|
||||||
MSBUILD_PATH: C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Current\Bin\
|
MSBUILD_PATH: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|||||||
4
.github/workflows/static-analysis.yml
vendored
4
.github/workflows/static-analysis.yml
vendored
@ -23,9 +23,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
if [[ "$PVS_STUDIO_LICENSE" != "" ]];
|
if [[ "$PVS_STUDIO_LICENSE" != "" ]];
|
||||||
then
|
then
|
||||||
wget -q https://files.pvs-studio.com/etc/pubkey.txt
|
wget -q https://files.viva64.com/etc/pubkey.txt
|
||||||
sudo apt-key add pubkey.txt
|
sudo apt-key add pubkey.txt
|
||||||
sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.pvs-studio.com/etc/viva64.list
|
sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y pvs-studio
|
sudo apt-get install -y pvs-studio
|
||||||
pvs-studio-analyzer credentials -o pvs-studio.lic $PVS_STUDIO_LICENSE
|
pvs-studio-analyzer credentials -o pvs-studio.lic $PVS_STUDIO_LICENSE
|
||||||
|
|||||||
15
.gitignore
vendored
15
.gitignore
vendored
@ -1,7 +1,5 @@
|
|||||||
## Misc artifacts
|
## OSX artifacts
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.claude
|
|
||||||
.vscode
|
|
||||||
|
|
||||||
## Dear ImGui artifacts
|
## Dear ImGui artifacts
|
||||||
imgui.ini
|
imgui.ini
|
||||||
@ -9,8 +7,6 @@ imgui*.ini
|
|||||||
|
|
||||||
## General build artifacts
|
## General build artifacts
|
||||||
*.o
|
*.o
|
||||||
*.so*
|
|
||||||
*.a
|
|
||||||
*.obj
|
*.obj
|
||||||
*.exe
|
*.exe
|
||||||
examples/*/Debug/*
|
examples/*/Debug/*
|
||||||
@ -59,16 +55,12 @@ examples/example_sdl3_wgpu/web/*
|
|||||||
.idea
|
.idea
|
||||||
cmake-build-*
|
cmake-build-*
|
||||||
|
|
||||||
## QNX artifacts
|
## VS code artifacts
|
||||||
*.pinfo
|
.vscode
|
||||||
*.dep
|
|
||||||
*.gcno
|
|
||||||
|
|
||||||
## Unix executables from our example Makefiles
|
## Unix executables from our example Makefiles
|
||||||
examples/example_apple_metal/example_apple_metal
|
examples/example_apple_metal/example_apple_metal
|
||||||
examples/example_apple_metal4/example_apple_metal4
|
|
||||||
examples/example_apple_opengl2/example_apple_opengl2
|
examples/example_apple_opengl2/example_apple_opengl2
|
||||||
examples/example_apple_opengl3/example_apple_opengl3
|
|
||||||
examples/example_glfw_metal/example_glfw_metal
|
examples/example_glfw_metal/example_glfw_metal
|
||||||
examples/example_glfw_opengl2/example_glfw_opengl2
|
examples/example_glfw_opengl2/example_glfw_opengl2
|
||||||
examples/example_glfw_opengl3/example_glfw_opengl3
|
examples/example_glfw_opengl3/example_glfw_opengl3
|
||||||
@ -81,7 +73,6 @@ examples/example_sdl2_opengl3/example_sdl2_opengl3
|
|||||||
examples/example_sdl2_sdlrenderer2/example_sdl2_sdlrenderer2
|
examples/example_sdl2_sdlrenderer2/example_sdl2_sdlrenderer2
|
||||||
examples/example_sdl2_vulkan/example_sdl2_vulkan
|
examples/example_sdl2_vulkan/example_sdl2_vulkan
|
||||||
examples/example_sdl3_metal/example_sdl3_metal
|
examples/example_sdl3_metal/example_sdl3_metal
|
||||||
examples/example_sdl3_metal4/example_sdl3_metal4
|
|
||||||
examples/example_sdl3_opengl3/example_sdl3_opengl3
|
examples/example_sdl3_opengl3/example_sdl3_opengl3
|
||||||
examples/example_sdl3_sdlgpu3/example_sdl3_sdlgpu3
|
examples/example_sdl3_sdlgpu3/example_sdl3_sdlgpu3
|
||||||
examples/example_sdl3_sdlrenderer3/example_sdl3_sdlrenderer3
|
examples/example_sdl3_sdlrenderer3/example_sdl3_sdlrenderer3
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Missing features or Issues:
|
// Missing features or Issues:
|
||||||
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
||||||
// [ ] Renderer: Missing support for DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest callbacks: Allegro5 cannot enable/disable LINEAR bitmap flags after creation.
|
|
||||||
// [ ] Platform: Missing gamepad support.
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
@ -22,7 +21,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState (others cannot be supported by Allegro5). (#9378)
|
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() and platform_io.ClearPlatformHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() and platform_io.ClearPlatformHandlers() on shutdown.
|
||||||
// 2025-08-12: Inputs: fixed missing support for ImGuiKey_PrintScreen under Windows, as raw Allegro 5 does not receive it.
|
// 2025-08-12: Inputs: fixed missing support for ImGuiKey_PrintScreen under Windows, as raw Allegro 5 does not receive it.
|
||||||
// 2025-08-12: Added ImGui_ImplAllegro5_SetDisplay() function to change current ALLEGRO_DISPLAY, as Allegro applications often need to do that.
|
// 2025-08-12: Added ImGui_ImplAllegro5_SetDisplay() function to change current ALLEGRO_DISPLAY, as Allegro applications often need to do that.
|
||||||
@ -138,10 +136,7 @@ static void ImGui_ImplAllegro5_SetupRenderState(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
// Render function.
|
||||||
static void ImGui_ImplAllegro5_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
|
|
||||||
// Render function
|
|
||||||
void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized
|
// Avoid rendering when minimized
|
||||||
@ -157,7 +152,6 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
// Backup Allegro state that will be modified
|
// Backup Allegro state that will be modified
|
||||||
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
ALLEGRO_TRANSFORM last_transform = *al_get_current_transform();
|
ALLEGRO_TRANSFORM last_transform = *al_get_current_transform();
|
||||||
ALLEGRO_TRANSFORM last_projection_transform = *al_get_current_projection_transform();
|
ALLEGRO_TRANSFORM last_projection_transform = *al_get_current_projection_transform();
|
||||||
int last_clip_x, last_clip_y, last_clip_w, last_clip_h;
|
int last_clip_x, last_clip_y, last_clip_w, last_clip_h;
|
||||||
@ -214,7 +208,8 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (pcmd->UserCallback)
|
if (pcmd->UserCallback)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplAllegro5_DrawCallback_ResetRenderState)
|
// (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);
|
ImGui_ImplAllegro5_SetupRenderState(draw_data);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -268,7 +263,8 @@ void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex)
|
|||||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
||||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
||||||
|
|
||||||
// Create texture (bilinear sampling is required)
|
// Create texture
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
const int new_bitmap_flags = al_get_new_bitmap_flags();
|
const int new_bitmap_flags = al_get_new_bitmap_flags();
|
||||||
int new_bitmap_format = al_get_new_bitmap_format();
|
int new_bitmap_format = al_get_new_bitmap_format();
|
||||||
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
|
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
|
||||||
@ -490,12 +486,11 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
|||||||
|
|
||||||
ImGui_ImplAllegro5_SetDisplay(display);
|
ImGui_ImplAllegro5_SetDisplay(display);
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
#if ALLEGRO_HAS_CLIPBOARD
|
#if ALLEGRO_HAS_CLIPBOARD
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
platform_io.Platform_SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
|
platform_io.Platform_SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
|
||||||
platform_io.Platform_GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
|
platform_io.Platform_GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
|
||||||
#endif
|
#endif
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplAllegro5_DrawCallback_ResetRenderState;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Missing features or Issues:
|
// Missing features or Issues:
|
||||||
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
||||||
// [ ] Renderer: Missing support for DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest callbacks: Allegro5 cannot enable/disable LINEAR bitmap flags after creation.
|
|
||||||
// [ ] Platform: Missing gamepad support.
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// dear imgui: Platform Binding for Android native app
|
// dear imgui: Platform Binding for Android native app
|
||||||
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
|
// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
|
||||||
@ -23,9 +23,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-07-15: Inputs: clear mouse position on touch release (AMOTION_EVENT_ACTION_UP) to prevent items from staying in hovered state. (#6627, #9474)
|
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
||||||
// 2023-04-11: Inputs: calling new io.AddMouseSourceEvent() to discriminate Mouse from Touch events.
|
|
||||||
// 2022-09-26: Inputs: renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
|
||||||
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago) with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago) with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
@ -232,8 +230,6 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event)
|
|||||||
{
|
{
|
||||||
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
||||||
io.AddMouseButtonEvent(0, event_action == AMOTION_EVENT_ACTION_DOWN);
|
io.AddMouseButtonEvent(0, event_action == AMOTION_EVENT_ACTION_DOWN);
|
||||||
if (event_action == AMOTION_EVENT_ACTION_UP) // (#6627, #9474)
|
|
||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// dear imgui: Platform Binding for Android native app
|
// dear imgui: Platform Binding for Android native app
|
||||||
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
|
// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy AKEYCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplDX10_GetRenderState().
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -17,9 +16,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-09-07: Round framebuffer dimensions to the nearest integer instead of truncating them. (#9538, 9515, #8628)
|
// 2026-01-19: DirectX11: Added 'SamplerNearest' in ImGui_ImplDX11_RenderState. Renamed 'SamplerDefault' to 'SamplerLinear'.
|
||||||
// 2026-04-23: DirectX10: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. Obsoleting samplers from ImGui_ImplDX10_RenderState. (#9378)
|
|
||||||
// 2026-01-19: DirectX10: Added 'SamplerNearest' in ImGui_ImplDX10_RenderState. Renamed 'SamplerDefault' to 'SamplerLinear'.
|
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
// 2025-06-11: DirectX10: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
// 2025-06-11: DirectX10: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
||||||
// 2025-05-07: DirectX10: Honor draw_data->FramebufferScale to allow for custom backends and experiment using it (consistently with other renderer backends, even though in normal condition it is not set under Windows).
|
// 2025-05-07: DirectX10: Honor draw_data->FramebufferScale to allow for custom backends and experiment using it (consistently with other renderer backends, even though in normal condition it is not set under Windows).
|
||||||
@ -101,11 +98,6 @@ static ImGui_ImplDX10_Data* ImGui_ImplDX10_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplDX10_RenderState* ImGui_ImplDX10_GetRenderState()
|
|
||||||
{
|
|
||||||
return (ImGui_ImplDX10_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* device)
|
static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* device)
|
||||||
{
|
{
|
||||||
@ -113,8 +105,8 @@ static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device*
|
|||||||
|
|
||||||
// Setup viewport
|
// Setup viewport
|
||||||
D3D10_VIEWPORT vp = {};
|
D3D10_VIEWPORT vp = {};
|
||||||
vp.Width = (UINT)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f);
|
vp.Width = (UINT)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
vp.Height = (UINT)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
vp.Height = (UINT)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
vp.MinDepth = 0.0f;
|
vp.MinDepth = 0.0f;
|
||||||
vp.MaxDepth = 1.0f;
|
vp.MaxDepth = 1.0f;
|
||||||
vp.TopLeftX = vp.TopLeftY = 0;
|
vp.TopLeftX = vp.TopLeftY = 0;
|
||||||
@ -155,17 +147,12 @@ static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device*
|
|||||||
device->GSSetShader(nullptr);
|
device->GSSetShader(nullptr);
|
||||||
|
|
||||||
// Setup render state
|
// Setup render state
|
||||||
const float blend_factor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
||||||
device->OMSetBlendState(bd->pBlendState, blend_factor, 0xffffffff);
|
device->OMSetBlendState(bd->pBlendState, blend_factor, 0xffffffff);
|
||||||
device->OMSetDepthStencilState(bd->pDepthStencilState, 0);
|
device->OMSetDepthStencilState(bd->pDepthStencilState, 0);
|
||||||
device->RSSetState(bd->pRasterizerState);
|
device->RSSetState(bd->pRasterizerState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplDX10_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplDX10_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); bd->pd3dDevice->PSSetSamplers(0, 1, &bd->pTexSamplerLinear); }
|
|
||||||
static void ImGui_ImplDX10_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); bd->pd3dDevice->PSSetSamplers(0, 1, &bd->pTexSamplerNearest); }
|
|
||||||
|
|
||||||
// Render function
|
// Render function
|
||||||
void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
@ -190,7 +177,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
D3D10_BUFFER_DESC desc = {};
|
D3D10_BUFFER_DESC desc = {};
|
||||||
desc.Usage = D3D10_USAGE_DYNAMIC;
|
desc.Usage = D3D10_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = (UINT)bd->VertexBufferSize * sizeof(ImDrawVert);
|
desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert);
|
||||||
desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
||||||
desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
|
||||||
desc.MiscFlags = 0;
|
desc.MiscFlags = 0;
|
||||||
@ -204,7 +191,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D10_BUFFER_DESC desc = {};
|
D3D10_BUFFER_DESC desc = {};
|
||||||
desc.Usage = D3D10_USAGE_DYNAMIC;
|
desc.Usage = D3D10_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = (UINT)bd->IndexBufferSize * sizeof(ImDrawIdx);
|
desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
desc.BindFlags = D3D10_BIND_INDEX_BUFFER;
|
desc.BindFlags = D3D10_BIND_INDEX_BUFFER;
|
||||||
desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
|
||||||
if (device->CreateBuffer(&desc, nullptr, &bd->pIB) < 0)
|
if (device->CreateBuffer(&desc, nullptr, &bd->pIB) < 0)
|
||||||
@ -273,6 +260,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
ImGui_ImplDX10_RenderState render_state;
|
ImGui_ImplDX10_RenderState render_state;
|
||||||
render_state.Device = bd->pd3dDevice;
|
render_state.Device = bd->pd3dDevice;
|
||||||
|
render_state.SamplerLinear = bd->pTexSamplerLinear;
|
||||||
|
render_state.SamplerNearest = bd->pTexSamplerNearest;
|
||||||
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
||||||
platform_io.Renderer_RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
@ -290,7 +279,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (pcmd->UserCallback != nullptr)
|
if (pcmd->UserCallback != nullptr)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplDX10_DrawCallback_ResetRenderState)
|
// (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, device);
|
ImGui_ImplDX10_SetupRenderState(draw_data, device);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -453,7 +443,7 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
|||||||
PS_INPUT main(VS_INPUT input)\
|
PS_INPUT main(VS_INPUT input)\
|
||||||
{\
|
{\
|
||||||
PS_INPUT output;\
|
PS_INPUT output;\
|
||||||
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.0f, 1.0f));\
|
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
|
||||||
output.col = input.col;\
|
output.col = input.col;\
|
||||||
output.uv = input.uv;\
|
output.uv = input.uv;\
|
||||||
return output;\
|
return output;\
|
||||||
@ -564,7 +554,8 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
|||||||
bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState);
|
bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create texture sampler (bilinear sampling is required)
|
// Create texture sampler
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
{
|
{
|
||||||
D3D10_SAMPLER_DESC desc;
|
D3D10_SAMPLER_DESC desc;
|
||||||
ZeroMemory(&desc, sizeof(desc));
|
ZeroMemory(&desc, sizeof(desc));
|
||||||
@ -572,10 +563,10 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
|||||||
desc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP;
|
desc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||||
desc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP;
|
desc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||||
desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
|
desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||||
desc.MipLODBias = 0.0f;
|
desc.MipLODBias = 0.f;
|
||||||
desc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
|
desc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
|
||||||
desc.MinLOD = 0.0f;
|
desc.MinLOD = 0.f;
|
||||||
desc.MaxLOD = 0.0f;
|
desc.MaxLOD = 0.f;
|
||||||
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
||||||
desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT;
|
desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT;
|
||||||
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerNearest);
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerNearest);
|
||||||
@ -622,9 +613,6 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
|||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
platform_io.Renderer_TextureMaxWidth = platform_io.Renderer_TextureMaxHeight = D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION;
|
platform_io.Renderer_TextureMaxWidth = platform_io.Renderer_TextureMaxHeight = D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION;
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplDX10_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplDX10_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplDX10_DrawCallback_SetSamplerNearest;
|
|
||||||
|
|
||||||
// Get factory from device
|
// Get factory from device
|
||||||
IDXGIDevice* pDXGIDevice = nullptr;
|
IDXGIDevice* pDXGIDevice = nullptr;
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplDX10_GetRenderState().
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -42,10 +41,9 @@ IMGUI_IMPL_API void ImGui_ImplDX10_UpdateTexture(ImTextureData* tex);
|
|||||||
struct ImGui_ImplDX10_RenderState
|
struct ImGui_ImplDX10_RenderState
|
||||||
{
|
{
|
||||||
ID3D10Device* Device;
|
ID3D10Device* Device;
|
||||||
|
ID3D10SamplerState* SamplerLinear;
|
||||||
|
ID3D10SamplerState* SamplerNearest;
|
||||||
ID3D10Buffer* VertexConstantBuffer;
|
ID3D10Buffer* VertexConstantBuffer;
|
||||||
//ID3D10SamplerState* SamplerLinear; // Use ImDrawList::AddCallback(ImGui::GetPlatform().DrawCallback_SetSamplerLinear)
|
|
||||||
//ID3D10SamplerState* SamplerNearest; // Use ImDrawList::AddCallback(ImGui::GetPlatform().DrawCallback_SetSamplerNearest)
|
|
||||||
};
|
};
|
||||||
IMGUI_IMPL_API ImGui_ImplDX10_RenderState* ImGui_ImplDX10_GetRenderState();
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplDX11_GetRenderState().
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-04-23: DirectX11: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. Obsoleting samplers from ImGui_ImplDX11_RenderState. (#9378)
|
|
||||||
// 2026-01-19: DirectX11: Added 'SamplerNearest' in ImGui_ImplDX11_RenderState. Renamed 'SamplerDefault' to 'SamplerLinear'.
|
// 2026-01-19: DirectX11: Added 'SamplerNearest' in ImGui_ImplDX11_RenderState. Renamed 'SamplerDefault' to 'SamplerLinear'.
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
// 2025-06-11: DirectX11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
// 2025-06-11: DirectX11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
||||||
@ -86,7 +85,6 @@ struct ImGui_ImplDX11_Data
|
|||||||
ID3D11DepthStencilState* pDepthStencilState;
|
ID3D11DepthStencilState* pDepthStencilState;
|
||||||
int VertexBufferSize;
|
int VertexBufferSize;
|
||||||
int IndexBufferSize;
|
int IndexBufferSize;
|
||||||
ImGui_ImplDX11_RenderState* RenderState; // == (ImGui_ImplDX11_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState during rendering.
|
|
||||||
|
|
||||||
ImGui_ImplDX11_Data() { memset((void*)this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
|
ImGui_ImplDX11_Data() { memset((void*)this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
|
||||||
};
|
};
|
||||||
@ -103,11 +101,6 @@ static ImGui_ImplDX11_Data* ImGui_ImplDX11_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplDX11_RenderState* ImGui_ImplDX11_GetRenderState()
|
|
||||||
{
|
|
||||||
return (ImGui_ImplDX11_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX11_SetupRenderState(const ImDrawData* draw_data, ID3D11DeviceContext* device_ctx)
|
static void ImGui_ImplDX11_SetupRenderState(const ImDrawData* draw_data, ID3D11DeviceContext* device_ctx)
|
||||||
{
|
{
|
||||||
@ -115,8 +108,8 @@ static void ImGui_ImplDX11_SetupRenderState(const ImDrawData* draw_data, ID3D11D
|
|||||||
|
|
||||||
// Setup viewport
|
// Setup viewport
|
||||||
D3D11_VIEWPORT vp = {};
|
D3D11_VIEWPORT vp = {};
|
||||||
vp.Width = (float)(int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f);
|
vp.Width = draw_data->DisplaySize.x * draw_data->FramebufferScale.x;
|
||||||
vp.Height = (float)(int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
vp.Height = draw_data->DisplaySize.y * draw_data->FramebufferScale.y;
|
||||||
vp.MinDepth = 0.0f;
|
vp.MinDepth = 0.0f;
|
||||||
vp.MaxDepth = 1.0f;
|
vp.MaxDepth = 1.0f;
|
||||||
vp.TopLeftX = vp.TopLeftY = 0;
|
vp.TopLeftX = vp.TopLeftY = 0;
|
||||||
@ -160,17 +153,12 @@ static void ImGui_ImplDX11_SetupRenderState(const ImDrawData* draw_data, ID3D11D
|
|||||||
device_ctx->CSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
device_ctx->CSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||||
|
|
||||||
// Setup render state
|
// Setup render state
|
||||||
const float blend_factor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
||||||
device_ctx->OMSetBlendState(bd->pBlendState, blend_factor, 0xffffffff);
|
device_ctx->OMSetBlendState(bd->pBlendState, blend_factor, 0xffffffff);
|
||||||
device_ctx->OMSetDepthStencilState(bd->pDepthStencilState, 0);
|
device_ctx->OMSetDepthStencilState(bd->pDepthStencilState, 0);
|
||||||
device_ctx->RSSetState(bd->pRasterizerState);
|
device_ctx->RSSetState(bd->pRasterizerState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplDX11_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplDX11_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); bd->RenderState->DeviceContext->PSSetSamplers(0, 1, &bd->pTexSamplerLinear); }
|
|
||||||
static void ImGui_ImplDX11_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); bd->RenderState->DeviceContext->PSSetSamplers(0, 1, &bd->pTexSamplerNearest); }
|
|
||||||
|
|
||||||
// Render function
|
// Render function
|
||||||
void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
@ -195,7 +183,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
D3D11_BUFFER_DESC desc = {};
|
D3D11_BUFFER_DESC desc = {};
|
||||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = (UINT)bd->VertexBufferSize * sizeof(ImDrawVert);
|
desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert);
|
||||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
desc.MiscFlags = 0;
|
desc.MiscFlags = 0;
|
||||||
@ -208,7 +196,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D11_BUFFER_DESC desc = {};
|
D3D11_BUFFER_DESC desc = {};
|
||||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
desc.ByteWidth = (UINT)bd->IndexBufferSize * sizeof(ImDrawIdx);
|
desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
if (bd->pd3dDevice->CreateBuffer(&desc, nullptr, &bd->pIB) < 0)
|
if (bd->pd3dDevice->CreateBuffer(&desc, nullptr, &bd->pIB) < 0)
|
||||||
@ -286,8 +274,10 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImGui_ImplDX11_RenderState render_state;
|
ImGui_ImplDX11_RenderState render_state;
|
||||||
render_state.Device = bd->pd3dDevice;
|
render_state.Device = bd->pd3dDevice;
|
||||||
render_state.DeviceContext = bd->pd3dDeviceContext;
|
render_state.DeviceContext = bd->pd3dDeviceContext;
|
||||||
|
render_state.SamplerLinear = bd->pTexSamplerLinear;
|
||||||
|
render_state.SamplerNearest = bd->pTexSamplerNearest;
|
||||||
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
@ -303,7 +293,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (pcmd->UserCallback != nullptr)
|
if (pcmd->UserCallback != nullptr)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplDX11_DrawCallback_ResetRenderState)
|
// (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, device);
|
ImGui_ImplDX11_SetupRenderState(draw_data, device);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -329,7 +320,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
global_idx_offset += draw_list->IdxBuffer.Size;
|
global_idx_offset += draw_list->IdxBuffer.Size;
|
||||||
global_vtx_offset += draw_list->VtxBuffer.Size;
|
global_vtx_offset += draw_list->VtxBuffer.Size;
|
||||||
}
|
}
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = nullptr;
|
platform_io.Renderer_RenderState = nullptr;
|
||||||
|
|
||||||
// Restore modified DX state
|
// Restore modified DX state
|
||||||
device->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
|
device->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
|
||||||
@ -467,7 +458,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
PS_INPUT main(VS_INPUT input)\
|
PS_INPUT main(VS_INPUT input)\
|
||||||
{\
|
{\
|
||||||
PS_INPUT output;\
|
PS_INPUT output;\
|
||||||
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.0f, 1.0f));\
|
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
|
||||||
output.col = input.col;\
|
output.col = input.col;\
|
||||||
output.uv = input.uv;\
|
output.uv = input.uv;\
|
||||||
return output;\
|
return output;\
|
||||||
@ -579,6 +570,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create texture sampler
|
// Create texture sampler
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
{
|
{
|
||||||
D3D11_SAMPLER_DESC desc;
|
D3D11_SAMPLER_DESC desc;
|
||||||
ZeroMemory(&desc, sizeof(desc));
|
ZeroMemory(&desc, sizeof(desc));
|
||||||
@ -586,10 +578,10 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||||
desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||||
desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||||
desc.MipLODBias = 0.0f;
|
desc.MipLODBias = 0.f;
|
||||||
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
desc.MinLOD = 0.0f;
|
desc.MinLOD = 0.f;
|
||||||
desc.MaxLOD = 0.0f;
|
desc.MaxLOD = 0.f;
|
||||||
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
||||||
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||||
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerNearest);
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerNearest);
|
||||||
@ -637,9 +629,6 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
|
|||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
platform_io.Renderer_TextureMaxWidth = platform_io.Renderer_TextureMaxHeight = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
|
platform_io.Renderer_TextureMaxWidth = platform_io.Renderer_TextureMaxHeight = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplDX11_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplDX11_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplDX11_DrawCallback_SetSamplerNearest;
|
|
||||||
|
|
||||||
// Get factory from device
|
// Get factory from device
|
||||||
IDXGIDevice* pDXGIDevice = nullptr;
|
IDXGIDevice* pDXGIDevice = nullptr;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplDX11_GetRenderState().
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -44,10 +44,9 @@ struct ImGui_ImplDX11_RenderState
|
|||||||
{
|
{
|
||||||
ID3D11Device* Device;
|
ID3D11Device* Device;
|
||||||
ID3D11DeviceContext* DeviceContext;
|
ID3D11DeviceContext* DeviceContext;
|
||||||
|
ID3D11SamplerState* SamplerLinear;
|
||||||
|
ID3D11SamplerState* SamplerNearest;
|
||||||
ID3D11Buffer* VertexConstantBuffer;
|
ID3D11Buffer* VertexConstantBuffer;
|
||||||
//ID3D11SamplerState* SamplerLinear; // Use ImDrawList::AddCallback(ImGui::GetPlatform().DrawCallback_SetSamplerLinear)
|
|
||||||
//ID3D11SamplerState* SamplerNearest; // Use ImDrawList::AddCallback(ImGui::GetPlatform().DrawCallback_SetSamplerNearest)
|
|
||||||
};
|
};
|
||||||
IMGUI_IMPL_API ImGui_ImplDX11_RenderState* ImGui_ImplDX11_GetRenderState();
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplDX12_GetRenderState().
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
|
|
||||||
// The aim of imgui_impl_dx12.h/.cpp is to be usable in your engine without any modification.
|
// The aim of imgui_impl_dx12.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/
|
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||||
@ -20,9 +20,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-09-07: Round framebuffer dimensions to the nearest integer instead of truncating them. (#9538, 9515, #8628)
|
|
||||||
// 2026-08-05: DirectX12: *BREAKING CHANGE* Removed support for legacy `ImGui_ImplDX12_Init()` signature obsoleted in 1.91.6 (2024-11-15) because it needed to forcefully disable support for ImGuiBackendFlags_RendererHasTextures. (#9487)
|
|
||||||
// 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. (#9378)
|
|
||||||
// 2025-10-11: DirectX12: Reuse texture upload buffer and grow it only when necessary. (#9002)
|
// 2025-10-11: DirectX12: Reuse texture upload buffer and grow it only when necessary. (#9002)
|
||||||
// 2025-09-29: DirectX12: Rework synchronization logic. (#8961)
|
// 2025-09-29: DirectX12: Rework synchronization logic. (#8961)
|
||||||
// 2025-09-29: DirectX12: Enable swapchain tearing to eliminate viewports framerate throttling. (#8965)
|
// 2025-09-29: DirectX12: Enable swapchain tearing to eliminate viewports framerate throttling. (#8965)
|
||||||
@ -94,8 +91,6 @@ struct ImGui_ImplDX12_Texture
|
|||||||
struct ImGui_ImplDX12_Data
|
struct ImGui_ImplDX12_Data
|
||||||
{
|
{
|
||||||
ImGui_ImplDX12_InitInfo InitInfo;
|
ImGui_ImplDX12_InitInfo InitInfo;
|
||||||
ImGui_ImplDX12_RenderState* RenderState;
|
|
||||||
|
|
||||||
IDXGIFactory5* pdxgiFactory;
|
IDXGIFactory5* pdxgiFactory;
|
||||||
ID3D12Device* pd3dDevice;
|
ID3D12Device* pd3dDevice;
|
||||||
ID3D12RootSignature* pRootSignatureLinear;
|
ID3D12RootSignature* pRootSignatureLinear;
|
||||||
@ -133,11 +128,6 @@ static ImGui_ImplDX12_Data* ImGui_ImplDX12_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplDX12_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX12_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplDX12_RenderState* ImGui_ImplDX12_GetRenderState()
|
|
||||||
{
|
|
||||||
return (ImGui_ImplDX12_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Buffers used during the rendering of a frame
|
// Buffers used during the rendering of a frame
|
||||||
struct ImGui_ImplDX12_RenderBuffers
|
struct ImGui_ImplDX12_RenderBuffers
|
||||||
{
|
{
|
||||||
@ -152,15 +142,19 @@ struct VERTEX_CONSTANT_BUFFER_DX12
|
|||||||
float mvp[4][4];
|
float mvp[4][4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME-WIP: Allow user to forward declare those two, for until we come up with a backend agnostic API to do this. (#9173)
|
||||||
|
void ImGui_ImplDX12_SetupSamplerLinear(ID3D12GraphicsCommandList* command_list);
|
||||||
|
void ImGui_ImplDX12_SetupSamplerNearest(ID3D12GraphicsCommandList* command_list);
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX12_SetupSamplerLinear(ID3D12GraphicsCommandList* command_list)
|
void ImGui_ImplDX12_SetupSamplerLinear(ID3D12GraphicsCommandList* command_list)
|
||||||
{
|
{
|
||||||
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
command_list->SetPipelineState(bd->pPipelineStateLinear);
|
command_list->SetPipelineState(bd->pPipelineStateLinear);
|
||||||
command_list->SetGraphicsRootSignature(bd->pRootSignatureLinear);
|
command_list->SetGraphicsRootSignature(bd->pRootSignatureLinear);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplDX12_SetupSamplerNearest(ID3D12GraphicsCommandList* command_list)
|
void ImGui_ImplDX12_SetupSamplerNearest(ID3D12GraphicsCommandList* command_list)
|
||||||
{
|
{
|
||||||
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
command_list->SetPipelineState(bd->pPipelineStateNearest);
|
command_list->SetPipelineState(bd->pPipelineStateNearest);
|
||||||
@ -189,8 +183,8 @@ static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12Graphic
|
|||||||
|
|
||||||
// Setup viewport
|
// Setup viewport
|
||||||
D3D12_VIEWPORT vp = {};
|
D3D12_VIEWPORT vp = {};
|
||||||
vp.Width = (float)(int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f);
|
vp.Width = draw_data->DisplaySize.x * draw_data->FramebufferScale.x;
|
||||||
vp.Height = (float)(int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
vp.Height = draw_data->DisplaySize.y * draw_data->FramebufferScale.y;
|
||||||
vp.MinDepth = 0.0f;
|
vp.MinDepth = 0.0f;
|
||||||
vp.MaxDepth = 1.0f;
|
vp.MaxDepth = 1.0f;
|
||||||
vp.TopLeftX = vp.TopLeftY = 0.0f;
|
vp.TopLeftX = vp.TopLeftY = 0.0f;
|
||||||
@ -206,7 +200,7 @@ static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12Graphic
|
|||||||
command_list->IASetVertexBuffers(0, 1, &vbv);
|
command_list->IASetVertexBuffers(0, 1, &vbv);
|
||||||
D3D12_INDEX_BUFFER_VIEW ibv = {};
|
D3D12_INDEX_BUFFER_VIEW ibv = {};
|
||||||
ibv.BufferLocation = fr->IndexBuffer->GetGPUVirtualAddress();
|
ibv.BufferLocation = fr->IndexBuffer->GetGPUVirtualAddress();
|
||||||
ibv.SizeInBytes = (UINT)fr->IndexBufferSize * sizeof(ImDrawIdx);
|
ibv.SizeInBytes = fr->IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
ibv.Format = sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
|
ibv.Format = sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
|
||||||
command_list->IASetIndexBuffer(&ibv);
|
command_list->IASetIndexBuffer(&ibv);
|
||||||
command_list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
command_list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
@ -214,7 +208,7 @@ static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12Graphic
|
|||||||
command_list->SetGraphicsRoot32BitConstants(0, 16, &vertex_constant_buffer, 0);
|
command_list->SetGraphicsRoot32BitConstants(0, 16, &vertex_constant_buffer, 0);
|
||||||
|
|
||||||
// Setup blend factor
|
// Setup blend factor
|
||||||
const float blend_factor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
||||||
command_list->OMSetBlendFactor(blend_factor);
|
command_list->OMSetBlendFactor(blend_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,11 +220,6 @@ static inline void SafeRelease(T*& res)
|
|||||||
res = nullptr;
|
res = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplDX12_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplDX12_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); ImGui_ImplDX12_SetupSamplerLinear(bd->RenderState->CommandList); }
|
|
||||||
static void ImGui_ImplDX12_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); ImGui_ImplDX12_SetupSamplerNearest(bd->RenderState->CommandList); }
|
|
||||||
|
|
||||||
// Render function
|
// Render function
|
||||||
void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* command_list)
|
void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* command_list)
|
||||||
{
|
{
|
||||||
@ -328,7 +317,7 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
ImGui_ImplDX12_RenderState render_state;
|
ImGui_ImplDX12_RenderState render_state;
|
||||||
render_state.Device = bd->pd3dDevice;
|
render_state.Device = bd->pd3dDevice;
|
||||||
render_state.CommandList = command_list;
|
render_state.CommandList = command_list;
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
@ -345,7 +334,7 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// 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.)
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
if (pcmd->UserCallback == ImGui_ImplDX12_DrawCallback_ResetRenderState)
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
ImGui_ImplDX12_SetupRenderState(draw_data, command_list, fr);
|
ImGui_ImplDX12_SetupRenderState(draw_data, command_list, fr);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -372,7 +361,7 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
global_idx_offset += draw_list->IdxBuffer.Size;
|
global_idx_offset += draw_list->IdxBuffer.Size;
|
||||||
global_vtx_offset += draw_list->VtxBuffer.Size;
|
global_vtx_offset += draw_list->VtxBuffer.Size;
|
||||||
}
|
}
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = nullptr;
|
platform_io.Renderer_RenderState = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplDX12_DestroyTexture(ImTextureData* tex)
|
static void ImGui_ImplDX12_DestroyTexture(ImTextureData* tex)
|
||||||
@ -615,17 +604,17 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
param[1].DescriptorTable.pDescriptorRanges = &descRange;
|
param[1].DescriptorTable.pDescriptorRanges = &descRange;
|
||||||
param[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
param[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
||||||
|
|
||||||
// Bilinear sampling is required
|
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||||
D3D12_STATIC_SAMPLER_DESC staticSampler[1] = {};
|
D3D12_STATIC_SAMPLER_DESC staticSampler[1] = {};
|
||||||
staticSampler[0].Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
staticSampler[0].Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
||||||
staticSampler[0].AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
staticSampler[0].AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||||
staticSampler[0].AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
staticSampler[0].AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||||
staticSampler[0].AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
staticSampler[0].AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||||
staticSampler[0].MipLODBias = 0.0f;
|
staticSampler[0].MipLODBias = 0.f;
|
||||||
staticSampler[0].MaxAnisotropy = 0;
|
staticSampler[0].MaxAnisotropy = 0;
|
||||||
staticSampler[0].ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
|
staticSampler[0].ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
|
||||||
staticSampler[0].BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK;
|
staticSampler[0].BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK;
|
||||||
staticSampler[0].MinLOD = 0.0f;
|
staticSampler[0].MinLOD = 0.f;
|
||||||
staticSampler[0].MaxLOD = D3D12_FLOAT32_MAX;
|
staticSampler[0].MaxLOD = D3D12_FLOAT32_MAX;
|
||||||
staticSampler[0].ShaderRegister = 0;
|
staticSampler[0].ShaderRegister = 0;
|
||||||
staticSampler[0].RegisterSpace = 0;
|
staticSampler[0].RegisterSpace = 0;
|
||||||
@ -675,7 +664,7 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
bd->pd3dDevice->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(&bd->pRootSignatureLinear));
|
bd->pd3dDevice->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(&bd->pRootSignatureLinear));
|
||||||
blob->Release();
|
blob->Release();
|
||||||
|
|
||||||
// Nearest sampler
|
// Root Signature for ImDrawCallback_SetSamplerNearest
|
||||||
staticSampler[0].Filter = D3D12_FILTER_MIN_MAG_MIP_POINT;
|
staticSampler[0].Filter = D3D12_FILTER_MIN_MAG_MIP_POINT;
|
||||||
if (D3D12SerializeRootSignatureFn(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, nullptr) != S_OK)
|
if (D3D12SerializeRootSignatureFn(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, nullptr) != S_OK)
|
||||||
return false;
|
return false;
|
||||||
@ -728,7 +717,7 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
PS_INPUT main(VS_INPUT input)\
|
PS_INPUT main(VS_INPUT input)\
|
||||||
{\
|
{\
|
||||||
PS_INPUT output;\
|
PS_INPUT output;\
|
||||||
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.0f, 1.0f));\
|
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
|
||||||
output.col = input.col;\
|
output.col = input.col;\
|
||||||
output.uv = input.uv;\
|
output.uv = input.uv;\
|
||||||
return output;\
|
return output;\
|
||||||
@ -824,6 +813,7 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pipeline State for ImDrawCallback_SetSamplerNearest
|
||||||
psoDesc.pRootSignature = bd->pRootSignatureNearest;
|
psoDesc.pRootSignature = bd->pRootSignatureNearest;
|
||||||
|
|
||||||
result_pipeline_state = bd->pd3dDevice->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&bd->pPipelineStateNearest));
|
result_pipeline_state = bd->pd3dDevice->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&bd->pPipelineStateNearest));
|
||||||
@ -937,11 +927,6 @@ bool ImGui_ImplDX12_Init(ImGui_ImplDX12_InitInfo* init_info)
|
|||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplDX12_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplDX12_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplDX12_DrawCallback_SetSamplerNearest;
|
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
if (init_info->SrvDescriptorAllocFn == nullptr)
|
if (init_info->SrvDescriptorAllocFn == nullptr)
|
||||||
ImGui_ImplDX12_InitLegacySingleDescriptorMode(init_info);
|
ImGui_ImplDX12_InitLegacySingleDescriptorMode(init_info);
|
||||||
@ -963,6 +948,36 @@ bool ImGui_ImplDX12_Init(ImGui_ImplDX12_InitInfo* init_info)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
// Legacy initialization API Obsoleted in 1.91.5
|
||||||
|
// 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, they must be in 'srv_descriptor_heap'
|
||||||
|
bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* srv_descriptor_heap, D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX12_InitInfo init_info;
|
||||||
|
init_info.Device = device;
|
||||||
|
init_info.NumFramesInFlight = num_frames_in_flight;
|
||||||
|
init_info.RTVFormat = rtv_format;
|
||||||
|
init_info.SrvDescriptorHeap = srv_descriptor_heap;
|
||||||
|
init_info.LegacySingleSrvCpuDescriptor = font_srv_cpu_desc_handle;
|
||||||
|
init_info.LegacySingleSrvGpuDescriptor = font_srv_gpu_desc_handle;
|
||||||
|
|
||||||
|
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
|
||||||
|
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||||
|
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||||
|
queueDesc.NodeMask = 1;
|
||||||
|
HRESULT hr = device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&init_info.CommandQueue));
|
||||||
|
IM_ASSERT(SUCCEEDED(hr));
|
||||||
|
|
||||||
|
bool ret = ImGui_ImplDX12_Init(&init_info);
|
||||||
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
bd->commandQueueOwned = true;
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasTextures; // Using legacy ImGui_ImplDX12_Init() call with 1 SRV descriptor we cannot support multiple textures.
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void ImGui_ImplDX12_Shutdown()
|
void ImGui_ImplDX12_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplDX12_GetRenderState().
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
|
|
||||||
// The aim of imgui_impl_dx12.h/.cpp is to be usable in your engine without any modification.
|
// The aim of imgui_impl_dx12.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/
|
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||||
@ -59,6 +59,13 @@ IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
|
|||||||
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);
|
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
// Legacy initialization API Obsoleted in 1.91.5
|
||||||
|
// - 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, they must be in 'srv_descriptor_heap'
|
||||||
|
// - When we introduced the ImGui_ImplDX12_InitInfo struct we also added a 'ID3D12CommandQueue* CommandQueue' field.
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* srv_descriptor_heap, D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||||
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
|
||||||
@ -74,15 +81,6 @@ struct ImGui_ImplDX12_RenderState
|
|||||||
ID3D12Device* Device;
|
ID3D12Device* Device;
|
||||||
ID3D12GraphicsCommandList* CommandList;
|
ID3D12GraphicsCommandList* CommandList;
|
||||||
};
|
};
|
||||||
IMGUI_IMPL_API ImGui_ImplDX12_RenderState* ImGui_ImplDX12_GetRenderState();
|
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
||||||
// Legacy initialization API Obsoleted in 1.91.5
|
|
||||||
// - 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, they must be in 'srv_descriptor_heap'
|
|
||||||
// - When we introduced the ImGui_ImplDX12_InitInfo struct we also added a 'ID3D12CommandQueue* CommandQueue' field.
|
|
||||||
// - DOES NOT SUPPORT ImGuiBackendFlags_RendererHasTextures.
|
|
||||||
//IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* srv_descriptor_heap, D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. (#9378)
|
|
||||||
// 2026-03-19: Fixed issue in ImGui_ImplDX9_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295, #9310)
|
// 2026-03-19: Fixed issue in ImGui_ImplDX9_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295, #9310)
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
// 2025-06-11: DirectX9: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
// 2025-06-11: DirectX9: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas.
|
||||||
@ -163,11 +162,6 @@ static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplDX9_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplDX9_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); }
|
|
||||||
static void ImGui_ImplDX9_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); }
|
|
||||||
|
|
||||||
// Render function.
|
// Render function.
|
||||||
void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
@ -190,14 +184,14 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
if (device->CreateVertexBuffer((UINT)bd->VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &bd->pVB, nullptr) < 0)
|
if (device->CreateVertexBuffer(bd->VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &bd->pVB, nullptr) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!bd->pIB || bd->IndexBufferSize < draw_data->TotalIdxCount)
|
if (!bd->pIB || bd->IndexBufferSize < draw_data->TotalIdxCount)
|
||||||
{
|
{
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
if (device->CreateIndexBuffer((UINT)bd->IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &bd->pIB, nullptr) < 0)
|
if (device->CreateIndexBuffer(bd->IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &bd->pIB, nullptr) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +269,8 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (pcmd->UserCallback != nullptr)
|
if (pcmd->UserCallback != nullptr)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplDX9_DrawCallback_ResetRenderState)
|
// (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);
|
ImGui_ImplDX9_SetupRenderState(draw_data);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -330,6 +325,46 @@ static bool ImGui_ImplDX9_CheckFormatSupport(LPDIRECT3DDEVICE9 pDevice, D3DFORMA
|
|||||||
return support;
|
return support;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
|
// Setup backend capabilities flags
|
||||||
|
ImGui_ImplDX9_Data* bd = IM_NEW(ImGui_ImplDX9_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
|
io.BackendRendererName = "imgui_impl_dx9";
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_TextureMaxWidth = platform_io.Renderer_TextureMaxHeight = 4096;
|
||||||
|
|
||||||
|
bd->pd3dDevice = device;
|
||||||
|
bd->pd3dDevice->AddRef();
|
||||||
|
bd->HasRgbaSupport = ImGui_ImplDX9_CheckFormatSupport(bd->pd3dDevice, D3DFMT_A8B8G8R8);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplDX9_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
|
||||||
|
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||||
|
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||||
|
|
||||||
|
io.BackendRendererName = nullptr;
|
||||||
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
||||||
|
platform_io.ClearRendererHandlers();
|
||||||
|
IM_DELETE(bd);
|
||||||
|
}
|
||||||
|
|
||||||
// Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices)
|
// Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices)
|
||||||
static void ImGui_ImplDX9_CopyTextureRegion(bool tex_use_colors, const ImU32* src, int src_pitch, ImU32* dst, int dst_pitch, int w, int h)
|
static void ImGui_ImplDX9_CopyTextureRegion(bool tex_use_colors, const ImU32* src, int src_pitch, ImU32* dst, int dst_pitch, int w, int h)
|
||||||
{
|
{
|
||||||
@ -442,50 +477,6 @@ void ImGui_ImplDX9_NewFrame()
|
|||||||
IM_UNUSED(bd);
|
IM_UNUSED(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
|
||||||
ImGui_ImplDX9_Data* bd = IM_NEW(ImGui_ImplDX9_Data)();
|
|
||||||
io.BackendRendererUserData = (void*)bd;
|
|
||||||
io.BackendRendererName = "imgui_impl_dx9";
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.Renderer_TextureMaxWidth = platform_io.Renderer_TextureMaxHeight = 4096;
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplDX9_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplDX9_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplDX9_DrawCallback_SetSamplerNearest;
|
|
||||||
|
|
||||||
bd->pd3dDevice = device;
|
|
||||||
bd->pd3dDevice->AddRef();
|
|
||||||
bd->HasRgbaSupport = ImGui_ImplDX9_CheckFormatSupport(bd->pd3dDevice, D3DFMT_A8B8G8R8);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplDX9_Shutdown()
|
|
||||||
{
|
|
||||||
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
|
|
||||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
|
||||||
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
|
||||||
io.BackendRendererUserData = nullptr;
|
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
|
||||||
platform_io.ClearRendererHandlers();
|
|
||||||
IM_DELETE(bd);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-04-21: Added a Win32-specific implementation of ImGui_ImplGlfw_GetContentScaleXXXX functions for legacy GLFW 3.2.
|
|
||||||
// 2026-03-25: Mouse cursor is properly restored if changed by user app/code while using glfwSetInputMode(..., GLFW_CURSOR_DISABLED) or ImGuiConfigFlags_NoMouseCursorChange. Amend change from 2025-12-10.
|
// 2026-03-25: Mouse cursor is properly restored if changed by user app/code while using glfwSetInputMode(..., GLFW_CURSOR_DISABLED) or ImGuiConfigFlags_NoMouseCursorChange. Amend change from 2025-12-10.
|
||||||
// 2026-02-10: Try to set IMGUI_IMPL_GLFW_DISABLE_X11 / IMGUI_IMPL_GLFW_DISABLE_WAYLAND automatically if corresponding headers are not accessible. (#9225)
|
// 2026-02-10: Try to set IMGUI_IMPL_GLFW_DISABLE_X11 / IMGUI_IMPL_GLFW_DISABLE_WAYLAND automatically if corresponding headers are not accessible. (#9225)
|
||||||
// 2025-12-12: Added IMGUI_IMPL_GLFW_DISABLE_X11 / IMGUI_IMPL_GLFW_DISABLE_WAYLAND to forcefully disable either.
|
// 2025-12-12: Added IMGUI_IMPL_GLFW_DISABLE_X11 / IMGUI_IMPL_GLFW_DISABLE_WAYLAND to forcefully disable either.
|
||||||
@ -213,7 +212,7 @@ struct ImGui_ImplGlfw_Data
|
|||||||
bool IsWayland;
|
bool IsWayland;
|
||||||
bool InstalledCallbacks;
|
bool InstalledCallbacks;
|
||||||
bool CallbacksChainForAllWindows;
|
bool CallbacksChainForAllWindows;
|
||||||
char BackendPlatformName[40];
|
char BackendPlatformName[32];
|
||||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||||
const char* CanvasSelector;
|
const char* CanvasSelector;
|
||||||
#endif
|
#endif
|
||||||
@ -676,13 +675,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
ImGui_ImplGlfw_Data* bd = IM_NEW(ImGui_ImplGlfw_Data)();
|
ImGui_ImplGlfw_Data* bd = IM_NEW(ImGui_ImplGlfw_Data)();
|
||||||
bd->Context = ImGui::GetCurrentContext();
|
snprintf(bd->BackendPlatformName, sizeof(bd->BackendPlatformName), "imgui_impl_glfw (%d)", GLFW_VERSION_COMBINED);
|
||||||
bd->Window = window;
|
|
||||||
bd->Time = 0.0;
|
|
||||||
bd->IsWayland = ImGui_ImplGlfw_IsWayland();
|
|
||||||
ImGui_ImplGlfw_ContextMap_Add(window, bd->Context);
|
|
||||||
|
|
||||||
snprintf(bd->BackendPlatformName, sizeof(bd->BackendPlatformName), "imgui_impl_glfw (%d)%s", GLFW_VERSION_COMBINED, bd->IsWayland ? " (Wayland)" : "");
|
|
||||||
io.BackendPlatformUserData = (void*)bd;
|
io.BackendPlatformUserData = (void*)bd;
|
||||||
io.BackendPlatformName = bd->BackendPlatformName;
|
io.BackendPlatformName = bd->BackendPlatformName;
|
||||||
#if GLFW_HAS_CREATECURSOR
|
#if GLFW_HAS_CREATECURSOR
|
||||||
@ -690,6 +683,12 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
#endif
|
#endif
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
|
||||||
|
bd->Context = ImGui::GetCurrentContext();
|
||||||
|
bd->Window = window;
|
||||||
|
bd->Time = 0.0;
|
||||||
|
bd->IsWayland = ImGui_ImplGlfw_IsWayland();
|
||||||
|
ImGui_ImplGlfw_ContextMap_Add(window, bd->Context);
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
#if GLFW_VERSION_COMBINED < 3300
|
#if GLFW_VERSION_COMBINED < 3300
|
||||||
platform_io.Platform_SetClipboardTextFn = [](ImGuiContext*, const char* text) { glfwSetClipboardString(ImGui_ImplGlfw_GetBackendData()->Window, text); };
|
platform_io.Platform_SetClipboardTextFn = [](ImGuiContext*, const char* text) { glfwSetClipboardString(ImGui_ImplGlfw_GetBackendData()->Window, text); };
|
||||||
@ -949,16 +948,6 @@ static void ImGui_ImplGlfw_UpdateGamepads()
|
|||||||
#undef MAP_ANALOG
|
#undef MAP_ANALOG
|
||||||
}
|
}
|
||||||
|
|
||||||
// For GFLW 3.2 + Windows: include a simplified non-monitor aware version of ImGui_ImplWin32_GetDpiScaleForMonitor().
|
|
||||||
// This is merely a band-aid to make using GLFW 3.2 a little bit nicer, but prefer to use GLFW 3.3+ or the full correct functions from the Win32 backend.
|
|
||||||
#if !GLFW_HAS_PER_MONITOR_DPI && defined(_WIN32) && !defined(NOGDI)
|
|
||||||
static float ImGui_ImplWin32_GetLegacyDpiScale() { const HDC dc = ::GetDC(nullptr); UINT xdpi = ::GetDeviceCaps(dc, LOGPIXELSX); ::ReleaseDC(nullptr, dc); return (float)xdpi / 96.0f; }
|
|
||||||
static void glfwGetWindowContentScale(GLFWwindow*, float* x_scale, float* y_scale) { *x_scale = *y_scale = ImGui_ImplWin32_GetLegacyDpiScale(); }
|
|
||||||
static void glfwGetMonitorContentScale(GLFWmonitor*, float* x_scale, float* y_scale) { *x_scale = *y_scale = ImGui_ImplWin32_GetLegacyDpiScale(); }
|
|
||||||
#undef GLFW_HAS_PER_MONITOR_DPI
|
|
||||||
#define GLFW_HAS_PER_MONITOR_DPI 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// - On Windows the process needs to be marked DPI-aware!! SDL2 doesn't do it by default. You can call ::SetProcessDPIAware() or call ImGui_ImplWin32_EnableDpiAwareness() from Win32 backend.
|
// - On Windows the process needs to be marked DPI-aware!! SDL2 doesn't do it by default. You can call ::SetProcessDPIAware() or call ImGui_ImplWin32_EnableDpiAwareness() from Win32 backend.
|
||||||
// - Apple platforms use FramebufferScale so we always return 1.0f.
|
// - Apple platforms use FramebufferScale so we always return 1.0f.
|
||||||
// - Some accessibility applications are declaring virtual monitors with a DPI of 0.0f, see #7902. We preserve this value for caller to handle.
|
// - Some accessibility applications are declaring virtual monitors with a DPI of 0.0f, see #7902. We preserve this value for caller to handle.
|
||||||
@ -1027,7 +1016,7 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
// (Accept glfwGetTime() not returning a monotonically increasing value. Seems to happens on disconnecting peripherals and probably on VMs and Emscripten, see #6491, #6189, #6114, #3644)
|
// (Accept glfwGetTime() not returning a monotonically increasing value. Seems to happens on disconnecting peripherals and probably on VMs and Emscripten, see #6491, #6189, #6114, #3644)
|
||||||
double current_time = glfwGetTime();
|
double current_time = glfwGetTime();
|
||||||
if (current_time <= bd->Time)
|
if (current_time <= bd->Time)
|
||||||
current_time = bd->Time + 0.00001;
|
current_time = bd->Time + 0.00001f;
|
||||||
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
|
|||||||
@ -16,12 +16,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-10-06: Added support for render passes with multiple color attachments: we render to the first one and leave the others untouched. (#9574)
|
|
||||||
// 2026-09-07: Round framebuffer dimensions to the nearest integer instead of truncating them. (#9538, 9515, #8628)
|
|
||||||
// 2026-04-28: Added support for standard draw callbacks (in platform_io): DrawCallback_SetSamplerLinear and DrawCallback_SetSamplerNearest. (#9378, #9381)
|
|
||||||
// 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState (others are not yet supported). (#9378)
|
|
||||||
// 2026-04-14: Metal: use a dedicated bufferCacheLock to avoid crashing when bufferCache is replaced by a new object while being used for @synchronize(). (#9367)
|
|
||||||
// 2026-04-03: Metal: avoid redundant vertex buffer bind in SetupRenderState. (#9343)
|
|
||||||
// 2026-03-19: Fixed issue in ImGui_ImplMetal_RenderDrawData() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295, #9310)
|
// 2026-03-19: Fixed issue in ImGui_ImplMetal_RenderDrawData() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295, #9310)
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplMetal_CreateFontsTexture() and ImGui_ImplMetal_DestroyFontsTexture().
|
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplMetal_CreateFontsTexture() and ImGui_ImplMetal_DestroyFontsTexture().
|
||||||
@ -59,16 +53,14 @@
|
|||||||
- (instancetype)initWithBuffer:(id<MTLBuffer>)buffer;
|
- (instancetype)initWithBuffer:(id<MTLBuffer>)buffer;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#define IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS 8 // Metal's limit (see Metal Feature Set Tables). Not configurable.
|
|
||||||
|
|
||||||
// An object that encapsulates the data necessary to uniquely identify a
|
// An object that encapsulates the data necessary to uniquely identify a
|
||||||
// render pipeline state. These are used as cache keys.
|
// render pipeline state. These are used as cache keys.
|
||||||
@interface FramebufferDescriptor : NSObject<NSCopying>
|
@interface FramebufferDescriptor : NSObject<NSCopying>
|
||||||
@property (nonatomic, assign) unsigned long sampleCount;
|
@property (nonatomic, assign) unsigned long sampleCount;
|
||||||
|
@property (nonatomic, assign) MTLPixelFormat colorPixelFormat;
|
||||||
@property (nonatomic, assign) MTLPixelFormat depthPixelFormat;
|
@property (nonatomic, assign) MTLPixelFormat depthPixelFormat;
|
||||||
@property (nonatomic, assign) MTLPixelFormat stencilPixelFormat;
|
@property (nonatomic, assign) MTLPixelFormat stencilPixelFormat;
|
||||||
- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor*)renderPassDescriptor;
|
- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor*)renderPassDescriptor;
|
||||||
- (MTLPixelFormat)colorPixelFormatAtIndex:(NSUInteger)index;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface MetalTexture : NSObject
|
@interface MetalTexture : NSObject
|
||||||
@ -82,12 +74,9 @@
|
|||||||
@interface MetalContext : NSObject
|
@interface MetalContext : NSObject
|
||||||
@property (nonatomic, strong) id<MTLDevice> device;
|
@property (nonatomic, strong) id<MTLDevice> device;
|
||||||
@property (nonatomic, strong) id<MTLDepthStencilState> depthStencilState;
|
@property (nonatomic, strong) id<MTLDepthStencilState> depthStencilState;
|
||||||
@property (nonatomic, strong) id<MTLSamplerState> samplerStateLinear;
|
|
||||||
@property (nonatomic, strong) id<MTLSamplerState> samplerStateNearest;
|
|
||||||
@property (nonatomic, strong) FramebufferDescriptor* framebufferDescriptor; // framebuffer descriptor for current frame; transient
|
@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) NSMutableDictionary* renderPipelineStateCache; // pipeline cache; keyed on framebuffer descriptors
|
||||||
@property (nonatomic, strong) NSMutableArray<MetalBuffer*>* bufferCache;
|
@property (nonatomic, strong) NSMutableArray<MetalBuffer*>* bufferCache;
|
||||||
@property (nonatomic, strong) NSObject* bufferCacheLock;
|
|
||||||
@property (nonatomic, assign) double lastBufferCachePurge;
|
@property (nonatomic, assign) double lastBufferCachePurge;
|
||||||
- (MetalBuffer*)dequeueReusableBufferOfLength:(NSUInteger)length device:(id<MTLDevice>)device;
|
- (MetalBuffer*)dequeueReusableBufferOfLength:(NSUInteger)length device:(id<MTLDevice>)device;
|
||||||
- (id<MTLRenderPipelineState>)renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor*)descriptor device:(id<MTLDevice>)device;
|
- (id<MTLRenderPipelineState>)renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor*)descriptor device:(id<MTLDevice>)device;
|
||||||
@ -96,7 +85,6 @@
|
|||||||
struct ImGui_ImplMetal_Data
|
struct ImGui_ImplMetal_Data
|
||||||
{
|
{
|
||||||
MetalContext* SharedMetalContext;
|
MetalContext* SharedMetalContext;
|
||||||
id<MTLRenderCommandEncoder> RenderCommandEncoder;
|
|
||||||
|
|
||||||
ImGui_ImplMetal_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplMetal_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@ -127,6 +115,7 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
|
|||||||
ImGui_ImplMetal_RenderDrawData(draw_data,
|
ImGui_ImplMetal_RenderDrawData(draw_data,
|
||||||
(__bridge id<MTLCommandBuffer>)(commandBuffer),
|
(__bridge id<MTLCommandBuffer>)(commandBuffer),
|
||||||
(__bridge id<MTLRenderCommandEncoder>)(commandEncoder));
|
(__bridge id<MTLRenderCommandEncoder>)(commandEncoder));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device)
|
bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device)
|
||||||
@ -138,6 +127,41 @@ bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device)
|
|||||||
|
|
||||||
#pragma mark - Dear ImGui Metal Backend API
|
#pragma mark - Dear ImGui Metal Backend API
|
||||||
|
|
||||||
|
bool ImGui_ImplMetal_Init(id<MTLDevice> device)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
|
ImGui_ImplMetal_Data* bd = IM_NEW(ImGui_ImplMetal_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
|
io.BackendRendererName = "imgui_impl_metal";
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
|
bd->SharedMetalContext = [[MetalContext alloc] init];
|
||||||
|
bd->SharedMetalContext.device = device;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplMetal_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
||||||
|
IM_UNUSED(bd);
|
||||||
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
|
||||||
|
ImGui_ImplMetal_DestroyDeviceObjects();
|
||||||
|
ImGui_ImplMetal_DestroyBackendData();
|
||||||
|
|
||||||
|
io.BackendRendererName = nullptr;
|
||||||
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
||||||
|
platform_io.ClearRendererHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
||||||
{
|
{
|
||||||
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
||||||
@ -167,8 +191,8 @@ static void ImGui_ImplMetal_SetupRenderState(ImDrawData* draw_data, id<MTLComman
|
|||||||
{
|
{
|
||||||
.originX = 0.0,
|
.originX = 0.0,
|
||||||
.originY = 0.0,
|
.originY = 0.0,
|
||||||
.width = (double)(int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f),
|
.width = (double)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x),
|
||||||
.height = (double)(int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f),
|
.height = (double)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y),
|
||||||
.znear = 0.0,
|
.znear = 0.0,
|
||||||
.zfar = 1.0
|
.zfar = 1.0
|
||||||
};
|
};
|
||||||
@ -190,16 +214,11 @@ static void ImGui_ImplMetal_SetupRenderState(ImDrawData* draw_data, id<MTLComman
|
|||||||
[commandEncoder setVertexBytes:&ortho_projection length:sizeof(ortho_projection) atIndex:1];
|
[commandEncoder setVertexBytes:&ortho_projection length:sizeof(ortho_projection) atIndex:1];
|
||||||
|
|
||||||
[commandEncoder setRenderPipelineState:renderPipelineState];
|
[commandEncoder setRenderPipelineState:renderPipelineState];
|
||||||
[commandEncoder setFragmentSamplerState:bd->SharedMetalContext.samplerStateLinear atIndex:0];
|
|
||||||
|
|
||||||
[commandEncoder setVertexBuffer:vertexBuffer.buffer offset:vertexBufferOffset atIndex:0];
|
[commandEncoder setVertexBuffer:vertexBuffer.buffer offset:0 atIndex:0];
|
||||||
|
[commandEncoder setVertexBufferOffset:vertexBufferOffset atIndex:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplMetal_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplMetal_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData(); [bd->RenderCommandEncoder setFragmentSamplerState:bd->SharedMetalContext.samplerStateLinear atIndex:0]; }
|
|
||||||
static void ImGui_ImplMetal_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData(); [bd->RenderCommandEncoder setFragmentSamplerState:bd->SharedMetalContext.samplerStateNearest atIndex:0]; }
|
|
||||||
|
|
||||||
// Metal Render function.
|
// Metal Render function.
|
||||||
void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer> commandBuffer, id<MTLRenderCommandEncoder> commandEncoder)
|
void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer> commandBuffer, id<MTLRenderCommandEncoder> commandEncoder)
|
||||||
{
|
{
|
||||||
@ -207,8 +226,8 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer>
|
|||||||
MetalContext* ctx = bd->SharedMetalContext;
|
MetalContext* ctx = bd->SharedMetalContext;
|
||||||
|
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// 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 + 0.5f);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdLists.Size == 0)
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdLists.Size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -236,7 +255,6 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer>
|
|||||||
MetalBuffer* vertexBuffer = [ctx dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device];
|
MetalBuffer* vertexBuffer = [ctx dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device];
|
||||||
MetalBuffer* indexBuffer = [ctx dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device];
|
MetalBuffer* indexBuffer = [ctx dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device];
|
||||||
|
|
||||||
bd->RenderCommandEncoder = commandEncoder;
|
|
||||||
ImGui_ImplMetal_SetupRenderState(draw_data, commandBuffer, commandEncoder, renderPipelineState, vertexBuffer, 0);
|
ImGui_ImplMetal_SetupRenderState(draw_data, commandBuffer, commandEncoder, renderPipelineState, vertexBuffer, 0);
|
||||||
|
|
||||||
// Will project scissor/clipping rectangles into framebuffer space
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
@ -257,7 +275,8 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer>
|
|||||||
if (pcmd->UserCallback)
|
if (pcmd->UserCallback)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplMetal_DrawCallback_ResetRenderState)
|
// (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_ImplMetal_SetupRenderState(draw_data, commandBuffer, commandEncoder, renderPipelineState, vertexBuffer, vertexBufferOffset);
|
ImGui_ImplMetal_SetupRenderState(draw_data, commandBuffer, commandEncoder, renderPipelineState, vertexBuffer, vertexBufferOffset);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -271,8 +290,8 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer>
|
|||||||
// Clamp to viewport as setScissorRect() won't accept values that are off bounds
|
// Clamp to viewport as setScissorRect() won't accept values that are off bounds
|
||||||
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
||||||
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
||||||
if (clip_max.x > (float)fb_width) { clip_max.x = (float)fb_width; }
|
if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; }
|
||||||
if (clip_max.y > (float)fb_height) { clip_max.y = (float)fb_height; }
|
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
||||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
continue;
|
continue;
|
||||||
if (pcmd->ElemCount == 0) // drawIndexedPrimitives() validation doesn't accept this
|
if (pcmd->ElemCount == 0) // drawIndexedPrimitives() validation doesn't accept this
|
||||||
@ -309,13 +328,14 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer>
|
|||||||
MetalContext* sharedMetalContext = bd->SharedMetalContext;
|
MetalContext* sharedMetalContext = bd->SharedMetalContext;
|
||||||
[commandBuffer addCompletedHandler:^(id<MTLCommandBuffer>)
|
[commandBuffer addCompletedHandler:^(id<MTLCommandBuffer>)
|
||||||
{
|
{
|
||||||
@synchronized(sharedMetalContext.bufferCacheLock)
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
{
|
@synchronized(sharedMetalContext.bufferCache)
|
||||||
[sharedMetalContext.bufferCache addObject:vertexBuffer];
|
{
|
||||||
[sharedMetalContext.bufferCache addObject:indexBuffer];
|
[sharedMetalContext.bufferCache addObject:vertexBuffer];
|
||||||
}
|
[sharedMetalContext.bufferCache addObject:indexBuffer];
|
||||||
|
}
|
||||||
|
});
|
||||||
}];
|
}];
|
||||||
bd->RenderCommandEncoder = nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplMetal_DestroyTexture(ImTextureData* tex)
|
static void ImGui_ImplMetal_DestroyTexture(ImTextureData* tex)
|
||||||
@ -392,17 +412,7 @@ bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device)
|
|||||||
depthStencilDescriptor.depthWriteEnabled = NO;
|
depthStencilDescriptor.depthWriteEnabled = NO;
|
||||||
depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
|
depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
|
||||||
bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
|
bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
|
||||||
MTLSamplerDescriptor* samplerDescriptor = [[MTLSamplerDescriptor alloc] init];
|
|
||||||
samplerDescriptor.minFilter = MTLSamplerMinMagFilterLinear;
|
|
||||||
samplerDescriptor.magFilter = MTLSamplerMinMagFilterLinear;
|
|
||||||
samplerDescriptor.mipFilter = MTLSamplerMipFilterLinear;
|
|
||||||
bd->SharedMetalContext.samplerStateLinear = [device newSamplerStateWithDescriptor:samplerDescriptor];
|
|
||||||
samplerDescriptor.minFilter = MTLSamplerMinMagFilterNearest;
|
|
||||||
samplerDescriptor.magFilter = MTLSamplerMinMagFilterNearest;
|
|
||||||
samplerDescriptor.mipFilter = MTLSamplerMipFilterNearest;
|
|
||||||
bd->SharedMetalContext.samplerStateNearest = [device newSamplerStateWithDescriptor:samplerDescriptor];
|
|
||||||
#ifdef IMGUI_IMPL_METAL_CPP
|
#ifdef IMGUI_IMPL_METAL_CPP
|
||||||
[samplerDescriptor release];
|
|
||||||
[depthStencilDescriptor release];
|
[depthStencilDescriptor release];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -419,48 +429,6 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
ImGui_ImplMetal_DestroyTexture(tex);
|
ImGui_ImplMetal_DestroyTexture(tex);
|
||||||
|
|
||||||
[bd->SharedMetalContext.renderPipelineStateCache removeAllObjects];
|
[bd->SharedMetalContext.renderPipelineStateCache removeAllObjects];
|
||||||
bd->SharedMetalContext.samplerStateLinear = nil;
|
|
||||||
bd->SharedMetalContext.samplerStateNearest = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGui_ImplMetal_Init(id<MTLDevice> device)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
|
||||||
|
|
||||||
ImGui_ImplMetal_Data* bd = IM_NEW(ImGui_ImplMetal_Data)();
|
|
||||||
io.BackendRendererUserData = (void*)bd;
|
|
||||||
io.BackendRendererName = "imgui_impl_metal";
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplMetal_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplMetal_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplMetal_DrawCallback_SetSamplerNearest;
|
|
||||||
|
|
||||||
bd->SharedMetalContext = [[MetalContext alloc] init];
|
|
||||||
bd->SharedMetalContext.device = device;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplMetal_Shutdown()
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
|
||||||
IM_UNUSED(bd);
|
|
||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
|
|
||||||
ImGui_ImplMetal_DestroyDeviceObjects();
|
|
||||||
ImGui_ImplMetal_DestroyBackendData();
|
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
|
||||||
io.BackendRendererUserData = nullptr;
|
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
|
||||||
platform_io.ClearRendererHandlers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - MetalBuffer implementation
|
#pragma mark - MetalBuffer implementation
|
||||||
@ -480,33 +448,23 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
#pragma mark - FramebufferDescriptor implementation
|
#pragma mark - FramebufferDescriptor implementation
|
||||||
|
|
||||||
@implementation FramebufferDescriptor
|
@implementation FramebufferDescriptor
|
||||||
{
|
|
||||||
MTLPixelFormat _colorPixelFormats[IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor*)renderPassDescriptor
|
- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor*)renderPassDescriptor
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
_sampleCount = renderPassDescriptor.colorAttachments[0].texture.sampleCount;
|
_sampleCount = renderPassDescriptor.colorAttachments[0].texture.sampleCount;
|
||||||
for (NSUInteger n = 0; n < IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS; n++)
|
_colorPixelFormat = renderPassDescriptor.colorAttachments[0].texture.pixelFormat;
|
||||||
_colorPixelFormats[n] = renderPassDescriptor.colorAttachments[n].texture.pixelFormat;
|
|
||||||
_depthPixelFormat = renderPassDescriptor.depthAttachment.texture.pixelFormat;
|
_depthPixelFormat = renderPassDescriptor.depthAttachment.texture.pixelFormat;
|
||||||
_stencilPixelFormat = renderPassDescriptor.stencilAttachment.texture.pixelFormat;
|
_stencilPixelFormat = renderPassDescriptor.stencilAttachment.texture.pixelFormat;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (MTLPixelFormat)colorPixelFormatAtIndex:(NSUInteger)index
|
|
||||||
{
|
|
||||||
return _colorPixelFormats[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (nonnull id)copyWithZone:(nullable NSZone*)zone
|
- (nonnull id)copyWithZone:(nullable NSZone*)zone
|
||||||
{
|
{
|
||||||
FramebufferDescriptor* copy = [[FramebufferDescriptor allocWithZone:zone] init];
|
FramebufferDescriptor* copy = [[FramebufferDescriptor allocWithZone:zone] init];
|
||||||
copy.sampleCount = self.sampleCount;
|
copy.sampleCount = self.sampleCount;
|
||||||
memcpy(copy->_colorPixelFormats, _colorPixelFormats, sizeof(_colorPixelFormats));
|
copy.colorPixelFormat = self.colorPixelFormat;
|
||||||
copy.depthPixelFormat = self.depthPixelFormat;
|
copy.depthPixelFormat = self.depthPixelFormat;
|
||||||
copy.stencilPixelFormat = self.stencilPixelFormat;
|
copy.stencilPixelFormat = self.stencilPixelFormat;
|
||||||
return copy;
|
return copy;
|
||||||
@ -515,12 +473,10 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
- (NSUInteger)hash
|
- (NSUInteger)hash
|
||||||
{
|
{
|
||||||
NSUInteger sc = _sampleCount & 0x3;
|
NSUInteger sc = _sampleCount & 0x3;
|
||||||
NSUInteger cf = _colorPixelFormats[0] & 0x3FF;
|
NSUInteger cf = _colorPixelFormat & 0x3FF;
|
||||||
NSUInteger df = _depthPixelFormat & 0x3FF;
|
NSUInteger df = _depthPixelFormat & 0x3FF;
|
||||||
NSUInteger sf = _stencilPixelFormat & 0x3FF;
|
NSUInteger sf = _stencilPixelFormat & 0x3FF;
|
||||||
NSUInteger hash = (sf << 22) | (df << 12) | (cf << 2) | sc;
|
NSUInteger hash = (sf << 22) | (df << 12) | (cf << 2) | sc;
|
||||||
for (NSUInteger n = 1; n < IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS; n++)
|
|
||||||
hash = hash * 31 + _colorPixelFormats[n];
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +486,7 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
if (![other isKindOfClass:[FramebufferDescriptor class]])
|
if (![other isKindOfClass:[FramebufferDescriptor class]])
|
||||||
return NO;
|
return NO;
|
||||||
return other.sampleCount == self.sampleCount &&
|
return other.sampleCount == self.sampleCount &&
|
||||||
memcmp(other->_colorPixelFormats, _colorPixelFormats, sizeof(_colorPixelFormats)) == 0 &&
|
other.colorPixelFormat == self.colorPixelFormat &&
|
||||||
other.depthPixelFormat == self.depthPixelFormat &&
|
other.depthPixelFormat == self.depthPixelFormat &&
|
||||||
other.stencilPixelFormat == self.stencilPixelFormat;
|
other.stencilPixelFormat == self.stencilPixelFormat;
|
||||||
}
|
}
|
||||||
@ -558,7 +514,6 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
{
|
{
|
||||||
self.renderPipelineStateCache = [NSMutableDictionary dictionary];
|
self.renderPipelineStateCache = [NSMutableDictionary dictionary];
|
||||||
self.bufferCache = [NSMutableArray array];
|
self.bufferCache = [NSMutableArray array];
|
||||||
self.bufferCacheLock = [[NSObject alloc] init];
|
|
||||||
_lastBufferCachePurge = GetMachAbsoluteTimeInSeconds();
|
_lastBufferCachePurge = GetMachAbsoluteTimeInSeconds();
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@ -566,9 +521,9 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
|
|
||||||
- (MetalBuffer*)dequeueReusableBufferOfLength:(NSUInteger)length device:(id<MTLDevice>)device
|
- (MetalBuffer*)dequeueReusableBufferOfLength:(NSUInteger)length device:(id<MTLDevice>)device
|
||||||
{
|
{
|
||||||
double now = GetMachAbsoluteTimeInSeconds();
|
uint64_t now = GetMachAbsoluteTimeInSeconds();
|
||||||
|
|
||||||
@synchronized(self.bufferCacheLock)
|
@synchronized(self.bufferCache)
|
||||||
{
|
{
|
||||||
// Purge old buffers that haven't been useful for a while
|
// Purge old buffers that haven't been useful for a while
|
||||||
if (now - self.lastBufferCachePurge > 1.0)
|
if (now - self.lastBufferCachePurge > 1.0)
|
||||||
@ -600,7 +555,7 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
return [[MetalBuffer alloc] initWithBuffer:backing];
|
return [[MetalBuffer alloc] initWithBuffer:backing];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bilinear sampling is required.
|
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||||
- (id<MTLRenderPipelineState>)renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor*)descriptor device:(id<MTLDevice>)device
|
- (id<MTLRenderPipelineState>)renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor*)descriptor device:(id<MTLDevice>)device
|
||||||
{
|
{
|
||||||
NSError* error = nil;
|
NSError* error = nil;
|
||||||
@ -635,9 +590,9 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"fragment half4 fragment_main(VertexOut in [[stage_in]],\n"
|
"fragment half4 fragment_main(VertexOut in [[stage_in]],\n"
|
||||||
" texture2d<half, access::sample> texture [[texture(0)]],\n"
|
" texture2d<half, access::sample> texture [[texture(0)]]) {\n"
|
||||||
" sampler textureSampler [[sampler(0)]]) {\n"
|
" constexpr sampler linearSampler(coord::normalized, min_filter::linear, mag_filter::linear, mip_filter::linear);\n"
|
||||||
" half4 texColor = texture.sample(textureSampler, in.texCoords);\n"
|
" half4 texColor = texture.sample(linearSampler, in.texCoords);\n"
|
||||||
" return half4(in.color) * texColor;\n"
|
" return half4(in.color) * texColor;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
@ -676,7 +631,7 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
pipelineDescriptor.fragmentFunction = fragmentFunction;
|
pipelineDescriptor.fragmentFunction = fragmentFunction;
|
||||||
pipelineDescriptor.vertexDescriptor = vertexDescriptor;
|
pipelineDescriptor.vertexDescriptor = vertexDescriptor;
|
||||||
pipelineDescriptor.rasterSampleCount = self.framebufferDescriptor.sampleCount;
|
pipelineDescriptor.rasterSampleCount = self.framebufferDescriptor.sampleCount;
|
||||||
pipelineDescriptor.colorAttachments[0].pixelFormat = [self.framebufferDescriptor colorPixelFormatAtIndex:0];
|
pipelineDescriptor.colorAttachments[0].pixelFormat = self.framebufferDescriptor.colorPixelFormat;
|
||||||
pipelineDescriptor.colorAttachments[0].blendingEnabled = YES;
|
pipelineDescriptor.colorAttachments[0].blendingEnabled = YES;
|
||||||
pipelineDescriptor.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd;
|
pipelineDescriptor.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd;
|
||||||
pipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
|
pipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
|
||||||
@ -684,11 +639,6 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
pipelineDescriptor.colorAttachments[0].alphaBlendOperation = MTLBlendOperationAdd;
|
pipelineDescriptor.colorAttachments[0].alphaBlendOperation = MTLBlendOperationAdd;
|
||||||
pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = MTLBlendFactorOne;
|
pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = MTLBlendFactorOne;
|
||||||
pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
|
pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
|
||||||
for (NSUInteger n = 1; n < IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS; n++) // Don't write to other color attachments, if any.
|
|
||||||
{
|
|
||||||
pipelineDescriptor.colorAttachments[n].pixelFormat = [self.framebufferDescriptor colorPixelFormatAtIndex:n];
|
|
||||||
pipelineDescriptor.colorAttachments[n].writeMask = MTLColorWriteMaskNone;
|
|
||||||
}
|
|
||||||
pipelineDescriptor.depthAttachmentPixelFormat = self.framebufferDescriptor.depthPixelFormat;
|
pipelineDescriptor.depthAttachmentPixelFormat = self.framebufferDescriptor.depthPixelFormat;
|
||||||
pipelineDescriptor.stencilAttachmentPixelFormat = self.framebufferDescriptor.stencilPixelFormat;
|
pipelineDescriptor.stencilAttachmentPixelFormat = self.framebufferDescriptor.stencilPixelFormat;
|
||||||
|
|
||||||
|
|||||||
@ -1,89 +0,0 @@
|
|||||||
// dear imgui: Renderer Backend for Metal 4
|
|
||||||
// This needs to be used along with a Platform Backend (e.g. OSX)
|
|
||||||
// Metal 4 requires Apple Silicon and macOS 26+.
|
|
||||||
|
|
||||||
// Implemented features:
|
|
||||||
// [X] Renderer: User texture binding. Use 'MTLTexture.gpuResourceID' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
|
||||||
// Missing features or Issues:
|
|
||||||
// [ ] Texture view pool support? Reevaluate which type to use for ImtextureID.
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
// Learn about Dear ImGui:
|
|
||||||
// - FAQ https://dearimgui.com/faq
|
|
||||||
// - Getting Started https://dearimgui.com/getting-started
|
|
||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
|
||||||
#ifndef IMGUI_DISABLE
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// ObjC API
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifdef __OBJC__
|
|
||||||
|
|
||||||
@class MTL4RenderPassDescriptor;
|
|
||||||
@protocol MTLDevice, MTL4CommandBuffer, MTL4RenderCommandEncoder, MTL4CommandQueue;
|
|
||||||
|
|
||||||
// framesInFlight must match the number of frames your application keeps in flight (e.g. the size of your own
|
|
||||||
// command buffer/allocator ring). The backend uses it to size its own per-frame-in-flight resources (constant
|
|
||||||
// buffer, vertex/index buffer cache) so the CPU never overwrites a slot the GPU may still be reading.
|
|
||||||
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplMetal4_Init(id<MTLDevice> device, id<MTL4CommandQueue> commandQueue, int framesInFlight);
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_Shutdown();
|
|
||||||
// frameInFlightIndex must match the slot you use to index your own per-frame-in-flight resources
|
|
||||||
// (e.g. the same index used to pick your command buffer/allocator), and must be < framesInFlight passed to Init().
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_NewFrame(MTL4RenderPassDescriptor* renderPassDescriptor, int frameInFlightIndex);
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_RenderDrawData(ImDrawData* drawData,
|
|
||||||
id<MTL4CommandBuffer> commandBuffer,
|
|
||||||
id<MTL4RenderCommandEncoder> commandEncoder);
|
|
||||||
|
|
||||||
// Called by Init/NewFrame/Shutdown
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplMetal4_CreateDeviceObjects(id<MTLDevice> device);
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_DestroyDeviceObjects();
|
|
||||||
|
|
||||||
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_UpdateTexture(ImTextureData* tex);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// C++ API
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
|
|
||||||
// More info about using Metal from C++: https://developer.apple.com/metal/cpp/
|
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_METAL_CPP
|
|
||||||
#ifndef __OBJC__
|
|
||||||
|
|
||||||
// Forward declare relevant classes from the MTL and MTL4 namespace
|
|
||||||
namespace MTL { class Device; }
|
|
||||||
namespace MTL4 { class CommandQueue; class CommandBuffer; class RenderPassDescriptor; class RenderCommandEncoder; }
|
|
||||||
|
|
||||||
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplMetal4_Init(MTL::Device* device, MTL4::CommandQueue* commandQueue, int framesInFlight);
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_Shutdown();
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_NewFrame(MTL4::RenderPassDescriptor* renderPassDescriptor, int frameInFlightIndex);
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_RenderDrawData(ImDrawData* draw_data,
|
|
||||||
MTL4::CommandBuffer* commandBuffer,
|
|
||||||
MTL4::RenderCommandEncoder* commandEncoder);
|
|
||||||
|
|
||||||
// Called by Init/NewFrame/Shutdown
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplMetal4_CreateDeviceObjects(MTL::Device* device);
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_DestroyDeviceObjects();
|
|
||||||
|
|
||||||
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplMetal4_UpdateTexture(ImTextureData* tex);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
|
||||||
@ -1,764 +0,0 @@
|
|||||||
// dear imgui: Renderer Backend for Metal 4
|
|
||||||
// This needs to be used along with a Platform Backend (e.g. OSX)
|
|
||||||
// Metal 4 requires Apple Silicon and macOS 26+.
|
|
||||||
|
|
||||||
// Implemented features:
|
|
||||||
// [X] Renderer: User texture binding. Use 'MTLTexture' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
|
||||||
// Missing features or Issues:
|
|
||||||
// [ ] Texture view pool support? Reevaluate which type to use for ImtextureID.
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
// Learn about Dear ImGui:
|
|
||||||
// - FAQ https://dearimgui.com/faq
|
|
||||||
// - Getting Started https://dearimgui.com/getting-started
|
|
||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
|
||||||
|
|
||||||
// CHANGELOG
|
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
|
||||||
// 2026-10-06: Added support for render passes with multiple color attachments: we render to the first one and leave the others untouched. (#9574)
|
|
||||||
// 2026-09-07: Round framebuffer dimensions to the nearest integer instead of truncating them. (#9538, 9515, #8628)
|
|
||||||
// 2026-07-07: Metal 4: Added metal-cpp support. (#9461)
|
|
||||||
// 2026-07-02: Metal 4: Added new Metal 4 backend implementation. (#9458)
|
|
||||||
|
|
||||||
#include "imgui.h"
|
|
||||||
#ifndef IMGUI_DISABLE
|
|
||||||
#include "imgui_impl_metal4.h"
|
|
||||||
#import <time.h>
|
|
||||||
#import <Metal/Metal.h>
|
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_METAL_CPP
|
|
||||||
#include <Metal/Metal.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma mark - Support classes and structs
|
|
||||||
|
|
||||||
struct ImGui_Metal4_ConstantData
|
|
||||||
{
|
|
||||||
float ModelViewProjectionMatrix[4][4];
|
|
||||||
};
|
|
||||||
|
|
||||||
@interface MetalBuffer : NSObject
|
|
||||||
@property (nonatomic, strong) id<MTLBuffer> buffer;
|
|
||||||
@property (nonatomic, assign) double lastReuseTime;
|
|
||||||
- (instancetype)initWithBuffer:(id<MTLBuffer>)buffer;
|
|
||||||
@end
|
|
||||||
|
|
||||||
#define IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS 8 // Metal's limit (see Metal Feature Set Tables). Not configurable.
|
|
||||||
|
|
||||||
// An object that encapsulates the data necessary to uniquely identify a
|
|
||||||
// render pipeline state. These are used as cache keys.
|
|
||||||
@interface FramebufferDescriptor : NSObject<NSCopying>
|
|
||||||
@property (nonatomic, assign) unsigned long sampleCount;
|
|
||||||
@property (nonatomic, assign) MTLPixelFormat depthPixelFormat;
|
|
||||||
@property (nonatomic, assign) MTLPixelFormat stencilPixelFormat;
|
|
||||||
- (instancetype)initWithRenderPassDescriptor:(MTL4RenderPassDescriptor*)renderPassDescriptor;
|
|
||||||
- (MTLPixelFormat)colorPixelFormatAtIndex:(NSUInteger)index;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface MetalTexture : NSObject
|
|
||||||
@property (nonatomic, strong) id<MTLTexture> metalTexture;
|
|
||||||
- (instancetype)initWithTexture:(id<MTLTexture>)metalTexture;
|
|
||||||
@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<MTLDevice> device;
|
|
||||||
@property (nonatomic, strong) id<MTL4CommandQueue> commandQueue;
|
|
||||||
@property (nonatomic, strong) id<MTLDepthStencilState> depthStencilState;
|
|
||||||
@property (nonatomic, strong) id<MTL4ArgumentTable> argumentTable;
|
|
||||||
@property (nonatomic, strong) id<MTLSamplerState> samplerStateLinear;
|
|
||||||
@property (nonatomic, strong) id<MTLSamplerState> samplerStateNearest;
|
|
||||||
@property (nonatomic, strong) id<MTLResidencySet> residencySet;
|
|
||||||
@property (nonatomic, strong) FramebufferDescriptor* framebufferDescriptor;
|
|
||||||
@property (nonatomic, strong) NSMutableDictionary* renderPipelineStateCache;
|
|
||||||
@property (nonatomic, assign) NSUInteger framesInFlight;
|
|
||||||
@property (nonatomic, assign) NSUInteger currentFrameSlot;
|
|
||||||
@property (nonatomic, strong) NSArray<id<MTLBuffer>>* constantBuffers;
|
|
||||||
@property (nonatomic, assign) ImGui_Metal4_ConstantData** constantBufferContentsArray;
|
|
||||||
@property (nonatomic, strong) NSMutableArray<NSMutableArray<MetalBuffer*>*>* bufferCaches;
|
|
||||||
@property (nonatomic, strong) NSObject* bufferCacheLock;
|
|
||||||
@property (nonatomic, assign) double lastBufferCachePurge;
|
|
||||||
- (id<MTLBuffer>)currentConstantBuffer;
|
|
||||||
- (ImGui_Metal4_ConstantData*)currentConstantBufferContents;
|
|
||||||
- (MetalBuffer*)dequeueReusableBufferOfLength:(NSUInteger)length device:(id<MTLDevice>)device;
|
|
||||||
- (id<MTLRenderPipelineState>)renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor*)descriptor device:(id<MTLDevice>)device;
|
|
||||||
@end
|
|
||||||
|
|
||||||
struct ImGui_ImplMetal4_Data
|
|
||||||
{
|
|
||||||
MetalContext* SharedMetalContext;
|
|
||||||
id<MTL4RenderCommandEncoder> RenderCommandEncoder;
|
|
||||||
|
|
||||||
ImGui_ImplMetal4_Data() { memset((void*)this, 0, sizeof(*this)); }
|
|
||||||
};
|
|
||||||
|
|
||||||
static ImGui_ImplMetal4_Data* ImGui_ImplMetal4_GetBackendData() { return ImGui::GetCurrentContext() ? (ImGui_ImplMetal4_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; }
|
|
||||||
static void ImGui_ImplMetal4_DestroyBackendData(){ IM_DELETE(ImGui_ImplMetal4_GetBackendData()); }
|
|
||||||
|
|
||||||
static inline CFTimeInterval GetMachAbsoluteTimeInSeconds() { return (CFTimeInterval)(double)(clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / 1e9); }
|
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_METAL_CPP
|
|
||||||
|
|
||||||
#pragma mark - Dear ImGui Metal C++ Backend API
|
|
||||||
|
|
||||||
bool ImGui_ImplMetal4_Init(MTL::Device* device, MTL4::CommandQueue* commandQueue, int framesInFlight)
|
|
||||||
{
|
|
||||||
return ImGui_ImplMetal4_Init((__bridge id<MTLDevice>)(device),(__bridge id<MTL4CommandQueue>)(commandQueue), framesInFlight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplMetal4_NewFrame(MTL4::RenderPassDescriptor* renderPassDescriptor, int frameInFlightIndex)
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_NewFrame((__bridge MTL4RenderPassDescriptor*)(renderPassDescriptor), frameInFlightIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplMetal4_RenderDrawData(ImDrawData* draw_data,
|
|
||||||
MTL4::CommandBuffer* commandBuffer,
|
|
||||||
MTL4::RenderCommandEncoder* commandEncoder)
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_RenderDrawData(draw_data,
|
|
||||||
(__bridge id<MTL4CommandBuffer>)(commandBuffer),
|
|
||||||
(__bridge id<MTL4RenderCommandEncoder>)(commandEncoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device)
|
|
||||||
{
|
|
||||||
return ImGui_ImplMetal4_CreateDeviceObjects((__bridge id<MTLDevice>)(device));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // #ifdef IMGUI_IMPL_METAL_CPP
|
|
||||||
|
|
||||||
#pragma mark - Dear ImGui Metal Backend API
|
|
||||||
|
|
||||||
void ImGui_ImplMetal4_NewFrame(MTL4RenderPassDescriptor* renderPassDescriptor, int frameInFlightIndex)
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_Data* bd = ImGui_ImplMetal4_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nil && "Context or backend not initialized! Did you call ImGui_ImplMetal4_Init()?");
|
|
||||||
IM_ASSERT(frameInFlightIndex < (int)bd->SharedMetalContext.framesInFlight && "frameInFlightIndex out of range! See framesInFlight passed to ImGui_ImplMetal4_Init().");
|
|
||||||
#ifdef IMGUI_IMPL_METAL_CPP
|
|
||||||
bd->SharedMetalContext.framebufferDescriptor = [[[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor]autorelease];
|
|
||||||
#else
|
|
||||||
bd->SharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor];
|
|
||||||
#endif
|
|
||||||
bd->SharedMetalContext.currentFrameSlot = (NSUInteger)frameInFlightIndex;
|
|
||||||
if (bd->SharedMetalContext.depthStencilState == nil)
|
|
||||||
ImGui_ImplMetal4_CreateDeviceObjects(bd->SharedMetalContext.device);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplMetal4_SetupRenderState(ImDrawData* draw_data, id<MTL4CommandBuffer> commandBuffer,
|
|
||||||
id<MTL4RenderCommandEncoder> commandEncoder, id<MTLRenderPipelineState> renderPipelineState,
|
|
||||||
MetalBuffer* vertexBuffer, size_t vertexBufferOffset)
|
|
||||||
{
|
|
||||||
IM_UNUSED(commandBuffer);
|
|
||||||
ImGui_ImplMetal4_Data* bd = ImGui_ImplMetal4_GetBackendData();
|
|
||||||
[commandEncoder setCullMode:MTLCullModeNone];
|
|
||||||
[commandEncoder setDepthStencilState:bd->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)(int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f),
|
|
||||||
.height = (double)(int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f),
|
|
||||||
.znear = 0.0,
|
|
||||||
.zfar = 1.0
|
|
||||||
};
|
|
||||||
[commandEncoder setViewport:viewport];
|
|
||||||
|
|
||||||
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 N = (float)viewport.znear;
|
|
||||||
float F = (float)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 },
|
|
||||||
};
|
|
||||||
ImGui_Metal4_ConstantData* constantBufferContents = [bd->SharedMetalContext currentConstantBufferContents];
|
|
||||||
memcpy(constantBufferContents->ModelViewProjectionMatrix, ortho_projection, sizeof(ortho_projection));
|
|
||||||
|
|
||||||
id<MTL4ArgumentTable> argumentTable = bd->SharedMetalContext.argumentTable;
|
|
||||||
[argumentTable setAddress:[bd->SharedMetalContext currentConstantBuffer].gpuAddress atIndex:1];
|
|
||||||
[argumentTable setAddress:(vertexBuffer.buffer.gpuAddress + vertexBufferOffset) attributeStride:sizeof(ImDrawVert) atIndex:0];
|
|
||||||
[argumentTable setSamplerState:bd->SharedMetalContext.samplerStateLinear.gpuResourceID atIndex:0];
|
|
||||||
[commandEncoder setArgumentTable:argumentTable atStages:MTLRenderStageVertex | MTLRenderStageFragment];
|
|
||||||
[commandEncoder setRenderPipelineState:renderPipelineState];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplMetal4_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplMetal4_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplMetal4_Data* bd = ImGui_ImplMetal4_GetBackendData(); [bd->SharedMetalContext.argumentTable setSamplerState:bd->SharedMetalContext.samplerStateLinear.gpuResourceID atIndex:0]; }
|
|
||||||
static void ImGui_ImplMetal4_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplMetal4_Data* bd = ImGui_ImplMetal4_GetBackendData(); [bd->SharedMetalContext.argumentTable setSamplerState:bd->SharedMetalContext.samplerStateNearest.gpuResourceID atIndex:0]; }
|
|
||||||
|
|
||||||
void ImGui_ImplMetal4_RenderDrawData(ImDrawData* draw_data, id<MTL4CommandBuffer> commandBuffer, id<MTL4RenderCommandEncoder> commandEncoder)
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_Data* bd = ImGui_ImplMetal4_GetBackendData();
|
|
||||||
MetalContext* ctx = bd->SharedMetalContext;
|
|
||||||
|
|
||||||
// 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 + 0.5f);
|
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
|
||||||
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdLists.Size == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
|
||||||
// (This almost always points to ImGui::GetPlatformIO().Textures[] but is part of ImDrawData to allow overriding or disabling texture updates).
|
|
||||||
if (draw_data->Textures != nullptr)
|
|
||||||
for (ImTextureData* tex : *draw_data->Textures)
|
|
||||||
if (tex->Status != ImTextureStatus_OK)
|
|
||||||
ImGui_ImplMetal4_UpdateTexture(tex);
|
|
||||||
|
|
||||||
// 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<MTLRenderPipelineState> renderPipelineState = ctx.renderPipelineStateCache[ctx.framebufferDescriptor];
|
|
||||||
if (renderPipelineState == nil)
|
|
||||||
{
|
|
||||||
// No luck; make a new render pipeline state
|
|
||||||
renderPipelineState = [ctx renderPipelineStateForFramebufferDescriptor:ctx.framebufferDescriptor device:commandBuffer.device];
|
|
||||||
|
|
||||||
// Cache render pipeline state for later reuse
|
|
||||||
ctx.renderPipelineStateCache[ctx.framebufferDescriptor] = renderPipelineState;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t vertexBufferLength = (size_t)draw_data->TotalVtxCount * sizeof(ImDrawVert);
|
|
||||||
size_t indexBufferLength = (size_t)draw_data->TotalIdxCount * sizeof(ImDrawIdx);
|
|
||||||
MetalBuffer* vertexBuffer = [ctx dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device];
|
|
||||||
MetalBuffer* indexBuffer = [ctx dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device];
|
|
||||||
|
|
||||||
bd->RenderCommandEncoder = commandEncoder;
|
|
||||||
ImGui_ImplMetal4_SetupRenderState(draw_data, commandBuffer, commandEncoder, renderPipelineState, vertexBuffer, 0);
|
|
||||||
|
|
||||||
// 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
|
|
||||||
size_t vertexBufferOffset = 0;
|
|
||||||
size_t indexBufferOffset = 0;
|
|
||||||
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
|
||||||
{
|
|
||||||
memcpy((char*)vertexBuffer.buffer.contents + vertexBufferOffset, draw_list->VtxBuffer.Data, (size_t)draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
|
||||||
memcpy((char*)indexBuffer.buffer.contents + indexBufferOffset, draw_list->IdxBuffer.Data, (size_t)draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
|
||||||
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
|
||||||
{
|
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
|
||||||
if (pcmd->UserCallback)
|
|
||||||
{
|
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
|
||||||
if (pcmd->UserCallback == ImGui_ImplMetal4_DrawCallback_ResetRenderState)
|
|
||||||
ImGui_ImplMetal4_SetupRenderState(draw_data, commandBuffer, commandEncoder, renderPipelineState, vertexBuffer, vertexBufferOffset);
|
|
||||||
else
|
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Project scissor/clipping rectangles into framebuffer space
|
|
||||||
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
|
||||||
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
|
||||||
|
|
||||||
// Clamp to viewport as setScissorRect() won't accept values that are off bounds
|
|
||||||
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
|
||||||
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
|
||||||
if (clip_max.x > (float)fb_width) { clip_max.x = (float)fb_width; }
|
|
||||||
if (clip_max.y > (float)fb_height) { clip_max.y = (float)fb_height; }
|
|
||||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
|
||||||
continue;
|
|
||||||
if (pcmd->ElemCount == 0) // drawIndexedPrimitives() validation doesn't accept this
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Apply scissor/clipping rectangle
|
|
||||||
MTLScissorRect scissorRect =
|
|
||||||
{
|
|
||||||
.x = NSUInteger(clip_min.x),
|
|
||||||
.y = NSUInteger(clip_min.y),
|
|
||||||
.width = NSUInteger(clip_max.x - clip_min.x),
|
|
||||||
.height = NSUInteger(clip_max.y - clip_min.y)
|
|
||||||
};
|
|
||||||
[commandEncoder setScissorRect:scissorRect];
|
|
||||||
|
|
||||||
// Bind texture, Draw
|
|
||||||
ImTextureID tex_id = pcmd->GetTexID();
|
|
||||||
if (tex_id != ImTextureID_Invalid)
|
|
||||||
{
|
|
||||||
id<MTLTexture> texture = (__bridge id<MTLTexture>)(void*)(intptr_t)tex_id;
|
|
||||||
[bd->SharedMetalContext.residencySet addAllocation:texture];
|
|
||||||
[bd->SharedMetalContext.argumentTable setTexture:texture.gpuResourceID atIndex:0];
|
|
||||||
}
|
|
||||||
|
|
||||||
[bd->SharedMetalContext.argumentTable setAddress:(vertexBuffer.buffer.gpuAddress + vertexBufferOffset + (pcmd->VtxOffset * sizeof(ImDrawVert))) attributeStride:sizeof(ImDrawVert) atIndex:0];
|
|
||||||
|
|
||||||
size_t indexBufferCmdOffset = indexBufferOffset + (pcmd->IdxOffset * sizeof(ImDrawIdx));
|
|
||||||
[commandEncoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle
|
|
||||||
indexCount:pcmd->ElemCount
|
|
||||||
indexType:sizeof(ImDrawIdx) == 2 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32
|
|
||||||
indexBuffer:indexBuffer.buffer.gpuAddress + indexBufferCmdOffset
|
|
||||||
indexBufferLength:indexBuffer.buffer.length - indexBufferCmdOffset];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vertexBufferOffset += (size_t)draw_list->VtxBuffer.Size * sizeof(ImDrawVert);
|
|
||||||
indexBufferOffset += (size_t)draw_list->IdxBuffer.Size * sizeof(ImDrawIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
MetalContext* sharedMetalContext = bd->SharedMetalContext;
|
|
||||||
@synchronized(sharedMetalContext.bufferCacheLock)
|
|
||||||
{
|
|
||||||
NSMutableArray<MetalBuffer*>* slotCache = sharedMetalContext.bufferCaches[sharedMetalContext.currentFrameSlot];
|
|
||||||
[slotCache addObject:vertexBuffer];
|
|
||||||
[slotCache addObject:indexBuffer];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit residency set
|
|
||||||
[bd->SharedMetalContext.residencySet commit];
|
|
||||||
bd->RenderCommandEncoder = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplMetal4_DestroyTexture(ImTextureData* tex)
|
|
||||||
{
|
|
||||||
if (MetalTexture* backend_tex = (__bridge_transfer MetalTexture*)(tex->BackendUserData))
|
|
||||||
{
|
|
||||||
IM_ASSERT(backend_tex.metalTexture == (__bridge id<MTLTexture>)(void*)(intptr_t)tex->TexID);
|
|
||||||
backend_tex.metalTexture = nil;
|
|
||||||
|
|
||||||
// Clear identifiers and mark as destroyed (in order to allow e.g. calling InvalidateDeviceObjects while running)
|
|
||||||
tex->SetTexID(ImTextureID_Invalid);
|
|
||||||
tex->BackendUserData = nullptr;
|
|
||||||
}
|
|
||||||
tex->SetStatus(ImTextureStatus_Destroyed);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplMetal4_UpdateTexture(ImTextureData* tex)
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_Data* bd = ImGui_ImplMetal4_GetBackendData();
|
|
||||||
if (tex->Status == ImTextureStatus_WantCreate)
|
|
||||||
{
|
|
||||||
// Create and upload new texture to graphics system
|
|
||||||
//IMGUI_DEBUG_LOG("UpdateTexture #%03d: WantCreate %dx%d\n", tex->UniqueID, tex->Width, tex->Height);
|
|
||||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
|
||||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
MTLTextureDescriptor* textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
|
|
||||||
width:(NSUInteger)tex->Width
|
|
||||||
height:(NSUInteger)tex->Height
|
|
||||||
mipmapped:NO];
|
|
||||||
textureDescriptor.usage = MTLTextureUsageShaderRead;
|
|
||||||
textureDescriptor.storageMode = MTLStorageModeShared;
|
|
||||||
|
|
||||||
id <MTLTexture> texture = [bd->SharedMetalContext.device newTextureWithDescriptor:textureDescriptor];
|
|
||||||
[bd->SharedMetalContext.residencySet addAllocation:texture];
|
|
||||||
[texture replaceRegion:MTLRegionMake2D(0, 0, (NSUInteger)tex->Width, (NSUInteger)tex->Height) mipmapLevel:0 withBytes:tex->Pixels bytesPerRow:(NSUInteger)tex->Width * 4];
|
|
||||||
MetalTexture* backend_tex = [[MetalTexture alloc] initWithTexture:texture];
|
|
||||||
|
|
||||||
// Store identifiers
|
|
||||||
tex->SetTexID((ImTextureID)(intptr_t)texture);
|
|
||||||
tex->SetStatus(ImTextureStatus_OK);
|
|
||||||
tex->BackendUserData = (__bridge_retained void*)(backend_tex);
|
|
||||||
}
|
|
||||||
else if (tex->Status == ImTextureStatus_WantUpdates)
|
|
||||||
{
|
|
||||||
// Update selected blocks. We only ever write to textures regions which have never been used before!
|
|
||||||
// This backend choose to use tex->Updates[] but you can use tex->UpdateRect to upload a single region.
|
|
||||||
MetalTexture* backend_tex = (__bridge MetalTexture*)(tex->BackendUserData);
|
|
||||||
for (ImTextureRect& r : tex->Updates)
|
|
||||||
{
|
|
||||||
[backend_tex.metalTexture replaceRegion:MTLRegionMake2D((NSUInteger)r.x, (NSUInteger)r.y, (NSUInteger)r.w, (NSUInteger)r.h)
|
|
||||||
mipmapLevel:0
|
|
||||||
withBytes:tex->GetPixelsAt(r.x, r.y)
|
|
||||||
bytesPerRow:(NSUInteger)tex->Width * 4];
|
|
||||||
}
|
|
||||||
tex->SetStatus(ImTextureStatus_OK);
|
|
||||||
}
|
|
||||||
else if (tex->Status == ImTextureStatus_WantDestroy && tex->UnusedFrames > 0)
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_DestroyTexture(tex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGui_ImplMetal4_CreateDeviceObjects(id<MTLDevice> device)
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_Data* bd = ImGui_ImplMetal4_GetBackendData();
|
|
||||||
|
|
||||||
MTLResidencySetDescriptor* residencySetDescriptor = [[MTLResidencySetDescriptor alloc] init];
|
|
||||||
residencySetDescriptor.initialCapacity = 1000;
|
|
||||||
|
|
||||||
NSError* error = nil;
|
|
||||||
bd->SharedMetalContext.residencySet = [device newResidencySetWithDescriptor:residencySetDescriptor error:&error];
|
|
||||||
IM_ASSERT(bd->SharedMetalContext.residencySet != nil && error == nil);
|
|
||||||
|
|
||||||
[bd->SharedMetalContext.commandQueue addResidencySet:bd->SharedMetalContext.residencySet];
|
|
||||||
|
|
||||||
MTLDepthStencilDescriptor* depthStencilDescriptor = [[MTLDepthStencilDescriptor alloc] init];
|
|
||||||
depthStencilDescriptor.depthWriteEnabled = NO;
|
|
||||||
depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
|
|
||||||
bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
|
|
||||||
MTLSamplerDescriptor* samplerDescriptor = [[MTLSamplerDescriptor alloc] init];
|
|
||||||
samplerDescriptor.supportArgumentBuffers = YES;
|
|
||||||
samplerDescriptor.minFilter = MTLSamplerMinMagFilterLinear;
|
|
||||||
samplerDescriptor.magFilter = MTLSamplerMinMagFilterLinear;
|
|
||||||
samplerDescriptor.mipFilter = MTLSamplerMipFilterLinear;
|
|
||||||
bd->SharedMetalContext.samplerStateLinear = [device newSamplerStateWithDescriptor:samplerDescriptor];
|
|
||||||
samplerDescriptor.minFilter = MTLSamplerMinMagFilterNearest;
|
|
||||||
samplerDescriptor.magFilter = MTLSamplerMinMagFilterNearest;
|
|
||||||
samplerDescriptor.mipFilter = MTLSamplerMipFilterNearest;
|
|
||||||
bd->SharedMetalContext.samplerStateNearest = [device newSamplerStateWithDescriptor:samplerDescriptor];
|
|
||||||
|
|
||||||
NSMutableArray<id<MTLBuffer>>* constantBuffers = [NSMutableArray array];
|
|
||||||
ImGui_Metal4_ConstantData** constantBufferContentsArray = (ImGui_Metal4_ConstantData**)malloc(sizeof(ImGui_Metal4_ConstantData*) * bd->SharedMetalContext.framesInFlight);
|
|
||||||
for (NSUInteger i = 0; i < bd->SharedMetalContext.framesInFlight; i++)
|
|
||||||
{
|
|
||||||
id<MTLBuffer> constantBuffer = [device newBufferWithLength:sizeof(ImGui_Metal4_ConstantData) options:MTLResourceStorageModeShared];
|
|
||||||
[constantBuffers addObject:constantBuffer];
|
|
||||||
constantBufferContentsArray[i] = (ImGui_Metal4_ConstantData*)constantBuffer.contents;
|
|
||||||
[bd->SharedMetalContext.residencySet addAllocation:constantBuffer];
|
|
||||||
}
|
|
||||||
bd->SharedMetalContext.constantBuffers = constantBuffers;
|
|
||||||
bd->SharedMetalContext.constantBufferContentsArray = constantBufferContentsArray;
|
|
||||||
|
|
||||||
MTL4ArgumentTableDescriptor* argumentTableDescriptor = [[MTL4ArgumentTableDescriptor alloc] init];
|
|
||||||
argumentTableDescriptor.maxBufferBindCount = 8;
|
|
||||||
argumentTableDescriptor.maxTextureBindCount = 8;
|
|
||||||
argumentTableDescriptor.maxSamplerStateBindCount = 8;
|
|
||||||
argumentTableDescriptor.supportAttributeStrides = YES; // required: vertex buffer is bound via setAddress:stride:atIndex: for stage_in fetch
|
|
||||||
|
|
||||||
bd->SharedMetalContext.argumentTable = [device newArgumentTableWithDescriptor:argumentTableDescriptor error:&error];
|
|
||||||
IM_ASSERT(bd->SharedMetalContext.argumentTable != nil && error == nil);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplMetal4_DestroyDeviceObjects()
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_Data* bd = ImGui_ImplMetal4_GetBackendData();
|
|
||||||
|
|
||||||
// Destroy all textures
|
|
||||||
for (ImTextureData* tex : ImGui::GetPlatformIO().Textures)
|
|
||||||
if (tex->RefCount == 1)
|
|
||||||
ImGui_ImplMetal4_DestroyTexture(tex);
|
|
||||||
|
|
||||||
[bd->SharedMetalContext.renderPipelineStateCache removeAllObjects];
|
|
||||||
bd->SharedMetalContext.samplerStateLinear = nil;
|
|
||||||
bd->SharedMetalContext.samplerStateNearest = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGui_ImplMetal4_Init(id<MTLDevice> device, id<MTL4CommandQueue> commandQueue, int framesInFlight)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
|
||||||
IM_ASSERT(framesInFlight > 0 && "framesInFlight must be at least 1!");
|
|
||||||
|
|
||||||
ImGui_ImplMetal4_Data* bd = IM_NEW(ImGui_ImplMetal4_Data)();
|
|
||||||
io.BackendRendererUserData = (void*)bd;
|
|
||||||
io.BackendRendererName = "imgui_impl_metal4";
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplMetal4_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplMetal4_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplMetal4_DrawCallback_SetSamplerNearest;
|
|
||||||
|
|
||||||
bd->SharedMetalContext = [[MetalContext alloc] init];
|
|
||||||
bd->SharedMetalContext.device = device;
|
|
||||||
bd->SharedMetalContext.commandQueue = commandQueue;
|
|
||||||
bd->SharedMetalContext.framesInFlight = (NSUInteger)framesInFlight;
|
|
||||||
NSMutableArray<NSMutableArray<MetalBuffer*>*>* bufferCaches = [NSMutableArray array];
|
|
||||||
for (NSUInteger i = 0; i < (NSUInteger)framesInFlight; i++)
|
|
||||||
[bufferCaches addObject:[NSMutableArray array]];
|
|
||||||
bd->SharedMetalContext.bufferCaches = bufferCaches;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplMetal4_Shutdown()
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_Data* bd = ImGui_ImplMetal4_GetBackendData();
|
|
||||||
IM_UNUSED(bd);
|
|
||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
|
|
||||||
ImGui_ImplMetal4_DestroyDeviceObjects();
|
|
||||||
ImGui_ImplMetal4_DestroyBackendData();
|
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
|
||||||
io.BackendRendererUserData = nullptr;
|
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
|
||||||
platform_io.ClearRendererHandlers();
|
|
||||||
}
|
|
||||||
|
|
||||||
@implementation MetalBuffer
|
|
||||||
- (instancetype)initWithBuffer:(id<MTLBuffer>)buffer
|
|
||||||
{
|
|
||||||
if ((self = [super init]))
|
|
||||||
{
|
|
||||||
_buffer = buffer;
|
|
||||||
_lastReuseTime = GetMachAbsoluteTimeInSeconds();
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
#pragma mark - FramebufferDescriptor implementation
|
|
||||||
|
|
||||||
@implementation FramebufferDescriptor
|
|
||||||
{
|
|
||||||
MTLPixelFormat _colorPixelFormats[IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (instancetype)initWithRenderPassDescriptor:(MTL4RenderPassDescriptor*)renderPassDescriptor
|
|
||||||
{
|
|
||||||
if ((self = [super init]))
|
|
||||||
{
|
|
||||||
_sampleCount = renderPassDescriptor.colorAttachments[0].texture.sampleCount;
|
|
||||||
for (NSUInteger n = 0; n < IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS; n++)
|
|
||||||
_colorPixelFormats[n] = renderPassDescriptor.colorAttachments[n].texture.pixelFormat;
|
|
||||||
_depthPixelFormat = renderPassDescriptor.depthAttachment.texture.pixelFormat;
|
|
||||||
_stencilPixelFormat = renderPassDescriptor.stencilAttachment.texture.pixelFormat;
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (MTLPixelFormat)colorPixelFormatAtIndex:(NSUInteger)index
|
|
||||||
{
|
|
||||||
return _colorPixelFormats[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (nonnull id)copyWithZone:(nullable NSZone*)zone
|
|
||||||
{
|
|
||||||
FramebufferDescriptor* copy = [[FramebufferDescriptor allocWithZone:zone] init];
|
|
||||||
copy.sampleCount = self.sampleCount;
|
|
||||||
memcpy(copy->_colorPixelFormats, _colorPixelFormats, sizeof(_colorPixelFormats));
|
|
||||||
copy.depthPixelFormat = self.depthPixelFormat;
|
|
||||||
copy.stencilPixelFormat = self.stencilPixelFormat;
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSUInteger)hash
|
|
||||||
{
|
|
||||||
NSUInteger sc = _sampleCount & 0x3;
|
|
||||||
NSUInteger cf = _colorPixelFormats[0] & 0x3FF;
|
|
||||||
NSUInteger df = _depthPixelFormat & 0x3FF;
|
|
||||||
NSUInteger sf = _stencilPixelFormat & 0x3FF;
|
|
||||||
NSUInteger hash = (sf << 22) | (df << 12) | (cf << 2) | sc;
|
|
||||||
for (NSUInteger n = 1; n < IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS; n++)
|
|
||||||
hash = hash * 31 + _colorPixelFormats[n];
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isEqual:(id)object
|
|
||||||
{
|
|
||||||
FramebufferDescriptor* other = object;
|
|
||||||
if (![other isKindOfClass:[FramebufferDescriptor class]])
|
|
||||||
return NO;
|
|
||||||
return other.sampleCount == self.sampleCount &&
|
|
||||||
memcmp(other->_colorPixelFormats, _colorPixelFormats, sizeof(_colorPixelFormats)) == 0 &&
|
|
||||||
other.depthPixelFormat == self.depthPixelFormat &&
|
|
||||||
other.stencilPixelFormat == self.stencilPixelFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
#pragma mark - MetalTexture implementation
|
|
||||||
|
|
||||||
@implementation MetalTexture
|
|
||||||
- (instancetype)initWithTexture:(id<MTLTexture>)metalTexture
|
|
||||||
{
|
|
||||||
if ((self = [super init]))
|
|
||||||
self.metalTexture = metalTexture;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
#pragma mark - MetalContext implementation
|
|
||||||
|
|
||||||
@implementation MetalContext
|
|
||||||
- (instancetype)init
|
|
||||||
{
|
|
||||||
if ((self = [super init]))
|
|
||||||
{
|
|
||||||
self.renderPipelineStateCache = [NSMutableDictionary dictionary];
|
|
||||||
self.bufferCacheLock = [[NSObject alloc] init];
|
|
||||||
_lastBufferCachePurge = GetMachAbsoluteTimeInSeconds();
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)dealloc
|
|
||||||
{
|
|
||||||
free(_constantBufferContentsArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id<MTLBuffer>)currentConstantBuffer
|
|
||||||
{
|
|
||||||
return self.constantBuffers[self.currentFrameSlot];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (ImGui_Metal4_ConstantData*)currentConstantBufferContents
|
|
||||||
{
|
|
||||||
return self.constantBufferContentsArray[self.currentFrameSlot];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (MetalBuffer*)dequeueReusableBufferOfLength:(NSUInteger)length device:(id<MTLDevice>)device
|
|
||||||
{
|
|
||||||
double now = GetMachAbsoluteTimeInSeconds();
|
|
||||||
NSMutableArray<MetalBuffer*>* slotCache = self.bufferCaches[self.currentFrameSlot];
|
|
||||||
|
|
||||||
@synchronized(self.bufferCacheLock)
|
|
||||||
{
|
|
||||||
// Purge old buffers that haven't been useful for a while
|
|
||||||
if (now - self.lastBufferCachePurge > 1.0)
|
|
||||||
{
|
|
||||||
for (NSMutableArray<MetalBuffer*>* cache in self.bufferCaches)
|
|
||||||
{
|
|
||||||
NSMutableArray* survivors = [NSMutableArray array];
|
|
||||||
for (MetalBuffer* candidate in cache)
|
|
||||||
if (candidate.lastReuseTime > self.lastBufferCachePurge)
|
|
||||||
[survivors addObject:candidate];
|
|
||||||
[cache setArray:survivors];
|
|
||||||
}
|
|
||||||
self.lastBufferCachePurge = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See if we have a buffer we can reuse, from this frame-in-flight slot's own cache
|
|
||||||
MetalBuffer* bestCandidate = nil;
|
|
||||||
for (MetalBuffer* candidate in slotCache)
|
|
||||||
if (candidate.buffer.length >= length && (bestCandidate == nil || bestCandidate.lastReuseTime > candidate.lastReuseTime))
|
|
||||||
bestCandidate = candidate;
|
|
||||||
|
|
||||||
if (bestCandidate != nil)
|
|
||||||
{
|
|
||||||
[slotCache removeObject:bestCandidate];
|
|
||||||
bestCandidate.lastReuseTime = now;
|
|
||||||
return bestCandidate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// No luck; make a new buffer
|
|
||||||
id<MTLBuffer> backing = [device newBufferWithLength:length options:MTLResourceStorageModeShared];
|
|
||||||
[self.residencySet addAllocation:backing];
|
|
||||||
return [[MetalBuffer alloc] initWithBuffer:backing];
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* shaderCode = R"(
|
|
||||||
#include <metal_stdlib>
|
|
||||||
using namespace metal;
|
|
||||||
|
|
||||||
struct Uniforms {
|
|
||||||
float4x4 projectionMatrix;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VertexIn {
|
|
||||||
float2 position [[attribute(0)]];
|
|
||||||
float2 texCoords [[attribute(1)]];
|
|
||||||
uchar4 color [[attribute(2)]];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VertexOut {
|
|
||||||
float4 position [[position]];
|
|
||||||
float2 texCoords;
|
|
||||||
float4 color;
|
|
||||||
};
|
|
||||||
|
|
||||||
vertex VertexOut vertex_main(VertexIn in [[stage_in]],
|
|
||||||
constant Uniforms &uniforms [[buffer(1)]])
|
|
||||||
{
|
|
||||||
VertexOut out;
|
|
||||||
out.position = uniforms.projectionMatrix * float4(in.position, 0, 1);
|
|
||||||
out.texCoords = in.texCoords;
|
|
||||||
out.color = float4(in.color) / float4(255.0);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment half4 fragment_main(VertexOut in [[stage_in]],
|
|
||||||
texture2d<half, access::sample> texture [[texture(0)]],
|
|
||||||
sampler textureSampler [[sampler(0)]])
|
|
||||||
{
|
|
||||||
half4 texColor = texture.sample(textureSampler, in.texCoords);
|
|
||||||
return half4(in.color) * texColor;
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
|
|
||||||
- (id<MTLRenderPipelineState>)renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor*)descriptor device:(id<MTLDevice>)device
|
|
||||||
{
|
|
||||||
NSError* error = nil;
|
|
||||||
|
|
||||||
id<MTLLibrary> library = [device newLibraryWithSource:[NSString stringWithUTF8String:shaderCode] options:nil error:&error];
|
|
||||||
if (library == nil)
|
|
||||||
{
|
|
||||||
NSLog(@"Error: failed to create Metal library: %@", error);
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
id<MTLFunction> vertexFunction = [library newFunctionWithName:@"vertex_main"];
|
|
||||||
id<MTLFunction> 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 = offsetof(ImDrawVert, pos);
|
|
||||||
vertexDescriptor.attributes[0].format = MTLVertexFormatFloat2; // position
|
|
||||||
vertexDescriptor.attributes[0].bufferIndex = 0;
|
|
||||||
vertexDescriptor.attributes[1].offset = offsetof(ImDrawVert, uv);
|
|
||||||
vertexDescriptor.attributes[1].format = MTLVertexFormatFloat2; // texCoords
|
|
||||||
vertexDescriptor.attributes[1].bufferIndex = 0;
|
|
||||||
vertexDescriptor.attributes[2].offset = 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.rasterSampleCount = self.framebufferDescriptor.sampleCount;
|
|
||||||
pipelineDescriptor.colorAttachments[0].pixelFormat = [self.framebufferDescriptor colorPixelFormatAtIndex:0];
|
|
||||||
pipelineDescriptor.colorAttachments[0].blendingEnabled = YES;
|
|
||||||
pipelineDescriptor.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd;
|
|
||||||
pipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
|
|
||||||
pipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
|
|
||||||
pipelineDescriptor.colorAttachments[0].alphaBlendOperation = MTLBlendOperationAdd;
|
|
||||||
pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = MTLBlendFactorOne;
|
|
||||||
pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
|
|
||||||
for (NSUInteger n = 1; n < IMGUI_IMPL_METAL_MAX_COLOR_ATTACHMENTS; n++) // Don't write to other color attachments, if any.
|
|
||||||
{
|
|
||||||
pipelineDescriptor.colorAttachments[n].pixelFormat = [self.framebufferDescriptor colorPixelFormatAtIndex:n];
|
|
||||||
pipelineDescriptor.colorAttachments[n].writeMask = MTLColorWriteMaskNone;
|
|
||||||
}
|
|
||||||
pipelineDescriptor.depthAttachmentPixelFormat = self.framebufferDescriptor.depthPixelFormat;
|
|
||||||
pipelineDescriptor.stencilAttachmentPixelFormat = self.framebufferDescriptor.stencilPixelFormat;
|
|
||||||
|
|
||||||
id<MTLRenderPipelineState> renderPipelineState = [device newRenderPipelineStateWithDescriptor:pipelineDescriptor error:&error];
|
|
||||||
if (error != nil)
|
|
||||||
NSLog(@"Error: failed to create Metal pipeline state: %@", error);
|
|
||||||
|
|
||||||
return renderPipelineState;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
|
||||||
@ -6,7 +6,6 @@
|
|||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// Missing features or Issues:
|
// Missing features or Issues:
|
||||||
// [ ] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [ ] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [ ] Renderer: Use of DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest is emulated by poking to glTexParameter(), as legacy OpenGL doesn't have glBindSampler().
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -26,10 +25,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-09-17: OpenGL: Added support for platform_io.DrawCallback_SetSamplerFromTex. (#9378)
|
|
||||||
// 2026-09-07: OpenGL: Round framebuffer dimensions to the nearest integer instead of truncating them. (#9538, 9515, #8628)
|
|
||||||
// 2026-07-15: OpenGL: Backup and restore GL_UNPACK_ROW_LENGTH and GL_UNPACK_ALIGNMENT in UpdateTexture() to avoid corrupting caller GL state. (#8802, #9473)
|
|
||||||
// 2026-04-23: OpenGL: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. (#9378)
|
|
||||||
// 2026-03-12: OpenGL: Fixed invalid assert in ImGui_ImplOpenGL3_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295)
|
// 2026-03-12: OpenGL: Fixed invalid assert in ImGui_ImplOpenGL3_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295)
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
// 2025-07-15: OpenGL: Set GL_UNPACK_ALIGNMENT to 1 before updating textures. (#8802)
|
// 2025-07-15: OpenGL: Set GL_UNPACK_ALIGNMENT to 1 before updating textures. (#8802)
|
||||||
@ -91,9 +86,6 @@
|
|||||||
// OpenGL data
|
// OpenGL data
|
||||||
struct ImGui_ImplOpenGL2_Data
|
struct ImGui_ImplOpenGL2_Data
|
||||||
{
|
{
|
||||||
bool UseTexParameterToSetSampler;
|
|
||||||
GLuint NextSampler;
|
|
||||||
|
|
||||||
ImGui_ImplOpenGL2_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplOpenGL2_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,6 +97,37 @@ static ImGui_ImplOpenGL2_Data* ImGui_ImplOpenGL2_GetBackendData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
bool ImGui_ImplOpenGL2_Init()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
|
// Setup backend capabilities flags
|
||||||
|
ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
|
io.BackendRendererName = "imgui_impl_opengl2";
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplOpenGL2_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
io.BackendRendererName = nullptr;
|
||||||
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasTextures);
|
||||||
|
platform_io.ClearRendererHandlers();
|
||||||
|
IM_DELETE(bd);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplOpenGL2_NewFrame()
|
void ImGui_ImplOpenGL2_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
|
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
|
||||||
@ -115,7 +138,6 @@ void ImGui_ImplOpenGL2_NewFrame()
|
|||||||
static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height)
|
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.
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
|
||||||
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
//glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // In order to composite our output buffer we need to preserve alpha
|
//glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // In order to composite our output buffer we need to preserve alpha
|
||||||
@ -134,9 +156,6 @@ static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
bd->UseTexParameterToSetSampler = false;
|
|
||||||
bd->NextSampler = GL_LINEAR;
|
|
||||||
|
|
||||||
// If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
|
// If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
|
||||||
// you may need to backup/reset/restore other state, e.g. for current shader using the commented lines below.
|
// you may need to backup/reset/restore other state, e.g. for current shader using the commented lines below.
|
||||||
// (DO NOT MODIFY THIS FILE! Add the code in your calling function)
|
// (DO NOT MODIFY THIS FILE! Add the code in your calling function)
|
||||||
@ -160,24 +179,14 @@ static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
// - IMPORTANT: Using DrawCallback_SetSamplerLinear/DrawCallback_SetSamplerNearest will trash glTexParameteri() values for the texture!!
|
|
||||||
// We cannot decently backup/restore that state because glGetTexParameteriv() is slow on many setups.
|
|
||||||
// - Using DrawCallback_SetSamplerFromTex will basically instruct the backend to use existing glTexParameteri() values without modifying anything, which is the initial state.
|
|
||||||
static void ImGui_ImplOpenGL2_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplOpenGL2_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData(); bd->UseTexParameterToSetSampler = true; bd->NextSampler = GL_LINEAR; }
|
|
||||||
static void ImGui_ImplOpenGL2_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData(); bd->UseTexParameterToSetSampler = true; bd->NextSampler = GL_NEAREST; }
|
|
||||||
static void ImGui_ImplOpenGL2_DrawCallback_SetSamplerFromTex(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData(); bd->UseTexParameterToSetSampler = false; }
|
|
||||||
|
|
||||||
// OpenGL2 Render function.
|
// OpenGL2 Render function.
|
||||||
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly.
|
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly.
|
||||||
// This is in order to be able to run within an OpenGL engine that doesn't do so.
|
// This is in order to be able to run within an OpenGL engine that doesn't do so.
|
||||||
void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
|
||||||
if (fb_width == 0 || fb_height == 0)
|
if (fb_width == 0 || fb_height == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -219,7 +228,8 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (pcmd->UserCallback)
|
if (pcmd->UserCallback)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplOpenGL2_DrawCallback_ResetRenderState)
|
// (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);
|
ImGui_ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -236,17 +246,7 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
glScissor((int)clip_min.x, (int)((float)fb_height - clip_max.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y));
|
glScissor((int)clip_min.x, (int)((float)fb_height - clip_max.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y));
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
GLuint pcmd_texture = (GLuint)(intptr_t)pcmd->GetTexID();
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID());
|
||||||
glBindTexture(GL_TEXTURE_2D, pcmd_texture);
|
|
||||||
|
|
||||||
// Emulate sampler change (even though it is technically part of texture data)
|
|
||||||
// As a sort of hack/workaround, we only start writing using glTextParameter() if sampler is ever changed explicitly.
|
|
||||||
if (bd->UseTexParameterToSetSampler)
|
|
||||||
{
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bd->NextSampler);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bd->NextSampler);
|
|
||||||
}
|
|
||||||
|
|
||||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer + pcmd->IdxOffset);
|
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer + pcmd->IdxOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,10 +271,6 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex)
|
void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex)
|
||||||
{
|
{
|
||||||
// Backup GL_UNPACK state that we modify, restore on exit.
|
|
||||||
GLint last_unpack_row_length = 0; GL_CALL(glGetIntegerv(GL_UNPACK_ROW_LENGTH, &last_unpack_row_length));
|
|
||||||
GLint last_unpack_alignment = 0; GL_CALL(glGetIntegerv(GL_UNPACK_ALIGNMENT, &last_unpack_alignment));
|
|
||||||
|
|
||||||
if (tex->Status == ImTextureStatus_WantCreate)
|
if (tex->Status == ImTextureStatus_WantCreate)
|
||||||
{
|
{
|
||||||
// Create and upload new texture to graphics system
|
// Create and upload new texture to graphics system
|
||||||
@ -284,7 +280,8 @@ void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex)
|
|||||||
const void* pixels = tex->GetPixels();
|
const void* pixels = tex->GetPixels();
|
||||||
GLuint gl_texture_id = 0;
|
GLuint gl_texture_id = 0;
|
||||||
|
|
||||||
// Upload texture to graphics system (bilinear sampling is required).
|
// Upload texture to graphics system
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
GLint last_texture;
|
GLint last_texture;
|
||||||
GL_CALL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
GL_CALL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
||||||
GL_CALL(glGenTextures(1, &gl_texture_id));
|
GL_CALL(glGenTextures(1, &gl_texture_id));
|
||||||
@ -330,10 +327,6 @@ void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex)
|
|||||||
tex->SetTexID(ImTextureID_Invalid);
|
tex->SetTexID(ImTextureID_Invalid);
|
||||||
tex->SetStatus(ImTextureStatus_Destroyed);
|
tex->SetStatus(ImTextureStatus_Destroyed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore GL_UNPACK state
|
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, last_unpack_row_length));
|
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, last_unpack_alignment));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplOpenGL2_CreateDeviceObjects()
|
bool ImGui_ImplOpenGL2_CreateDeviceObjects()
|
||||||
@ -351,43 +344,6 @@ void ImGui_ImplOpenGL2_DestroyDeviceObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplOpenGL2_Init()
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
|
||||||
ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)();
|
|
||||||
io.BackendRendererUserData = (void*)bd;
|
|
||||||
io.BackendRendererName = "imgui_impl_opengl2";
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplOpenGL2_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplOpenGL2_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplOpenGL2_DrawCallback_SetSamplerNearest;
|
|
||||||
platform_io.DrawCallback_SetSamplerFromTex = ImGui_ImplOpenGL2_DrawCallback_SetSamplerFromTex;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplOpenGL2_Shutdown()
|
|
||||||
{
|
|
||||||
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
|
|
||||||
ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
|
||||||
io.BackendRendererUserData = nullptr;
|
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasTextures);
|
|
||||||
platform_io.ClearRendererHandlers();
|
|
||||||
IM_DELETE(bd);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
|||||||
@ -6,7 +6,6 @@
|
|||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// Missing features or Issues:
|
// Missing features or Issues:
|
||||||
// [ ] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [ ] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [ ] Renderer: Use of DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest is emulated by poking to glTexParameter(), as legacy OpenGL doesn't have glBindSampler().
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!]
|
// [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!]
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplOpenGL3_GetRenderState().
|
|
||||||
|
|
||||||
// About WebGL/ES:
|
// About WebGL/ES:
|
||||||
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||||
@ -24,16 +23,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-10-01: OpenGL: Added ImGui_ImplOpenGL3_SetClipOrigin() to specify clip origins (GL_LOWER_LEFT/GL_UPPER_LEFT, or use 0 to autodetect). (#2186, #3998, #3146, #3143, #8640)
|
|
||||||
// (Breaking): we now default to GL_LOWER_LEFT instead of 0=autodetect. Because 1) detection is not reliable and 2) is slow.
|
|
||||||
// 2026-10-01: OpenGL: Avoid querying glGetIntegerv(GL_CLIP_ORIGIN) multiple times when using DrawCallback_ResetRenderState. (#2186, #3998, #3146, #3143, #8640)
|
|
||||||
// 2026-09-17: OpenGL: Added support for platform_io.DrawCallback_SetSamplerFromTex. (#9378)
|
|
||||||
// 2026-09-07: OpenGL: Round framebuffer dimensions to the nearest integer instead of truncating them. (#9538, 9515, #8628)
|
|
||||||
// 2026-07-15: OpenGL: Backup and restore GL_UNPACK_ROW_LENGTH and GL_UNPACK_ALIGNMENT in UpdateTexture() to avoid corrupting caller GL state. (#8802, #9473)
|
|
||||||
// 2026-06-17: OpenGL: Expose selected render state in ImGui_ImplOpenGL3_RenderState, Allowing to dynamically select between use of glBindSampler() and glTexParameter(). You can access in 'void* platform_io.Renderer_RenderState' during rendering.
|
|
||||||
// 2026-06-03: OpenGL: GLSL version detection assume GLSL 410 when GL context is 4.1. Fixes an issue running on macOS with Wine. (#9427, #6577)
|
|
||||||
// 2026-04-23: OpenGL: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. (#9378)
|
|
||||||
// (Breaking): this change prioritize using glBindSampler() when available, which would override glTexParameter() settings you may have set on custom textures.
|
|
||||||
// 2026-03-12: OpenGL: Fixed invalid assert in ImGui_ImplOpenGL3_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295)
|
// 2026-03-12: OpenGL: Fixed invalid assert in ImGui_ImplOpenGL3_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295)
|
||||||
// 2025-12-11: OpenGL: Fixed embedded loader multiple init/shutdown cycles broken on some platforms. (#8792, #9112)
|
// 2025-12-11: OpenGL: Fixed embedded loader multiple init/shutdown cycles broken on some platforms. (#8792, #9112)
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
@ -192,10 +181,6 @@
|
|||||||
#define IMGUI_IMPL_OPENGL_LOADER_IMGL3W
|
#define IMGUI_IMPL_OPENGL_LOADER_IMGL3W
|
||||||
#include "imgui_impl_opengl3_loader.h"
|
#include "imgui_impl_opengl3_loader.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef GL_LOWER_LEFT
|
|
||||||
#define GL_LOWER_LEFT 0x8CA1
|
|
||||||
#define GL_UPPER_LEFT 0x8CA2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Vertex arrays are not supported on ES2/WebGL1 unless Emscripten which uses an extension
|
// Vertex arrays are not supported on ES2/WebGL1 unless Emscripten which uses an extension
|
||||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
@ -266,13 +251,7 @@ struct ImGui_ImplOpenGL3_Data
|
|||||||
bool HasPolygonMode;
|
bool HasPolygonMode;
|
||||||
bool HasBindSampler;
|
bool HasBindSampler;
|
||||||
bool HasClipOrigin;
|
bool HasClipOrigin;
|
||||||
GLenum ClipOriginRequest; // Default = GL_LOWER_LEFT. Change using ImGui_ImplOpenGL3_SetClipOrigin().
|
|
||||||
GLenum ClipOriginCurrent;
|
|
||||||
bool UseBufferSubData;
|
bool UseBufferSubData;
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
|
||||||
GLuint TexSamplers[2]; // Used if HasBindSimpler. (0=linear, 1=nearest)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ImVector<char> TempBuffer;
|
ImVector<char> TempBuffer;
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplOpenGL3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
@ -285,11 +264,6 @@ static ImGui_ImplOpenGL3_Data* ImGui_ImplOpenGL3_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_RenderState* ImGui_ImplOpenGL3_GetRenderState()
|
|
||||||
{
|
|
||||||
return (ImGui_ImplOpenGL3_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only)
|
// OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only)
|
||||||
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
struct ImGui_ImplOpenGL3_VtxAttribState
|
struct ImGui_ImplOpenGL3_VtxAttribState
|
||||||
@ -338,6 +312,139 @@ static void ImGui_ImplOpenGL3_ShutdownLoader()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
|
// Initialize loader
|
||||||
|
if (!ImGui_ImplOpenGL3_InitLoader())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Setup backend capabilities flags
|
||||||
|
ImGui_ImplOpenGL3_Data* bd = IM_NEW(ImGui_ImplOpenGL3_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
|
io.BackendRendererName = "imgui_impl_opengl3";
|
||||||
|
|
||||||
|
// Query for GL version (e.g. 320 for GL 3.2)
|
||||||
|
const char* gl_version_str = (const char*)glGetString(GL_VERSION);
|
||||||
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
|
// GLES 2
|
||||||
|
bd->GlVersion = 200;
|
||||||
|
bd->GlProfileIsES2 = true;
|
||||||
|
IM_UNUSED(gl_version_str);
|
||||||
|
#else
|
||||||
|
// Desktop or GLES 3
|
||||||
|
GLint major = 0;
|
||||||
|
GLint minor = 0;
|
||||||
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||||
|
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||||
|
if (major == 0 && minor == 0)
|
||||||
|
sscanf(gl_version_str, "%d.%d", &major, &minor); // Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>"
|
||||||
|
bd->GlVersion = (GLuint)(major * 100 + minor * 10);
|
||||||
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &bd->MaxTextureSize);
|
||||||
|
|
||||||
|
#if defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
|
bd->GlProfileIsES3 = true;
|
||||||
|
#else
|
||||||
|
if (strncmp(gl_version_str, "OpenGL ES 3", 11) == 0)
|
||||||
|
bd->GlProfileIsES3 = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GL_CONTEXT_PROFILE_MASK)
|
||||||
|
if (!bd->GlProfileIsES3 && bd->GlVersion >= 320)
|
||||||
|
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &bd->GlProfileMask);
|
||||||
|
bd->GlProfileIsCompat = (bd->GlProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bd->UseBufferSubData = false;
|
||||||
|
/*
|
||||||
|
// Query vendor to enable glBufferSubData kludge
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (const char* vendor = (const char*)glGetString(GL_VENDOR))
|
||||||
|
if (strncmp(vendor, "Intel", 5) == 0)
|
||||||
|
bd->UseBufferSubData = true;
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
||||||
|
printf("GlVersion = %d, \"%s\"\nGlProfileIsCompat = %d\nGlProfileMask = 0x%X\nGlProfileIsES2/IsEs3 = %d/%d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", bd->GlVersion, gl_version_str, bd->GlProfileIsCompat, bd->GlProfileMask, bd->GlProfileIsES2, bd->GlProfileIsES3, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG]
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
|
if (bd->GlVersion >= 320)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
#endif
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_TextureMaxWidth = platform_io.Renderer_TextureMaxHeight = (int)bd->MaxTextureSize;
|
||||||
|
|
||||||
|
// 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 nullptr if unsure.
|
||||||
|
if (glsl_version == nullptr)
|
||||||
|
{
|
||||||
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
|
glsl_version = "#version 100";
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
|
glsl_version = "#version 300 es";
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
glsl_version = "#version 150";
|
||||||
|
#else
|
||||||
|
glsl_version = "#version 130";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_COUNTOF(bd->GlslVersionString));
|
||||||
|
strcpy(bd->GlslVersionString, glsl_version);
|
||||||
|
strcat(bd->GlslVersionString, "\n");
|
||||||
|
|
||||||
|
// Make an arbitrary GL call (we don't actually need the result)
|
||||||
|
// IF YOU GET A CRASH HERE: it probably means the OpenGL function loader didn't do its job. Let us know!
|
||||||
|
GLint current_texture;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
||||||
|
|
||||||
|
// Detect extensions we support
|
||||||
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
||||||
|
bd->HasPolygonMode = (!bd->GlProfileIsES2 && !bd->GlProfileIsES3);
|
||||||
|
#endif
|
||||||
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
|
bd->HasBindSampler = (bd->GlVersion >= 330 || bd->GlProfileIsES3);
|
||||||
|
#endif
|
||||||
|
bd->HasClipOrigin = (bd->GlVersion >= 450);
|
||||||
|
#ifdef IMGUI_IMPL_OPENGL_HAS_EXTENSIONS
|
||||||
|
GLint num_extensions = 0;
|
||||||
|
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
|
||||||
|
for (GLint i = 0; i < num_extensions; i++)
|
||||||
|
{
|
||||||
|
const char* extension = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||||
|
if (extension != nullptr && strcmp(extension, "GL_ARB_clip_control") == 0)
|
||||||
|
bd->HasClipOrigin = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplOpenGL3_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
io.BackendRendererName = nullptr;
|
||||||
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
||||||
|
platform_io.ClearRendererHandlers();
|
||||||
|
IM_DELETE(bd);
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL3_ShutdownLoader();
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplOpenGL3_NewFrame()
|
void ImGui_ImplOpenGL3_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||||
@ -349,7 +456,7 @@ void ImGui_ImplOpenGL3_NewFrame()
|
|||||||
IM_ASSERT(0 && "ImGui_ImplOpenGL3_CreateDeviceObjects() failed!");
|
IM_ASSERT(0 && "ImGui_ImplOpenGL3_CreateDeviceObjects() failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, ImGui_ImplOpenGL3_RenderState* render_state, int fb_width, int fb_height, GLuint vertex_array_object)
|
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
|
||||||
{
|
{
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||||
|
|
||||||
@ -370,6 +477,17 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, ImGui_Impl
|
|||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
||||||
|
#if defined(GL_CLIP_ORIGIN)
|
||||||
|
bool clip_origin_lower_left = true;
|
||||||
|
if (bd->HasClipOrigin)
|
||||||
|
{
|
||||||
|
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
|
// 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.
|
// 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.
|
||||||
GL_CALL(glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height));
|
GL_CALL(glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height));
|
||||||
@ -377,7 +495,9 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, ImGui_Impl
|
|||||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||||
float T = draw_data->DisplayPos.y;
|
float T = draw_data->DisplayPos.y;
|
||||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||||
if (bd->ClipOriginCurrent == GL_UPPER_LEFT) { float tmp = T; T = B; B = tmp; } // Swap top and bottom
|
#if defined(GL_CLIP_ORIGIN)
|
||||||
|
if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
|
||||||
|
#endif
|
||||||
const float ortho_projection[4][4] =
|
const float ortho_projection[4][4] =
|
||||||
{
|
{
|
||||||
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||||
@ -389,16 +509,9 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, ImGui_Impl
|
|||||||
glUniform1i(bd->AttribLocationTex, 0);
|
glUniform1i(bd->AttribLocationTex, 0);
|
||||||
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||||
|
|
||||||
render_state->UseBindSampler = bd->HasBindSampler;
|
|
||||||
render_state->UseTexParameterFilter = false;
|
|
||||||
render_state->CurrentSampler = 0;
|
|
||||||
render_state->CurrentTexParameterFilter = 0;
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
if (bd->HasBindSampler && render_state->UseBindSampler)
|
if (bd->HasBindSampler)
|
||||||
{
|
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 and GL ES 3.0 may set that otherwise.
|
||||||
render_state->CurrentSampler = bd->TexSamplers[0];
|
|
||||||
glBindSampler(0, render_state->CurrentSampler); // We use combined texture/sampler state. Applications using GL 3.3 and GL ES 3.0 may set that otherwise.
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
(void)vertex_array_object;
|
(void)vertex_array_object;
|
||||||
@ -417,64 +530,14 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, ImGui_Impl
|
|||||||
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)offsetof(ImDrawVert, col)));
|
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)offsetof(ImDrawVert, col)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplOpenGL3_DrawCallback_SetSampler(unsigned int sampler_idx, unsigned int tex_parameter_filter)
|
|
||||||
{
|
|
||||||
ImGui_ImplOpenGL3_RenderState* render_state = ImGui_ImplOpenGL3_GetRenderState();
|
|
||||||
IM_UNUSED(sampler_idx);
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
|
||||||
if (bd->HasBindSampler && render_state->UseBindSampler)
|
|
||||||
{
|
|
||||||
render_state->CurrentSampler = bd->TexSamplers[sampler_idx];
|
|
||||||
render_state->UseTexParameterFilter = false;
|
|
||||||
glBindSampler(0, render_state->CurrentSampler);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
render_state->UseTexParameterFilter = true;
|
|
||||||
render_state->CurrentTexParameterFilter = tex_parameter_filter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
// - IMPORTANT: Using DrawCallback_SetSamplerLinear/DrawCallback_SetSamplerNearest will trash glTexParameteri() values for the texture if used on a GL context not supporting glBindSampler()!!
|
|
||||||
// We cannot decently backup/restore that state because glGetTexParameteriv() is slow on many setups.
|
|
||||||
// - Using DrawCallback_SetSamplerFromTex will basically instruct the backend to use existing glTexParameteri() values without modifying anything.
|
|
||||||
static void ImGui_ImplOpenGL3_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplOpenGL3_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplOpenGL3_DrawCallback_SetSampler(0, GL_LINEAR); }
|
|
||||||
static void ImGui_ImplOpenGL3_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplOpenGL3_DrawCallback_SetSampler(1, GL_NEAREST); }
|
|
||||||
static void ImGui_ImplOpenGL3_DrawCallback_SetSamplerFromTex(const ImDrawList*, const ImDrawCmd*)
|
|
||||||
{
|
|
||||||
ImGui_ImplOpenGL3_RenderState* render_state = ImGui_ImplOpenGL3_GetRenderState();
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
|
||||||
if (bd->HasBindSampler)
|
|
||||||
{
|
|
||||||
render_state->CurrentSampler = 0;
|
|
||||||
glBindSampler(0, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
render_state->UseBindSampler = false;
|
|
||||||
render_state->UseTexParameterFilter = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default is GL_LOWER_LEFT since 2026/10/01. Used to be auto.
|
|
||||||
void ImGui_ImplOpenGL3_SetClipOrigin(unsigned int clip_origin)
|
|
||||||
{
|
|
||||||
IM_ASSERT(clip_origin == 0 || clip_origin == GL_UPPER_LEFT || clip_origin == GL_LOWER_LEFT);
|
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
|
||||||
bd->ClipOriginRequest = clip_origin;
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenGL3 Render function.
|
// OpenGL3 Render function.
|
||||||
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly.
|
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly.
|
||||||
// This is in order to be able to run within an OpenGL engine that doesn't do so.
|
// This is in order to be able to run within an OpenGL engine that doesn't do so.
|
||||||
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// 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 + 0.5f);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0)
|
if (fb_width <= 0 || fb_height <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -528,17 +591,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
GLboolean last_enable_primitive_restart = (!bd->GlProfileIsES3 && bd->GlVersion >= 310) ? glIsEnabled(GL_PRIMITIVE_RESTART) : GL_FALSE;
|
GLboolean last_enable_primitive_restart = (!bd->GlProfileIsES3 && bd->GlVersion >= 310) ? glIsEnabled(GL_PRIMITIVE_RESTART) : GL_FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
|
||||||
bd->ClipOriginCurrent = bd->ClipOriginRequest;
|
|
||||||
if (bd->ClipOriginCurrent == 0)
|
|
||||||
{
|
|
||||||
bd->ClipOriginCurrent = GL_LOWER_LEFT;
|
|
||||||
#ifdef GL_CLIP_ORIGIN
|
|
||||||
if (bd->HasClipOrigin)
|
|
||||||
glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)&bd->ClipOriginCurrent);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup desired GL state
|
// 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)
|
// 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.
|
// The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound.
|
||||||
@ -546,13 +598,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
GL_CALL(glGenVertexArrays(1, &vertex_array_object));
|
GL_CALL(glGenVertexArrays(1, &vertex_array_object));
|
||||||
#endif
|
#endif
|
||||||
|
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||||
// Setup render state structure (for callbacks and custom texture bindings)
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
ImGui_ImplOpenGL3_RenderState render_state = {};
|
|
||||||
platform_io.Renderer_RenderState = &render_state;
|
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, &render_state, fb_width, fb_height, vertex_array_object);
|
|
||||||
|
|
||||||
// Will project scissor/clipping rectangles into framebuffer space
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
@ -598,8 +644,9 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (pcmd->UserCallback != nullptr)
|
if (pcmd->UserCallback != nullptr)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplOpenGL3_DrawCallback_ResetRenderState)
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, &render_state, fb_width, fb_height, vertex_array_object);
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
|
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
}
|
}
|
||||||
@ -616,15 +663,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
GL_CALL(glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()));
|
GL_CALL(glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()));
|
||||||
|
|
||||||
// Emulate sampler change (even though it is technically part of texture data)
|
|
||||||
// As a sort of hack/workaround, we only start writing using glTexParameter() if sampler is ever changed explicitly.
|
|
||||||
if (render_state.UseTexParameterFilter)
|
|
||||||
{
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, render_state.CurrentTexParameterFilter);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, render_state.CurrentTexParameterFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
if (bd->GlVersion >= 320)
|
if (bd->GlVersion >= 320)
|
||||||
GL_CALL(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));
|
GL_CALL(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));
|
||||||
@ -634,7 +672,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
platform_io.Renderer_RenderState = nullptr;
|
|
||||||
|
|
||||||
// Destroy the temporary VAO
|
// Destroy the temporary VAO
|
||||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
@ -693,15 +730,13 @@ static void ImGui_ImplOpenGL3_DestroyTexture(ImTextureData* tex)
|
|||||||
|
|
||||||
void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
||||||
{
|
{
|
||||||
// Backup GL_UNPACK state that we modify, restore on exit.
|
// FIXME: Consider backing up and restoring
|
||||||
GLint last_unpack_row_length = 0; (void)last_unpack_row_length;
|
if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates)
|
||||||
GLint last_unpack_alignment = 0; (void)last_unpack_alignment;
|
|
||||||
const bool last_unpack_state_save_and_restore = (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates);
|
|
||||||
if (last_unpack_state_save_and_restore)
|
|
||||||
{
|
{
|
||||||
#ifdef GL_UNPACK_ROW_LENGTH // Not on WebGL/ES
|
#ifdef GL_UNPACK_ROW_LENGTH // Not on WebGL/ES
|
||||||
GL_CALL(glGetIntegerv(GL_UNPACK_ROW_LENGTH, &last_unpack_row_length));
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
||||||
GL_CALL(glGetIntegerv(GL_UNPACK_ALIGNMENT, &last_unpack_alignment));
|
#endif
|
||||||
|
#ifdef GL_UNPACK_ALIGNMENT
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
|
GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -715,7 +750,8 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
|||||||
const void* pixels = tex->GetPixels();
|
const void* pixels = tex->GetPixels();
|
||||||
GLuint gl_texture_id = 0;
|
GLuint gl_texture_id = 0;
|
||||||
|
|
||||||
// Upload texture to graphics system (bilinear sampling is required).
|
// Upload texture to graphics system
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
GLint last_texture;
|
GLint last_texture;
|
||||||
GL_CALL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
GL_CALL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
||||||
GL_CALL(glGenTextures(1, &gl_texture_id));
|
GL_CALL(glGenTextures(1, &gl_texture_id));
|
||||||
@ -724,9 +760,6 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
|||||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
||||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
|
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
|
||||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
||||||
#if GL_UNPACK_ROW_LENGTH // Not on WebGL/ES
|
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
|
||||||
#endif
|
|
||||||
GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->Width, tex->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->Width, tex->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
||||||
|
|
||||||
// Store identifiers
|
// Store identifiers
|
||||||
@ -749,6 +782,7 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
|||||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->Width));
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->Width));
|
||||||
for (ImTextureRect& r : tex->Updates)
|
for (ImTextureRect& r : tex->Updates)
|
||||||
GL_CALL(glTexSubImage2D(GL_TEXTURE_2D, 0, r.x, r.y, r.w, r.h, GL_RGBA, GL_UNSIGNED_BYTE, tex->GetPixelsAt(r.x, r.y)));
|
GL_CALL(glTexSubImage2D(GL_TEXTURE_2D, 0, r.x, r.y, r.w, r.h, GL_RGBA, GL_UNSIGNED_BYTE, tex->GetPixelsAt(r.x, r.y)));
|
||||||
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
||||||
#else
|
#else
|
||||||
// GL ES doesn't have GL_UNPACK_ROW_LENGTH, so we need to (A) copy to a contiguous buffer or (B) upload line by line.
|
// GL ES doesn't have GL_UNPACK_ROW_LENGTH, so we need to (A) copy to a contiguous buffer or (B) upload line by line.
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||||
@ -768,15 +802,6 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
|||||||
}
|
}
|
||||||
else if (tex->Status == ImTextureStatus_WantDestroy && tex->UnusedFrames > 0)
|
else if (tex->Status == ImTextureStatus_WantDestroy && tex->UnusedFrames > 0)
|
||||||
ImGui_ImplOpenGL3_DestroyTexture(tex);
|
ImGui_ImplOpenGL3_DestroyTexture(tex);
|
||||||
|
|
||||||
// Restore GL_UNPACK state
|
|
||||||
if (last_unpack_state_save_and_restore)
|
|
||||||
{
|
|
||||||
#ifdef GL_UNPACK_ROW_LENGTH
|
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, last_unpack_row_length));
|
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, last_unpack_alignment));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
// 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.
|
||||||
@ -1003,20 +1028,6 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
|||||||
glGenBuffers(1, &bd->VboHandle);
|
glGenBuffers(1, &bd->VboHandle);
|
||||||
glGenBuffers(1, &bd->ElementsHandle);
|
glGenBuffers(1, &bd->ElementsHandle);
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
|
||||||
if (bd->HasBindSampler)
|
|
||||||
{
|
|
||||||
glGenSamplers(2, &bd->TexSamplers[0]);
|
|
||||||
for (int sampler_n = 0; sampler_n < 2; sampler_n++)
|
|
||||||
{
|
|
||||||
GL_CALL(glSamplerParameteri(bd->TexSamplers[sampler_n], GL_TEXTURE_MIN_FILTER, (sampler_n == 0) ? GL_LINEAR : GL_NEAREST));
|
|
||||||
GL_CALL(glSamplerParameteri(bd->TexSamplers[sampler_n], GL_TEXTURE_MAG_FILTER, (sampler_n == 0) ? GL_LINEAR : GL_NEAREST));
|
|
||||||
GL_CALL(glSamplerParameteri(bd->TexSamplers[sampler_n], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
|
|
||||||
GL_CALL(glSamplerParameteri(bd->TexSamplers[sampler_n], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Restore modified GL state
|
// Restore modified GL state
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||||
@ -1034,9 +1045,6 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
|||||||
{
|
{
|
||||||
ImGui_ImplOpenGL3_InitLoader();
|
ImGui_ImplOpenGL3_InitLoader();
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
|
||||||
if (bd->TexSamplers[0]) { glDeleteSamplers(2, &bd->TexSamplers[0]); bd->TexSamplers[0] = bd->TexSamplers[1] = 0; }
|
|
||||||
#endif
|
|
||||||
if (bd->VboHandle) { glDeleteBuffers(1, &bd->VboHandle); bd->VboHandle = 0; }
|
if (bd->VboHandle) { glDeleteBuffers(1, &bd->VboHandle); bd->VboHandle = 0; }
|
||||||
if (bd->ElementsHandle) { glDeleteBuffers(1, &bd->ElementsHandle); bd->ElementsHandle = 0; }
|
if (bd->ElementsHandle) { glDeleteBuffers(1, &bd->ElementsHandle); bd->ElementsHandle = 0; }
|
||||||
if (bd->ShaderHandle) { glDeleteProgram(bd->ShaderHandle); bd->ShaderHandle = 0; }
|
if (bd->ShaderHandle) { glDeleteProgram(bd->ShaderHandle); bd->ShaderHandle = 0; }
|
||||||
@ -1047,147 +1055,6 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
|||||||
ImGui_ImplOpenGL3_DestroyTexture(tex);
|
ImGui_ImplOpenGL3_DestroyTexture(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
|
||||||
|
|
||||||
// Initialize loader
|
|
||||||
if (!ImGui_ImplOpenGL3_InitLoader())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
|
||||||
ImGui_ImplOpenGL3_Data* bd = IM_NEW(ImGui_ImplOpenGL3_Data)();
|
|
||||||
io.BackendRendererUserData = (void*)bd;
|
|
||||||
io.BackendRendererName = "imgui_impl_opengl3";
|
|
||||||
|
|
||||||
// Query for GL version (e.g. 320 for GL 3.2)
|
|
||||||
const char* gl_version_str = (const char*)glGetString(GL_VERSION);
|
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
|
||||||
// GLES 2
|
|
||||||
bd->GlVersion = 200;
|
|
||||||
bd->GlProfileIsES2 = true;
|
|
||||||
IM_UNUSED(gl_version_str);
|
|
||||||
#else
|
|
||||||
// Desktop or GLES 3
|
|
||||||
GLint major = 0;
|
|
||||||
GLint minor = 0;
|
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
|
||||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
|
||||||
if (major == 0 && minor == 0)
|
|
||||||
sscanf(gl_version_str, "%d.%d", &major, &minor); // Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>"
|
|
||||||
bd->GlVersion = (GLuint)(major * 100 + minor * 10);
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &bd->MaxTextureSize);
|
|
||||||
|
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES3)
|
|
||||||
bd->GlProfileIsES3 = true;
|
|
||||||
#else
|
|
||||||
if (strncmp(gl_version_str, "OpenGL ES 3", 11) == 0)
|
|
||||||
bd->GlProfileIsES3 = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GL_CONTEXT_PROFILE_MASK)
|
|
||||||
if (!bd->GlProfileIsES3 && bd->GlVersion >= 320)
|
|
||||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &bd->GlProfileMask);
|
|
||||||
bd->GlProfileIsCompat = (bd->GlProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bd->UseBufferSubData = false;
|
|
||||||
/*
|
|
||||||
// Query vendor to enable glBufferSubData kludge
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (const char* vendor = (const char*)glGetString(GL_VENDOR))
|
|
||||||
if (strncmp(vendor, "Intel", 5) == 0)
|
|
||||||
bd->UseBufferSubData = true;
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
|
||||||
printf("GlVersion = %d, \"%s\"\nGlProfileIsCompat = %d\nGlProfileMask = 0x%X\nGlProfileIsES2/IsEs3 = %d/%d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", bd->GlVersion, gl_version_str, bd->GlProfileIsCompat, bd->GlProfileMask, bd->GlProfileIsES2, bd->GlProfileIsES3, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
|
||||||
if (bd->GlVersion >= 320)
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
|
||||||
#endif
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.Renderer_TextureMaxWidth = platform_io.Renderer_TextureMaxHeight = (int)bd->MaxTextureSize;
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplOpenGL3_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplOpenGL3_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplOpenGL3_DrawCallback_SetSamplerNearest;
|
|
||||||
platform_io.DrawCallback_SetSamplerFromTex = ImGui_ImplOpenGL3_DrawCallback_SetSamplerFromTex;
|
|
||||||
|
|
||||||
// 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 nullptr if unsure.
|
|
||||||
if (glsl_version == nullptr)
|
|
||||||
{
|
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
|
||||||
glsl_version = "#version 100";
|
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
|
||||||
glsl_version = "#version 300 es";
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
glsl_version = "#version 150";
|
|
||||||
#else
|
|
||||||
if (bd->GlVersion >= 410)
|
|
||||||
glsl_version = "#version 410";
|
|
||||||
else
|
|
||||||
glsl_version = "#version 130";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_COUNTOF(bd->GlslVersionString));
|
|
||||||
strcpy(bd->GlslVersionString, glsl_version);
|
|
||||||
strcat(bd->GlslVersionString, "\n");
|
|
||||||
|
|
||||||
// Make an arbitrary GL call (we don't actually need the result)
|
|
||||||
// IF YOU GET A CRASH HERE: it probably means the OpenGL function loader didn't do its job. Let us know!
|
|
||||||
GLint current_texture;
|
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
|
||||||
|
|
||||||
// Detect extensions we support
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
|
||||||
bd->HasPolygonMode = (!bd->GlProfileIsES2 && !bd->GlProfileIsES3);
|
|
||||||
#endif
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
|
||||||
bd->HasBindSampler = (bd->GlVersion >= 330 || bd->GlProfileIsES3);
|
|
||||||
#endif
|
|
||||||
bd->HasClipOrigin = (bd->GlVersion >= 450);
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_HAS_EXTENSIONS
|
|
||||||
GLint num_extensions = 0;
|
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
|
|
||||||
for (GLint i = 0; i < num_extensions; i++)
|
|
||||||
{
|
|
||||||
const char* extension = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
|
||||||
if (extension != nullptr && strcmp(extension, "GL_ARB_clip_control") == 0)
|
|
||||||
bd->HasClipOrigin = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
bd->ClipOriginCurrent = bd->ClipOriginRequest = GL_LOWER_LEFT;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplOpenGL3_Shutdown()
|
|
||||||
{
|
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
|
||||||
io.BackendRendererUserData = nullptr;
|
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
|
||||||
platform_io.ClearRendererHandlers();
|
|
||||||
IM_DELETE(bd);
|
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_ShutdownLoader();
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!]
|
// [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!]
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplOpenGL3_GetRenderState().
|
|
||||||
|
|
||||||
// About WebGL/ES:
|
// About WebGL/ES:
|
||||||
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||||
@ -44,9 +43,6 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
|||||||
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
|
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex);
|
IMGUI_IMPL_API void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex);
|
||||||
|
|
||||||
// (Advanced) Specify clip origin, same value as glClipControl() or 0 for auto-detection.
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_SetClipOrigin(unsigned int gl_clip_origin);
|
|
||||||
|
|
||||||
// Configuration flags to add in your imconfig file:
|
// Configuration flags to add in your imconfig file:
|
||||||
//#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten)
|
//#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten)
|
||||||
//#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android)
|
//#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android)
|
||||||
@ -69,16 +65,4 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_SetClipOrigin(unsigned int gl_clip_ori
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// [BETA] Selected render state data shared with callbacks.
|
|
||||||
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplOpenGL3_RenderDrawData() call.
|
|
||||||
// (Please open an issue if you feel you need access to more data)
|
|
||||||
struct ImGui_ImplOpenGL3_RenderState
|
|
||||||
{
|
|
||||||
bool UseBindSampler;
|
|
||||||
bool UseTexParameterFilter;
|
|
||||||
unsigned int CurrentSampler; // (GLuint) Used if UseBindSampler == true (and are available), otherwise always 0
|
|
||||||
unsigned int CurrentTexParameterFilter; // (GLuint) Used if UseTexParameterFilter == true
|
|
||||||
};
|
|
||||||
IMGUI_IMPL_API ImGui_ImplOpenGL3_RenderState* ImGui_ImplOpenGL3_GetRenderState();
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@ -114,7 +114,7 @@ extern "C" {
|
|||||||
#define GLAPI extern
|
#define GLAPI extern
|
||||||
#endif
|
#endif
|
||||||
/* glcorearb.h is for use with OpenGL core profile implementations.
|
/* glcorearb.h is for use with OpenGL core profile implementations.
|
||||||
** It should be placed in the same directory as gl.h and
|
** It should should be placed in the same directory as gl.h and
|
||||||
** included as <GL/glcorearb.h>.
|
** included as <GL/glcorearb.h>.
|
||||||
**
|
**
|
||||||
** glcorearb.h includes only APIs in the latest OpenGL core profile
|
** glcorearb.h includes only APIs in the latest OpenGL core profile
|
||||||
@ -303,7 +303,6 @@ typedef khronos_uint16_t GLushort;
|
|||||||
#define GL_LINK_STATUS 0x8B82
|
#define GL_LINK_STATUS 0x8B82
|
||||||
#define GL_INFO_LOG_LENGTH 0x8B84
|
#define GL_INFO_LOG_LENGTH 0x8B84
|
||||||
#define GL_CURRENT_PROGRAM 0x8B8D
|
#define GL_CURRENT_PROGRAM 0x8B8D
|
||||||
#define GL_LOWER_LEFT 0x8CA1
|
|
||||||
#define GL_UPPER_LEFT 0x8CA2
|
#define GL_UPPER_LEFT 0x8CA2
|
||||||
typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
|
typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
|
||||||
typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
|
typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
|
||||||
|
|||||||
@ -1,759 +0,0 @@
|
|||||||
// dear imgui: Platform Backend for QNX Screen
|
|
||||||
// This needs to be used along with a Renderer Backend (e.g. OpenGL3, Vulkan).
|
|
||||||
|
|
||||||
// Implemented features:
|
|
||||||
// [X] Platform: Keyboard support. Uses io.AddKeyEvent() and native QNX key symbols.
|
|
||||||
// [X] Platform: Mouse support. Handles position, three buttons and horizontal/vertical wheels.
|
|
||||||
// [X] Platform: Touch support. Maps the first active touch contact to the primary mouse button.
|
|
||||||
// [X] Platform: Focus and window-size updates.
|
|
||||||
// Missing features or Issues:
|
|
||||||
// [ ] Platform: Clipboard support.
|
|
||||||
// [ ] Platform: Gamepad support.
|
|
||||||
// [ ] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors).
|
|
||||||
// [ ] Platform: Multi-viewport support.
|
|
||||||
|
|
||||||
// CHANGELOG
|
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
|
||||||
// 2026-08-04: Initial QNX Screen backend. (#9492)
|
|
||||||
|
|
||||||
#include "imgui.h"
|
|
||||||
#ifndef IMGUI_DISABLE
|
|
||||||
#include "imgui_impl_qnx.h"
|
|
||||||
|
|
||||||
#include <float.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/keycodes.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
static unsigned int ImGui_ImplQNX_KeySymToUnicode(unsigned int keysym);
|
|
||||||
|
|
||||||
struct ImGui_ImplQNX_Data
|
|
||||||
{
|
|
||||||
screen_context_t Context;
|
|
||||||
screen_window_t Window;
|
|
||||||
uint64_t TimeNanoseconds;
|
|
||||||
int MouseButtons;
|
|
||||||
int ActiveTouchId;
|
|
||||||
bool LeftSuper;
|
|
||||||
bool RightSuper;
|
|
||||||
|
|
||||||
ImGui_ImplQNX_Data()
|
|
||||||
{
|
|
||||||
memset(this, 0, sizeof(*this));
|
|
||||||
ActiveTouchId = -1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static ImGui_ImplQNX_Data* ImGui_ImplQNX_GetBackendData()
|
|
||||||
{
|
|
||||||
return ImGui::GetCurrentContext() != nullptr ? (ImGui_ImplQNX_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint64_t ImGui_ImplQNX_GetTimeNanoseconds()
|
|
||||||
{
|
|
||||||
struct timespec timestamp = {};
|
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, ×tamp) != 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return (uint64_t)timestamp.tv_sec * UINT64_C(1000000000) + (uint64_t)timestamp.tv_nsec;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ImGuiKey ImGui_ImplQNX_KeyCodeToImGuiKey(int key_code)
|
|
||||||
{
|
|
||||||
switch (key_code)
|
|
||||||
{
|
|
||||||
case KEYCODE_TAB: return ImGuiKey_Tab;
|
|
||||||
case KEYCODE_LEFT: return ImGuiKey_LeftArrow;
|
|
||||||
case KEYCODE_RIGHT: return ImGuiKey_RightArrow;
|
|
||||||
case KEYCODE_UP: return ImGuiKey_UpArrow;
|
|
||||||
case KEYCODE_DOWN: return ImGuiKey_DownArrow;
|
|
||||||
case KEYCODE_PG_UP: return ImGuiKey_PageUp;
|
|
||||||
case KEYCODE_PG_DOWN: return ImGuiKey_PageDown;
|
|
||||||
case KEYCODE_HOME: return ImGuiKey_Home;
|
|
||||||
case KEYCODE_END: return ImGuiKey_End;
|
|
||||||
case KEYCODE_INSERT: return ImGuiKey_Insert;
|
|
||||||
case KEYCODE_DELETE: return ImGuiKey_Delete;
|
|
||||||
case KEYCODE_BACKSPACE: return ImGuiKey_Backspace;
|
|
||||||
case KEYCODE_SPACE: return ImGuiKey_Space;
|
|
||||||
case KEYCODE_RETURN: return ImGuiKey_Enter;
|
|
||||||
case KEYCODE_ESCAPE: return ImGuiKey_Escape;
|
|
||||||
case KEYCODE_APOSTROPHE: return ImGuiKey_Apostrophe;
|
|
||||||
case KEYCODE_COMMA: return ImGuiKey_Comma;
|
|
||||||
case KEYCODE_MINUS: return ImGuiKey_Minus;
|
|
||||||
case KEYCODE_PERIOD: return ImGuiKey_Period;
|
|
||||||
case KEYCODE_SLASH: return ImGuiKey_Slash;
|
|
||||||
case KEYCODE_SEMICOLON: return ImGuiKey_Semicolon;
|
|
||||||
case KEYCODE_EQUAL: return ImGuiKey_Equal;
|
|
||||||
case KEYCODE_LEFT_BRACKET: return ImGuiKey_LeftBracket;
|
|
||||||
case KEYCODE_BACK_SLASH: return ImGuiKey_Backslash;
|
|
||||||
case KEYCODE_RIGHT_BRACKET: return ImGuiKey_RightBracket;
|
|
||||||
case KEYCODE_GRAVE: return ImGuiKey_GraveAccent;
|
|
||||||
case KEYCODE_CAPS_LOCK: return ImGuiKey_CapsLock;
|
|
||||||
case KEYCODE_SCROLL_LOCK: return ImGuiKey_ScrollLock;
|
|
||||||
case KEYCODE_NUM_LOCK: return ImGuiKey_NumLock;
|
|
||||||
case KEYCODE_PRINT: return ImGuiKey_PrintScreen;
|
|
||||||
case KEYCODE_PAUSE: return ImGuiKey_Pause;
|
|
||||||
case KEYCODE_KP_DIVIDE: return ImGuiKey_KeypadDivide;
|
|
||||||
case KEYCODE_KP_MULTIPLY: return ImGuiKey_KeypadMultiply;
|
|
||||||
case KEYCODE_KP_MINUS: return ImGuiKey_KeypadSubtract;
|
|
||||||
case KEYCODE_KP_PLUS: return ImGuiKey_KeypadAdd;
|
|
||||||
case KEYCODE_KP_ENTER: return ImGuiKey_KeypadEnter;
|
|
||||||
// QNX reports keypad digits by their navigation key-cap names.
|
|
||||||
case KEYCODE_KP_INSERT: return ImGuiKey_Keypad0;
|
|
||||||
case KEYCODE_KP_END: return ImGuiKey_Keypad1;
|
|
||||||
case KEYCODE_KP_DOWN: return ImGuiKey_Keypad2;
|
|
||||||
case KEYCODE_KP_PG_DOWN: return ImGuiKey_Keypad3;
|
|
||||||
case KEYCODE_KP_LEFT: return ImGuiKey_Keypad4;
|
|
||||||
case KEYCODE_KP_FIVE: return ImGuiKey_Keypad5;
|
|
||||||
case KEYCODE_KP_RIGHT: return ImGuiKey_Keypad6;
|
|
||||||
case KEYCODE_KP_HOME: return ImGuiKey_Keypad7;
|
|
||||||
case KEYCODE_KP_UP: return ImGuiKey_Keypad8;
|
|
||||||
case KEYCODE_KP_PG_UP: return ImGuiKey_Keypad9;
|
|
||||||
case KEYCODE_KP_DELETE: return ImGuiKey_KeypadDecimal;
|
|
||||||
case KEYCODE_LEFT_CTRL: return ImGuiKey_LeftCtrl;
|
|
||||||
case KEYCODE_LEFT_SHIFT: return ImGuiKey_LeftShift;
|
|
||||||
case KEYCODE_LEFT_ALT: return ImGuiKey_LeftAlt;
|
|
||||||
case KEYCODE_RIGHT_CTRL: return ImGuiKey_RightCtrl;
|
|
||||||
case KEYCODE_RIGHT_SHIFT: return ImGuiKey_RightShift;
|
|
||||||
case KEYCODE_RIGHT_ALT: return ImGuiKey_RightAlt;
|
|
||||||
case KEYCODE_LEFT_HYPER: return ImGuiKey_LeftSuper;
|
|
||||||
case KEYCODE_RIGHT_HYPER: return ImGuiKey_RightSuper;
|
|
||||||
case KEYCODE_MENU: return ImGuiKey_Menu;
|
|
||||||
case KEYCODE_ZERO: return ImGuiKey_0;
|
|
||||||
case KEYCODE_ONE: return ImGuiKey_1;
|
|
||||||
case KEYCODE_TWO: return ImGuiKey_2;
|
|
||||||
case KEYCODE_THREE: return ImGuiKey_3;
|
|
||||||
case KEYCODE_FOUR: return ImGuiKey_4;
|
|
||||||
case KEYCODE_FIVE: return ImGuiKey_5;
|
|
||||||
case KEYCODE_SIX: return ImGuiKey_6;
|
|
||||||
case KEYCODE_SEVEN: return ImGuiKey_7;
|
|
||||||
case KEYCODE_EIGHT: return ImGuiKey_8;
|
|
||||||
case KEYCODE_NINE: return ImGuiKey_9;
|
|
||||||
case KEYCODE_A: return ImGuiKey_A;
|
|
||||||
case KEYCODE_B: return ImGuiKey_B;
|
|
||||||
case KEYCODE_C: return ImGuiKey_C;
|
|
||||||
case KEYCODE_D: return ImGuiKey_D;
|
|
||||||
case KEYCODE_E: return ImGuiKey_E;
|
|
||||||
case KEYCODE_F: return ImGuiKey_F;
|
|
||||||
case KEYCODE_G: return ImGuiKey_G;
|
|
||||||
case KEYCODE_H: return ImGuiKey_H;
|
|
||||||
case KEYCODE_I: return ImGuiKey_I;
|
|
||||||
case KEYCODE_J: return ImGuiKey_J;
|
|
||||||
case KEYCODE_K: return ImGuiKey_K;
|
|
||||||
case KEYCODE_L: return ImGuiKey_L;
|
|
||||||
case KEYCODE_M: return ImGuiKey_M;
|
|
||||||
case KEYCODE_N: return ImGuiKey_N;
|
|
||||||
case KEYCODE_O: return ImGuiKey_O;
|
|
||||||
case KEYCODE_P: return ImGuiKey_P;
|
|
||||||
case KEYCODE_Q: return ImGuiKey_Q;
|
|
||||||
case KEYCODE_R: return ImGuiKey_R;
|
|
||||||
case KEYCODE_S: return ImGuiKey_S;
|
|
||||||
case KEYCODE_T: return ImGuiKey_T;
|
|
||||||
case KEYCODE_U: return ImGuiKey_U;
|
|
||||||
case KEYCODE_V: return ImGuiKey_V;
|
|
||||||
case KEYCODE_W: return ImGuiKey_W;
|
|
||||||
case KEYCODE_X: return ImGuiKey_X;
|
|
||||||
case KEYCODE_Y: return ImGuiKey_Y;
|
|
||||||
case KEYCODE_Z: return ImGuiKey_Z;
|
|
||||||
case KEYCODE_F1: return ImGuiKey_F1;
|
|
||||||
case KEYCODE_F2: return ImGuiKey_F2;
|
|
||||||
case KEYCODE_F3: return ImGuiKey_F3;
|
|
||||||
case KEYCODE_F4: return ImGuiKey_F4;
|
|
||||||
case KEYCODE_F5: return ImGuiKey_F5;
|
|
||||||
case KEYCODE_F6: return ImGuiKey_F6;
|
|
||||||
case KEYCODE_F7: return ImGuiKey_F7;
|
|
||||||
case KEYCODE_F8: return ImGuiKey_F8;
|
|
||||||
case KEYCODE_F9: return ImGuiKey_F9;
|
|
||||||
case KEYCODE_F10: return ImGuiKey_F10;
|
|
||||||
case KEYCODE_F11: return ImGuiKey_F11;
|
|
||||||
case KEYCODE_F12: return ImGuiKey_F12;
|
|
||||||
default: return ImGuiKey_None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplQNX_UpdateKeyModifiers(ImGuiIO& io, ImGui_ImplQNX_Data* bd, int modifiers, ImGuiKey key, bool down)
|
|
||||||
{
|
|
||||||
// SCREEN_PROPERTY_MODIFIERS is the authoritative state for Shift/Ctrl/Alt.
|
|
||||||
// Tracking those keys locally loses sticky modifiers and can become stale if
|
|
||||||
// a key transition is consumed elsewhere. qterm uses this same Screen state.
|
|
||||||
if (key == ImGuiKey_LeftSuper)
|
|
||||||
{
|
|
||||||
bd->LeftSuper = down;
|
|
||||||
}
|
|
||||||
else if (key == ImGuiKey_RightSuper)
|
|
||||||
{
|
|
||||||
bd->RightSuper = down;
|
|
||||||
}
|
|
||||||
|
|
||||||
io.AddKeyEvent(ImGuiMod_Ctrl, (modifiers & KEYMOD_CTRL) != 0);
|
|
||||||
io.AddKeyEvent(ImGuiMod_Shift, (modifiers & KEYMOD_SHIFT) != 0);
|
|
||||||
io.AddKeyEvent(ImGuiMod_Alt, (modifiers & KEYMOD_ALT) != 0);
|
|
||||||
io.AddKeyEvent(ImGuiMod_Super, bd->LeftSuper || bd->RightSuper);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplQNX_ClearModifierState(ImGuiIO& io, ImGui_ImplQNX_Data* bd)
|
|
||||||
{
|
|
||||||
bd->LeftSuper = false;
|
|
||||||
bd->RightSuper = false;
|
|
||||||
io.AddKeyEvent(ImGuiMod_Ctrl, false);
|
|
||||||
io.AddKeyEvent(ImGuiMod_Shift, false);
|
|
||||||
io.AddKeyEvent(ImGuiMod_Alt, false);
|
|
||||||
io.AddKeyEvent(ImGuiMod_Super, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool ImGui_ImplQNX_IsTextCodePoint(unsigned int code_point)
|
|
||||||
{
|
|
||||||
// At this point the QNX keysym has already been converted to Unicode.
|
|
||||||
// Do not reject Unicode private-use characters: a user keymap may emit one.
|
|
||||||
const bool surrogate = code_point >= 0xd800u && code_point <= 0xdfffu;
|
|
||||||
const bool control = code_point < 0x20u || (code_point >= 0x7fu && code_point <= 0x9fu);
|
|
||||||
return code_point <= IM_UNICODE_CODEPOINT_MAX && !surrogate && !control;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool ImGui_ImplQNX_ProcessKeyboardEvent(ImGui_ImplQNX_Data* bd, screen_event_t event)
|
|
||||||
{
|
|
||||||
int flags = 0;
|
|
||||||
int modifiers = 0;
|
|
||||||
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_FLAGS, &flags) != 0 ||
|
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_MODIFIERS, &modifiers) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// KEY_CAP is the unmodified key identity used for ImGuiKey events. SYM is
|
|
||||||
// the layout/modifier-translated QNX keysym used for text input.
|
|
||||||
int key_cap = 0;
|
|
||||||
int key_sym = 0;
|
|
||||||
int scan_code = 0;
|
|
||||||
const bool cap_valid = (flags & SCREEN_FLAG_CAP_VALID) != 0;
|
|
||||||
const bool sym_valid = (flags & SCREEN_FLAG_SYM_VALID) != 0;
|
|
||||||
const bool scan_valid = (flags & SCREEN_FLAG_SCAN_VALID) != 0;
|
|
||||||
const bool down = (flags & (SCREEN_FLAG_KEY_DOWN | SCREEN_FLAG_KEY_REPEAT)) != 0;
|
|
||||||
|
|
||||||
if (cap_valid && screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &key_cap) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (sym_valid && screen_get_event_property_iv(event, SCREEN_PROPERTY_SYM, &key_sym) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (scan_valid && screen_get_event_property_iv(event, SCREEN_PROPERTY_SCAN, &scan_code) != 0)
|
|
||||||
{
|
|
||||||
scan_code = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ImGuiKey key = cap_valid ? ImGui_ImplQNX_KeyCodeToImGuiKey(key_cap) : ImGuiKey_None;
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
|
|
||||||
// Modifier events must precede the ordinary key event in Dear ImGui's queue.
|
|
||||||
// Unlike qterm, we still submit the individual modifier key because ImGui
|
|
||||||
// exposes Left/Right Ctrl, Shift, Alt and Super as named keys.
|
|
||||||
ImGui_ImplQNX_UpdateKeyModifiers(io, bd, modifiers, key, down);
|
|
||||||
|
|
||||||
if (key != ImGuiKey_None)
|
|
||||||
{
|
|
||||||
io.AddKeyEvent(key, down);
|
|
||||||
io.SetKeyEventNativeData(key, key_cap, scan_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool text_added = false;
|
|
||||||
if (down && sym_valid && key_sym >= 0)
|
|
||||||
{
|
|
||||||
const unsigned int keysym = (unsigned int)key_sym;
|
|
||||||
// QNX special/function symbols begin at KEYCODE_PC_KEYS. Printable
|
|
||||||
// symbols below that boundary use X11 keysym encoding. Also accept the
|
|
||||||
// standard directly encoded UCS keysym form (0x01000000 | codepoint).
|
|
||||||
if (keysym < (unsigned int)KEYCODE_PC_KEYS || (keysym & 0xff000000u) == 0x01000000u)
|
|
||||||
{
|
|
||||||
const unsigned int code_point = ImGui_ImplQNX_KeySymToUnicode(keysym);
|
|
||||||
if (ImGui_ImplQNX_IsTextCodePoint(code_point))
|
|
||||||
{
|
|
||||||
io.AddInputCharacter(code_point);
|
|
||||||
text_added = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return key != ImGuiKey_None || text_added || cap_valid || sym_valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool ImGui_ImplQNX_ProcessPointerEvent(ImGui_ImplQNX_Data* bd, screen_event_t event)
|
|
||||||
{
|
|
||||||
int position[2] = {};
|
|
||||||
int buttons = 0;
|
|
||||||
int wheel_vertical = 0;
|
|
||||||
int wheel_horizontal = 0;
|
|
||||||
|
|
||||||
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, position) != 0 &&
|
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, position) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttons) != 0)
|
|
||||||
{
|
|
||||||
buttons = bd->MouseButtons;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
io.AddMouseSourceEvent(ImGuiMouseSource_Mouse);
|
|
||||||
io.AddMousePosEvent((float)position[0], (float)position[1]);
|
|
||||||
|
|
||||||
const int changed_buttons = buttons ^ bd->MouseButtons;
|
|
||||||
if ((changed_buttons & SCREEN_LEFT_MOUSE_BUTTON) != 0)
|
|
||||||
{
|
|
||||||
io.AddMouseButtonEvent(0, (buttons & SCREEN_LEFT_MOUSE_BUTTON) != 0);
|
|
||||||
}
|
|
||||||
if ((changed_buttons & SCREEN_RIGHT_MOUSE_BUTTON) != 0)
|
|
||||||
{
|
|
||||||
io.AddMouseButtonEvent(1, (buttons & SCREEN_RIGHT_MOUSE_BUTTON) != 0);
|
|
||||||
}
|
|
||||||
if ((changed_buttons & SCREEN_MIDDLE_MOUSE_BUTTON) != 0)
|
|
||||||
{
|
|
||||||
io.AddMouseButtonEvent(2, (buttons & SCREEN_MIDDLE_MOUSE_BUTTON) != 0);
|
|
||||||
}
|
|
||||||
bd->MouseButtons = buttons;
|
|
||||||
|
|
||||||
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheel_vertical) != 0)
|
|
||||||
{
|
|
||||||
wheel_vertical = 0;
|
|
||||||
}
|
|
||||||
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_HORIZONTAL_WHEEL, &wheel_horizontal) != 0)
|
|
||||||
{
|
|
||||||
wheel_horizontal = 0;
|
|
||||||
}
|
|
||||||
if (wheel_vertical != 0 || wheel_horizontal != 0)
|
|
||||||
{
|
|
||||||
// Screen: up/left are negative. Dear ImGui: up/left are positive.
|
|
||||||
io.AddMouseWheelEvent((float)-wheel_horizontal, (float)-wheel_vertical);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool ImGui_ImplQNX_ProcessTouchEvent(ImGui_ImplQNX_Data* bd, screen_event_t event, int event_type)
|
|
||||||
{
|
|
||||||
int touch_id = -1;
|
|
||||||
int position[2] = {};
|
|
||||||
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, &touch_id) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool is_release = event_type == SCREEN_EVENT_MTOUCH_RELEASE;
|
|
||||||
if (bd->ActiveTouchId != -1 && touch_id != bd->ActiveTouchId)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
io.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);
|
|
||||||
|
|
||||||
if (!is_release)
|
|
||||||
{
|
|
||||||
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, position) != 0 &&
|
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, position) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
io.AddMousePosEvent((float)position[0], (float)position[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event_type == SCREEN_EVENT_MTOUCH_TOUCH)
|
|
||||||
{
|
|
||||||
bd->ActiveTouchId = touch_id;
|
|
||||||
io.AddMouseButtonEvent(0, true);
|
|
||||||
}
|
|
||||||
else if (is_release)
|
|
||||||
{
|
|
||||||
io.AddMouseButtonEvent(0, false);
|
|
||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
|
||||||
bd->ActiveTouchId = -1;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGui_ImplQNX_ProcessEvent(screen_event_t event)
|
|
||||||
{
|
|
||||||
ImGui_ImplQNX_Data* bd = ImGui_ImplQNX_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplQNX_Init()?");
|
|
||||||
if (bd == nullptr || event == nullptr)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int event_type = SCREEN_EVENT_NONE;
|
|
||||||
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &event_type) != 0 || event_type == SCREEN_EVENT_NONE)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
switch (event_type)
|
|
||||||
{
|
|
||||||
case SCREEN_EVENT_KEYBOARD:
|
|
||||||
return ImGui_ImplQNX_ProcessKeyboardEvent(bd, event);
|
|
||||||
case SCREEN_EVENT_POINTER:
|
|
||||||
return ImGui_ImplQNX_ProcessPointerEvent(bd, event);
|
|
||||||
case SCREEN_EVENT_MTOUCH_TOUCH:
|
|
||||||
case SCREEN_EVENT_MTOUCH_MOVE:
|
|
||||||
case SCREEN_EVENT_MTOUCH_RELEASE:
|
|
||||||
return ImGui_ImplQNX_ProcessTouchEvent(bd, event, event_type);
|
|
||||||
case SCREEN_EVENT_PROPERTY:
|
|
||||||
{
|
|
||||||
int property = 0;
|
|
||||||
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_NAME, &property) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (property == SCREEN_PROPERTY_FOCUS)
|
|
||||||
{
|
|
||||||
int focused = 0;
|
|
||||||
if (screen_get_window_property_iv(bd->Window, SCREEN_PROPERTY_FOCUS, &focused) == 0)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
io.AddFocusEvent(focused != 0);
|
|
||||||
if (focused == 0)
|
|
||||||
{
|
|
||||||
ImGui_ImplQNX_ClearModifierState(io, bd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (property == SCREEN_PROPERTY_SIZE || property == SCREEN_PROPERTY_BUFFER_SIZE || property == SCREEN_PROPERTY_VISIBLE)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case SCREEN_EVENT_CLOSE:
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
io.AddFocusEvent(false);
|
|
||||||
ImGui_ImplQNX_ClearModifierState(io, bd);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGui_ImplQNX_Init(screen_context_t context, screen_window_t window)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
|
||||||
IM_ASSERT(context != nullptr && window != nullptr);
|
|
||||||
if (context == nullptr || window == nullptr)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui_ImplQNX_Data* bd = IM_NEW(ImGui_ImplQNX_Data)();
|
|
||||||
io.BackendPlatformUserData = (void*)bd;
|
|
||||||
io.BackendPlatformName = "imgui_impl_qnx";
|
|
||||||
|
|
||||||
bd->Context = context;
|
|
||||||
bd->Window = window;
|
|
||||||
bd->TimeNanoseconds = ImGui_ImplQNX_GetTimeNanoseconds();
|
|
||||||
|
|
||||||
int focused = 0;
|
|
||||||
if (screen_get_window_property_iv(window, SCREEN_PROPERTY_FOCUS, &focused) == 0)
|
|
||||||
{
|
|
||||||
io.AddFocusEvent(focused != 0);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplQNX_Shutdown()
|
|
||||||
{
|
|
||||||
ImGui_ImplQNX_Data* bd = ImGui_ImplQNX_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
|
||||||
if (bd == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
io.BackendPlatformName = nullptr;
|
|
||||||
io.BackendPlatformUserData = nullptr;
|
|
||||||
IM_DELETE(bd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplQNX_NewFrame()
|
|
||||||
{
|
|
||||||
ImGui_ImplQNX_Data* bd = ImGui_ImplQNX_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplQNX_Init()?");
|
|
||||||
if (bd == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
int size[2] = {};
|
|
||||||
if (screen_get_window_property_iv(bd->Window, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0 ||
|
|
||||||
size[0] <= 0 || size[1] <= 0)
|
|
||||||
{
|
|
||||||
size[0] = 0;
|
|
||||||
size[1] = 0;
|
|
||||||
(void)screen_get_window_property_iv(bd->Window, SCREEN_PROPERTY_SIZE, size);
|
|
||||||
}
|
|
||||||
if (size[0] > 0 && size[1] > 0)
|
|
||||||
{
|
|
||||||
io.DisplaySize = ImVec2((float)size[0], (float)size[1]);
|
|
||||||
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint64_t current_time = ImGui_ImplQNX_GetTimeNanoseconds();
|
|
||||||
if (current_time > bd->TimeNanoseconds && bd->TimeNanoseconds != 0)
|
|
||||||
{
|
|
||||||
io.DeltaTime = (float)((double)(current_time - bd->TimeNanoseconds) / 1000000000.0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
io.DeltaTime = 1.0f / 60.0f;
|
|
||||||
}
|
|
||||||
bd->TimeNanoseconds = current_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generated by Markus Kuhn's public-domain unicode/convmap.pl from X11 keysymdef.h and UnicodeData.
|
|
||||||
// Original source: https://www.cl.cam.ac.uk/~mgk25/ucs/keysym2ucs.c
|
|
||||||
// The table must remain sorted by keysym for the binary search below.
|
|
||||||
struct ImGui_ImplQNX_KeySymPair
|
|
||||||
{
|
|
||||||
uint16_t KeySym;
|
|
||||||
uint16_t Unicode;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const ImGui_ImplQNX_KeySymPair ImGui_ImplQNX_KeySymTable[] =
|
|
||||||
{
|
|
||||||
{ 0x01a1, 0x0104 }, { 0x01a2, 0x02d8 }, { 0x01a3, 0x0141 }, { 0x01a5, 0x013d },
|
|
||||||
{ 0x01a6, 0x015a }, { 0x01a9, 0x0160 }, { 0x01aa, 0x015e }, { 0x01ab, 0x0164 },
|
|
||||||
{ 0x01ac, 0x0179 }, { 0x01ae, 0x017d }, { 0x01af, 0x017b }, { 0x01b1, 0x0105 },
|
|
||||||
{ 0x01b2, 0x02db }, { 0x01b3, 0x0142 }, { 0x01b5, 0x013e }, { 0x01b6, 0x015b },
|
|
||||||
{ 0x01b7, 0x02c7 }, { 0x01b9, 0x0161 }, { 0x01ba, 0x015f }, { 0x01bb, 0x0165 },
|
|
||||||
{ 0x01bc, 0x017a }, { 0x01bd, 0x02dd }, { 0x01be, 0x017e }, { 0x01bf, 0x017c },
|
|
||||||
{ 0x01c0, 0x0154 }, { 0x01c3, 0x0102 }, { 0x01c5, 0x0139 }, { 0x01c6, 0x0106 },
|
|
||||||
{ 0x01c8, 0x010c }, { 0x01ca, 0x0118 }, { 0x01cc, 0x011a }, { 0x01cf, 0x010e },
|
|
||||||
{ 0x01d0, 0x0110 }, { 0x01d1, 0x0143 }, { 0x01d2, 0x0147 }, { 0x01d5, 0x0150 },
|
|
||||||
{ 0x01d8, 0x0158 }, { 0x01d9, 0x016e }, { 0x01db, 0x0170 }, { 0x01de, 0x0162 },
|
|
||||||
{ 0x01e0, 0x0155 }, { 0x01e3, 0x0103 }, { 0x01e5, 0x013a }, { 0x01e6, 0x0107 },
|
|
||||||
{ 0x01e8, 0x010d }, { 0x01ea, 0x0119 }, { 0x01ec, 0x011b }, { 0x01ef, 0x010f },
|
|
||||||
{ 0x01f0, 0x0111 }, { 0x01f1, 0x0144 }, { 0x01f2, 0x0148 }, { 0x01f5, 0x0151 },
|
|
||||||
{ 0x01f8, 0x0159 }, { 0x01f9, 0x016f }, { 0x01fb, 0x0171 }, { 0x01fe, 0x0163 },
|
|
||||||
{ 0x01ff, 0x02d9 }, { 0x02a1, 0x0126 }, { 0x02a6, 0x0124 }, { 0x02a9, 0x0130 },
|
|
||||||
{ 0x02ab, 0x011e }, { 0x02ac, 0x0134 }, { 0x02b1, 0x0127 }, { 0x02b6, 0x0125 },
|
|
||||||
{ 0x02b9, 0x0131 }, { 0x02bb, 0x011f }, { 0x02bc, 0x0135 }, { 0x02c5, 0x010a },
|
|
||||||
{ 0x02c6, 0x0108 }, { 0x02d5, 0x0120 }, { 0x02d8, 0x011c }, { 0x02dd, 0x016c },
|
|
||||||
{ 0x02de, 0x015c }, { 0x02e5, 0x010b }, { 0x02e6, 0x0109 }, { 0x02f5, 0x0121 },
|
|
||||||
{ 0x02f8, 0x011d }, { 0x02fd, 0x016d }, { 0x02fe, 0x015d }, { 0x03a2, 0x0138 },
|
|
||||||
{ 0x03a3, 0x0156 }, { 0x03a5, 0x0128 }, { 0x03a6, 0x013b }, { 0x03aa, 0x0112 },
|
|
||||||
{ 0x03ab, 0x0122 }, { 0x03ac, 0x0166 }, { 0x03b3, 0x0157 }, { 0x03b5, 0x0129 },
|
|
||||||
{ 0x03b6, 0x013c }, { 0x03ba, 0x0113 }, { 0x03bb, 0x0123 }, { 0x03bc, 0x0167 },
|
|
||||||
{ 0x03bd, 0x014a }, { 0x03bf, 0x014b }, { 0x03c0, 0x0100 }, { 0x03c7, 0x012e },
|
|
||||||
{ 0x03cc, 0x0116 }, { 0x03cf, 0x012a }, { 0x03d1, 0x0145 }, { 0x03d2, 0x014c },
|
|
||||||
{ 0x03d3, 0x0136 }, { 0x03d9, 0x0172 }, { 0x03dd, 0x0168 }, { 0x03de, 0x016a },
|
|
||||||
{ 0x03e0, 0x0101 }, { 0x03e7, 0x012f }, { 0x03ec, 0x0117 }, { 0x03ef, 0x012b },
|
|
||||||
{ 0x03f1, 0x0146 }, { 0x03f2, 0x014d }, { 0x03f3, 0x0137 }, { 0x03f9, 0x0173 },
|
|
||||||
{ 0x03fd, 0x0169 }, { 0x03fe, 0x016b }, { 0x047e, 0x203e }, { 0x04a1, 0x3002 },
|
|
||||||
{ 0x04a2, 0x300c }, { 0x04a3, 0x300d }, { 0x04a4, 0x3001 }, { 0x04a5, 0x30fb },
|
|
||||||
{ 0x04a6, 0x30f2 }, { 0x04a7, 0x30a1 }, { 0x04a8, 0x30a3 }, { 0x04a9, 0x30a5 },
|
|
||||||
{ 0x04aa, 0x30a7 }, { 0x04ab, 0x30a9 }, { 0x04ac, 0x30e3 }, { 0x04ad, 0x30e5 },
|
|
||||||
{ 0x04ae, 0x30e7 }, { 0x04af, 0x30c3 }, { 0x04b0, 0x30fc }, { 0x04b1, 0x30a2 },
|
|
||||||
{ 0x04b2, 0x30a4 }, { 0x04b3, 0x30a6 }, { 0x04b4, 0x30a8 }, { 0x04b5, 0x30aa },
|
|
||||||
{ 0x04b6, 0x30ab }, { 0x04b7, 0x30ad }, { 0x04b8, 0x30af }, { 0x04b9, 0x30b1 },
|
|
||||||
{ 0x04ba, 0x30b3 }, { 0x04bb, 0x30b5 }, { 0x04bc, 0x30b7 }, { 0x04bd, 0x30b9 },
|
|
||||||
{ 0x04be, 0x30bb }, { 0x04bf, 0x30bd }, { 0x04c0, 0x30bf }, { 0x04c1, 0x30c1 },
|
|
||||||
{ 0x04c2, 0x30c4 }, { 0x04c3, 0x30c6 }, { 0x04c4, 0x30c8 }, { 0x04c5, 0x30ca },
|
|
||||||
{ 0x04c6, 0x30cb }, { 0x04c7, 0x30cc }, { 0x04c8, 0x30cd }, { 0x04c9, 0x30ce },
|
|
||||||
{ 0x04ca, 0x30cf }, { 0x04cb, 0x30d2 }, { 0x04cc, 0x30d5 }, { 0x04cd, 0x30d8 },
|
|
||||||
{ 0x04ce, 0x30db }, { 0x04cf, 0x30de }, { 0x04d0, 0x30df }, { 0x04d1, 0x30e0 },
|
|
||||||
{ 0x04d2, 0x30e1 }, { 0x04d3, 0x30e2 }, { 0x04d4, 0x30e4 }, { 0x04d5, 0x30e6 },
|
|
||||||
{ 0x04d6, 0x30e8 }, { 0x04d7, 0x30e9 }, { 0x04d8, 0x30ea }, { 0x04d9, 0x30eb },
|
|
||||||
{ 0x04da, 0x30ec }, { 0x04db, 0x30ed }, { 0x04dc, 0x30ef }, { 0x04dd, 0x30f3 },
|
|
||||||
{ 0x04de, 0x309b }, { 0x04df, 0x309c }, { 0x05ac, 0x060c }, { 0x05bb, 0x061b },
|
|
||||||
{ 0x05bf, 0x061f }, { 0x05c1, 0x0621 }, { 0x05c2, 0x0622 }, { 0x05c3, 0x0623 },
|
|
||||||
{ 0x05c4, 0x0624 }, { 0x05c5, 0x0625 }, { 0x05c6, 0x0626 }, { 0x05c7, 0x0627 },
|
|
||||||
{ 0x05c8, 0x0628 }, { 0x05c9, 0x0629 }, { 0x05ca, 0x062a }, { 0x05cb, 0x062b },
|
|
||||||
{ 0x05cc, 0x062c }, { 0x05cd, 0x062d }, { 0x05ce, 0x062e }, { 0x05cf, 0x062f },
|
|
||||||
{ 0x05d0, 0x0630 }, { 0x05d1, 0x0631 }, { 0x05d2, 0x0632 }, { 0x05d3, 0x0633 },
|
|
||||||
{ 0x05d4, 0x0634 }, { 0x05d5, 0x0635 }, { 0x05d6, 0x0636 }, { 0x05d7, 0x0637 },
|
|
||||||
{ 0x05d8, 0x0638 }, { 0x05d9, 0x0639 }, { 0x05da, 0x063a }, { 0x05e0, 0x0640 },
|
|
||||||
{ 0x05e1, 0x0641 }, { 0x05e2, 0x0642 }, { 0x05e3, 0x0643 }, { 0x05e4, 0x0644 },
|
|
||||||
{ 0x05e5, 0x0645 }, { 0x05e6, 0x0646 }, { 0x05e7, 0x0647 }, { 0x05e8, 0x0648 },
|
|
||||||
{ 0x05e9, 0x0649 }, { 0x05ea, 0x064a }, { 0x05eb, 0x064b }, { 0x05ec, 0x064c },
|
|
||||||
{ 0x05ed, 0x064d }, { 0x05ee, 0x064e }, { 0x05ef, 0x064f }, { 0x05f0, 0x0650 },
|
|
||||||
{ 0x05f1, 0x0651 }, { 0x05f2, 0x0652 }, { 0x06a1, 0x0452 }, { 0x06a2, 0x0453 },
|
|
||||||
{ 0x06a3, 0x0451 }, { 0x06a4, 0x0454 }, { 0x06a5, 0x0455 }, { 0x06a6, 0x0456 },
|
|
||||||
{ 0x06a7, 0x0457 }, { 0x06a8, 0x0458 }, { 0x06a9, 0x0459 }, { 0x06aa, 0x045a },
|
|
||||||
{ 0x06ab, 0x045b }, { 0x06ac, 0x045c }, { 0x06ae, 0x045e }, { 0x06af, 0x045f },
|
|
||||||
{ 0x06b0, 0x2116 }, { 0x06b1, 0x0402 }, { 0x06b2, 0x0403 }, { 0x06b3, 0x0401 },
|
|
||||||
{ 0x06b4, 0x0404 }, { 0x06b5, 0x0405 }, { 0x06b6, 0x0406 }, { 0x06b7, 0x0407 },
|
|
||||||
{ 0x06b8, 0x0408 }, { 0x06b9, 0x0409 }, { 0x06ba, 0x040a }, { 0x06bb, 0x040b },
|
|
||||||
{ 0x06bc, 0x040c }, { 0x06be, 0x040e }, { 0x06bf, 0x040f }, { 0x06c0, 0x044e },
|
|
||||||
{ 0x06c1, 0x0430 }, { 0x06c2, 0x0431 }, { 0x06c3, 0x0446 }, { 0x06c4, 0x0434 },
|
|
||||||
{ 0x06c5, 0x0435 }, { 0x06c6, 0x0444 }, { 0x06c7, 0x0433 }, { 0x06c8, 0x0445 },
|
|
||||||
{ 0x06c9, 0x0438 }, { 0x06ca, 0x0439 }, { 0x06cb, 0x043a }, { 0x06cc, 0x043b },
|
|
||||||
{ 0x06cd, 0x043c }, { 0x06ce, 0x043d }, { 0x06cf, 0x043e }, { 0x06d0, 0x043f },
|
|
||||||
{ 0x06d1, 0x044f }, { 0x06d2, 0x0440 }, { 0x06d3, 0x0441 }, { 0x06d4, 0x0442 },
|
|
||||||
{ 0x06d5, 0x0443 }, { 0x06d6, 0x0436 }, { 0x06d7, 0x0432 }, { 0x06d8, 0x044c },
|
|
||||||
{ 0x06d9, 0x044b }, { 0x06da, 0x0437 }, { 0x06db, 0x0448 }, { 0x06dc, 0x044d },
|
|
||||||
{ 0x06dd, 0x0449 }, { 0x06de, 0x0447 }, { 0x06df, 0x044a }, { 0x06e0, 0x042e },
|
|
||||||
{ 0x06e1, 0x0410 }, { 0x06e2, 0x0411 }, { 0x06e3, 0x0426 }, { 0x06e4, 0x0414 },
|
|
||||||
{ 0x06e5, 0x0415 }, { 0x06e6, 0x0424 }, { 0x06e7, 0x0413 }, { 0x06e8, 0x0425 },
|
|
||||||
{ 0x06e9, 0x0418 }, { 0x06ea, 0x0419 }, { 0x06eb, 0x041a }, { 0x06ec, 0x041b },
|
|
||||||
{ 0x06ed, 0x041c }, { 0x06ee, 0x041d }, { 0x06ef, 0x041e }, { 0x06f0, 0x041f },
|
|
||||||
{ 0x06f1, 0x042f }, { 0x06f2, 0x0420 }, { 0x06f3, 0x0421 }, { 0x06f4, 0x0422 },
|
|
||||||
{ 0x06f5, 0x0423 }, { 0x06f6, 0x0416 }, { 0x06f7, 0x0412 }, { 0x06f8, 0x042c },
|
|
||||||
{ 0x06f9, 0x042b }, { 0x06fa, 0x0417 }, { 0x06fb, 0x0428 }, { 0x06fc, 0x042d },
|
|
||||||
{ 0x06fd, 0x0429 }, { 0x06fe, 0x0427 }, { 0x06ff, 0x042a }, { 0x07a1, 0x0386 },
|
|
||||||
{ 0x07a2, 0x0388 }, { 0x07a3, 0x0389 }, { 0x07a4, 0x038a }, { 0x07a5, 0x03aa },
|
|
||||||
{ 0x07a7, 0x038c }, { 0x07a8, 0x038e }, { 0x07a9, 0x03ab }, { 0x07ab, 0x038f },
|
|
||||||
{ 0x07ae, 0x0385 }, { 0x07af, 0x2015 }, { 0x07b1, 0x03ac }, { 0x07b2, 0x03ad },
|
|
||||||
{ 0x07b3, 0x03ae }, { 0x07b4, 0x03af }, { 0x07b5, 0x03ca }, { 0x07b6, 0x0390 },
|
|
||||||
{ 0x07b7, 0x03cc }, { 0x07b8, 0x03cd }, { 0x07b9, 0x03cb }, { 0x07ba, 0x03b0 },
|
|
||||||
{ 0x07bb, 0x03ce }, { 0x07c1, 0x0391 }, { 0x07c2, 0x0392 }, { 0x07c3, 0x0393 },
|
|
||||||
{ 0x07c4, 0x0394 }, { 0x07c5, 0x0395 }, { 0x07c6, 0x0396 }, { 0x07c7, 0x0397 },
|
|
||||||
{ 0x07c8, 0x0398 }, { 0x07c9, 0x0399 }, { 0x07ca, 0x039a }, { 0x07cb, 0x039b },
|
|
||||||
{ 0x07cc, 0x039c }, { 0x07cd, 0x039d }, { 0x07ce, 0x039e }, { 0x07cf, 0x039f },
|
|
||||||
{ 0x07d0, 0x03a0 }, { 0x07d1, 0x03a1 }, { 0x07d2, 0x03a3 }, { 0x07d4, 0x03a4 },
|
|
||||||
{ 0x07d5, 0x03a5 }, { 0x07d6, 0x03a6 }, { 0x07d7, 0x03a7 }, { 0x07d8, 0x03a8 },
|
|
||||||
{ 0x07d9, 0x03a9 }, { 0x07e1, 0x03b1 }, { 0x07e2, 0x03b2 }, { 0x07e3, 0x03b3 },
|
|
||||||
{ 0x07e4, 0x03b4 }, { 0x07e5, 0x03b5 }, { 0x07e6, 0x03b6 }, { 0x07e7, 0x03b7 },
|
|
||||||
{ 0x07e8, 0x03b8 }, { 0x07e9, 0x03b9 }, { 0x07ea, 0x03ba }, { 0x07eb, 0x03bb },
|
|
||||||
{ 0x07ec, 0x03bc }, { 0x07ed, 0x03bd }, { 0x07ee, 0x03be }, { 0x07ef, 0x03bf },
|
|
||||||
{ 0x07f0, 0x03c0 }, { 0x07f1, 0x03c1 }, { 0x07f2, 0x03c3 }, { 0x07f3, 0x03c2 },
|
|
||||||
{ 0x07f4, 0x03c4 }, { 0x07f5, 0x03c5 }, { 0x07f6, 0x03c6 }, { 0x07f7, 0x03c7 },
|
|
||||||
{ 0x07f8, 0x03c8 }, { 0x07f9, 0x03c9 }, { 0x08a1, 0x23b7 }, { 0x08a2, 0x250c },
|
|
||||||
{ 0x08a3, 0x2500 }, { 0x08a4, 0x2320 }, { 0x08a5, 0x2321 }, { 0x08a6, 0x2502 },
|
|
||||||
{ 0x08a7, 0x23a1 }, { 0x08a8, 0x23a3 }, { 0x08a9, 0x23a4 }, { 0x08aa, 0x23a6 },
|
|
||||||
{ 0x08ab, 0x239b }, { 0x08ac, 0x239d }, { 0x08ad, 0x239e }, { 0x08ae, 0x23a0 },
|
|
||||||
{ 0x08af, 0x23a8 }, { 0x08b0, 0x23ac }, { 0x08bc, 0x2264 }, { 0x08bd, 0x2260 },
|
|
||||||
{ 0x08be, 0x2265 }, { 0x08bf, 0x222b }, { 0x08c0, 0x2234 }, { 0x08c1, 0x221d },
|
|
||||||
{ 0x08c2, 0x221e }, { 0x08c5, 0x2207 }, { 0x08c8, 0x223c }, { 0x08c9, 0x2243 },
|
|
||||||
{ 0x08cd, 0x21d4 }, { 0x08ce, 0x21d2 }, { 0x08cf, 0x2261 }, { 0x08d6, 0x221a },
|
|
||||||
{ 0x08da, 0x2282 }, { 0x08db, 0x2283 }, { 0x08dc, 0x2229 }, { 0x08dd, 0x222a },
|
|
||||||
{ 0x08de, 0x2227 }, { 0x08df, 0x2228 }, { 0x08ef, 0x2202 }, { 0x08f6, 0x0192 },
|
|
||||||
{ 0x08fb, 0x2190 }, { 0x08fc, 0x2191 }, { 0x08fd, 0x2192 }, { 0x08fe, 0x2193 },
|
|
||||||
{ 0x09e0, 0x25c6 }, { 0x09e1, 0x2592 }, { 0x09e2, 0x2409 }, { 0x09e3, 0x240c },
|
|
||||||
{ 0x09e4, 0x240d }, { 0x09e5, 0x240a }, { 0x09e8, 0x2424 }, { 0x09e9, 0x240b },
|
|
||||||
{ 0x09ea, 0x2518 }, { 0x09eb, 0x2510 }, { 0x09ec, 0x250c }, { 0x09ed, 0x2514 },
|
|
||||||
{ 0x09ee, 0x253c }, { 0x09ef, 0x23ba }, { 0x09f0, 0x23bb }, { 0x09f1, 0x2500 },
|
|
||||||
{ 0x09f2, 0x23bc }, { 0x09f3, 0x23bd }, { 0x09f4, 0x251c }, { 0x09f5, 0x2524 },
|
|
||||||
{ 0x09f6, 0x2534 }, { 0x09f7, 0x252c }, { 0x09f8, 0x2502 }, { 0x0aa1, 0x2003 },
|
|
||||||
{ 0x0aa2, 0x2002 }, { 0x0aa3, 0x2004 }, { 0x0aa4, 0x2005 }, { 0x0aa5, 0x2007 },
|
|
||||||
{ 0x0aa6, 0x2008 }, { 0x0aa7, 0x2009 }, { 0x0aa8, 0x200a }, { 0x0aa9, 0x2014 },
|
|
||||||
{ 0x0aaa, 0x2013 }, { 0x0aae, 0x2026 }, { 0x0aaf, 0x2025 }, { 0x0ab0, 0x2153 },
|
|
||||||
{ 0x0ab1, 0x2154 }, { 0x0ab2, 0x2155 }, { 0x0ab3, 0x2156 }, { 0x0ab4, 0x2157 },
|
|
||||||
{ 0x0ab5, 0x2158 }, { 0x0ab6, 0x2159 }, { 0x0ab7, 0x215a }, { 0x0ab8, 0x2105 },
|
|
||||||
{ 0x0abb, 0x2012 }, { 0x0abc, 0x2329 }, { 0x0abe, 0x232a }, { 0x0ac3, 0x215b },
|
|
||||||
{ 0x0ac4, 0x215c }, { 0x0ac5, 0x215d }, { 0x0ac6, 0x215e }, { 0x0ac9, 0x2122 },
|
|
||||||
{ 0x0aca, 0x2613 }, { 0x0acc, 0x25c1 }, { 0x0acd, 0x25b7 }, { 0x0ace, 0x25cb },
|
|
||||||
{ 0x0acf, 0x25af }, { 0x0ad0, 0x2018 }, { 0x0ad1, 0x2019 }, { 0x0ad2, 0x201c },
|
|
||||||
{ 0x0ad3, 0x201d }, { 0x0ad4, 0x211e }, { 0x0ad6, 0x2032 }, { 0x0ad7, 0x2033 },
|
|
||||||
{ 0x0ad9, 0x271d }, { 0x0adb, 0x25ac }, { 0x0adc, 0x25c0 }, { 0x0add, 0x25b6 },
|
|
||||||
{ 0x0ade, 0x25cf }, { 0x0adf, 0x25ae }, { 0x0ae0, 0x25e6 }, { 0x0ae1, 0x25ab },
|
|
||||||
{ 0x0ae2, 0x25ad }, { 0x0ae3, 0x25b3 }, { 0x0ae4, 0x25bd }, { 0x0ae5, 0x2606 },
|
|
||||||
{ 0x0ae6, 0x2022 }, { 0x0ae7, 0x25aa }, { 0x0ae8, 0x25b2 }, { 0x0ae9, 0x25bc },
|
|
||||||
{ 0x0aea, 0x261c }, { 0x0aeb, 0x261e }, { 0x0aec, 0x2663 }, { 0x0aed, 0x2666 },
|
|
||||||
{ 0x0aee, 0x2665 }, { 0x0af0, 0x2720 }, { 0x0af1, 0x2020 }, { 0x0af2, 0x2021 },
|
|
||||||
{ 0x0af3, 0x2713 }, { 0x0af4, 0x2717 }, { 0x0af5, 0x266f }, { 0x0af6, 0x266d },
|
|
||||||
{ 0x0af7, 0x2642 }, { 0x0af8, 0x2640 }, { 0x0af9, 0x260e }, { 0x0afa, 0x2315 },
|
|
||||||
{ 0x0afb, 0x2117 }, { 0x0afc, 0x2038 }, { 0x0afd, 0x201a }, { 0x0afe, 0x201e },
|
|
||||||
{ 0x0ba3, 0x003c }, { 0x0ba6, 0x003e }, { 0x0ba8, 0x2228 }, { 0x0ba9, 0x2227 },
|
|
||||||
{ 0x0bc0, 0x00af }, { 0x0bc2, 0x22a5 }, { 0x0bc3, 0x2229 }, { 0x0bc4, 0x230a },
|
|
||||||
{ 0x0bc6, 0x005f }, { 0x0bca, 0x2218 }, { 0x0bcc, 0x2395 }, { 0x0bce, 0x22a4 },
|
|
||||||
{ 0x0bcf, 0x25cb }, { 0x0bd3, 0x2308 }, { 0x0bd6, 0x222a }, { 0x0bd8, 0x2283 },
|
|
||||||
{ 0x0bda, 0x2282 }, { 0x0bdc, 0x22a2 }, { 0x0bfc, 0x22a3 }, { 0x0cdf, 0x2017 },
|
|
||||||
{ 0x0ce0, 0x05d0 }, { 0x0ce1, 0x05d1 }, { 0x0ce2, 0x05d2 }, { 0x0ce3, 0x05d3 },
|
|
||||||
{ 0x0ce4, 0x05d4 }, { 0x0ce5, 0x05d5 }, { 0x0ce6, 0x05d6 }, { 0x0ce7, 0x05d7 },
|
|
||||||
{ 0x0ce8, 0x05d8 }, { 0x0ce9, 0x05d9 }, { 0x0cea, 0x05da }, { 0x0ceb, 0x05db },
|
|
||||||
{ 0x0cec, 0x05dc }, { 0x0ced, 0x05dd }, { 0x0cee, 0x05de }, { 0x0cef, 0x05df },
|
|
||||||
{ 0x0cf0, 0x05e0 }, { 0x0cf1, 0x05e1 }, { 0x0cf2, 0x05e2 }, { 0x0cf3, 0x05e3 },
|
|
||||||
{ 0x0cf4, 0x05e4 }, { 0x0cf5, 0x05e5 }, { 0x0cf6, 0x05e6 }, { 0x0cf7, 0x05e7 },
|
|
||||||
{ 0x0cf8, 0x05e8 }, { 0x0cf9, 0x05e9 }, { 0x0cfa, 0x05ea }, { 0x0da1, 0x0e01 },
|
|
||||||
{ 0x0da2, 0x0e02 }, { 0x0da3, 0x0e03 }, { 0x0da4, 0x0e04 }, { 0x0da5, 0x0e05 },
|
|
||||||
{ 0x0da6, 0x0e06 }, { 0x0da7, 0x0e07 }, { 0x0da8, 0x0e08 }, { 0x0da9, 0x0e09 },
|
|
||||||
{ 0x0daa, 0x0e0a }, { 0x0dab, 0x0e0b }, { 0x0dac, 0x0e0c }, { 0x0dad, 0x0e0d },
|
|
||||||
{ 0x0dae, 0x0e0e }, { 0x0daf, 0x0e0f }, { 0x0db0, 0x0e10 }, { 0x0db1, 0x0e11 },
|
|
||||||
{ 0x0db2, 0x0e12 }, { 0x0db3, 0x0e13 }, { 0x0db4, 0x0e14 }, { 0x0db5, 0x0e15 },
|
|
||||||
{ 0x0db6, 0x0e16 }, { 0x0db7, 0x0e17 }, { 0x0db8, 0x0e18 }, { 0x0db9, 0x0e19 },
|
|
||||||
{ 0x0dba, 0x0e1a }, { 0x0dbb, 0x0e1b }, { 0x0dbc, 0x0e1c }, { 0x0dbd, 0x0e1d },
|
|
||||||
{ 0x0dbe, 0x0e1e }, { 0x0dbf, 0x0e1f }, { 0x0dc0, 0x0e20 }, { 0x0dc1, 0x0e21 },
|
|
||||||
{ 0x0dc2, 0x0e22 }, { 0x0dc3, 0x0e23 }, { 0x0dc4, 0x0e24 }, { 0x0dc5, 0x0e25 },
|
|
||||||
{ 0x0dc6, 0x0e26 }, { 0x0dc7, 0x0e27 }, { 0x0dc8, 0x0e28 }, { 0x0dc9, 0x0e29 },
|
|
||||||
{ 0x0dca, 0x0e2a }, { 0x0dcb, 0x0e2b }, { 0x0dcc, 0x0e2c }, { 0x0dcd, 0x0e2d },
|
|
||||||
{ 0x0dce, 0x0e2e }, { 0x0dcf, 0x0e2f }, { 0x0dd0, 0x0e30 }, { 0x0dd1, 0x0e31 },
|
|
||||||
{ 0x0dd2, 0x0e32 }, { 0x0dd3, 0x0e33 }, { 0x0dd4, 0x0e34 }, { 0x0dd5, 0x0e35 },
|
|
||||||
{ 0x0dd6, 0x0e36 }, { 0x0dd7, 0x0e37 }, { 0x0dd8, 0x0e38 }, { 0x0dd9, 0x0e39 },
|
|
||||||
{ 0x0dda, 0x0e3a }, { 0x0ddf, 0x0e3f }, { 0x0de0, 0x0e40 }, { 0x0de1, 0x0e41 },
|
|
||||||
{ 0x0de2, 0x0e42 }, { 0x0de3, 0x0e43 }, { 0x0de4, 0x0e44 }, { 0x0de5, 0x0e45 },
|
|
||||||
{ 0x0de6, 0x0e46 }, { 0x0de7, 0x0e47 }, { 0x0de8, 0x0e48 }, { 0x0de9, 0x0e49 },
|
|
||||||
{ 0x0dea, 0x0e4a }, { 0x0deb, 0x0e4b }, { 0x0dec, 0x0e4c }, { 0x0ded, 0x0e4d },
|
|
||||||
{ 0x0df0, 0x0e50 }, { 0x0df1, 0x0e51 }, { 0x0df2, 0x0e52 }, { 0x0df3, 0x0e53 },
|
|
||||||
{ 0x0df4, 0x0e54 }, { 0x0df5, 0x0e55 }, { 0x0df6, 0x0e56 }, { 0x0df7, 0x0e57 },
|
|
||||||
{ 0x0df8, 0x0e58 }, { 0x0df9, 0x0e59 }, { 0x0ea1, 0x3131 }, { 0x0ea2, 0x3132 },
|
|
||||||
{ 0x0ea3, 0x3133 }, { 0x0ea4, 0x3134 }, { 0x0ea5, 0x3135 }, { 0x0ea6, 0x3136 },
|
|
||||||
{ 0x0ea7, 0x3137 }, { 0x0ea8, 0x3138 }, { 0x0ea9, 0x3139 }, { 0x0eaa, 0x313a },
|
|
||||||
{ 0x0eab, 0x313b }, { 0x0eac, 0x313c }, { 0x0ead, 0x313d }, { 0x0eae, 0x313e },
|
|
||||||
{ 0x0eaf, 0x313f }, { 0x0eb0, 0x3140 }, { 0x0eb1, 0x3141 }, { 0x0eb2, 0x3142 },
|
|
||||||
{ 0x0eb3, 0x3143 }, { 0x0eb4, 0x3144 }, { 0x0eb5, 0x3145 }, { 0x0eb6, 0x3146 },
|
|
||||||
{ 0x0eb7, 0x3147 }, { 0x0eb8, 0x3148 }, { 0x0eb9, 0x3149 }, { 0x0eba, 0x314a },
|
|
||||||
{ 0x0ebb, 0x314b }, { 0x0ebc, 0x314c }, { 0x0ebd, 0x314d }, { 0x0ebe, 0x314e },
|
|
||||||
{ 0x0ebf, 0x314f }, { 0x0ec0, 0x3150 }, { 0x0ec1, 0x3151 }, { 0x0ec2, 0x3152 },
|
|
||||||
{ 0x0ec3, 0x3153 }, { 0x0ec4, 0x3154 }, { 0x0ec5, 0x3155 }, { 0x0ec6, 0x3156 },
|
|
||||||
{ 0x0ec7, 0x3157 }, { 0x0ec8, 0x3158 }, { 0x0ec9, 0x3159 }, { 0x0eca, 0x315a },
|
|
||||||
{ 0x0ecb, 0x315b }, { 0x0ecc, 0x315c }, { 0x0ecd, 0x315d }, { 0x0ece, 0x315e },
|
|
||||||
{ 0x0ecf, 0x315f }, { 0x0ed0, 0x3160 }, { 0x0ed1, 0x3161 }, { 0x0ed2, 0x3162 },
|
|
||||||
{ 0x0ed3, 0x3163 }, { 0x0ed4, 0x11a8 }, { 0x0ed5, 0x11a9 }, { 0x0ed6, 0x11aa },
|
|
||||||
{ 0x0ed7, 0x11ab }, { 0x0ed8, 0x11ac }, { 0x0ed9, 0x11ad }, { 0x0eda, 0x11ae },
|
|
||||||
{ 0x0edb, 0x11af }, { 0x0edc, 0x11b0 }, { 0x0edd, 0x11b1 }, { 0x0ede, 0x11b2 },
|
|
||||||
{ 0x0edf, 0x11b3 }, { 0x0ee0, 0x11b4 }, { 0x0ee1, 0x11b5 }, { 0x0ee2, 0x11b6 },
|
|
||||||
{ 0x0ee3, 0x11b7 }, { 0x0ee4, 0x11b8 }, { 0x0ee5, 0x11b9 }, { 0x0ee6, 0x11ba },
|
|
||||||
{ 0x0ee7, 0x11bb }, { 0x0ee8, 0x11bc }, { 0x0ee9, 0x11bd }, { 0x0eea, 0x11be },
|
|
||||||
{ 0x0eeb, 0x11bf }, { 0x0eec, 0x11c0 }, { 0x0eed, 0x11c1 }, { 0x0eee, 0x11c2 },
|
|
||||||
{ 0x0eef, 0x316d }, { 0x0ef0, 0x3171 }, { 0x0ef1, 0x3178 }, { 0x0ef2, 0x317f },
|
|
||||||
{ 0x0ef3, 0x3181 }, { 0x0ef4, 0x3184 }, { 0x0ef5, 0x3186 }, { 0x0ef6, 0x318d },
|
|
||||||
{ 0x0ef7, 0x318e }, { 0x0ef8, 0x11eb }, { 0x0ef9, 0x11f0 }, { 0x0efa, 0x11f9 },
|
|
||||||
{ 0x0eff, 0x20a9 }, { 0x13a4, 0x20ac }, { 0x13bc, 0x0152 }, { 0x13bd, 0x0153 },
|
|
||||||
{ 0x13be, 0x0178 }, { 0x20ac, 0x20ac },
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned int ImGui_ImplQNX_KeySymToUnicode(unsigned int keysym)
|
|
||||||
{
|
|
||||||
// Latin-1 keysyms map directly to Unicode.
|
|
||||||
if ((keysym >= 0x0020u && keysym <= 0x007eu) ||
|
|
||||||
(keysym >= 0x00a0u && keysym <= 0x00ffu))
|
|
||||||
{
|
|
||||||
return keysym;
|
|
||||||
}
|
|
||||||
|
|
||||||
// X11-style directly encoded UCS keysyms use 0x01000000 | codepoint.
|
|
||||||
if ((keysym & 0xff000000u) == 0x01000000u)
|
|
||||||
{
|
|
||||||
const unsigned int codepoint = keysym & 0x00ffffffu;
|
|
||||||
return codepoint <= IM_UNICODE_CODEPOINT_MAX ? codepoint : 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
int min = 0;
|
|
||||||
int max = (int)(sizeof(ImGui_ImplQNX_KeySymTable) / sizeof(ImGui_ImplQNX_KeySymTable[0])) - 1;
|
|
||||||
while (max >= min)
|
|
||||||
{
|
|
||||||
const int mid = min + (max - min) / 2;
|
|
||||||
if (ImGui_ImplQNX_KeySymTable[mid].KeySym < keysym)
|
|
||||||
{
|
|
||||||
min = mid + 1;
|
|
||||||
}
|
|
||||||
else if (ImGui_ImplQNX_KeySymTable[mid].KeySym > keysym)
|
|
||||||
{
|
|
||||||
max = mid - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return ImGui_ImplQNX_KeySymTable[mid].Unicode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
// dear imgui: Platform Backend for QNX Screen
|
|
||||||
// This needs to be used along with a Renderer Backend (e.g. OpenGL3, Vulkan).
|
|
||||||
|
|
||||||
// Implemented features:
|
|
||||||
// [X] Platform: Keyboard support. Uses io.AddKeyEvent() and native QNX key symbols.
|
|
||||||
// [X] Platform: Mouse support. Handles position, three buttons and horizontal/vertical wheels.
|
|
||||||
// [X] Platform: Touch support. Maps the first active touch contact to the primary mouse button.
|
|
||||||
// [X] Platform: Focus and window-size updates.
|
|
||||||
// Missing features or Issues:
|
|
||||||
// [ ] Platform: Clipboard support.
|
|
||||||
// [ ] Platform: Gamepad support.
|
|
||||||
// [ ] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors).
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
// Learn about Dear ImGui:
|
|
||||||
// - FAQ https://dearimgui.com/faq
|
|
||||||
// - Getting Started https://dearimgui.com/getting-started
|
|
||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
|
||||||
#ifndef IMGUI_DISABLE
|
|
||||||
|
|
||||||
#include <screen/screen.h>
|
|
||||||
|
|
||||||
// The application owns the Screen context, window and event object.
|
|
||||||
// Poll events with screen_get_event() and pass each non-NONE event to ProcessEvent().
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplQNX_Init(screen_context_t context, screen_window_t window);
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplQNX_Shutdown();
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplQNX_NewFrame();
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplQNX_ProcessEvent(screen_event_t event);
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
|
||||||
@ -21,9 +21,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-08-06: Fixed querying framebuffer scale when using Metal. (#5592)
|
|
||||||
// 2026-07-15: Inputs: restore SDL_StartTextInput()/SDL_StopTextInput() in IME handler for on-screen keyboard support on Android/mobile. (#7636, #9474)
|
|
||||||
// 2026-04-16: Made ImGui_ImplSDL2_GetContentScaleForWindow(), ImGui_ImplSDL2_GetContentScaleForDisplay() helpers return a minimum of 1.0f, as some Linux setup seems to report <1.0f value and this breaks scaling border size. (#9369)
|
|
||||||
// 2026-02-13: Inputs: systems other than X11 are back to starting mouse capture on mouse down (reverts 2025-02-26 change). Only X11 requires waiting for a drag by default (not ideal, but a better default for X11 users). Added ImGui_ImplSDL2_SetMouseCaptureMode() for X11 debugger users. (#3650, #6410, #9235)
|
// 2026-02-13: Inputs: systems other than X11 are back to starting mouse capture on mouse down (reverts 2025-02-26 change). Only X11 requires waiting for a drag by default (not ideal, but a better default for X11 users). Added ImGui_ImplSDL2_SetMouseCaptureMode() for X11 debugger users. (#3650, #6410, #9235)
|
||||||
// 2026-01-15: Changed GetClipboardText() handler to return nullptr on error aka clipboard contents is not text. Consistent with other backends. (#9168)
|
// 2026-01-15: Changed GetClipboardText() handler to return nullptr on error aka clipboard contents is not text. Consistent with other backends. (#9168)
|
||||||
// 2025-09-24: Skip using the SDL_GetGlobalMouseState() state when one of our window is hovered, as the SDL_MOUSEMOTION data is reliable. Fix macOS notch mouse coordinates issue in fullscreen mode + better perf on X11. (#7919, #7786)
|
// 2025-09-24: Skip using the SDL_GetGlobalMouseState() state when one of our window is hovered, as the SDL_MOUSEMOTION data is reliable. Fix macOS notch mouse coordinates issue in fullscreen mode + better perf on X11. (#7919, #7786)
|
||||||
@ -136,18 +133,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#define SDL_HAS_PER_MONITOR_DPI SDL_VERSION_ATLEAST(2,0,4)
|
#define SDL_HAS_PER_MONITOR_DPI SDL_VERSION_ATLEAST(2,0,4)
|
||||||
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
||||||
#if defined(__APPLE__)
|
|
||||||
#define SDL_HAS_METAL SDL_VERSION_ATLEAST(2,0,14)
|
|
||||||
#else
|
|
||||||
#define SDL_HAS_METAL 0
|
|
||||||
#endif
|
|
||||||
#define SDL_HAS_OPEN_URL SDL_VERSION_ATLEAST(2,0,14)
|
#define SDL_HAS_OPEN_URL SDL_VERSION_ATLEAST(2,0,14)
|
||||||
#if SDL_HAS_VULKAN
|
#if SDL_HAS_VULKAN
|
||||||
#include <SDL_vulkan.h>
|
#include <SDL_vulkan.h>
|
||||||
#endif
|
#endif
|
||||||
#if SDL_HAS_METAL
|
|
||||||
#include <SDL_metal.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// SDL Data
|
// SDL Data
|
||||||
struct ImGui_ImplSDL2_Data
|
struct ImGui_ImplSDL2_Data
|
||||||
@ -157,8 +146,7 @@ struct ImGui_ImplSDL2_Data
|
|||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
Uint64 Time;
|
Uint64 Time;
|
||||||
char* ClipboardTextData;
|
char* ClipboardTextData;
|
||||||
char BackendPlatformName[64];
|
char BackendPlatformName[48];
|
||||||
bool IsWayland;
|
|
||||||
|
|
||||||
// Mouse handling
|
// Mouse handling
|
||||||
Uint32 MouseWindowID;
|
Uint32 MouseWindowID;
|
||||||
@ -215,18 +203,6 @@ static void ImGui_ImplSDL2_PlatformSetImeData(ImGuiContext*, ImGuiViewport*, ImG
|
|||||||
r.w = 1;
|
r.w = 1;
|
||||||
r.h = (int)data->InputLineHeight;
|
r.h = (int)data->InputLineHeight;
|
||||||
SDL_SetTextInputRect(&r);
|
SDL_SetTextInputRect(&r);
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
// SDL_StartTextInput() is needed on Android (and some other platforms) to show the on-screen keyboard. (#7636, #9474, #6306)
|
|
||||||
// It was removed in a7703fe6 due to concerns about its relation to desktop IME, but is required on mobile.
|
|
||||||
SDL_StartTextInput();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
SDL_StopTextInput();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,12 +498,11 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
SDL_version ver_runtime;
|
SDL_version ver_runtime;
|
||||||
SDL_VERSION(&ver_compiled);
|
SDL_VERSION(&ver_compiled);
|
||||||
SDL_GetVersion(&ver_runtime);
|
SDL_GetVersion(&ver_runtime);
|
||||||
const char* sdl_video_driver = SDL_GetCurrentVideoDriver();
|
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)();
|
ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)();
|
||||||
snprintf(bd->BackendPlatformName, sizeof(bd->BackendPlatformName), "imgui_impl_sdl2 (%u.%u.%u, %u.%u.%u) (%s)",
|
snprintf(bd->BackendPlatformName, sizeof(bd->BackendPlatformName), "imgui_impl_sdl2 (%u.%u.%u, %u.%u.%u)",
|
||||||
ver_compiled.major, ver_compiled.minor, ver_compiled.patch, ver_runtime.major, ver_runtime.minor, ver_runtime.patch, sdl_video_driver);
|
ver_compiled.major, ver_compiled.minor, ver_compiled.patch, ver_runtime.major, ver_runtime.minor, ver_runtime.patch);
|
||||||
io.BackendPlatformUserData = (void*)bd;
|
io.BackendPlatformUserData = (void*)bd;
|
||||||
io.BackendPlatformName = bd->BackendPlatformName;
|
io.BackendPlatformName = bd->BackendPlatformName;
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
@ -536,16 +511,16 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->WindowID = SDL_GetWindowID(window);
|
bd->WindowID = SDL_GetWindowID(window);
|
||||||
bd->Renderer = renderer;
|
bd->Renderer = renderer;
|
||||||
bd->IsWayland = strcmp(sdl_video_driver, "Wayland") == 0;
|
|
||||||
|
|
||||||
// Check and store if we are on a SDL backend that supports SDL_GetGlobalMouseState() and SDL_CaptureMouse()
|
// Check and store if we are on a SDL backend that supports SDL_GetGlobalMouseState() and SDL_CaptureMouse()
|
||||||
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
|
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
|
||||||
bd->MouseCanUseGlobalState = false;
|
bd->MouseCanUseGlobalState = false;
|
||||||
bd->MouseCaptureMode = ImGui_ImplSDL2_MouseCaptureMode_Disabled;
|
bd->MouseCaptureMode = ImGui_ImplSDL2_MouseCaptureMode_Disabled;
|
||||||
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
||||||
|
const char* sdl_backend = SDL_GetCurrentVideoDriver();
|
||||||
const char* capture_and_global_state_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
|
const char* capture_and_global_state_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
|
||||||
for (const char* item : capture_and_global_state_whitelist)
|
for (const char* item : capture_and_global_state_whitelist)
|
||||||
if (strncmp(sdl_video_driver, item, strlen(item)) == 0)
|
if (strncmp(sdl_backend, item, strlen(item)) == 0)
|
||||||
{
|
{
|
||||||
bd->MouseCanUseGlobalState = true;
|
bd->MouseCanUseGlobalState = true;
|
||||||
bd->MouseCaptureMode = (strcmp(item, "x11") == 0) ? ImGui_ImplSDL2_MouseCaptureMode_EnabledAfterDrag : ImGui_ImplSDL2_MouseCaptureMode_Enabled;
|
bd->MouseCaptureMode = (strcmp(item, "x11") == 0) ? ImGui_ImplSDL2_MouseCaptureMode_EnabledAfterDrag : ImGui_ImplSDL2_MouseCaptureMode_Enabled;
|
||||||
@ -773,7 +748,6 @@ float ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window)
|
|||||||
return ImGui_ImplSDL2_GetContentScaleForDisplay(SDL_GetWindowDisplayIndex(window));
|
return ImGui_ImplSDL2_GetContentScaleForDisplay(SDL_GetWindowDisplayIndex(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
// SDL_GetDisplayDPI() seems rather unreliable on Linux.
|
|
||||||
float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index)
|
float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index)
|
||||||
{
|
{
|
||||||
const char* sdl_driver = SDL_GetCurrentVideoDriver();
|
const char* sdl_driver = SDL_GetCurrentVideoDriver();
|
||||||
@ -783,11 +757,7 @@ float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index)
|
|||||||
#if !defined(__APPLE__) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
|
#if !defined(__APPLE__) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
|
||||||
float dpi = 0.0f;
|
float dpi = 0.0f;
|
||||||
if (SDL_GetDisplayDPI(display_index, &dpi, nullptr, nullptr) == 0)
|
if (SDL_GetDisplayDPI(display_index, &dpi, nullptr, nullptr) == 0)
|
||||||
{
|
|
||||||
if (dpi < 96.0f)
|
|
||||||
dpi = 96.0f;
|
|
||||||
return dpi / 96.0f;
|
return dpi / 96.0f;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
IM_UNUSED(display_index);
|
IM_UNUSED(display_index);
|
||||||
@ -908,17 +878,13 @@ static void ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(SDL_Window* window,
|
|||||||
#if SDL_HAS_VULKAN
|
#if SDL_HAS_VULKAN
|
||||||
else if (SDL_GetWindowFlags(window) & SDL_WINDOW_VULKAN)
|
else if (SDL_GetWindowFlags(window) & SDL_WINDOW_VULKAN)
|
||||||
SDL_Vulkan_GetDrawableSize(window, &display_w, &display_h);
|
SDL_Vulkan_GetDrawableSize(window, &display_w, &display_h);
|
||||||
#endif
|
|
||||||
#if SDL_HAS_METAL
|
|
||||||
else if (SDL_GetWindowFlags(window) & SDL_WINDOW_METAL)
|
|
||||||
SDL_Metal_GetDrawableSize(window, &display_w, &display_h);
|
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
SDL_GL_GetDrawableSize(window, &display_w, &display_h);
|
SDL_GL_GetDrawableSize(window, &display_w, &display_h);
|
||||||
if (out_size != nullptr)
|
if (out_size != nullptr)
|
||||||
*out_size = ImVec2((float)w, (float)h);
|
*out_size = ImVec2((float)w, (float)h);
|
||||||
if (out_framebuffer_scale != nullptr)
|
if (out_framebuffer_scale != nullptr)
|
||||||
*out_framebuffer_scale = (w > 0 && h > 0) ? ImVec2((float)display_w / (float)w, (float)display_h / (float)h) : ImVec2(1.0f, 1.0f);
|
*out_framebuffer_scale = (w > 0 && h > 0) ? ImVec2((float)display_w / w, (float)display_h / h) : ImVec2(1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL2_NewFrame()
|
void ImGui_ImplSDL2_NewFrame()
|
||||||
@ -936,7 +902,7 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
Uint64 current_time = SDL_GetPerformanceCounter();
|
Uint64 current_time = SDL_GetPerformanceCounter();
|
||||||
if (current_time <= bd->Time)
|
if (current_time <= bd->Time)
|
||||||
current_time = bd->Time + 1;
|
current_time = bd->Time + 1;
|
||||||
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / (double)frequency) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
if (bd->MouseLastLeaveFrame && bd->MouseLastLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
if (bd->MouseLastLeaveFrame && bd->MouseLastLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
||||||
|
|||||||
@ -111,8 +111,7 @@ struct ImGui_ImplSDL3_Data
|
|||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
Uint64 Time;
|
Uint64 Time;
|
||||||
char* ClipboardTextData;
|
char* ClipboardTextData;
|
||||||
char BackendPlatformName[64];
|
char BackendPlatformName[48];
|
||||||
bool IsWayland;
|
|
||||||
|
|
||||||
// IME handling
|
// IME handling
|
||||||
SDL_Window* ImeWindow;
|
SDL_Window* ImeWindow;
|
||||||
@ -503,13 +502,11 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
//SDL_SetHint(SDL_HINT_EVENT_LOGGING, "2");
|
//SDL_SetHint(SDL_HINT_EVENT_LOGGING, "2");
|
||||||
|
|
||||||
const int ver_linked = SDL_GetVersion();
|
const int ver_linked = SDL_GetVersion();
|
||||||
const char* sdl_video_driver = SDL_GetCurrentVideoDriver();
|
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
ImGui_ImplSDL3_Data* bd = IM_NEW(ImGui_ImplSDL3_Data)();
|
ImGui_ImplSDL3_Data* bd = IM_NEW(ImGui_ImplSDL3_Data)();
|
||||||
snprintf(bd->BackendPlatformName, sizeof(bd->BackendPlatformName), "imgui_impl_sdl3 (%d.%d.%d; %d.%d.%d) (%s)",
|
snprintf(bd->BackendPlatformName, sizeof(bd->BackendPlatformName), "imgui_impl_sdl3 (%d.%d.%d; %d.%d.%d)",
|
||||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION, SDL_VERSIONNUM_MAJOR(ver_linked), SDL_VERSIONNUM_MINOR(ver_linked), SDL_VERSIONNUM_MICRO(ver_linked),
|
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION, SDL_VERSIONNUM_MAJOR(ver_linked), SDL_VERSIONNUM_MINOR(ver_linked), SDL_VERSIONNUM_MICRO(ver_linked));
|
||||||
sdl_video_driver);
|
|
||||||
io.BackendPlatformUserData = (void*)bd;
|
io.BackendPlatformUserData = (void*)bd;
|
||||||
io.BackendPlatformName = bd->BackendPlatformName;
|
io.BackendPlatformName = bd->BackendPlatformName;
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
@ -518,16 +515,16 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->WindowID = SDL_GetWindowID(window);
|
bd->WindowID = SDL_GetWindowID(window);
|
||||||
bd->Renderer = renderer;
|
bd->Renderer = renderer;
|
||||||
bd->IsWayland = strcmp(sdl_video_driver, "wayland") == 0;
|
|
||||||
|
|
||||||
// Check and store if we are on a SDL backend that supports SDL_GetGlobalMouseState() and SDL_CaptureMouse()
|
// Check and store if we are on a SDL backend that supports SDL_GetGlobalMouseState() and SDL_CaptureMouse()
|
||||||
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
|
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
|
||||||
bd->MouseCanUseGlobalState = false;
|
bd->MouseCanUseGlobalState = false;
|
||||||
bd->MouseCaptureMode = ImGui_ImplSDL3_MouseCaptureMode_Disabled;
|
bd->MouseCaptureMode = ImGui_ImplSDL3_MouseCaptureMode_Disabled;
|
||||||
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
||||||
|
const char* sdl_backend = SDL_GetCurrentVideoDriver();
|
||||||
const char* capture_and_global_state_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
|
const char* capture_and_global_state_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
|
||||||
for (const char* item : capture_and_global_state_whitelist)
|
for (const char* item : capture_and_global_state_whitelist)
|
||||||
if (strncmp(sdl_video_driver, item, strlen(item)) == 0)
|
if (strncmp(sdl_backend, item, strlen(item)) == 0)
|
||||||
{
|
{
|
||||||
bd->MouseCanUseGlobalState = true;
|
bd->MouseCanUseGlobalState = true;
|
||||||
bd->MouseCaptureMode = (strcmp(item, "x11") == 0) ? ImGui_ImplSDL3_MouseCaptureMode_EnabledAfterDrag : ImGui_ImplSDL3_MouseCaptureMode_Enabled;
|
bd->MouseCaptureMode = (strcmp(item, "x11") == 0) ? ImGui_ImplSDL3_MouseCaptureMode_EnabledAfterDrag : ImGui_ImplSDL3_MouseCaptureMode_Enabled;
|
||||||
@ -689,8 +686,8 @@ static void ImGui_ImplSDL3_UpdateMouseData()
|
|||||||
int window_x, window_y;
|
int window_x, window_y;
|
||||||
SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
|
SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
|
||||||
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
|
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
|
||||||
mouse_x -= (float)window_x;
|
mouse_x -= window_x;
|
||||||
mouse_y -= (float)window_y;
|
mouse_y -= window_y;
|
||||||
io.AddMousePosEvent(mouse_x, mouse_y);
|
io.AddMousePosEvent(mouse_x, mouse_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -863,7 +860,7 @@ void ImGui_ImplSDL3_NewFrame()
|
|||||||
Uint64 current_time = SDL_GetPerformanceCounter();
|
Uint64 current_time = SDL_GetPerformanceCounter();
|
||||||
if (current_time <= bd->Time)
|
if (current_time <= bd->Time)
|
||||||
current_time = bd->Time + 1;
|
current_time = bd->Time + 1;
|
||||||
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / (double)frequency) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
if (bd->MousePendingLeaveFrame && bd->MousePendingLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
if (bd->MousePendingLeaveFrame && bd->MousePendingLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'SDL_GPUTexture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef! **IMPORTANT** Before 2025/08/08, ImTextureID was a reference to a SDL_GPUTextureSamplerBinding struct.
|
// [X] Renderer: User texture binding. Use 'SDL_GPUTexture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef! **IMPORTANT** Before 2025/08/08, ImTextureID was a reference to a SDL_GPUTextureSamplerBinding struct.
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplSDLGPU3_GetRenderState().
|
|
||||||
|
|
||||||
// The aim of imgui_impl_sdlgpu3.h/.cpp is to be usable in your engine without any modification.
|
// The aim of imgui_impl_sdlgpu3.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/
|
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||||
@ -23,8 +22,6 @@
|
|||||||
// Calling the function is MANDATORY, otherwise the ImGui will not upload neither the vertex nor the index buffer for the GPU. See imgui_impl_sdlgpu3.cpp for more info.
|
// Calling the function is MANDATORY, otherwise the ImGui will not upload neither the vertex nor the index buffer for the GPU. See imgui_impl_sdlgpu3.cpp for more info.
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// 2026-09-07: Round framebuffer dimensions to the nearest integer instead of truncating them. (#9538, 9515, #8628)
|
|
||||||
// 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. Obsoleting samplers from ImGui_ImplSDLGPU3_RenderState. (#9378)
|
|
||||||
// 2026-03-19: Fixed issue in ImGui_ImplSDLGPU3_DestroyTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295, #9310)
|
// 2026-03-19: Fixed issue in ImGui_ImplSDLGPU3_DestroyTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295, #9310)
|
||||||
// 2026-02-25: Removed unnecessary call to SDL_WaitForGPUIdle when releasing vertex/index buffers. (#9262)
|
// 2026-02-25: Removed unnecessary call to SDL_WaitForGPUIdle when releasing vertex/index buffers. (#9262)
|
||||||
// 2025-11-26: macOS version can use MSL shaders in order to support macOS 10.14+ (vs Metallib shaders requiring macOS 14+). Requires calling SDL_CreateGPUDevice() with SDL_GPU_SHADERFORMAT_MSL.
|
// 2025-11-26: macOS version can use MSL shaders in order to support macOS 10.14+ (vs Metallib shaders requiring macOS 14+). Requires calling SDL_CreateGPUDevice() with SDL_GPU_SHADERFORMAT_MSL.
|
||||||
@ -62,10 +59,6 @@ struct ImGui_ImplSDLGPU3_Data
|
|||||||
{
|
{
|
||||||
ImGui_ImplSDLGPU3_InitInfo InitInfo;
|
ImGui_ImplSDLGPU3_InitInfo InitInfo;
|
||||||
|
|
||||||
// Render state
|
|
||||||
ImGui_ImplSDLGPU3_RenderState* RenderState = nullptr; // == ImGui::GetPlatformIO().Renderer_RenderState during rendering.
|
|
||||||
SDL_GPUSampler* CurrentSampler = nullptr;
|
|
||||||
|
|
||||||
// Graphics pipeline & shaders
|
// Graphics pipeline & shaders
|
||||||
SDL_GPUShader* VertexShader = nullptr;
|
SDL_GPUShader* VertexShader = nullptr;
|
||||||
SDL_GPUShader* FragmentShader = nullptr;
|
SDL_GPUShader* FragmentShader = nullptr;
|
||||||
@ -94,15 +87,10 @@ static ImGui_ImplSDLGPU3_Data* ImGui_ImplSDLGPU3_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLGPU3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLGPU3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplSDLGPU3_RenderState* ImGui_ImplSDLGPU3_GetRenderState()
|
static void ImGui_ImplSDLGPU3_SetupRenderState(ImDrawData* draw_data, ImGui_ImplSDLGPU3_RenderState* render_state, SDL_GPUGraphicsPipeline* pipeline, SDL_GPUCommandBuffer* command_buffer, SDL_GPURenderPass* render_pass, ImGui_ImplSDLGPU3_FrameData* fd, uint32_t fb_width, uint32_t fb_height)
|
||||||
{
|
|
||||||
return (ImGui_ImplSDLGPU3_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplSDLGPU3_SetupRenderState(ImDrawData* draw_data, SDL_GPUGraphicsPipeline* pipeline, SDL_GPUCommandBuffer* command_buffer, SDL_GPURenderPass* render_pass, ImGui_ImplSDLGPU3_FrameData* fd, uint32_t fb_width, uint32_t fb_height)
|
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData();
|
ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData();
|
||||||
bd->CurrentSampler = bd->TexSamplerLinear;
|
render_state->SamplerCurrent = bd->TexSamplerLinear;
|
||||||
|
|
||||||
// Bind graphics pipeline
|
// Bind graphics pipeline
|
||||||
SDL_BindGPUGraphicsPipeline(render_pass, pipeline);
|
SDL_BindGPUGraphicsPipeline(render_pass, pipeline);
|
||||||
@ -170,8 +158,8 @@ static void CreateOrResizeBuffers(SDL_GPUBuffer** buffer, SDL_GPUTransferBuffer*
|
|||||||
void ImGui_ImplSDLGPU3_PrepareDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffer* command_buffer)
|
void ImGui_ImplSDLGPU3_PrepareDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffer* command_buffer)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// 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 + 0.5f);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0 || draw_data->TotalVtxCount <= 0)
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->TotalVtxCount <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -186,8 +174,8 @@ void ImGui_ImplSDLGPU3_PrepareDrawData(ImDrawData* draw_data, SDL_GPUCommandBuff
|
|||||||
ImGui_ImplSDLGPU3_InitInfo* v = &bd->InitInfo;
|
ImGui_ImplSDLGPU3_InitInfo* v = &bd->InitInfo;
|
||||||
ImGui_ImplSDLGPU3_FrameData* fd = &bd->MainWindowFrameData;
|
ImGui_ImplSDLGPU3_FrameData* fd = &bd->MainWindowFrameData;
|
||||||
|
|
||||||
uint32_t vertex_size = (uint32_t)draw_data->TotalVtxCount * sizeof(ImDrawVert);
|
uint32_t vertex_size = draw_data->TotalVtxCount * sizeof(ImDrawVert);
|
||||||
uint32_t index_size = (uint32_t)draw_data->TotalIdxCount * sizeof(ImDrawIdx);
|
uint32_t index_size = draw_data->TotalIdxCount * sizeof(ImDrawIdx);
|
||||||
if (fd->VertexBuffer == nullptr || fd->VertexBufferSize < vertex_size)
|
if (fd->VertexBuffer == nullptr || fd->VertexBufferSize < vertex_size)
|
||||||
CreateOrResizeBuffers(&fd->VertexBuffer, &fd->VertexTransferBuffer, &fd->VertexBufferSize, vertex_size, SDL_GPU_BUFFERUSAGE_VERTEX);
|
CreateOrResizeBuffers(&fd->VertexBuffer, &fd->VertexTransferBuffer, &fd->VertexBufferSize, vertex_size, SDL_GPU_BUFFERUSAGE_VERTEX);
|
||||||
if (fd->IndexBuffer == nullptr || fd->IndexBufferSize < index_size)
|
if (fd->IndexBuffer == nullptr || fd->IndexBufferSize < index_size)
|
||||||
@ -228,16 +216,11 @@ void ImGui_ImplSDLGPU3_PrepareDrawData(ImDrawData* draw_data, SDL_GPUCommandBuff
|
|||||||
SDL_EndGPUCopyPass(copy_pass);
|
SDL_EndGPUCopyPass(copy_pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplSDLGPU3_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplSDLGPU3_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData(); bd->CurrentSampler = bd->TexSamplerLinear; }
|
|
||||||
static void ImGui_ImplSDLGPU3_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData(); bd->CurrentSampler = bd->TexSamplerNearest; }
|
|
||||||
|
|
||||||
void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffer* command_buffer, SDL_GPURenderPass* render_pass, SDL_GPUGraphicsPipeline* pipeline)
|
void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffer* command_buffer, SDL_GPURenderPass* render_pass, SDL_GPUGraphicsPipeline* pipeline)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// 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 + 0.5f);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0)
|
if (fb_width <= 0 || fb_height <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -255,9 +238,11 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
ImGui_ImplSDLGPU3_RenderState render_state;
|
ImGui_ImplSDLGPU3_RenderState render_state;
|
||||||
render_state.Device = bd->InitInfo.Device;
|
render_state.Device = bd->InitInfo.Device;
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = &render_state;
|
render_state.SamplerLinear = render_state.SamplerCurrent = bd->TexSamplerLinear;
|
||||||
|
render_state.SamplerNearest = bd->TexSamplerNearest;
|
||||||
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, &render_state, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
@ -271,8 +256,9 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
if (pcmd->UserCallback != nullptr)
|
if (pcmd->UserCallback != nullptr)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplSDLGPU3_DrawCallback_ResetRenderState)
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
|
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, &render_state, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
}
|
}
|
||||||
@ -285,8 +271,8 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
// Clamp to viewport as SDL_SetGPUScissor() won't accept values that are off bounds
|
// Clamp to viewport as SDL_SetGPUScissor() won't accept values that are off bounds
|
||||||
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
||||||
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
||||||
if (clip_max.x > (float)fb_width) { clip_max.x = (float)fb_width; }
|
if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; }
|
||||||
if (clip_max.y > (float)fb_height) { clip_max.y = (float)fb_height; }
|
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
||||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -301,7 +287,7 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
// Bind DescriptorSet with font or user texture
|
// Bind DescriptorSet with font or user texture
|
||||||
SDL_GPUTextureSamplerBinding texture_sampler_binding;
|
SDL_GPUTextureSamplerBinding texture_sampler_binding;
|
||||||
texture_sampler_binding.texture = (SDL_GPUTexture*)(intptr_t)pcmd->GetTexID();
|
texture_sampler_binding.texture = (SDL_GPUTexture*)(intptr_t)pcmd->GetTexID();
|
||||||
texture_sampler_binding.sampler = bd->CurrentSampler;
|
texture_sampler_binding.sampler = render_state.SamplerCurrent;
|
||||||
SDL_BindGPUFragmentSamplers(render_pass, 0, &texture_sampler_binding, 1);
|
SDL_BindGPUFragmentSamplers(render_pass, 0, &texture_sampler_binding, 1);
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
@ -320,8 +306,6 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
// We perform a call to SDL_SetGPUScissor() to set back a full viewport which is likely to fix things for 99% users but technically this is not perfect. (See github #4644)
|
// We perform a call to SDL_SetGPUScissor() to set back a full viewport which is likely to fix things for 99% users but technically this is not perfect. (See github #4644)
|
||||||
SDL_Rect scissor_rect { 0, 0, fb_width, fb_height };
|
SDL_Rect scissor_rect { 0, 0, fb_width, fb_height };
|
||||||
SDL_SetGPUScissor(render_pass, &scissor_rect);
|
SDL_SetGPUScissor(render_pass, &scissor_rect);
|
||||||
|
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDLGPU3_DestroyTexture(ImTextureData* tex)
|
static void ImGui_ImplSDLGPU3_DestroyTexture(ImTextureData* tex)
|
||||||
@ -598,7 +582,7 @@ void ImGui_ImplSDLGPU3_CreateDeviceObjects()
|
|||||||
|
|
||||||
if (bd->TexSamplerLinear == nullptr)
|
if (bd->TexSamplerLinear == nullptr)
|
||||||
{
|
{
|
||||||
// Bilinear sampling is required.
|
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||||
SDL_GPUSamplerCreateInfo sampler_info = {};
|
SDL_GPUSamplerCreateInfo sampler_info = {};
|
||||||
sampler_info.min_filter = SDL_GPU_FILTER_LINEAR;
|
sampler_info.min_filter = SDL_GPU_FILTER_LINEAR;
|
||||||
sampler_info.mag_filter = SDL_GPU_FILTER_LINEAR;
|
sampler_info.mag_filter = SDL_GPU_FILTER_LINEAR;
|
||||||
@ -672,11 +656,6 @@ bool ImGui_ImplSDLGPU3_Init(ImGui_ImplSDLGPU3_InitInfo* info)
|
|||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplSDLGPU3_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplSDLGPU3_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplSDLGPU3_DrawCallback_SetSamplerNearest;
|
|
||||||
|
|
||||||
IM_ASSERT(info->Device != nullptr);
|
IM_ASSERT(info->Device != nullptr);
|
||||||
IM_ASSERT(info->ColorTargetFormat != SDL_GPU_TEXTUREFORMAT_INVALID);
|
IM_ASSERT(info->ColorTargetFormat != SDL_GPU_TEXTUREFORMAT_INVALID);
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'SDL_GPUTexture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef! **IMPORTANT** Before 2025/08/08, ImTextureID was a reference to a SDL_GPUTextureSamplerBinding struct.
|
// [X] Renderer: User texture binding. Use 'SDL_GPUTexture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef! **IMPORTANT** Before 2025/08/08, ImTextureID was a reference to a SDL_GPUTextureSamplerBinding struct.
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplSDLGPU3_GetRenderState().
|
|
||||||
|
|
||||||
// The aim of imgui_impl_sdlgpu3.h/.cpp is to be usable in your engine without any modification.
|
// The aim of imgui_impl_sdlgpu3.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/
|
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||||
@ -58,7 +57,9 @@ IMGUI_IMPL_API void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex);
|
|||||||
struct ImGui_ImplSDLGPU3_RenderState
|
struct ImGui_ImplSDLGPU3_RenderState
|
||||||
{
|
{
|
||||||
SDL_GPUDevice* Device;
|
SDL_GPUDevice* Device;
|
||||||
|
SDL_GPUSampler* SamplerLinear; // Bilinear filtering sampler
|
||||||
|
SDL_GPUSampler* SamplerNearest; // Nearest/point filtering sampler
|
||||||
|
SDL_GPUSampler* SamplerCurrent; // Current sampler (may be changed by callback)
|
||||||
};
|
};
|
||||||
IMGUI_IMPL_API ImGui_ImplSDLGPU3_RenderState* ImGui_ImplSDLGPU3_GetRenderState();
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@ -14,10 +14,8 @@
|
|||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
// Missing features or Issues:
|
|
||||||
// [ ] Renderer: Missing support for DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest callbacks: SDLRenderer2 does not support changing SDL_SCALE_MODE while rendering.
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can copy and 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// Learn about Dear ImGui:
|
// Learn about Dear ImGui:
|
||||||
// - FAQ https://dearimgui.com/faq
|
// - FAQ https://dearimgui.com/faq
|
||||||
@ -26,8 +24,6 @@
|
|||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
|
||||||
// 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState (others cannot be supported). (#9378)
|
|
||||||
// 2026-03-12: Fixed invalid assert in ImGui_ImplSDLRenderer2_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295)
|
// 2026-03-12: Fixed invalid assert in ImGui_ImplSDLRenderer2_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295)
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLRenderer2_CreateFontsTexture() and ImGui_ImplSDLRenderer2_DestroyFontsTexture().
|
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLRenderer2_CreateFontsTexture() and ImGui_ImplSDLRenderer2_DestroyFontsTexture().
|
||||||
@ -55,8 +51,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SDL
|
// SDL
|
||||||
#include <SDL_render.h>
|
#include <SDL.h>
|
||||||
#include <SDL_version.h>
|
|
||||||
#if !SDL_VERSION_ATLEAST(2,0,17)
|
#if !SDL_VERSION_ATLEAST(2,0,17)
|
||||||
#error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function
|
#error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function
|
||||||
#endif
|
#endif
|
||||||
@ -76,12 +71,42 @@ static ImGui_ImplSDLRenderer2_Data* ImGui_ImplSDLRenderer2_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer2_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer2_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer2_RenderState* ImGui_ImplSDLRenderer2_GetRenderState()
|
// Functions
|
||||||
|
bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
return (ImGui_ImplSDLRenderer2_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
||||||
|
|
||||||
|
// Setup backend capabilities flags
|
||||||
|
ImGui_ImplSDLRenderer2_Data* bd = IM_NEW(ImGui_ImplSDLRenderer2_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
|
io.BackendRendererName = "imgui_impl_sdlrenderer2";
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
|
bd->Renderer = renderer;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplSDLRenderer2_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
|
||||||
|
ImGui_ImplSDLRenderer2_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
io.BackendRendererName = nullptr;
|
||||||
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
||||||
|
platform_io.ClearRendererHandlers();
|
||||||
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
|
||||||
static void ImGui_ImplSDLRenderer2_SetupRenderState(SDL_Renderer* renderer)
|
static void ImGui_ImplSDLRenderer2_SetupRenderState(SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
// Clear out any viewports and cliprect set by the user
|
// Clear out any viewports and cliprect set by the user
|
||||||
@ -97,9 +122,6 @@ void ImGui_ImplSDLRenderer2_NewFrame()
|
|||||||
IM_UNUSED(bd);
|
IM_UNUSED(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplSDLRenderer2_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer)
|
void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
// If there's a scale factor set by the user, use that instead
|
// If there's a scale factor set by the user, use that instead
|
||||||
@ -162,7 +184,8 @@ void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
if (pcmd->UserCallback)
|
if (pcmd->UserCallback)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplSDLRenderer2_DrawCallback_ResetRenderState)
|
// (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_ImplSDLRenderer2_SetupRenderState(renderer);
|
ImGui_ImplSDLRenderer2_SetupRenderState(renderer);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -219,7 +242,8 @@ void ImGui_ImplSDLRenderer2_UpdateTexture(ImTextureData* tex)
|
|||||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
||||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
||||||
|
|
||||||
// Create texture (bilinear sampling is required)
|
// Create texture
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
SDL_Texture* sdl_texture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, tex->Width, tex->Height);
|
SDL_Texture* sdl_texture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, tex->Width, tex->Height);
|
||||||
IM_ASSERT(sdl_texture != nullptr && "Backend failed to create texture!");
|
IM_ASSERT(sdl_texture != nullptr && "Backend failed to create texture!");
|
||||||
SDL_UpdateTexture(sdl_texture, nullptr, tex->GetPixels(), tex->GetPitch());
|
SDL_UpdateTexture(sdl_texture, nullptr, tex->GetPixels(), tex->GetPitch());
|
||||||
@ -269,44 +293,6 @@ void ImGui_ImplSDLRenderer2_DestroyDeviceObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
|
||||||
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
|
||||||
ImGui_ImplSDLRenderer2_Data* bd = IM_NEW(ImGui_ImplSDLRenderer2_Data)();
|
|
||||||
io.BackendRendererUserData = (void*)bd;
|
|
||||||
io.BackendRendererName = "imgui_impl_sdlrenderer2";
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplSDLRenderer2_DrawCallback_ResetRenderState;
|
|
||||||
|
|
||||||
bd->Renderer = renderer;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer2_Shutdown()
|
|
||||||
{
|
|
||||||
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer2_DestroyDeviceObjects();
|
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
|
||||||
io.BackendRendererUserData = nullptr;
|
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
|
||||||
platform_io.ClearRendererHandlers();
|
|
||||||
IM_DELETE(bd);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
|||||||
@ -14,8 +14,6 @@
|
|||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
// Missing features or Issues:
|
|
||||||
// [ ] Renderer: Missing support for DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest callbacks: SDLRenderer2 does not support changing SDL_SCALE_MODE while rendering.
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -51,6 +49,5 @@ struct ImGui_ImplSDLRenderer2_RenderState
|
|||||||
{
|
{
|
||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
};
|
};
|
||||||
IMGUI_IMPL_API ImGui_ImplSDLRenderer2_RenderState* ImGui_ImplSDLRenderer2_GetRenderState();
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@ -13,9 +13,9 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplSDLRenderer3_GetRenderState().
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can copy and 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// Learn about Dear ImGui:
|
// Learn about Dear ImGui:
|
||||||
// - FAQ https://dearimgui.com/faq
|
// - FAQ https://dearimgui.com/faq
|
||||||
@ -24,10 +24,6 @@
|
|||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
|
||||||
// 2026-09-17: Restore modified texture scale modes at the end of RenderDrawData(). Added DrawCallback_SetSamplerFromTex support. Added CurrentScaleMode in ImGui_ImplSDLRenderer3_RenderState (#9543, #9378)
|
|
||||||
// 2026-07-15: Fixed default sampler state to be linear (broken 2026-04-23). (#9470, #9378)
|
|
||||||
// 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. (#9378)
|
|
||||||
// 2026-03-12: Fixed invalid assert in ImGui_ImplSDLRenderer3_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295)
|
// 2026-03-12: Fixed invalid assert in ImGui_ImplSDLRenderer3_UpdateTexture() if ImTextureID_Invalid is defined to be != 0, which became the default since 2026-03-12. (#9295)
|
||||||
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearRendererHandlers() on shutdown.
|
||||||
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLRenderer3_CreateFontsTexture() and ImGui_ImplSDLRenderer3_DestroyFontsTexture().
|
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLRenderer3_CreateFontsTexture() and ImGui_ImplSDLRenderer3_DestroyFontsTexture().
|
||||||
@ -52,24 +48,16 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SDL
|
// SDL
|
||||||
#include <SDL3/SDL_render.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL3/SDL_version.h>
|
|
||||||
#if !SDL_VERSION_ATLEAST(3,0,0)
|
#if !SDL_VERSION_ATLEAST(3,0,0)
|
||||||
#error This backend requires SDL 3.0.0+
|
#error This backend requires SDL 3.0.0+
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SDL_Renderer data
|
// SDL_Renderer data
|
||||||
struct ImGui_ImplSDLRenderer3_TexScaleModeEntry
|
|
||||||
{
|
|
||||||
SDL_Texture* Texture;
|
|
||||||
SDL_ScaleMode ScaleModeBackup;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ImGui_ImplSDLRenderer3_Data
|
struct ImGui_ImplSDLRenderer3_Data
|
||||||
{
|
{
|
||||||
SDL_Renderer* Renderer; // Main viewport's renderer
|
SDL_Renderer* Renderer; // Main viewport's renderer
|
||||||
ImVector<SDL_FColor> ColorBuffer;
|
ImVector<SDL_FColor> ColorBuffer;
|
||||||
ImVector<ImGui_ImplSDLRenderer3_TexScaleModeEntry> TexScaleModeBackups; // Backup of texture scale modes
|
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@ -81,21 +69,48 @@ static ImGui_ImplSDLRenderer3_Data* ImGui_ImplSDLRenderer3_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer3_RenderState* ImGui_ImplSDLRenderer3_GetRenderState()
|
// Functions
|
||||||
|
bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
return (ImGui_ImplSDLRenderer3_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
||||||
|
|
||||||
|
// Setup backend capabilities flags
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = IM_NEW(ImGui_ImplSDLRenderer3_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
|
io.BackendRendererName = "imgui_impl_sdlrenderer3";
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
|
bd->Renderer = renderer;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplSDLRenderer3_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
|
||||||
|
ImGui_ImplSDLRenderer3_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
io.BackendRendererName = nullptr;
|
||||||
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
||||||
|
platform_io.ClearRendererHandlers();
|
||||||
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
|
||||||
static void ImGui_ImplSDLRenderer3_SetupRenderState(SDL_Renderer* renderer)
|
static void ImGui_ImplSDLRenderer3_SetupRenderState(SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLRenderer3_RenderState* render_state = ImGui_ImplSDLRenderer3_GetRenderState();
|
|
||||||
|
|
||||||
// Clear out any viewports and cliprect set by the user
|
// Clear out any viewports and cliprect set by the user
|
||||||
// FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process.
|
// FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process.
|
||||||
SDL_SetRenderViewport(renderer, nullptr);
|
SDL_SetRenderViewport(renderer, nullptr);
|
||||||
SDL_SetRenderClipRect(renderer, nullptr);
|
SDL_SetRenderClipRect(renderer, nullptr);
|
||||||
render_state->CurrentScaleMode = SDL_SCALEMODE_LINEAR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer3_NewFrame()
|
void ImGui_ImplSDLRenderer3_NewFrame()
|
||||||
@ -123,64 +138,6 @@ static int SDL_RenderGeometryRaw8BitColor(SDL_Renderer* renderer, ImVector<SDL_F
|
|||||||
return SDL_RenderGeometryRaw(renderer, texture, xy, xy_stride, color3, sizeof(*color3), uv, uv_stride, num_vertices, indices, num_indices, size_indices);
|
return SDL_RenderGeometryRaw(renderer, texture, xy, xy_stride, color3, sizeof(*color3), uv, uv_stride, num_vertices, indices, num_indices, size_indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplSDLRenderer3_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplSDLRenderer3_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplSDLRenderer3_RenderState* render_state = ImGui_ImplSDLRenderer3_GetRenderState(); render_state->CurrentScaleMode = SDL_SCALEMODE_LINEAR; }
|
|
||||||
static void ImGui_ImplSDLRenderer3_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplSDLRenderer3_RenderState* render_state = ImGui_ImplSDLRenderer3_GetRenderState(); render_state->CurrentScaleMode = SDL_SCALEMODE_NEAREST; }
|
|
||||||
static void ImGui_ImplSDLRenderer3_DrawCallback_SetSamplerFromTex(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplSDLRenderer3_RenderState* render_state = ImGui_ImplSDLRenderer3_GetRenderState(); render_state->CurrentScaleMode = SDL_SCALEMODE_INVALID; } // SDL_SCALEMODE_INVALID = use/keep value in texture.
|
|
||||||
|
|
||||||
// SDLRenderer has various design issues which makes it hard to do it compared to regular graphics API.
|
|
||||||
// - scale/filtering mode is tied to a texture.
|
|
||||||
// - scale/filtering mode is not queued as part of the SDL_RenderGeometryXXX commands, so a change in one texture requires a flush.
|
|
||||||
static void ImGui_ImplSDLRenderer3_TexScaleModeUpdate(SDL_Renderer* renderer, SDL_Texture* tex, SDL_ScaleMode desired_scale_mode)
|
|
||||||
{
|
|
||||||
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
|
||||||
if (desired_scale_mode != SDL_SCALEMODE_INVALID)
|
|
||||||
{
|
|
||||||
// Enforce a scale mode
|
|
||||||
SDL_ScaleMode tex_scale_mode = desired_scale_mode;
|
|
||||||
if (!SDL_GetTextureScaleMode(tex, &tex_scale_mode) || tex_scale_mode == desired_scale_mode)
|
|
||||||
return;
|
|
||||||
SDL_FlushRenderer(renderer);
|
|
||||||
SDL_SetTextureScaleMode(tex, desired_scale_mode);
|
|
||||||
|
|
||||||
// Store backup of old scale mode (FIXME-OPT)
|
|
||||||
for (ImGui_ImplSDLRenderer3_TexScaleModeEntry& entry : bd->TexScaleModeBackups)
|
|
||||||
if (entry.Texture == tex)
|
|
||||||
{
|
|
||||||
if (entry.ScaleModeBackup == SDL_SCALEMODE_INVALID)
|
|
||||||
entry.ScaleModeBackup = tex_scale_mode;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ImGui_ImplSDLRenderer3_TexScaleModeEntry entry = { tex, tex_scale_mode };
|
|
||||||
bd->TexScaleModeBackups.push_back(entry);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Use scale mode that was set in texture by user. If there is an entry, restore it and clear the entry.
|
|
||||||
for (ImGui_ImplSDLRenderer3_TexScaleModeEntry& entry : bd->TexScaleModeBackups)
|
|
||||||
if (entry.Texture == tex && entry.ScaleModeBackup != SDL_SCALEMODE_INVALID)
|
|
||||||
{
|
|
||||||
SDL_FlushRenderer(renderer);
|
|
||||||
SDL_SetTextureScaleMode(tex, entry.ScaleModeBackup);
|
|
||||||
entry.ScaleModeBackup = SDL_SCALEMODE_INVALID;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplSDLRenderer3_TexScaleModeRestoreBackups(SDL_Renderer* renderer)
|
|
||||||
{
|
|
||||||
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
|
||||||
if (bd->TexScaleModeBackups.Size == 0)
|
|
||||||
return;
|
|
||||||
SDL_FlushRenderer(renderer);
|
|
||||||
for (ImGui_ImplSDLRenderer3_TexScaleModeEntry& entry : bd->TexScaleModeBackups)
|
|
||||||
if (entry.ScaleModeBackup != SDL_SCALEMODE_INVALID)
|
|
||||||
SDL_SetTextureScaleMode(entry.Texture, entry.ScaleModeBackup);
|
|
||||||
bd->TexScaleModeBackups.resize(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer)
|
void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
@ -222,16 +179,15 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
SDL_GetRenderViewport(renderer, &old.Viewport);
|
SDL_GetRenderViewport(renderer, &old.Viewport);
|
||||||
SDL_GetRenderClipRect(renderer, &old.ClipRect);
|
SDL_GetRenderClipRect(renderer, &old.ClipRect);
|
||||||
|
|
||||||
|
// Setup desired state
|
||||||
|
ImGui_ImplSDLRenderer3_SetupRenderState(renderer);
|
||||||
|
|
||||||
// Setup render state structure (for callbacks and custom texture bindings)
|
// Setup render state structure (for callbacks and custom texture bindings)
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
ImGui_ImplSDLRenderer3_RenderState render_state;
|
ImGui_ImplSDLRenderer3_RenderState render_state;
|
||||||
render_state.Renderer = renderer;
|
render_state.Renderer = renderer;
|
||||||
platform_io.Renderer_RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
// Setup desired state
|
|
||||||
ImGui_ImplSDLRenderer3_SetupRenderState(renderer);
|
|
||||||
IM_ASSERT(bd->TexScaleModeBackups.Size == 0);
|
|
||||||
|
|
||||||
// Will project scissor/clipping rectangles into framebuffer space
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
ImVec2 clip_scale = render_scale;
|
ImVec2 clip_scale = render_scale;
|
||||||
@ -248,7 +204,8 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
if (pcmd->UserCallback)
|
if (pcmd->UserCallback)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplSDLRenderer3_DrawCallback_ResetRenderState)
|
// (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_ImplSDLRenderer3_SetupRenderState(renderer);
|
ImGui_ImplSDLRenderer3_SetupRenderState(renderer);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -264,17 +221,16 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
if (clip_max.y > (float)fb_height) { clip_max.y = (float)fb_height; }
|
if (clip_max.y > (float)fb_height) { clip_max.y = (float)fb_height; }
|
||||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) };
|
SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) };
|
||||||
SDL_SetRenderClipRect(renderer, &r);
|
SDL_SetRenderClipRect(renderer, &r);
|
||||||
|
|
||||||
// Setup texture scale/filtering mode
|
|
||||||
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
|
||||||
ImGui_ImplSDLRenderer3_TexScaleModeUpdate(renderer, tex, render_state.CurrentScaleMode);
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
||||||
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
||||||
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col));
|
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.19+
|
||||||
|
|
||||||
|
// Bind texture, Draw
|
||||||
|
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
||||||
SDL_RenderGeometryRaw8BitColor(renderer, bd->ColorBuffer, tex,
|
SDL_RenderGeometryRaw8BitColor(renderer, bd->ColorBuffer, tex,
|
||||||
xy, (int)sizeof(ImDrawVert),
|
xy, (int)sizeof(ImDrawVert),
|
||||||
color, (int)sizeof(ImDrawVert),
|
color, (int)sizeof(ImDrawVert),
|
||||||
@ -289,7 +245,6 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
// Restore modified SDL_Renderer state
|
// Restore modified SDL_Renderer state
|
||||||
SDL_SetRenderViewport(renderer, old.ViewportEnabled ? &old.Viewport : nullptr);
|
SDL_SetRenderViewport(renderer, old.ViewportEnabled ? &old.Viewport : nullptr);
|
||||||
SDL_SetRenderClipRect(renderer, old.ClipEnabled ? &old.ClipRect : nullptr);
|
SDL_SetRenderClipRect(renderer, old.ClipEnabled ? &old.ClipRect : nullptr);
|
||||||
ImGui_ImplSDLRenderer3_TexScaleModeRestoreBackups(renderer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer3_UpdateTexture(ImTextureData* tex)
|
void ImGui_ImplSDLRenderer3_UpdateTexture(ImTextureData* tex)
|
||||||
@ -303,7 +258,8 @@ void ImGui_ImplSDLRenderer3_UpdateTexture(ImTextureData* tex)
|
|||||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
||||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
||||||
|
|
||||||
// Create texture (bilinear sampling is required)
|
// Create texture
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
SDL_Texture* sdl_texture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, tex->Width, tex->Height);
|
SDL_Texture* sdl_texture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, tex->Width, tex->Height);
|
||||||
IM_ASSERT(sdl_texture != nullptr && "Backend failed to create texture!");
|
IM_ASSERT(sdl_texture != nullptr && "Backend failed to create texture!");
|
||||||
SDL_UpdateTexture(sdl_texture, nullptr, tex->GetPixels(), tex->GetPitch());
|
SDL_UpdateTexture(sdl_texture, nullptr, tex->GetPixels(), tex->GetPitch());
|
||||||
@ -353,47 +309,6 @@ void ImGui_ImplSDLRenderer3_DestroyDeviceObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
|
||||||
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
|
||||||
ImGui_ImplSDLRenderer3_Data* bd = IM_NEW(ImGui_ImplSDLRenderer3_Data)();
|
|
||||||
io.BackendRendererUserData = (void*)bd;
|
|
||||||
io.BackendRendererName = "imgui_impl_sdlrenderer3";
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplSDLRenderer3_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplSDLRenderer3_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplSDLRenderer3_DrawCallback_SetSamplerNearest;
|
|
||||||
platform_io.DrawCallback_SetSamplerFromTex = ImGui_ImplSDLRenderer3_DrawCallback_SetSamplerFromTex;
|
|
||||||
|
|
||||||
bd->Renderer = renderer;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer3_Shutdown()
|
|
||||||
{
|
|
||||||
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer3_DestroyDeviceObjects();
|
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
|
||||||
io.BackendRendererUserData = nullptr;
|
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures);
|
|
||||||
platform_io.ClearRendererHandlers();
|
|
||||||
IM_DELETE(bd);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
|||||||
@ -13,9 +13,9 @@
|
|||||||
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplSDLRenderer3_GetRenderState().
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can copy and 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// Learn about Dear ImGui:
|
// Learn about Dear ImGui:
|
||||||
// - FAQ https://dearimgui.com/faq
|
// - FAQ https://dearimgui.com/faq
|
||||||
@ -27,8 +27,7 @@
|
|||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
#ifndef IMGUI_DISABLE
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
// For SDL_ScaleMode which cannot be forward declared.
|
struct SDL_Renderer;
|
||||||
#include <SDL3/SDL_render.h>
|
|
||||||
|
|
||||||
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer);
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer);
|
||||||
@ -49,8 +48,6 @@ IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_UpdateTexture(ImTextureData* tex)
|
|||||||
struct ImGui_ImplSDLRenderer3_RenderState
|
struct ImGui_ImplSDLRenderer3_RenderState
|
||||||
{
|
{
|
||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
SDL_ScaleMode CurrentScaleMode; // Current scale mode during render. Set to SDL_SCALEMODE_INVALID to use "SetSamplerFromTex" mode.
|
|
||||||
};
|
};
|
||||||
IMGUI_IMPL_API ImGui_ImplSDLRenderer3_RenderState* ImGui_ImplSDLRenderer3_GetRenderState();
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@ -2,10 +2,10 @@
|
|||||||
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [!] Renderer: User texture binding. Use a VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE 'VkDescriptorSet' as texture identifier. Call ImGui_ImplVulkan_AddTexture() to register one. Read the FAQ about ImTextureID/ImTextureRef + https://github.com/ocornut/imgui/pull/914 for discussions.
|
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as texture identifier. Call ImGui_ImplVulkan_AddTexture() to register one. Read the FAQ about ImTextureID/ImTextureRef + https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplVulkan_GetRenderState().
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
|
|
||||||
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
|
// 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/
|
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||||
@ -27,19 +27,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-10-06: Added support for dynamic rendering with multiple color attachments (PipelineRenderingCreateInfo.colorAttachmentCount > 1): we render to the first one and leave the others untouched. (#9574)
|
|
||||||
// 2026-09-07: Round framebuffer dimensions to the nearest integer instead of truncating them. (#9538, 9515, #8628)
|
|
||||||
// 2026-09-03: Added for support for multiple Vulkan contexts with custom loaders. (#6616)
|
|
||||||
// 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. (#9378)
|
|
||||||
// 2026-04-22: *BREAKING CHANGE* redesigned to use separate ImageView + Sampler instead of Combined Image Sampler. This change allows us to facilitate changing samplers, in line with other backends.
|
|
||||||
// - When registering custom textures: changed ImGui_ImplVulkan_AddTexture() signature to remove Sampler.
|
|
||||||
// - Before: ImGui_ImplVulkan_AddTexture(VkSampler, VkImageView, VkImageLayout)
|
|
||||||
// - After: ImGui_ImplVulkan_AddTexture(VkImageView, VkImageLayout)
|
|
||||||
// - Kept inline redirection function that ignores the sampler.
|
|
||||||
// - When creating your own descriptor pool (instead of letting backend creates its own):
|
|
||||||
// - Before: need at least IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE descriptors of type VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER.
|
|
||||||
// - After: need at least IMGUI_IMPL_VULKAN_MINIMUM_SAMPLED_IMAGE_POOL_SIZE descriptors of type VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE.
|
|
||||||
// + IMGUI_IMPL_VULKAN_MINIMUM_SAMPLER_POOL_SIZE descriptors of type VK_DESCRIPTOR_TYPE_SAMPLER.
|
|
||||||
// 2026-03-11: Vulkan: Added ImGui_ImplVulkan_PipelineInfo::ExtraDynamicStates[] to allow specifying extra dynamic states to add when creating the VkPipeline. (#9211)
|
// 2026-03-11: Vulkan: Added ImGui_ImplVulkan_PipelineInfo::ExtraDynamicStates[] to allow specifying extra dynamic states to add when creating the VkPipeline. (#9211)
|
||||||
// 2025-09-26: [Helpers] *BREAKING CHANGE*: Vulkan: Helper ImGui_ImplVulkanH_DestroyWindow() does not call vkDestroySurfaceKHR(): as surface is created by caller of ImGui_ImplVulkanH_CreateOrResizeWindow(), it is more consistent that we don't destroy it. (#9163)
|
// 2025-09-26: [Helpers] *BREAKING CHANGE*: Vulkan: Helper ImGui_ImplVulkanH_DestroyWindow() does not call vkDestroySurfaceKHR(): as surface is created by caller of ImGui_ImplVulkanH_CreateOrResizeWindow(), it is more consistent that we don't destroy it. (#9163)
|
||||||
// 2026-01-05: [Helpers] *BREAKING CHANGE*: Vulkan: Helper for creating render pass uses ImGui_ImplVulkanH_Window::AttachmentDesc to create render pass. Removed ClearEnabled. (#9152)
|
// 2026-01-05: [Helpers] *BREAKING CHANGE*: Vulkan: Helper for creating render pass uses ImGui_ImplVulkanH_Window::AttachmentDesc to create render pass. Removed ClearEnabled. (#9152)
|
||||||
@ -233,28 +220,10 @@ static bool g_FunctionsLoaded = true;
|
|||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUpdateDescriptorSets) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUpdateDescriptorSets) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkWaitForFences)
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkWaitForFences)
|
||||||
|
|
||||||
struct ImGui_ImplVulkan_Functions
|
|
||||||
{
|
|
||||||
// Define function pointers
|
// Define function pointers
|
||||||
#define IMGUI_VULKAN_FUNC_DEF(func) PFN_##func pfn_##func;
|
#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func;
|
||||||
IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_DEF)
|
IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_DEF)
|
||||||
#undef IMGUI_VULKAN_FUNC_DEF
|
#undef IMGUI_VULKAN_FUNC_DEF
|
||||||
};
|
|
||||||
|
|
||||||
// Globally available function pointers used for initialization of the backend data
|
|
||||||
static ImGui_ImplVulkan_Functions ImGuiImplVulkanFuncs;
|
|
||||||
|
|
||||||
// Multi Vulkan contexts support: wrap each Vulkan function pointer to properly dispatch it using the current backend data
|
|
||||||
static ImGui_ImplVulkan_Functions& ImGui_ImplVulkan_GetFunctions();
|
|
||||||
#define IMGUI_VULKAN_FUNC_WRAPPER(func) \
|
|
||||||
template<typename... Args> \
|
|
||||||
auto func(Args&&... args) -> decltype(ImGui_ImplVulkan_GetFunctions().pfn_##func(args...)) \
|
|
||||||
{ \
|
|
||||||
return ImGui_ImplVulkan_GetFunctions().pfn_##func(args...); \
|
|
||||||
}
|
|
||||||
IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_WRAPPER)
|
|
||||||
#undef IMGUI_VULKAN_FUNC_WRAPPER
|
|
||||||
|
|
||||||
#endif // IMGUI_IMPL_VULKAN_USE_LOADER
|
#endif // IMGUI_IMPL_VULKAN_USE_LOADER
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
@ -297,12 +266,10 @@ struct ImGui_ImplVulkan_Texture
|
|||||||
struct ImGui_ImplVulkan_Data
|
struct ImGui_ImplVulkan_Data
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_InitInfo VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo VulkanInitInfo;
|
||||||
ImGui_ImplVulkan_RenderState* RenderState; // == ImGui::GetPlatformIO().Renderer_RenderState during rendering.
|
|
||||||
VkDeviceSize BufferMemoryAlignment;
|
VkDeviceSize BufferMemoryAlignment;
|
||||||
VkDeviceSize NonCoherentAtomSize;
|
VkDeviceSize NonCoherentAtomSize;
|
||||||
VkPipelineCreateFlags PipelineCreateFlags;
|
VkPipelineCreateFlags PipelineCreateFlags;
|
||||||
VkDescriptorSetLayout DescriptorSetLayoutTexture;
|
VkDescriptorSetLayout DescriptorSetLayout;
|
||||||
VkDescriptorSetLayout DescriptorSetLayoutSampler;
|
|
||||||
VkPipelineLayout PipelineLayout;
|
VkPipelineLayout PipelineLayout;
|
||||||
VkPipeline Pipeline; // pipeline for main render pass (created by app)
|
VkPipeline Pipeline; // pipeline for main render pass (created by app)
|
||||||
VkShaderModule ShaderModuleVert;
|
VkShaderModule ShaderModuleVert;
|
||||||
@ -311,21 +278,13 @@ struct ImGui_ImplVulkan_Data
|
|||||||
ImVector<VkFormat> PipelineRenderingCreateInfoColorAttachmentFormats; // Deep copy of format array
|
ImVector<VkFormat> PipelineRenderingCreateInfoColorAttachmentFormats; // Deep copy of format array
|
||||||
|
|
||||||
// Texture management
|
// Texture management
|
||||||
VkSampler SamplerLinear;
|
VkSampler TexSamplerLinear;
|
||||||
VkSampler SamplerNearest;
|
|
||||||
VkDescriptorSet SamplerLinearDS;
|
|
||||||
VkDescriptorSet SamplerNearestDS;
|
|
||||||
VkCommandPool TexCommandPool;
|
VkCommandPool TexCommandPool;
|
||||||
VkCommandBuffer TexCommandBuffer;
|
VkCommandBuffer TexCommandBuffer;
|
||||||
|
|
||||||
// Render buffers for main window
|
// Render buffers for main window
|
||||||
ImGui_ImplVulkan_WindowRenderBuffers MainWindowRenderBuffers;
|
ImGui_ImplVulkan_WindowRenderBuffers MainWindowRenderBuffers;
|
||||||
|
|
||||||
// Vulkan function pointers loaded for this context
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
|
|
||||||
ImGui_ImplVulkan_Functions Functions;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ImGui_ImplVulkan_Data()
|
ImGui_ImplVulkan_Data()
|
||||||
{
|
{
|
||||||
memset((void*)this, 0, sizeof(*this));
|
memset((void*)this, 0, sizeof(*this));
|
||||||
@ -359,7 +318,7 @@ void main()
|
|||||||
*/
|
*/
|
||||||
static uint32_t __glsl_shader_vert_spv[] =
|
static uint32_t __glsl_shader_vert_spv[] =
|
||||||
{
|
{
|
||||||
0x07230203,0x00010000,0x0008000b,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x00080001,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||||
0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015,
|
0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015,
|
||||||
0x0000001b,0x0000001c,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
|
0x0000001b,0x0000001c,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
|
||||||
@ -372,10 +331,10 @@ static uint32_t __glsl_shader_vert_spv[] =
|
|||||||
0x00050006,0x0000001e,0x00000000,0x61635375,0x0000656c,0x00060006,0x0000001e,0x00000001,
|
0x00050006,0x0000001e,0x00000000,0x61635375,0x0000656c,0x00060006,0x0000001e,0x00000001,
|
||||||
0x61725475,0x616c736e,0x00006574,0x00030005,0x00000020,0x00006370,0x00040047,0x0000000b,
|
0x61725475,0x616c736e,0x00006574,0x00030005,0x00000020,0x00006370,0x00040047,0x0000000b,
|
||||||
0x0000001e,0x00000000,0x00040047,0x0000000f,0x0000001e,0x00000002,0x00040047,0x00000015,
|
0x0000001e,0x00000000,0x00040047,0x0000000f,0x0000001e,0x00000002,0x00040047,0x00000015,
|
||||||
0x0000001e,0x00000001,0x00030047,0x00000019,0x00000002,0x00050048,0x00000019,0x00000000,
|
0x0000001e,0x00000001,0x00050048,0x00000019,0x00000000,0x0000000b,0x00000000,0x00030047,
|
||||||
0x0000000b,0x00000000,0x00040047,0x0000001c,0x0000001e,0x00000000,0x00030047,0x0000001e,
|
0x00000019,0x00000002,0x00040047,0x0000001c,0x0000001e,0x00000000,0x00050048,0x0000001e,
|
||||||
0x00000002,0x00050048,0x0000001e,0x00000000,0x00000023,0x00000000,0x00050048,0x0000001e,
|
0x00000000,0x00000023,0x00000000,0x00050048,0x0000001e,0x00000001,0x00000023,0x00000008,
|
||||||
0x00000001,0x00000023,0x00000008,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,
|
0x00030047,0x0000001e,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,
|
||||||
0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040017,
|
0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040017,
|
||||||
0x00000008,0x00000006,0x00000002,0x0004001e,0x00000009,0x00000007,0x00000008,0x00040020,
|
0x00000008,0x00000006,0x00000002,0x0004001e,0x00000009,0x00000007,0x00000008,0x00040020,
|
||||||
0x0000000a,0x00000003,0x00000009,0x0004003b,0x0000000a,0x0000000b,0x00000003,0x00040015,
|
0x0000000a,0x00000003,0x00000009,0x0004003b,0x0000000a,0x0000000b,0x00000003,0x00040015,
|
||||||
@ -407,44 +366,39 @@ static uint32_t __glsl_shader_vert_spv[] =
|
|||||||
/*
|
/*
|
||||||
#version 450 core
|
#version 450 core
|
||||||
layout(location = 0) out vec4 fColor;
|
layout(location = 0) out vec4 fColor;
|
||||||
layout(set=0, binding=0) uniform texture2D _Texture;
|
layout(set=0, binding=0) uniform sampler2D sTexture;
|
||||||
layout(set=1, binding=0) uniform sampler _Sampler;
|
|
||||||
layout(location = 0) in struct { vec4 Color; vec2 UV; } In;
|
layout(location = 0) in struct { vec4 Color; vec2 UV; } In;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
fColor = In.Color * texture(sampler2D(_Texture, _Sampler), In.UV.st);
|
fColor = In.Color * texture(sTexture, In.UV.st);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
static uint32_t __glsl_shader_frag_spv[] =
|
static uint32_t __glsl_shader_frag_spv[] =
|
||||||
{
|
{
|
||||||
0x07230203,0x00010000,0x0008000b,0x00000023,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||||
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000d,0x00030010,
|
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000d,0x00030010,
|
||||||
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
|
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
|
||||||
0x00000000,0x00040005,0x00000009,0x6c6f4366,0x0000726f,0x00030005,0x0000000b,0x00000000,
|
0x00000000,0x00040005,0x00000009,0x6c6f4366,0x0000726f,0x00030005,0x0000000b,0x00000000,
|
||||||
0x00050006,0x0000000b,0x00000000,0x6f6c6f43,0x00000072,0x00040006,0x0000000b,0x00000001,
|
0x00050006,0x0000000b,0x00000000,0x6f6c6f43,0x00000072,0x00040006,0x0000000b,0x00000001,
|
||||||
0x00005655,0x00030005,0x0000000d,0x00006e49,0x00050005,0x00000015,0x7865545f,0x65727574,
|
0x00005655,0x00030005,0x0000000d,0x00006e49,0x00050005,0x00000016,0x78655473,0x65727574,
|
||||||
0x00000000,0x00050005,0x00000019,0x6d61535f,0x72656c70,0x00000000,0x00040047,0x00000009,
|
0x00000000,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x0000001e,
|
||||||
0x0000001e,0x00000000,0x00040047,0x0000000d,0x0000001e,0x00000000,0x00040047,0x00000015,
|
0x00000000,0x00040047,0x00000016,0x00000022,0x00000000,0x00040047,0x00000016,0x00000021,
|
||||||
0x00000021,0x00000000,0x00040047,0x00000015,0x00000022,0x00000000,0x00040047,0x00000019,
|
0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
|
||||||
0x00000021,0x00000000,0x00040047,0x00000019,0x00000022,0x00000001,0x00020013,0x00000002,
|
0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,
|
||||||
0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,
|
0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040017,0x0000000a,0x00000006,
|
||||||
0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,0x00000007,0x0004003b,0x00000008,
|
0x00000002,0x0004001e,0x0000000b,0x00000007,0x0000000a,0x00040020,0x0000000c,0x00000001,
|
||||||
0x00000009,0x00000003,0x00040017,0x0000000a,0x00000006,0x00000002,0x0004001e,0x0000000b,
|
0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040015,0x0000000e,0x00000020,
|
||||||
0x00000007,0x0000000a,0x00040020,0x0000000c,0x00000001,0x0000000b,0x0004003b,0x0000000c,
|
0x00000001,0x0004002b,0x0000000e,0x0000000f,0x00000000,0x00040020,0x00000010,0x00000001,
|
||||||
0x0000000d,0x00000001,0x00040015,0x0000000e,0x00000020,0x00000001,0x0004002b,0x0000000e,
|
0x00000007,0x00090019,0x00000013,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,
|
||||||
0x0000000f,0x00000000,0x00040020,0x00000010,0x00000001,0x00000007,0x00090019,0x00000013,
|
0x00000001,0x00000000,0x0003001b,0x00000014,0x00000013,0x00040020,0x00000015,0x00000000,
|
||||||
0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x00040020,
|
0x00000014,0x0004003b,0x00000015,0x00000016,0x00000000,0x0004002b,0x0000000e,0x00000018,
|
||||||
0x00000014,0x00000000,0x00000013,0x0004003b,0x00000014,0x00000015,0x00000000,0x0002001a,
|
0x00000001,0x00040020,0x00000019,0x00000001,0x0000000a,0x00050036,0x00000002,0x00000004,
|
||||||
0x00000017,0x00040020,0x00000018,0x00000000,0x00000017,0x0004003b,0x00000018,0x00000019,
|
0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000010,0x00000011,0x0000000d,
|
||||||
0x00000000,0x0003001b,0x0000001b,0x00000013,0x0004002b,0x0000000e,0x0000001d,0x00000001,
|
0x0000000f,0x0004003d,0x00000007,0x00000012,0x00000011,0x0004003d,0x00000014,0x00000017,
|
||||||
0x00040020,0x0000001e,0x00000001,0x0000000a,0x00050036,0x00000002,0x00000004,0x00000000,
|
0x00000016,0x00050041,0x00000019,0x0000001a,0x0000000d,0x00000018,0x0004003d,0x0000000a,
|
||||||
0x00000003,0x000200f8,0x00000005,0x00050041,0x00000010,0x00000011,0x0000000d,0x0000000f,
|
0x0000001b,0x0000001a,0x00050057,0x00000007,0x0000001c,0x00000017,0x0000001b,0x00050085,
|
||||||
0x0004003d,0x00000007,0x00000012,0x00000011,0x0004003d,0x00000013,0x00000016,0x00000015,
|
0x00000007,0x0000001d,0x00000012,0x0000001c,0x0003003e,0x00000009,0x0000001d,0x000100fd,
|
||||||
0x0004003d,0x00000017,0x0000001a,0x00000019,0x00050056,0x0000001b,0x0000001c,0x00000016,
|
|
||||||
0x0000001a,0x00050041,0x0000001e,0x0000001f,0x0000000d,0x0000001d,0x0004003d,0x0000000a,
|
|
||||||
0x00000020,0x0000001f,0x00050057,0x00000007,0x00000021,0x0000001c,0x00000020,0x00050085,
|
|
||||||
0x00000007,0x00000022,0x00000012,0x00000021,0x0003003e,0x00000009,0x00000022,0x000100fd,
|
|
||||||
0x00010038
|
0x00010038
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -460,21 +414,6 @@ static ImGui_ImplVulkan_Data* ImGui_ImplVulkan_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplVulkan_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplVulkan_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplVulkan_RenderState* ImGui_ImplVulkan_GetRenderState()
|
|
||||||
{
|
|
||||||
return (ImGui_ImplVulkan_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
|
|
||||||
// Get the Vulkan function pointers used by the current backend.
|
|
||||||
// If no backend is available, return the currently loaded global function pointers (ImGuiImplVulkanFuncs).
|
|
||||||
static ImGui_ImplVulkan_Functions& ImGui_ImplVulkan_GetFunctions()
|
|
||||||
{
|
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
|
||||||
return bd ? bd->Functions : ImGuiImplVulkanFuncs;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint32_t ImGui_ImplVulkan_MemoryType(VkMemoryPropertyFlags properties, uint32_t type_bits)
|
static uint32_t ImGui_ImplVulkan_MemoryType(VkMemoryPropertyFlags properties, uint32_t type_bits)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
@ -542,7 +481,9 @@ static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline
|
|||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
|
||||||
// Bind pipeline:
|
// Bind pipeline:
|
||||||
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
{
|
||||||
|
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||||
|
}
|
||||||
|
|
||||||
// Bind Vertex And Index Buffer:
|
// Bind Vertex And Index Buffer:
|
||||||
if (draw_data->TotalVtxCount > 0)
|
if (draw_data->TotalVtxCount > 0)
|
||||||
@ -554,48 +495,35 @@ static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup viewport:
|
// Setup viewport:
|
||||||
VkViewport viewport;
|
{
|
||||||
viewport.x = 0;
|
VkViewport viewport;
|
||||||
viewport.y = 0;
|
viewport.x = 0;
|
||||||
viewport.width = (float)fb_width;
|
viewport.y = 0;
|
||||||
viewport.height = (float)fb_height;
|
viewport.width = (float)fb_width;
|
||||||
viewport.minDepth = 0.0f;
|
viewport.height = (float)fb_height;
|
||||||
viewport.maxDepth = 1.0f;
|
viewport.minDepth = 0.0f;
|
||||||
vkCmdSetViewport(command_buffer, 0, 1, &viewport);
|
viewport.maxDepth = 1.0f;
|
||||||
|
vkCmdSetViewport(command_buffer, 0, 1, &viewport);
|
||||||
|
}
|
||||||
|
|
||||||
// Setup scale and translation:
|
// 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.
|
// 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 constants[4];
|
{
|
||||||
constants[0] = 2.0f / draw_data->DisplaySize.x; // Scale
|
float constants[4];
|
||||||
constants[1] = 2.0f / draw_data->DisplaySize.y;
|
constants[0] = 2.0f / draw_data->DisplaySize.x; // Scale
|
||||||
constants[2] = -1.0f - draw_data->DisplayPos.x * constants[0]; // Translate
|
constants[1] = 2.0f / draw_data->DisplaySize.y;
|
||||||
constants[3] = -1.0f - draw_data->DisplayPos.y * constants[1];
|
constants[2] = -1.0f - draw_data->DisplayPos.x * constants[0]; // Translate
|
||||||
vkCmdPushConstants(command_buffer, bd->PipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, (uint32_t)sizeof(float) * 4, constants);
|
constants[3] = -1.0f - draw_data->DisplayPos.y * constants[1];
|
||||||
|
vkCmdPushConstants(command_buffer, bd->PipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(float) * 4, constants);
|
||||||
// Setup sampler
|
}
|
||||||
vkCmdBindDescriptorSets(bd->RenderState->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 1, 1, &bd->SamplerLinearDS, 0, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplVulkan_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplVulkan_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); vkCmdBindDescriptorSets(bd->RenderState->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->RenderState->PipelineLayout, 1, 1, &bd->SamplerLinearDS, 0, nullptr); }
|
|
||||||
static void ImGui_ImplVulkan_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); vkCmdBindDescriptorSets(bd->RenderState->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->RenderState->PipelineLayout, 1, 1, &bd->SamplerNearestDS, 0, nullptr); }
|
|
||||||
|
|
||||||
// If you want to use your own sampler, you can create your own callback, access ImGui_ImplVulkan_RenderState for command-buffer and pipeline layout, e.g.
|
|
||||||
/*
|
|
||||||
void ImGui_ImplVulkan_DrawCallback_SetSamplerCustom(const ImDrawList*, const ImDrawCmd* cmd)
|
|
||||||
{
|
|
||||||
ImGui_ImplVulkan_RenderState* render_state = (ImGui_ImplVulkan_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
|
||||||
vkCmdBindDescriptorSets(render_state->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, render_state->PipelineLayout, 1, 1, (VkDescriptorSet*)cmd->UserCallbackData, 0, nullptr);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Render function
|
// Render function
|
||||||
void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline)
|
void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// 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 + 0.5f);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0)
|
if (fb_width <= 0 || fb_height <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -661,16 +589,16 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
vkUnmapMemory(v->Device, rb->IndexBufferMemory);
|
vkUnmapMemory(v->Device, rb->IndexBufferMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setup desired Vulkan state
|
||||||
|
ImGui_ImplVulkan_SetupRenderState(draw_data, pipeline, command_buffer, rb, fb_width, fb_height);
|
||||||
|
|
||||||
// Setup render state structure (for callbacks and custom texture bindings)
|
// Setup render state structure (for callbacks and custom texture bindings)
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
ImGui_ImplVulkan_RenderState render_state;
|
ImGui_ImplVulkan_RenderState render_state;
|
||||||
render_state.CommandBuffer = command_buffer;
|
render_state.CommandBuffer = command_buffer;
|
||||||
render_state.Pipeline = pipeline;
|
render_state.Pipeline = pipeline;
|
||||||
render_state.PipelineLayout = bd->PipelineLayout;
|
render_state.PipelineLayout = bd->PipelineLayout;
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
// Setup desired Vulkan state
|
|
||||||
ImGui_ImplVulkan_SetupRenderState(draw_data, pipeline, command_buffer, rb, fb_width, fb_height);
|
|
||||||
|
|
||||||
// Will project scissor/clipping rectangles into framebuffer space
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
@ -678,7 +606,7 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
VkDescriptorSet last_image_view = VK_NULL_HANDLE;
|
VkDescriptorSet last_desc_set = VK_NULL_HANDLE;
|
||||||
int global_vtx_offset = 0;
|
int global_vtx_offset = 0;
|
||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
@ -689,13 +617,12 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
if (pcmd->UserCallback != nullptr)
|
if (pcmd->UserCallback != nullptr)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplVulkan_DrawCallback_ResetRenderState)
|
// (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, pipeline, command_buffer, rb, fb_width, fb_height);
|
ImGui_ImplVulkan_SetupRenderState(draw_data, pipeline, command_buffer, rb, fb_width, fb_height);
|
||||||
last_image_view = VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
|
last_desc_set = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -706,8 +633,8 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
// Clamp to viewport as vkCmdSetScissor() won't accept values that are off bounds
|
// Clamp to viewport as vkCmdSetScissor() won't accept values that are off bounds
|
||||||
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
||||||
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
||||||
if (clip_max.x > (float)fb_width) { clip_max.x = (float)fb_width; }
|
if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; }
|
||||||
if (clip_max.y > (float)fb_height) { clip_max.y = (float)fb_height; }
|
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
||||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -719,11 +646,11 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
scissor.extent.height = (uint32_t)(clip_max.y - clip_min.y);
|
scissor.extent.height = (uint32_t)(clip_max.y - clip_min.y);
|
||||||
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
|
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
|
||||||
|
|
||||||
// Bind DescriptorSets for image view (font or user texture) and samplers
|
// Bind DescriptorSet with font or user texture
|
||||||
VkDescriptorSet image_view = (VkDescriptorSet)pcmd->GetTexID();
|
VkDescriptorSet desc_set = (VkDescriptorSet)pcmd->GetTexID();
|
||||||
if (image_view != last_image_view)
|
if (desc_set != last_desc_set)
|
||||||
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 0, 1, &image_view, 0, nullptr);
|
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 0, 1, &desc_set, 0, nullptr);
|
||||||
last_image_view = image_view;
|
last_desc_set = desc_set;
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
||||||
@ -732,7 +659,7 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
global_idx_offset += draw_list->IdxBuffer.Size;
|
global_idx_offset += draw_list->IdxBuffer.Size;
|
||||||
global_vtx_offset += draw_list->VtxBuffer.Size;
|
global_vtx_offset += draw_list->VtxBuffer.Size;
|
||||||
}
|
}
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = nullptr;
|
platform_io.Renderer_RenderState = nullptr;
|
||||||
|
|
||||||
// Note: at this point both vkCmdSetViewport() and vkCmdSetScissor() have been called.
|
// Note: at this point both vkCmdSetViewport() and vkCmdSetScissor() have been called.
|
||||||
// Our last values will leak into user/application rendering IF:
|
// Our last values will leak into user/application rendering IF:
|
||||||
@ -826,7 +753,7 @@ void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the Descriptor Set
|
// Create the Descriptor Set
|
||||||
backend_tex->DescriptorSet = ImGui_ImplVulkan_AddTexture(backend_tex->ImageView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
backend_tex->DescriptorSet = ImGui_ImplVulkan_AddTexture(bd->TexSamplerLinear, backend_tex->ImageView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||||
|
|
||||||
// Store identifiers
|
// Store identifiers
|
||||||
tex->SetTexID((ImTextureID)backend_tex->DescriptorSet);
|
tex->SetTexID((ImTextureID)backend_tex->DescriptorSet);
|
||||||
@ -1063,14 +990,7 @@ static VkPipeline ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAlloc
|
|||||||
ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||||
ms_info.rasterizationSamples = (info->MSAASamples != 0) ? info->MSAASamples : VK_SAMPLE_COUNT_1_BIT;
|
ms_info.rasterizationSamples = (info->MSAASamples != 0) ? info->MSAASamples : VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
|
||||||
// Blend into the first color attachment. With dynamic rendering, other color attachments of the rendering are left untouched (requires independentBlend feature).
|
VkPipelineColorBlendAttachmentState color_attachment[1] = {};
|
||||||
int color_attachment_count = 1;
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
|
||||||
if (bd->VulkanInitInfo.UseDynamicRendering && info->PipelineRenderingCreateInfo.colorAttachmentCount > 1)
|
|
||||||
color_attachment_count = (int)info->PipelineRenderingCreateInfo.colorAttachmentCount;
|
|
||||||
#endif
|
|
||||||
ImVector<VkPipelineColorBlendAttachmentState> color_attachment;
|
|
||||||
color_attachment.resize(color_attachment_count, VkPipelineColorBlendAttachmentState()); // colorWriteMask = 0
|
|
||||||
color_attachment[0].blendEnable = VK_TRUE;
|
color_attachment[0].blendEnable = VK_TRUE;
|
||||||
color_attachment[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
color_attachment[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
||||||
color_attachment[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
color_attachment[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||||
@ -1085,8 +1005,8 @@ static VkPipeline ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAlloc
|
|||||||
|
|
||||||
VkPipelineColorBlendStateCreateInfo blend_info = {};
|
VkPipelineColorBlendStateCreateInfo blend_info = {};
|
||||||
blend_info.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
blend_info.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||||
blend_info.attachmentCount = (uint32_t)color_attachment.Size;
|
blend_info.attachmentCount = 1;
|
||||||
blend_info.pAttachments = color_attachment.Data;
|
blend_info.pAttachments = color_attachment;
|
||||||
|
|
||||||
ImVector<VkDynamicState> dynamic_states = info->ExtraDynamicStates;
|
ImVector<VkDynamicState> dynamic_states = info->ExtraDynamicStates;
|
||||||
dynamic_states.push_back(VK_DYNAMIC_STATE_VIEWPORT);
|
dynamic_states.push_back(VK_DYNAMIC_STATE_VIEWPORT);
|
||||||
@ -1128,82 +1048,15 @@ static VkPipeline ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAlloc
|
|||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplVulkan_CreateDescriptorSetLayout(VkDescriptorSetLayout* p_layout, VkDescriptorType descriptor_type)
|
|
||||||
{
|
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
|
||||||
|
|
||||||
VkDescriptorSetLayoutBinding binding[1] = {};
|
|
||||||
binding[0].descriptorType = descriptor_type;
|
|
||||||
binding[0].descriptorCount = 1;
|
|
||||||
binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
|
||||||
VkDescriptorSetLayoutCreateInfo info = {};
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
|
||||||
info.bindingCount = 1;
|
|
||||||
info.pBindings = binding;
|
|
||||||
VkResult err = vkCreateDescriptorSetLayout(v->Device, &info, v->Allocator, p_layout);
|
|
||||||
check_vk_result(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
static VkDescriptorSet ImGui_ImplVulkan_CreateSamplerDS(VkSampler sampler)
|
|
||||||
{
|
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
|
||||||
|
|
||||||
VkDescriptorSet descriptor_set;
|
|
||||||
VkDescriptorSetAllocateInfo alloc_info = {};
|
|
||||||
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
|
||||||
alloc_info.descriptorPool = bd->DescriptorPool ? bd->DescriptorPool : v->DescriptorPool;
|
|
||||||
alloc_info.descriptorSetCount = 1;
|
|
||||||
alloc_info.pSetLayouts = &bd->DescriptorSetLayoutSampler;
|
|
||||||
VkResult err = vkAllocateDescriptorSets(v->Device, &alloc_info, &descriptor_set);
|
|
||||||
check_vk_result(err);
|
|
||||||
|
|
||||||
VkDescriptorImageInfo desc_image = {};
|
|
||||||
desc_image.sampler = sampler;
|
|
||||||
VkWriteDescriptorSet sampler_write_desc = {};
|
|
||||||
sampler_write_desc.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
||||||
sampler_write_desc.dstSet = descriptor_set;
|
|
||||||
sampler_write_desc.descriptorCount = 1;
|
|
||||||
sampler_write_desc.dstBinding = 0;
|
|
||||||
sampler_write_desc.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
|
|
||||||
sampler_write_desc.pImageInfo = &desc_image;
|
|
||||||
vkUpdateDescriptorSets(v->Device, 1, &sampler_write_desc, 0, nullptr);
|
|
||||||
return descriptor_set;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGui_ImplVulkan_CreateDeviceObjects()
|
bool ImGui_ImplVulkan_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
VkResult err;
|
VkResult err;
|
||||||
|
|
||||||
if (!bd->DescriptorSetLayoutTexture)
|
if (!bd->TexSamplerLinear)
|
||||||
ImGui_ImplVulkan_CreateDescriptorSetLayout(&bd->DescriptorSetLayoutTexture, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
|
|
||||||
if (!bd->DescriptorSetLayoutSampler)
|
|
||||||
ImGui_ImplVulkan_CreateDescriptorSetLayout(&bd->DescriptorSetLayoutSampler, VK_DESCRIPTOR_TYPE_SAMPLER);
|
|
||||||
|
|
||||||
if (v->DescriptorPoolSize != 0)
|
|
||||||
{
|
|
||||||
IM_ASSERT(v->DescriptorPoolSize >= IMGUI_IMPL_VULKAN_MINIMUM_SAMPLED_IMAGE_POOL_SIZE);
|
|
||||||
VkDescriptorPoolSize pool_sizes[] =
|
|
||||||
{
|
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, v->DescriptorPoolSize },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLER, IMGUI_IMPL_VULKAN_MINIMUM_SAMPLER_POOL_SIZE },
|
|
||||||
};
|
|
||||||
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 = v->DescriptorPoolSize + IMGUI_IMPL_VULKAN_MINIMUM_SAMPLER_POOL_SIZE;
|
|
||||||
pool_info.poolSizeCount = (uint32_t)IM_COUNTOF(pool_sizes);
|
|
||||||
pool_info.pPoolSizes = pool_sizes;
|
|
||||||
err = vkCreateDescriptorPool(v->Device, &pool_info, v->Allocator, &bd->DescriptorPool);
|
|
||||||
check_vk_result(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create samplers (bilinear sampling is required)
|
|
||||||
if (!bd->SamplerLinear || !bd->SamplerNearest)
|
|
||||||
{
|
{
|
||||||
|
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||||
VkSamplerCreateInfo info = {};
|
VkSamplerCreateInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||||
info.magFilter = VK_FILTER_LINEAR;
|
info.magFilter = VK_FILTER_LINEAR;
|
||||||
@ -1215,16 +1068,37 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
info.minLod = -1000;
|
info.minLod = -1000;
|
||||||
info.maxLod = 1000;
|
info.maxLod = 1000;
|
||||||
info.maxAnisotropy = 1.0f;
|
info.maxAnisotropy = 1.0f;
|
||||||
err = vkCreateSampler(v->Device, &info, v->Allocator, &bd->SamplerLinear);
|
err = vkCreateSampler(v->Device, &info, v->Allocator, &bd->TexSamplerLinear);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
bd->SamplerLinearDS = ImGui_ImplVulkan_CreateSamplerDS(bd->SamplerLinear);
|
}
|
||||||
|
|
||||||
info.magFilter = VK_FILTER_NEAREST;
|
if (!bd->DescriptorSetLayout)
|
||||||
info.minFilter = VK_FILTER_NEAREST;
|
{
|
||||||
info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
|
VkDescriptorSetLayoutBinding binding[1] = {};
|
||||||
err = vkCreateSampler(v->Device, &info, v->Allocator, &bd->SamplerNearest);
|
binding[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
|
binding[0].descriptorCount = 1;
|
||||||
|
binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
|
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, &bd->DescriptorSetLayout);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v->DescriptorPoolSize != 0)
|
||||||
|
{
|
||||||
|
IM_ASSERT(v->DescriptorPoolSize >= IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE);
|
||||||
|
VkDescriptorPoolSize pool_size = { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, v->DescriptorPoolSize };
|
||||||
|
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 = v->DescriptorPoolSize;
|
||||||
|
pool_info.poolSizeCount = 1;
|
||||||
|
pool_info.pPoolSizes = &pool_size;
|
||||||
|
|
||||||
|
err = vkCreateDescriptorPool(v->Device, &pool_info, v->Allocator, &bd->DescriptorPool);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
bd->SamplerNearestDS = ImGui_ImplVulkan_CreateSamplerDS(bd->SamplerNearest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bd->PipelineLayout)
|
if (!bd->PipelineLayout)
|
||||||
@ -1234,10 +1108,10 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||||
push_constants[0].offset = sizeof(float) * 0;
|
push_constants[0].offset = sizeof(float) * 0;
|
||||||
push_constants[0].size = sizeof(float) * 4;
|
push_constants[0].size = sizeof(float) * 4;
|
||||||
VkDescriptorSetLayout set_layout[2] = { bd->DescriptorSetLayoutTexture, bd->DescriptorSetLayoutSampler };
|
VkDescriptorSetLayout set_layout[1] = { bd->DescriptorSetLayout };
|
||||||
VkPipelineLayoutCreateInfo layout_info = {};
|
VkPipelineLayoutCreateInfo layout_info = {};
|
||||||
layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||||
layout_info.setLayoutCount = 2;
|
layout_info.setLayoutCount = 1;
|
||||||
layout_info.pSetLayouts = set_layout;
|
layout_info.pSetLayouts = set_layout;
|
||||||
layout_info.pushConstantRangeCount = 1;
|
layout_info.pushConstantRangeCount = 1;
|
||||||
layout_info.pPushConstantRanges = push_constants;
|
layout_info.pPushConstantRanges = push_constants;
|
||||||
@ -1317,12 +1191,10 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
|
|||||||
|
|
||||||
if (bd->TexCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->TexCommandPool, 1, &bd->TexCommandBuffer); bd->TexCommandBuffer = VK_NULL_HANDLE; }
|
if (bd->TexCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->TexCommandPool, 1, &bd->TexCommandBuffer); bd->TexCommandBuffer = VK_NULL_HANDLE; }
|
||||||
if (bd->TexCommandPool) { vkDestroyCommandPool(v->Device, bd->TexCommandPool, v->Allocator); bd->TexCommandPool = VK_NULL_HANDLE; }
|
if (bd->TexCommandPool) { vkDestroyCommandPool(v->Device, bd->TexCommandPool, v->Allocator); bd->TexCommandPool = VK_NULL_HANDLE; }
|
||||||
if (bd->SamplerLinear) { vkDestroySampler(v->Device, bd->SamplerLinear, v->Allocator); bd->SamplerLinear = VK_NULL_HANDLE; }
|
if (bd->TexSamplerLinear) { vkDestroySampler(v->Device, bd->TexSamplerLinear, v->Allocator); bd->TexSamplerLinear = VK_NULL_HANDLE; }
|
||||||
if (bd->SamplerNearest) { vkDestroySampler(v->Device, bd->SamplerNearest, v->Allocator); bd->SamplerNearest = VK_NULL_HANDLE; }
|
|
||||||
if (bd->ShaderModuleVert) { vkDestroyShaderModule(v->Device, bd->ShaderModuleVert, v->Allocator); bd->ShaderModuleVert = VK_NULL_HANDLE; }
|
if (bd->ShaderModuleVert) { vkDestroyShaderModule(v->Device, bd->ShaderModuleVert, v->Allocator); bd->ShaderModuleVert = VK_NULL_HANDLE; }
|
||||||
if (bd->ShaderModuleFrag) { vkDestroyShaderModule(v->Device, bd->ShaderModuleFrag, v->Allocator); bd->ShaderModuleFrag = VK_NULL_HANDLE; }
|
if (bd->ShaderModuleFrag) { vkDestroyShaderModule(v->Device, bd->ShaderModuleFrag, v->Allocator); bd->ShaderModuleFrag = VK_NULL_HANDLE; }
|
||||||
if (bd->DescriptorSetLayoutTexture) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayoutTexture, v->Allocator); bd->DescriptorSetLayoutTexture = VK_NULL_HANDLE; }
|
if (bd->DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayout, v->Allocator); bd->DescriptorSetLayout = VK_NULL_HANDLE; }
|
||||||
if (bd->DescriptorSetLayoutSampler) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayoutSampler, v->Allocator); bd->DescriptorSetLayoutSampler = VK_NULL_HANDLE; }
|
|
||||||
if (bd->PipelineLayout) { vkDestroyPipelineLayout(v->Device, bd->PipelineLayout, v->Allocator); bd->PipelineLayout = VK_NULL_HANDLE; }
|
if (bd->PipelineLayout) { vkDestroyPipelineLayout(v->Device, bd->PipelineLayout, v->Allocator); bd->PipelineLayout = VK_NULL_HANDLE; }
|
||||||
if (bd->Pipeline) { vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator); bd->Pipeline = VK_NULL_HANDLE; }
|
if (bd->Pipeline) { vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator); bd->Pipeline = VK_NULL_HANDLE; }
|
||||||
if (bd->DescriptorPool) { vkDestroyDescriptorPool(v->Device, bd->DescriptorPool, v->Allocator); bd->DescriptorPool = VK_NULL_HANDLE; }
|
if (bd->DescriptorPool) { vkDestroyDescriptorPool(v->Device, bd->DescriptorPool, v->Allocator); bd->DescriptorPool = VK_NULL_HANDLE; }
|
||||||
@ -1369,8 +1241,8 @@ bool ImGui_ImplVulkan_LoadFunctions(uint32_t api_version, PFN_vkVoidFunction(
|
|||||||
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
|
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
|
||||||
#define IMGUI_VULKAN_FUNC_LOAD(func) \
|
#define IMGUI_VULKAN_FUNC_LOAD(func) \
|
||||||
ImGuiImplVulkanFuncs.pfn_##func = reinterpret_cast<PFN_##func>(loader_func(#func, user_data)); \
|
func = reinterpret_cast<decltype(func)>(loader_func(#func, user_data)); \
|
||||||
if (ImGuiImplVulkanFuncs.pfn_##func == nullptr) \
|
if (func == nullptr) \
|
||||||
return false;
|
return false;
|
||||||
IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_LOAD)
|
IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_LOAD)
|
||||||
#undef IMGUI_VULKAN_FUNC_LOAD
|
#undef IMGUI_VULKAN_FUNC_LOAD
|
||||||
@ -1418,11 +1290,6 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
|||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplVulkan_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplVulkan_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplVulkan_DrawCallback_SetSamplerNearest;
|
|
||||||
|
|
||||||
// Sanity checks
|
// Sanity checks
|
||||||
IM_ASSERT(info->Instance != VK_NULL_HANDLE);
|
IM_ASSERT(info->Instance != VK_NULL_HANDLE);
|
||||||
IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
|
IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
|
||||||
@ -1438,9 +1305,6 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
|||||||
IM_ASSERT(info->PipelineInfoMain.RenderPass == VK_NULL_HANDLE);
|
IM_ASSERT(info->PipelineInfoMain.RenderPass == VK_NULL_HANDLE);
|
||||||
|
|
||||||
bd->VulkanInitInfo = *info;
|
bd->VulkanInitInfo = *info;
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
|
|
||||||
bd->Functions = ImGuiImplVulkanFuncs;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VkPhysicalDeviceProperties properties;
|
VkPhysicalDeviceProperties properties;
|
||||||
vkGetPhysicalDeviceProperties(info->PhysicalDevice, &properties);
|
vkGetPhysicalDeviceProperties(info->PhysicalDevice, &properties);
|
||||||
@ -1491,7 +1355,7 @@ void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
|
|||||||
|
|
||||||
// Register a texture by creating a descriptor
|
// Register a texture by creating a descriptor
|
||||||
// FIXME: This is experimental in the sense that we are unsure how to best design/tackle this problem, please post to https://github.com/ocornut/imgui/pull/914 if you have suggestions.
|
// FIXME: This is experimental in the sense that we are unsure how to best design/tackle this problem, please post to https://github.com/ocornut/imgui/pull/914 if you have suggestions.
|
||||||
VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkImageView image_view, VkImageLayout image_layout)
|
VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
@ -1504,7 +1368,7 @@ VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkImageView image_view, VkImageLayou
|
|||||||
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
alloc_info.descriptorPool = pool;
|
alloc_info.descriptorPool = pool;
|
||||||
alloc_info.descriptorSetCount = 1;
|
alloc_info.descriptorSetCount = 1;
|
||||||
alloc_info.pSetLayouts = &bd->DescriptorSetLayoutTexture;
|
alloc_info.pSetLayouts = &bd->DescriptorSetLayout;
|
||||||
VkResult err = vkAllocateDescriptorSets(v->Device, &alloc_info, &descriptor_set);
|
VkResult err = vkAllocateDescriptorSets(v->Device, &alloc_info, &descriptor_set);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
@ -1513,27 +1377,20 @@ VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkImageView image_view, VkImageLayou
|
|||||||
if (descriptor_set != VK_NULL_HANDLE)
|
if (descriptor_set != VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
VkDescriptorImageInfo desc_image[1] = {};
|
VkDescriptorImageInfo desc_image[1] = {};
|
||||||
|
desc_image[0].sampler = sampler;
|
||||||
desc_image[0].imageView = image_view;
|
desc_image[0].imageView = image_view;
|
||||||
desc_image[0].imageLayout = image_layout;
|
desc_image[0].imageLayout = image_layout;
|
||||||
VkWriteDescriptorSet write_desc[1] = {};
|
VkWriteDescriptorSet write_desc[1] = {};
|
||||||
write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
write_desc[0].dstSet = descriptor_set;
|
write_desc[0].dstSet = descriptor_set;
|
||||||
write_desc[0].descriptorCount = 1;
|
write_desc[0].descriptorCount = 1;
|
||||||
write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
write_desc[0].pImageInfo = desc_image;
|
write_desc[0].pImageInfo = desc_image;
|
||||||
vkUpdateDescriptorSets(v->Device, 1, write_desc, 0, nullptr);
|
vkUpdateDescriptorSets(v->Device, 1, write_desc, 0, nullptr);
|
||||||
}
|
}
|
||||||
return descriptor_set;
|
return descriptor_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
||||||
VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout)
|
|
||||||
{
|
|
||||||
IM_UNUSED(sampler);
|
|
||||||
return ImGui_ImplVulkan_AddTexture(image_view, image_layout);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set)
|
void ImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
|||||||
@ -2,10 +2,10 @@
|
|||||||
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [!] Renderer: User texture binding. Use a VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE 'VkDescriptorSet' as texture identifier. Call ImGui_ImplVulkan_AddTexture() to register one. Read the FAQ about ImTextureID/ImTextureRef + https://github.com/ocornut/imgui/pull/914 for discussions.
|
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as texture identifier. Call ImGui_ImplVulkan_AddTexture() to register one. Read the FAQ about ImTextureID/ImTextureRef + https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplVulkan_GetRenderState().
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
|
|
||||||
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
|
// 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/
|
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||||
@ -78,8 +78,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Backend uses a small number of descriptors per font atlas + as many as additional calls done to ImGui_ImplVulkan_AddTexture().
|
// Backend uses a small number of descriptors per font atlas + as many as additional calls done to ImGui_ImplVulkan_AddTexture().
|
||||||
#define IMGUI_IMPL_VULKAN_MINIMUM_SAMPLED_IMAGE_POOL_SIZE (8) // Minimum per atlas
|
#define IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE (8) // Minimum per atlas
|
||||||
#define IMGUI_IMPL_VULKAN_MINIMUM_SAMPLER_POOL_SIZE (2) // Minimum for linear + nearest
|
|
||||||
|
|
||||||
// Specify settings to create pipeline and swapchain
|
// Specify settings to create pipeline and swapchain
|
||||||
struct ImGui_ImplVulkan_PipelineInfo
|
struct ImGui_ImplVulkan_PipelineInfo
|
||||||
@ -101,7 +100,6 @@ struct ImGui_ImplVulkan_PipelineInfo
|
|||||||
// - As an convenience, by setting DescriptorPoolSize > 0 the backend will create one for you.
|
// - As an convenience, by setting DescriptorPoolSize > 0 the backend will create one for you.
|
||||||
// - About dynamic rendering:
|
// - About dynamic rendering:
|
||||||
// - When using dynamic rendering, set UseDynamicRendering=true + fill PipelineInfoMain.PipelineRenderingCreateInfo structure.
|
// - When using dynamic rendering, set UseDynamicRendering=true + fill PipelineInfoMain.PipelineRenderingCreateInfo structure.
|
||||||
// - PipelineRenderingCreateInfo may describe multiple color attachments: we render to the first one and leave the others untouched. This requires the 'independentBlend' device feature.
|
|
||||||
struct ImGui_ImplVulkan_InitInfo
|
struct ImGui_ImplVulkan_InitInfo
|
||||||
{
|
{
|
||||||
uint32_t ApiVersion; // Fill with API version of Instance, e.g. VK_API_VERSION_1_3 or your value of VkApplicationInfo::apiVersion. May be lower than header version (VK_HEADER_VERSION_COMPLETE)
|
uint32_t ApiVersion; // Fill with API version of Instance, e.g. VK_API_VERSION_1_3 or your value of VkApplicationInfo::apiVersion. May be lower than header version (VK_HEADER_VERSION_COMPLETE)
|
||||||
@ -111,7 +109,7 @@ struct ImGui_ImplVulkan_InitInfo
|
|||||||
uint32_t QueueFamily;
|
uint32_t QueueFamily;
|
||||||
VkQueue Queue;
|
VkQueue Queue;
|
||||||
VkDescriptorPool DescriptorPool; // See requirements in note above; ignored if using DescriptorPoolSize > 0
|
VkDescriptorPool DescriptorPool; // See requirements in note above; ignored if using DescriptorPoolSize > 0
|
||||||
uint32_t DescriptorPoolSize; // Optional: set to create internal ImageView descriptor pool automatically instead of using DescriptorPool.
|
uint32_t DescriptorPoolSize; // Optional: set to create internal descriptor pool automatically instead of using DescriptorPool.
|
||||||
uint32_t MinImageCount; // >= 2
|
uint32_t MinImageCount; // >= 2
|
||||||
uint32_t ImageCount; // >= MinImageCount
|
uint32_t ImageCount; // >= MinImageCount
|
||||||
VkPipelineCache PipelineCache; // Optional
|
VkPipelineCache PipelineCache; // Optional
|
||||||
@ -154,21 +152,18 @@ IMGUI_IMPL_API void ImGui_ImplVulkan_CreateMainPipeline(const ImGui_
|
|||||||
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
|
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex);
|
||||||
|
|
||||||
// Register a texture (VkDescriptorSet for a VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE == ImTextureID)
|
// Register a texture (VkDescriptorSet == ImTextureID)
|
||||||
IMGUI_IMPL_API VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkImageView image_view, VkImageLayout image_layout);
|
// FIXME: This is experimental in the sense that we are unsure how to best design/tackle this problem
|
||||||
|
// Please post to https://github.com/ocornut/imgui/pull/914 if you have suggestions.
|
||||||
|
IMGUI_IMPL_API VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set);
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
||||||
IMGUI_IMPL_API VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout); // Ignore VkSampler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Optional: load Vulkan functions with a custom function loader
|
// Optional: load Vulkan functions with a custom function loader
|
||||||
// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES
|
// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(uint32_t api_version, PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data = nullptr);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(uint32_t api_version, PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data = nullptr);
|
||||||
|
|
||||||
// [BETA] Selected render state data shared with callbacks.
|
// [BETA] Selected render state data shared with callbacks.
|
||||||
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplVulkan_RenderDrawData() call.
|
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplVulkan_RenderDrawData() call.
|
||||||
// ImGui_ImplVulkan_RenderState* render_state = (ImGui_ImplVulkan_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
|
||||||
// (Please open an issue if you feel you need access to more data)
|
// (Please open an issue if you feel you need access to more data)
|
||||||
struct ImGui_ImplVulkan_RenderState
|
struct ImGui_ImplVulkan_RenderState
|
||||||
{
|
{
|
||||||
@ -176,7 +171,6 @@ struct ImGui_ImplVulkan_RenderState
|
|||||||
VkPipeline Pipeline;
|
VkPipeline Pipeline;
|
||||||
VkPipelineLayout PipelineLayout;
|
VkPipelineLayout PipelineLayout;
|
||||||
};
|
};
|
||||||
IMGUI_IMPL_API ImGui_ImplVulkan_RenderState* ImGui_ImplVulkan_GetRenderState();
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Internal / Miscellaneous Vulkan Helpers
|
// Internal / Miscellaneous Vulkan Helpers
|
||||||
@ -260,7 +254,7 @@ struct ImGui_ImplVulkanH_Window
|
|||||||
memset((void*)this, 0, sizeof(*this));
|
memset((void*)this, 0, sizeof(*this));
|
||||||
|
|
||||||
// Parameters to create SwapChain
|
// Parameters to create SwapChain
|
||||||
PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR; // Ensure we get an error if user doesn't set this.
|
PresentMode = (VkPresentModeKHR)~0; // Ensure we get an error if user doesn't set this.
|
||||||
|
|
||||||
// Parameters to create RenderPass
|
// Parameters to create RenderPass
|
||||||
AttachmentDesc.format = VK_FORMAT_UNDEFINED; // Will automatically use wd->SurfaceFormat.format.
|
AttachmentDesc.format = VK_FORMAT_UNDEFINED; // Will automatically use wd->SurfaceFormat.format.
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
// [X] Renderer: Texture updates support for dynamic font system (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font system (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplWGPU_GetRenderState().
|
|
||||||
|
|
||||||
// Read imgui_impl_wgpu.h about how to use the IMGUI_IMPL_WEBGPU_BACKEND_WGPU or IMGUI_IMPL_WEBGPU_BACKEND_DAWN flags.
|
// Read imgui_impl_wgpu.h about how to use the IMGUI_IMPL_WEBGPU_BACKEND_WGPU or IMGUI_IMPL_WEBGPU_BACKEND_DAWN flags.
|
||||||
|
|
||||||
@ -20,10 +20,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-09-07: Round framebuffer dimensions to the nearest integer instead of truncating them. (#9538, 9515, #8628)
|
|
||||||
// 2026-08-31: Update to compile with wgpu-native 29.0. (#9377, #9532, #9530)
|
|
||||||
// 2026-08-18: Fixed passing non-integer sizes to `wgpuRenderPassEncoderSetViewport() when FramebufferScale is >1.0f. (#9515, #8628)
|
|
||||||
// 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. (#9378)
|
|
||||||
// 2026-03-25: Added support for WGVK native backend via IMGUI_IMPL_WEBGPU_BACKEND_WGVK define, with SPIRV shaders if WGSL is not available. (#9316, #9246, #9257)
|
// 2026-03-25: Added support for WGVK native backend via IMGUI_IMPL_WEBGPU_BACKEND_WGVK define, with SPIRV shaders if WGSL is not available. (#9316, #9246, #9257)
|
||||||
// 2026-03-09: Removed support for Emscripten < 4.0.10. (#9281)
|
// 2026-03-09: Removed support for Emscripten < 4.0.10. (#9281)
|
||||||
// 2025-10-16: Update to compile with Dawn and Emscripten's 4.0.10+ '--use-port=emdawnwebgpu' ports. (#8381, #8898)
|
// 2025-10-16: Update to compile with Dawn and Emscripten's 4.0.10+ '--use-port=emdawnwebgpu' ports. (#8381, #8898)
|
||||||
@ -68,6 +64,12 @@
|
|||||||
#error Emscripten <4.0.10 with '-sUSE_WEBGPU=1' is not supported anymore.
|
#error Emscripten <4.0.10 with '-sUSE_WEBGPU=1' is not supported anymore.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined IMGUI_IMPL_WEBGPU_BACKEND_DAWN || defined IMGUI_IMPL_WEBGPU_BACKEND_WGVK
|
||||||
|
// Dawn renamed WGPUProgrammableStageDescriptor to WGPUComputeState (see: https://github.com/webgpu-native/webgpu-headers/pull/413)
|
||||||
|
// Using type alias until WGPU adopts the same naming convention (#8369)
|
||||||
|
using WGPUProgrammableStageDescriptor = WGPUComputeState;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Dear ImGui prototypes from imgui_internal.h
|
// Dear ImGui prototypes from imgui_internal.h
|
||||||
extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed);
|
extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed);
|
||||||
#define MEMALIGN(_SIZE,_ALIGN) (((_SIZE) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1)) // Memory align (copied from IM_ALIGN() macro).
|
#define MEMALIGN(_SIZE,_ALIGN) (((_SIZE) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1)) // Memory align (copied from IM_ALIGN() macro).
|
||||||
@ -81,13 +83,11 @@ struct ImGui_ImplWGPU_Texture
|
|||||||
|
|
||||||
struct RenderResources
|
struct RenderResources
|
||||||
{
|
{
|
||||||
WGPUSampler SamplerLinear = nullptr; // Bilinear sampler
|
WGPUSampler Sampler = nullptr; // Sampler for textures
|
||||||
WGPUSampler SamplerNearest = nullptr; // Nearest/point sampler
|
WGPUBuffer Uniforms = nullptr; // Shader uniforms
|
||||||
WGPUBuffer Uniforms = nullptr; // Shader uniforms
|
WGPUBindGroup CommonBindGroup = nullptr; // Resources bind-group to bind the common resources to pipeline
|
||||||
WGPUBindGroup CommonBindGroupLinear = nullptr; // Common bind-group bound to group 0 (uniforms + SamplerLinear)
|
ImGuiStorage ImageBindGroups; // Resources bind-group to bind the font/image resources to pipeline (this is a key->value map)
|
||||||
WGPUBindGroup CommonBindGroupNearest = nullptr; // Common bind-group bound to group 0 (uniforms + SamplerNearest)
|
WGPUBindGroupLayout ImageBindGroupLayout = nullptr; // Cache layout used for the image bind group. Avoids allocating unnecessary JS objects when working with WebASM
|
||||||
ImGuiStorage ImageBindGroups; // Resources bind-group to bind the font/image resources to pipeline (this is a key->value map)
|
|
||||||
WGPUBindGroupLayout ImageBindGroupLayout = nullptr; // Cache layout used for the image bind group. Avoids allocating unnecessary JS objects when working with WebASM
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FrameResources
|
struct FrameResources
|
||||||
@ -114,7 +114,6 @@ struct ImGui_ImplWGPU_Data
|
|||||||
WGPUTextureFormat renderTargetFormat = WGPUTextureFormat_Undefined;
|
WGPUTextureFormat renderTargetFormat = WGPUTextureFormat_Undefined;
|
||||||
WGPUTextureFormat depthStencilFormat = WGPUTextureFormat_Undefined;
|
WGPUTextureFormat depthStencilFormat = WGPUTextureFormat_Undefined;
|
||||||
WGPURenderPipeline pipelineState = nullptr;
|
WGPURenderPipeline pipelineState = nullptr;
|
||||||
ImGui_ImplWGPU_RenderState* RenderState = nullptr; // == ImGui::GetPlatformIO().Renderer_RenderState during rendering.
|
|
||||||
|
|
||||||
RenderResources renderResources;
|
RenderResources renderResources;
|
||||||
FrameResources* pFrameResources = nullptr;
|
FrameResources* pFrameResources = nullptr;
|
||||||
@ -129,11 +128,6 @@ static ImGui_ImplWGPU_Data* ImGui_ImplWGPU_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplWGPU_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplWGPU_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplWGPU_RenderState* ImGui_ImplWGPU_GetRenderState()
|
|
||||||
{
|
|
||||||
return (ImGui_ImplWGPU_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// SHADERS
|
// SHADERS
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -302,11 +296,9 @@ static void SafeRelease(WGPUShaderModule& res)
|
|||||||
}
|
}
|
||||||
static void SafeRelease(RenderResources& res)
|
static void SafeRelease(RenderResources& res)
|
||||||
{
|
{
|
||||||
SafeRelease(res.SamplerLinear);
|
SafeRelease(res.Sampler);
|
||||||
SafeRelease(res.SamplerNearest);
|
|
||||||
SafeRelease(res.Uniforms);
|
SafeRelease(res.Uniforms);
|
||||||
SafeRelease(res.CommonBindGroupLinear);
|
SafeRelease(res.CommonBindGroup);
|
||||||
SafeRelease(res.CommonBindGroupNearest);
|
|
||||||
SafeRelease(res.ImageBindGroupLayout);
|
SafeRelease(res.ImageBindGroupLayout);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -318,10 +310,9 @@ static void SafeRelease(FrameResources& res)
|
|||||||
SafeRelease(res.VertexBufferHost);
|
SafeRelease(res.VertexBufferHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WGPUComputeState ImGui_ImplWGPU_CreateShaderModuleWGSL(const char* wgsl_source)
|
static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModuleWGSL(const char* wgsl_source)
|
||||||
{
|
{
|
||||||
ImGui_ImplWGPU_Data* bd = ImGui_ImplWGPU_GetBackendData();
|
ImGui_ImplWGPU_Data* bd = ImGui_ImplWGPU_GetBackendData();
|
||||||
IM_UNUSED(bd);
|
|
||||||
|
|
||||||
WGPUShaderSourceWGSL wgsl_desc = {};
|
WGPUShaderSourceWGSL wgsl_desc = {};
|
||||||
wgsl_desc.chain.sType = WGPUSType_ShaderSourceWGSL;
|
wgsl_desc.chain.sType = WGPUSType_ShaderSourceWGSL;
|
||||||
@ -330,35 +321,14 @@ static WGPUComputeState ImGui_ImplWGPU_CreateShaderModuleWGSL(const char* wgsl_s
|
|||||||
WGPUShaderModuleDescriptor desc = {};
|
WGPUShaderModuleDescriptor desc = {};
|
||||||
desc.nextInChain = (WGPUChainedStruct*)&wgsl_desc;
|
desc.nextInChain = (WGPUChainedStruct*)&wgsl_desc;
|
||||||
|
|
||||||
// Detect shader compilation errors by using an error scope.
|
WGPUProgrammableStageDescriptor stage_desc = {};
|
||||||
// Flag to be passed into the validation callback `userdata1` pointer.
|
stage_desc.module = wgpuDeviceCreateShaderModule(bd->wgpuDevice, &desc);
|
||||||
int validation_error = 0;
|
|
||||||
wgpuDevicePushErrorScope(bd->wgpuDevice, WGPUErrorFilter_Validation);
|
|
||||||
WGPUShaderModule module = wgpuDeviceCreateShaderModule(bd->wgpuDevice, &desc);
|
|
||||||
WGPUPopErrorScopeCallbackInfo pop_cb = {};
|
|
||||||
pop_cb.mode = WGPUCallbackMode_AllowSpontaneous;
|
|
||||||
pop_cb.callback = [](WGPUPopErrorScopeStatus, WGPUErrorType type, WGPUStringView, void* userdata1, void*)
|
|
||||||
{
|
|
||||||
if (type == WGPUErrorType_Validation)
|
|
||||||
*static_cast<int*>(userdata1) = 1;
|
|
||||||
};
|
|
||||||
pop_cb.userdata1 = &validation_error;
|
|
||||||
wgpuDevicePopErrorScope(bd->wgpuDevice, pop_cb);
|
|
||||||
|
|
||||||
WGPUComputeState stage_desc = {};
|
stage_desc.entryPoint = { "main", WGPU_STRLEN };
|
||||||
if (module && !validation_error)
|
|
||||||
{
|
|
||||||
stage_desc.module = module;
|
|
||||||
stage_desc.entryPoint = { "main", WGPU_STRLEN };
|
|
||||||
}
|
|
||||||
else if (module)
|
|
||||||
{
|
|
||||||
wgpuShaderModuleRelease(module);
|
|
||||||
}
|
|
||||||
return stage_desc;
|
return stage_desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WGPUComputeState ImGui_ImplWGPU_CreateShaderModuleSPIRV(const void* spirv_binary, size_t spirv_length)
|
static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModuleSPIRV(const void* spirv_binary, size_t spirv_length)
|
||||||
{
|
{
|
||||||
ImGui_ImplWGPU_Data* bd = ImGui_ImplWGPU_GetBackendData();
|
ImGui_ImplWGPU_Data* bd = ImGui_ImplWGPU_GetBackendData();
|
||||||
|
|
||||||
@ -370,7 +340,7 @@ static WGPUComputeState ImGui_ImplWGPU_CreateShaderModuleSPIRV(const void* spirv
|
|||||||
WGPUShaderModuleDescriptor desc = {};
|
WGPUShaderModuleDescriptor desc = {};
|
||||||
desc.nextInChain = (WGPUChainedStruct*)&spirv_desc;
|
desc.nextInChain = (WGPUChainedStruct*)&spirv_desc;
|
||||||
|
|
||||||
WGPUComputeState stage_desc = {};
|
WGPUProgrammableStageDescriptor stage_desc = {};
|
||||||
stage_desc.module = wgpuDeviceCreateShaderModule(bd->wgpuDevice, &desc);
|
stage_desc.module = wgpuDeviceCreateShaderModule(bd->wgpuDevice, &desc);
|
||||||
|
|
||||||
stage_desc.entryPoint = { "main", WGPU_STRLEN };
|
stage_desc.entryPoint = { "main", WGPU_STRLEN };
|
||||||
@ -442,32 +412,26 @@ static void ImGui_ImplWGPU_SetupRenderState(ImDrawData* draw_data, WGPURenderPas
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup viewport
|
// Setup viewport
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f);
|
wgpuRenderPassEncoderSetViewport(ctx, 0, 0, draw_data->FramebufferScale.x * draw_data->DisplaySize.x, draw_data->FramebufferScale.y * draw_data->DisplaySize.y, 0, 1);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
|
||||||
wgpuRenderPassEncoderSetViewport(ctx, 0, 0, (float)fb_width, (float)fb_height, 0, 1);
|
|
||||||
|
|
||||||
// Bind shader and vertex buffers
|
// Bind shader and vertex buffers
|
||||||
wgpuRenderPassEncoderSetVertexBuffer(ctx, 0, fr->VertexBuffer, 0, fr->VertexBufferSize * sizeof(ImDrawVert));
|
wgpuRenderPassEncoderSetVertexBuffer(ctx, 0, fr->VertexBuffer, 0, fr->VertexBufferSize * sizeof(ImDrawVert));
|
||||||
wgpuRenderPassEncoderSetIndexBuffer(ctx, fr->IndexBuffer, sizeof(ImDrawIdx) == 2 ? WGPUIndexFormat_Uint16 : WGPUIndexFormat_Uint32, 0, fr->IndexBufferSize * sizeof(ImDrawIdx));
|
wgpuRenderPassEncoderSetIndexBuffer(ctx, fr->IndexBuffer, sizeof(ImDrawIdx) == 2 ? WGPUIndexFormat_Uint16 : WGPUIndexFormat_Uint32, 0, fr->IndexBufferSize * sizeof(ImDrawIdx));
|
||||||
wgpuRenderPassEncoderSetPipeline(ctx, bd->pipelineState);
|
wgpuRenderPassEncoderSetPipeline(ctx, bd->pipelineState);
|
||||||
wgpuRenderPassEncoderSetBindGroup(ctx, 0, bd->renderResources.CommonBindGroupLinear, 0, nullptr);
|
wgpuRenderPassEncoderSetBindGroup(ctx, 0, bd->renderResources.CommonBindGroup, 0, nullptr);
|
||||||
|
|
||||||
// Setup blend factor
|
// Setup blend factor
|
||||||
WGPUColor blend_color = { 0.0f, 0.0f, 0.0f, 0.0f };
|
WGPUColor blend_color = { 0.f, 0.f, 0.f, 0.f };
|
||||||
wgpuRenderPassEncoderSetBlendConstant(ctx, &blend_color);
|
wgpuRenderPassEncoderSetBlendConstant(ctx, &blend_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw callbacks
|
|
||||||
static void ImGui_ImplWGPU_DrawCallback_ResetRenderState(const ImDrawList*, const ImDrawCmd*) {} // Intentionally empty. Used as an identifier for rendering loop to call its code. Simpler to implement this way.
|
|
||||||
static void ImGui_ImplWGPU_DrawCallback_SetSamplerLinear(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplWGPU_Data* bd = ImGui_ImplWGPU_GetBackendData(); wgpuRenderPassEncoderSetBindGroup(bd->RenderState->RenderPassEncoder, 0, bd->renderResources.CommonBindGroupLinear, 0, nullptr); }
|
|
||||||
static void ImGui_ImplWGPU_DrawCallback_SetSamplerNearest(const ImDrawList*, const ImDrawCmd*) { ImGui_ImplWGPU_Data* bd = ImGui_ImplWGPU_GetBackendData(); wgpuRenderPassEncoderSetBindGroup(bd->RenderState->RenderPassEncoder, 0, bd->renderResources.CommonBindGroupNearest, 0, nullptr); }
|
|
||||||
|
|
||||||
// Render function
|
// 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_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder)
|
void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized
|
// Avoid rendering when minimized
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdLists.Size == 0)
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdLists.Size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -557,7 +521,7 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
ImGui_ImplWGPU_RenderState render_state;
|
ImGui_ImplWGPU_RenderState render_state;
|
||||||
render_state.Device = bd->wgpuDevice;
|
render_state.Device = bd->wgpuDevice;
|
||||||
render_state.RenderPassEncoder = pass_encoder;
|
render_state.RenderPassEncoder = pass_encoder;
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
@ -573,7 +537,8 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
if (pcmd->UserCallback != nullptr)
|
if (pcmd->UserCallback != nullptr)
|
||||||
{
|
{
|
||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
if (pcmd->UserCallback == ImGui_ImplWGPU_DrawCallback_ResetRenderState)
|
// (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_ImplWGPU_SetupRenderState(draw_data, pass_encoder, fr);
|
ImGui_ImplWGPU_SetupRenderState(draw_data, pass_encoder, fr);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
@ -584,11 +549,12 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
ImTextureID tex_id = pcmd->GetTexID();
|
ImTextureID tex_id = pcmd->GetTexID();
|
||||||
ImGuiID tex_id_hash = ImHashData(&tex_id, sizeof(tex_id), 0);
|
ImGuiID tex_id_hash = ImHashData(&tex_id, sizeof(tex_id), 0);
|
||||||
WGPUBindGroup bind_group = (WGPUBindGroup)bd->renderResources.ImageBindGroups.GetVoidPtr(tex_id_hash);
|
WGPUBindGroup bind_group = (WGPUBindGroup)bd->renderResources.ImageBindGroups.GetVoidPtr(tex_id_hash);
|
||||||
if (!bind_group && tex_id != 0)
|
if (!bind_group)
|
||||||
if ((bind_group = ImGui_ImplWGPU_CreateImageBindGroup(bd->renderResources.ImageBindGroupLayout, (WGPUTextureView)tex_id)) != 0)
|
{
|
||||||
bd->renderResources.ImageBindGroups.SetVoidPtr(tex_id_hash, bind_group);
|
bind_group = ImGui_ImplWGPU_CreateImageBindGroup(bd->renderResources.ImageBindGroupLayout, (WGPUTextureView)tex_id);
|
||||||
if (bind_group)
|
bd->renderResources.ImageBindGroups.SetVoidPtr(tex_id_hash, bind_group);
|
||||||
wgpuRenderPassEncoderSetBindGroup(pass_encoder, 1, (WGPUBindGroup)bind_group, 0, nullptr);
|
}
|
||||||
|
wgpuRenderPassEncoderSetBindGroup(pass_encoder, 1, (WGPUBindGroup)bind_group, 0, nullptr);
|
||||||
|
|
||||||
// Project scissor/clipping rectangles into framebuffer space
|
// Project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
||||||
@ -597,8 +563,8 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
// Clamp to viewport as wgpuRenderPassEncoderSetScissorRect() won't accept values that are off bounds
|
// Clamp to viewport as wgpuRenderPassEncoderSetScissorRect() won't accept values that are off bounds
|
||||||
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
||||||
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
||||||
if (clip_max.x > (float)fb_width) { clip_max.x = (float)fb_width; }
|
if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; }
|
||||||
if (clip_max.y > (float)fb_height) { clip_max.y = (float)fb_height; }
|
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
||||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -620,7 +586,7 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
}
|
}
|
||||||
image_bind_groups.Data.resize(0);
|
image_bind_groups.Data.resize(0);
|
||||||
|
|
||||||
platform_io.Renderer_RenderState = bd->RenderState = nullptr;
|
platform_io.Renderer_RenderState = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplWGPU_DestroyTexture(ImTextureData* tex)
|
static void ImGui_ImplWGPU_DestroyTexture(ImTextureData* tex)
|
||||||
@ -773,7 +739,7 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
graphics_pipeline_desc.layout = wgpuDeviceCreatePipelineLayout(bd->wgpuDevice, &layout_desc);
|
graphics_pipeline_desc.layout = wgpuDeviceCreatePipelineLayout(bd->wgpuDevice, &layout_desc);
|
||||||
|
|
||||||
// Create the vertex shader
|
// Create the vertex shader
|
||||||
WGPUComputeState vertex_shader_desc = ImGui_ImplWGPU_CreateShaderModuleWGSL(__shader_vert_wgsl);
|
WGPUProgrammableStageDescriptor vertex_shader_desc = ImGui_ImplWGPU_CreateShaderModuleWGSL(__shader_vert_wgsl);
|
||||||
if (!vertex_shader_desc.module) vertex_shader_desc = ImGui_ImplWGPU_CreateShaderModuleSPIRV(__shader_vert_spirv, sizeof(__shader_vert_spirv));
|
if (!vertex_shader_desc.module) vertex_shader_desc = ImGui_ImplWGPU_CreateShaderModuleSPIRV(__shader_vert_spirv, sizeof(__shader_vert_spirv));
|
||||||
graphics_pipeline_desc.vertex.module = vertex_shader_desc.module;
|
graphics_pipeline_desc.vertex.module = vertex_shader_desc.module;
|
||||||
graphics_pipeline_desc.vertex.entryPoint = vertex_shader_desc.entryPoint;
|
graphics_pipeline_desc.vertex.entryPoint = vertex_shader_desc.entryPoint;
|
||||||
@ -781,9 +747,15 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
// Vertex input configuration
|
// Vertex input configuration
|
||||||
WGPUVertexAttribute attribute_desc[] =
|
WGPUVertexAttribute attribute_desc[] =
|
||||||
{
|
{
|
||||||
|
#if defined IMGUI_IMPL_WEBGPU_BACKEND_DAWN || defined IMGUI_IMPL_WEBGPU_BACKEND_WGVK
|
||||||
{ nullptr, WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, pos), 0 },
|
{ nullptr, WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, pos), 0 },
|
||||||
{ nullptr, WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, uv), 1 },
|
{ nullptr, WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, uv), 1 },
|
||||||
{ nullptr, WGPUVertexFormat_Unorm8x4, (uint64_t)offsetof(ImDrawVert, col), 2 },
|
{ nullptr, WGPUVertexFormat_Unorm8x4, (uint64_t)offsetof(ImDrawVert, col), 2 },
|
||||||
|
#else
|
||||||
|
{ WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, pos), 0 },
|
||||||
|
{ WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, uv), 1 },
|
||||||
|
{ WGPUVertexFormat_Unorm8x4, (uint64_t)offsetof(ImDrawVert, col), 2 },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
WGPUVertexBufferLayout buffer_layouts[1];
|
WGPUVertexBufferLayout buffer_layouts[1];
|
||||||
@ -796,7 +768,7 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
graphics_pipeline_desc.vertex.buffers = buffer_layouts;
|
graphics_pipeline_desc.vertex.buffers = buffer_layouts;
|
||||||
|
|
||||||
// Create the pixel shader
|
// Create the pixel shader
|
||||||
WGPUComputeState pixel_shader_desc = ImGui_ImplWGPU_CreateShaderModuleWGSL(__shader_frag_wgsl);
|
WGPUProgrammableStageDescriptor pixel_shader_desc = ImGui_ImplWGPU_CreateShaderModuleWGSL(__shader_frag_wgsl);
|
||||||
if (!pixel_shader_desc.module) pixel_shader_desc = ImGui_ImplWGPU_CreateShaderModuleSPIRV(__shader_frag_spirv, sizeof(__shader_frag_spirv));
|
if (!pixel_shader_desc.module) pixel_shader_desc = ImGui_ImplWGPU_CreateShaderModuleSPIRV(__shader_frag_spirv, sizeof(__shader_frag_spirv));
|
||||||
|
|
||||||
// Create the blending setup
|
// Create the blending setup
|
||||||
@ -842,34 +814,29 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
|
|
||||||
ImGui_ImplWGPU_CreateUniformBuffer();
|
ImGui_ImplWGPU_CreateUniformBuffer();
|
||||||
|
|
||||||
// Create samplers (Linear/Nearest) (bilinear sampling is required)
|
// Create sampler
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
WGPUSamplerDescriptor sampler_desc = {};
|
WGPUSamplerDescriptor sampler_desc = {};
|
||||||
|
sampler_desc.minFilter = WGPUFilterMode_Linear;
|
||||||
|
sampler_desc.magFilter = WGPUFilterMode_Linear;
|
||||||
|
sampler_desc.mipmapFilter = WGPUMipmapFilterMode_Linear;
|
||||||
sampler_desc.addressModeU = WGPUAddressMode_ClampToEdge;
|
sampler_desc.addressModeU = WGPUAddressMode_ClampToEdge;
|
||||||
sampler_desc.addressModeV = WGPUAddressMode_ClampToEdge;
|
sampler_desc.addressModeV = WGPUAddressMode_ClampToEdge;
|
||||||
sampler_desc.addressModeW = WGPUAddressMode_ClampToEdge;
|
sampler_desc.addressModeW = WGPUAddressMode_ClampToEdge;
|
||||||
sampler_desc.maxAnisotropy = 1;
|
sampler_desc.maxAnisotropy = 1;
|
||||||
sampler_desc.minFilter = WGPUFilterMode_Linear;
|
bd->renderResources.Sampler = wgpuDeviceCreateSampler(bd->wgpuDevice, &sampler_desc);
|
||||||
sampler_desc.magFilter = WGPUFilterMode_Linear;
|
|
||||||
sampler_desc.mipmapFilter = WGPUMipmapFilterMode_Linear;
|
|
||||||
bd->renderResources.SamplerLinear = wgpuDeviceCreateSampler(bd->wgpuDevice, &sampler_desc);
|
|
||||||
sampler_desc.minFilter = WGPUFilterMode_Nearest;
|
|
||||||
sampler_desc.magFilter = WGPUFilterMode_Nearest;
|
|
||||||
sampler_desc.mipmapFilter = WGPUMipmapFilterMode_Nearest;
|
|
||||||
bd->renderResources.SamplerNearest = wgpuDeviceCreateSampler(bd->wgpuDevice, &sampler_desc);
|
|
||||||
|
|
||||||
// Create resource bind groups (one per sampler, otherwise identical)
|
// Create resource bind group
|
||||||
WGPUBindGroupEntry common_bg_entries[] =
|
WGPUBindGroupEntry common_bg_entries[] =
|
||||||
{
|
{
|
||||||
{ nullptr, 0, bd->renderResources.Uniforms, 0, MEMALIGN(sizeof(Uniforms), 16), 0, 0 },
|
{ nullptr, 0, bd->renderResources.Uniforms, 0, MEMALIGN(sizeof(Uniforms), 16), 0, 0 },
|
||||||
{ nullptr, 1, 0, 0, 0, bd->renderResources.SamplerLinear, 0 },
|
{ nullptr, 1, 0, 0, 0, bd->renderResources.Sampler, 0 },
|
||||||
};
|
};
|
||||||
WGPUBindGroupDescriptor common_bg_descriptor = {};
|
WGPUBindGroupDescriptor common_bg_descriptor = {};
|
||||||
common_bg_descriptor.layout = bg_layouts[0];
|
common_bg_descriptor.layout = bg_layouts[0];
|
||||||
common_bg_descriptor.entryCount = sizeof(common_bg_entries) / sizeof(WGPUBindGroupEntry);
|
common_bg_descriptor.entryCount = sizeof(common_bg_entries) / sizeof(WGPUBindGroupEntry);
|
||||||
common_bg_descriptor.entries = common_bg_entries;
|
common_bg_descriptor.entries = common_bg_entries;
|
||||||
bd->renderResources.CommonBindGroupLinear = wgpuDeviceCreateBindGroup(bd->wgpuDevice, &common_bg_descriptor);
|
bd->renderResources.CommonBindGroup = wgpuDeviceCreateBindGroup(bd->wgpuDevice, &common_bg_descriptor);
|
||||||
common_bg_entries[1].sampler = bd->renderResources.SamplerNearest;
|
|
||||||
bd->renderResources.CommonBindGroupNearest = wgpuDeviceCreateBindGroup(bd->wgpuDevice, &common_bg_descriptor);
|
|
||||||
bd->renderResources.ImageBindGroupLayout = bg_layouts[1];
|
bd->renderResources.ImageBindGroupLayout = bg_layouts[1];
|
||||||
|
|
||||||
SafeRelease(vertex_shader_desc.module);
|
SafeRelease(vertex_shader_desc.module);
|
||||||
@ -921,11 +888,6 @@ bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info)
|
|||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.DrawCallback_ResetRenderState = ImGui_ImplWGPU_DrawCallback_ResetRenderState;
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear = ImGui_ImplWGPU_DrawCallback_SetSamplerLinear;
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest = ImGui_ImplWGPU_DrawCallback_SetSamplerNearest;
|
|
||||||
|
|
||||||
bd->initInfo = *init_info;
|
bd->initInfo = *init_info;
|
||||||
bd->wgpuDevice = init_info->Device;
|
bd->wgpuDevice = init_info->Device;
|
||||||
bd->defaultQueue = wgpuDeviceGetQueue(bd->wgpuDevice);
|
bd->defaultQueue = wgpuDeviceGetQueue(bd->wgpuDevice);
|
||||||
@ -934,7 +896,11 @@ bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info)
|
|||||||
bd->numFramesInFlight = init_info->NumFramesInFlight;
|
bd->numFramesInFlight = init_info->NumFramesInFlight;
|
||||||
bd->frameIndex = UINT_MAX;
|
bd->frameIndex = UINT_MAX;
|
||||||
|
|
||||||
|
bd->renderResources.Sampler = nullptr;
|
||||||
|
bd->renderResources.Uniforms = nullptr;
|
||||||
|
bd->renderResources.CommonBindGroup = nullptr;
|
||||||
bd->renderResources.ImageBindGroups.Data.reserve(100);
|
bd->renderResources.ImageBindGroups.Data.reserve(100);
|
||||||
|
bd->renderResources.ImageBindGroupLayout = nullptr;
|
||||||
|
|
||||||
// Create buffers with a default size (they will later be grown as needed)
|
// Create buffers with a default size (they will later be grown as needed)
|
||||||
bd->pFrameResources = new FrameResources[bd->numFramesInFlight];
|
bd->pFrameResources = new FrameResources[bd->numFramesInFlight];
|
||||||
@ -989,7 +955,11 @@ void ImGui_ImplWGPU_NewFrame()
|
|||||||
|
|
||||||
bool ImGui_ImplWGPU_IsSurfaceStatusError(WGPUSurfaceGetCurrentTextureStatus status)
|
bool ImGui_ImplWGPU_IsSurfaceStatusError(WGPUSurfaceGetCurrentTextureStatus status)
|
||||||
{
|
{
|
||||||
|
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) || defined(IMGUI_IMPL_WEBGPU_BACKEND_WGVK)
|
||||||
return (status == WGPUSurfaceGetCurrentTextureStatus_Error);
|
return (status == WGPUSurfaceGetCurrentTextureStatus_Error);
|
||||||
|
#else
|
||||||
|
return (status == WGPUSurfaceGetCurrentTextureStatus_OutOfMemory || status == WGPUSurfaceGetCurrentTextureStatus_DeviceLost);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplWGPU_IsSurfaceStatusSubOptimal(WGPUSurfaceGetCurrentTextureStatus status)
|
bool ImGui_ImplWGPU_IsSurfaceStatusSubOptimal(WGPUSurfaceGetCurrentTextureStatus status)
|
||||||
@ -1002,6 +972,7 @@ bool ImGui_ImplWGPU_IsSurfaceStatusSubOptimal(WGPUSurfaceGetCurrentTextureStatus
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helpers to obtain a string
|
// Helpers to obtain a string
|
||||||
|
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) || defined(IMGUI_IMPL_WEBGPU_BACKEND_WGVK)
|
||||||
const char* ImGui_ImplWGPU_GetErrorTypeName(WGPUErrorType type)
|
const char* ImGui_ImplWGPU_GetErrorTypeName(WGPUErrorType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
@ -1024,7 +995,7 @@ const char* ImGui_ImplWGPU_GetDeviceLostReasonName(WGPUDeviceLostReason type)
|
|||||||
default: return "Unknown";
|
default: return "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) && !defined(__EMSCRIPTEN__)
|
#elif !defined(__EMSCRIPTEN__)
|
||||||
const char* ImGui_ImplWGPU_GetLogLevelName(WGPULogLevel level)
|
const char* ImGui_ImplWGPU_GetLogLevelName(WGPULogLevel level)
|
||||||
{
|
{
|
||||||
switch (level)
|
switch (level)
|
||||||
|
|||||||
@ -17,8 +17,8 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID/ImTextureRef!
|
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID/ImTextureRef!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
// [X] Renderer: Texture updates support for dynamic font system (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font system (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Expose selected render state for draw callbacks to use. Access with ImGui_ImplWGPU_GetRenderState().
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -81,7 +81,6 @@ struct ImGui_ImplWGPU_RenderState
|
|||||||
WGPUDevice Device;
|
WGPUDevice Device;
|
||||||
WGPURenderPassEncoder RenderPassEncoder;
|
WGPURenderPassEncoder RenderPassEncoder;
|
||||||
};
|
};
|
||||||
IMGUI_IMPL_API ImGui_ImplWGPU_RenderState* ImGui_ImplWGPU_GetRenderState();
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Internal Helpers
|
// Internal Helpers
|
||||||
@ -96,9 +95,10 @@ bool ImGui_ImplWGPU_IsSurfaceStatusSubOptimal(WGPUSurfaceGetCurrentTextur
|
|||||||
void ImGui_ImplWGPU_DebugPrintAdapterInfo(const WGPUAdapter& adapter);
|
void ImGui_ImplWGPU_DebugPrintAdapterInfo(const WGPUAdapter& adapter);
|
||||||
const char* ImGui_ImplWGPU_GetBackendTypeName(WGPUBackendType type);
|
const char* ImGui_ImplWGPU_GetBackendTypeName(WGPUBackendType type);
|
||||||
const char* ImGui_ImplWGPU_GetAdapterTypeName(WGPUAdapterType type);
|
const char* ImGui_ImplWGPU_GetAdapterTypeName(WGPUAdapterType type);
|
||||||
|
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN)
|
||||||
const char* ImGui_ImplWGPU_GetDeviceLostReasonName(WGPUDeviceLostReason type);
|
const char* ImGui_ImplWGPU_GetDeviceLostReasonName(WGPUDeviceLostReason type);
|
||||||
const char* ImGui_ImplWGPU_GetErrorTypeName(WGPUErrorType type);
|
const char* ImGui_ImplWGPU_GetErrorTypeName(WGPUErrorType type);
|
||||||
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) && !defined(__EMSCRIPTEN__)
|
#elif defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
|
||||||
const char* ImGui_ImplWGPU_GetLogLevelName(WGPULogLevel level);
|
const char* ImGui_ImplWGPU_GetLogLevelName(WGPULogLevel level);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2026-05-19: DPI: ImGui_ImplWin32_EnableDpiAwareness() helper uses SetProcessDpiAwarenessContext() instead of SetThreadDpiAwarenessContext(), fixes DPI scaling issues with e.g. OpenGL. (#9403)
|
|
||||||
// 2026-01-28: Inputs: Minor optimization not submitting gamepad input if packet number has not changed (reworked from 2025-09-23 attempt). (#9202, #8556)
|
// 2026-01-28: Inputs: Minor optimization not submitting gamepad input if packet number has not changed (reworked from 2025-09-23 attempt). (#9202, #8556)
|
||||||
// 2025-12-03: Inputs: handle WM_IME_CHAR/WM_IME_COMPOSITION messages to support Unicode inputs on MBCS (non-Unicode) Windows. (#9099, #3653, #5961)
|
// 2025-12-03: Inputs: handle WM_IME_CHAR/WM_IME_COMPOSITION messages to support Unicode inputs on MBCS (non-Unicode) Windows. (#9099, #3653, #5961)
|
||||||
// 2025-10-19: Inputs: Revert previous change to allow for io.ClearInputKeys() on focus-out not losing gamepad state.
|
// 2025-10-19: Inputs: Revert previous change to allow for io.ClearInputKeys() on focus-out not losing gamepad state.
|
||||||
@ -413,7 +412,7 @@ void ImGui_ImplWin32_NewFrame()
|
|||||||
// Setup time step
|
// Setup time step
|
||||||
INT64 current_time = 0;
|
INT64 current_time = 0;
|
||||||
::QueryPerformanceCounter((LARGE_INTEGER*)¤t_time);
|
::QueryPerformanceCounter((LARGE_INTEGER*)¤t_time);
|
||||||
io.DeltaTime = (float)((double)(current_time - bd->Time) / (double)bd->TicksPerSecond);
|
io.DeltaTime = (float)(current_time - bd->Time) / bd->TicksPerSecond;
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
// Update OS mouse position
|
// Update OS mouse position
|
||||||
@ -887,7 +886,6 @@ DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
|
|||||||
typedef HRESULT(WINAPI* PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS); // Shcore.lib + dll, Windows 8.1+
|
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 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)
|
typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); // User32.lib + dll, Windows 10 v1607+ (Creators Update)
|
||||||
typedef BOOL(WINAPI* PFN_SetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); // User32.lib + dll, Windows 10 v1703+ (Creators Update)
|
|
||||||
|
|
||||||
// Helper function to enable DPI awareness without setting up a manifest
|
// Helper function to enable DPI awareness without setting up a manifest
|
||||||
void ImGui_ImplWin32_EnableDpiAwareness()
|
void ImGui_ImplWin32_EnableDpiAwareness()
|
||||||
@ -895,12 +893,7 @@ void ImGui_ImplWin32_EnableDpiAwareness()
|
|||||||
if (_IsWindows10OrGreater())
|
if (_IsWindows10OrGreater())
|
||||||
{
|
{
|
||||||
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
||||||
if (PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContextFn = (PFN_SetProcessDpiAwarenessContext)::GetProcAddress(user32_dll, "SetProcessDpiAwarenessContext")) // Windows 10 v1703+
|
if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext"))
|
||||||
{
|
|
||||||
SetProcessDpiAwarenessContextFn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext")) // Windows 10 v1607+
|
|
||||||
{
|
{
|
||||||
SetThreadDpiAwarenessContextFn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
SetThreadDpiAwarenessContextFn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||||
return;
|
return;
|
||||||
@ -937,7 +930,7 @@ float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
|
|||||||
{
|
{
|
||||||
GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
|
GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
|
||||||
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
|
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
|
||||||
return (float)xdpi / 96.0f;
|
return xdpi / 96.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef NOGDI
|
#ifndef NOGDI
|
||||||
@ -947,7 +940,7 @@ float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
|
|||||||
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
|
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
|
||||||
::ReleaseDC(nullptr, dc);
|
::ReleaseDC(nullptr, dc);
|
||||||
#endif
|
#endif
|
||||||
return (float)xdpi / 96.0f;
|
return xdpi / 96.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd)
|
float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd)
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
#version 450 core
|
#version 450 core
|
||||||
layout(location = 0) out vec4 fColor;
|
layout(location = 0) out vec4 fColor;
|
||||||
|
|
||||||
layout(set=0, binding=0) uniform texture2D _Texture;
|
layout(set=0, binding=0) uniform sampler2D sTexture;
|
||||||
layout(set=1, binding=0) uniform sampler _Sampler;
|
|
||||||
|
|
||||||
layout(location = 0) in struct {
|
layout(location = 0) in struct {
|
||||||
vec4 Color;
|
vec4 Color;
|
||||||
@ -11,5 +10,5 @@ layout(location = 0) in struct {
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
fColor = In.Color * texture(sampler2D(_Texture, _Sampler), In.UV.st);
|
fColor = In.Color * texture(sTexture, In.UV.st);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,14 +72,13 @@ For example, the [example_win32_directx11](https://github.com/ocornut/imgui/tree
|
|||||||
|
|
||||||
In the [backends/](https://github.com/ocornut/imgui/blob/master/backends) folder:
|
In the [backends/](https://github.com/ocornut/imgui/blob/master/backends) folder:
|
||||||
|
|
||||||
List of Platform Backends:
|
List of Platforms Backends:
|
||||||
|
|
||||||
imgui_impl_android.cpp ; Android native app API
|
imgui_impl_android.cpp ; Android native app API
|
||||||
imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/
|
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 backends)
|
imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl backends)
|
||||||
imgui_impl_sdl2.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
imgui_impl_sdl2.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
||||||
imgui_impl_sdl3.cpp ; SDL3 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
imgui_impl_sdl3.cpp ; SDL3 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
||||||
imgui_impl_qnx.cpp ; QNX Screen
|
|
||||||
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
||||||
imgui_impl_glut.cpp ; GLUT/FreeGLUT (this is prehistoric software and absolutely not recommended today!)
|
imgui_impl_glut.cpp ; GLUT/FreeGLUT (this is prehistoric software and absolutely not recommended today!)
|
||||||
|
|
||||||
@ -90,7 +89,6 @@ List of Renderer Backends:
|
|||||||
imgui_impl_dx11.cpp ; DirectX11
|
imgui_impl_dx11.cpp ; DirectX11
|
||||||
imgui_impl_dx12.cpp ; DirectX12
|
imgui_impl_dx12.cpp ; DirectX12
|
||||||
imgui_impl_metal.mm ; Metal (ObjC or C++)
|
imgui_impl_metal.mm ; Metal (ObjC or C++)
|
||||||
imgui_impl_metal4.mm ; Metal 4 (ObjC or C++)
|
|
||||||
imgui_impl_opengl2.cpp ; OpenGL 2 (legacy fixed pipeline. Don't use with modern OpenGL code!)
|
imgui_impl_opengl2.cpp ; OpenGL 2 (legacy fixed pipeline. Don't use with modern OpenGL code!)
|
||||||
imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2/3, WebGL
|
imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2/3, WebGL
|
||||||
imgui_impl_sdlgpu3.cpp ; SDL_GPU (portable 3D graphics API of SDL3)
|
imgui_impl_sdlgpu3.cpp ; SDL_GPU (portable 3D graphics API of SDL3)
|
||||||
@ -118,7 +116,7 @@ If you are not sure which backend to use, the recommended platform/frameworks fo
|
|||||||
| GLFW | https://github.com/glfw/glfw | imgui_impl_glfw.cpp | |
|
| GLFW | https://github.com/glfw/glfw | imgui_impl_glfw.cpp | |
|
||||||
| Sokol | https://github.com/floooh/sokol | [util/sokol_imgui.h](https://github.com/floooh/sokol/blob/master/util/sokol_imgui.h) | Lower-level than GLFW/SDL |
|
| Sokol | https://github.com/floooh/sokol | [util/sokol_imgui.h](https://github.com/floooh/sokol/blob/master/util/sokol_imgui.h) | Lower-level than GLFW/SDL |
|
||||||
|
|
||||||
If your application runs on Windows or if you are using multi-viewports, the imgui_impl_win32 backend handles some details better than other backends.
|
If your application runs on Windows or if you are using multi-viewport, the win32 backend handles some details a little better than other backends.
|
||||||
|
|
||||||
## Using third-party Backends
|
## Using third-party Backends
|
||||||
|
|
||||||
@ -235,7 +233,9 @@ void MyImGuiBackend_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// - Scissor enabled
|
// - Scissor enabled
|
||||||
MyEngineSetupenderState();
|
MyEngineSetupenderState();
|
||||||
|
|
||||||
// TODO: Setup texture sampler to bilinear (NOT point/nearest filtering).
|
// TODO: Setup texture sampling state
|
||||||
|
// - Sample with bilinear filtering (NOT point/nearest filtering).
|
||||||
|
// - Use 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines;' to allow point/nearest filtering.
|
||||||
|
|
||||||
// TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
|
// TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
|
||||||
|
|
||||||
@ -255,8 +255,8 @@ void MyImGuiBackend_RenderDrawData(ImDrawData* draw_data)
|
|||||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||||
if (pcmd->UserCallback)
|
if (pcmd->UserCallback)
|
||||||
{
|
{
|
||||||
if (pcmd->UserCallback == platform_io.DrawCallback_ResetRenderState)
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
MyEngineSetupSenderState();
|
MyEngineSetupenderState();
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(cmd_list, pcmd);
|
pcmd->UserCallback(cmd_list, pcmd);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,926 +35,6 @@ HOW TO UPDATE?
|
|||||||
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
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!
|
- Please report any issue!
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.93.1 WIP (In Progress)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Breaking Changes:
|
|
||||||
|
|
||||||
Autumn cleanup of stuff marked obsolete more than two years ago:
|
|
||||||
|
|
||||||
- Commented out legacy names/functions which were obsoleted in 1.90.7 (May 2024);
|
|
||||||
- `ImGuiMod_Shortcut` --> `ImGuiMod_Ctrl` (since 1.90.7 it maps to Cmd on macOS)
|
|
||||||
- Commented out legacy names/functions which were obsoleted in 1.90.9 (July 2024);
|
|
||||||
- `ImGuiCol_TabActive` --> `ImGuiCol_TabSelected`
|
|
||||||
- `ImGuiCol_TabUnfocused` --> `ImGuiCol_TabDimmed`
|
|
||||||
- `ImGuiCol_TabUnfocusedActive` --> `ImGuiCol_TabDimmedSelected`
|
|
||||||
- Commented out legacy names/functions which were obsoleted in 1.91.0 (July 2024);
|
|
||||||
- `ImGuiSelectableFlags_DontClosePopups` --> `ImGuiSelectableFlags_NoAutoClosePopups`
|
|
||||||
- `PushButtonRepeat(bool repeat)` --> `PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat)`
|
|
||||||
- `PopButtonRepeat()` --> `PopItemFlag()`
|
|
||||||
- `PushTabStop(bool tab_stop)` --> `PushItemFlag(ImGuiItemFlags_NoTabStop, !tab_stop);`
|
|
||||||
- `PopTabStop()` --> `PopItemFlag()`
|
|
||||||
- Commented out legacy names/functions which were obsoleted in 1.91.1 (Sept 2024);
|
|
||||||
- `io.GetClipboardTextFn` --> `platform_io.Platform_GetClipboardTextFn`
|
|
||||||
- `io.SetClipboardTextFn` --> `platform_io.Platform_SetClipboardTextFn`
|
|
||||||
- `io.ClipboardUserData` --> `platform_io.Platform_ClipboardUserData`
|
|
||||||
- Please also try to get rid of calls to `GetContentRegionMax()`, `GetWindowContentRegionMin()`
|
|
||||||
and `GetWindowContentRegionMax()` will may be removed soon-ish: you should not
|
|
||||||
ever need those functions. See #7838.
|
|
||||||
|
|
||||||
|
|
||||||
Other Changes:
|
|
||||||
|
|
||||||
- Style:
|
|
||||||
- `StyleColorsDark()`: tweaked WindowBg to be darker than in 1.93.0.
|
|
||||||
- Added `style.SymbolArrowSizeFactor`, `style.SymbolArrowThicknessFactor` to tweak the
|
|
||||||
shape and look of arrows. Made default arrow stroked. (#5233, #2431, #2235, #6730, #8243)
|
|
||||||
Legacy arrow: size: (0.60f,0.70f), thickness: 0.0f
|
|
||||||
New arrow: size: (0.72f,0.40f), thickness: 0.30f
|
|
||||||
- Windows:
|
|
||||||
- Using `SetNextWindowPos()` with a pivot while a window is hidden and measuring
|
|
||||||
size will still apply temporary position until size is figured out. (#9568)
|
|
||||||
- TreeNode:
|
|
||||||
- TreeNodeGetOpen(): added flags parameter to allow passing `ImGuiTreeNodeFlags_DefaultOpen`
|
|
||||||
or `ImGuiTreeNodeFlags_Leaf`. (#9569, #9592, #3823, #9251) [@adalisk-emikhaylov, @Yaki-Blake]
|
|
||||||
- Popups:
|
|
||||||
- Modals: fixed an assert displaying a modal in an environment where
|
|
||||||
`io.DisplayFramebufferScale` is not an integer (regression in 1.93.0). (#9598)
|
|
||||||
- Tables:
|
|
||||||
- Fixed various border overshooting issues, some mostly visible with transparent
|
|
||||||
borders and under specific conditions: (#4678)
|
|
||||||
- On non-scrolling tables, inner horizontal borders slightly overlapped
|
|
||||||
outer vertical ones with certain settings.
|
|
||||||
- On non-scrolling tables, clamping lower border coordinates to stay within
|
|
||||||
visible range (no visible change, but it makes ImDrawCmd AABB more sensible).
|
|
||||||
- Fixed vertical inner borders slightly overlapping bottom outer border.
|
|
||||||
- Fixed various issues using `ImGuiTableFlags_NoHostExtendX`/`_NoHostExtendY`:
|
|
||||||
- Fixed selectable highlight straying off the X2/Y2 clipping limit.
|
|
||||||
- Fixed parent window work rectangle affecting the Y2 clipping limit.
|
|
||||||
- Fixed the Y2 clipping limit overlapping bottom outer border.
|
|
||||||
- Multi-Select:
|
|
||||||
- Fixed `ImGuiSelectionBasicStorage::GetNextSelectedItem()` reading one past the
|
|
||||||
end of storage when trailing items are unselected (#9604) [@MilosLord]
|
|
||||||
- Drags: fixed handling of `ImGuiSliderFlags_WrapAround`: value could temporarily
|
|
||||||
escape the range when dragging fast. (#9612, #9611, #7749) [@swayie, @ocornut]
|
|
||||||
- ColorEdit:
|
|
||||||
- ColorButton, ColorEdit, ColorPicker: fixed an issue rendering colors when
|
|
||||||
inside a `BeginDisabled(false)` block, caused by the alpha cancelling-out
|
|
||||||
code in 1.93.0. (#9511, #9613, #9614) [@tksuoran]
|
|
||||||
- ImVec2: added a check for cases where a custom `IM_VEC2_CLASS_EXTRA` macro
|
|
||||||
adds an extra `operator=` to ImVec2. This isn't supported but should not
|
|
||||||
be needed as you should have a constructor to convert from your type to ImVec2.
|
|
||||||
- CI: added some ARM64 builds. (#9593) [@Harishmcw]
|
|
||||||
- Examples: renamed various helper batch files from build_win32.bat to build_win.bat
|
|
||||||
to reflect that they can also build X64 or ARM64, given the right environment.
|
|
||||||
Made the script detect the environment when needed (e.g. to specify library path).
|
|
||||||
- Examples: added support for ARM64 in selected build_win.bat helpers. (#9593) [@Harishmcw]
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.93.0 (Released 2026-10-14)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.93.0
|
|
||||||
|
|
||||||
In 1.93.0, the `ImDrawList` rendering API has been improved to be more robust and
|
|
||||||
more consistent over the whole range of shapes. The rendering now matches much closer
|
|
||||||
to common vector drawing APIs, like html canvas. Improvements, like anti-aliased line
|
|
||||||
endings and stroke position were added. The coordinates passed to the API are now
|
|
||||||
consistently describing shape outlines.
|
|
||||||
|
|
||||||
For code using custom rendering: some details are now rendered slightly differently
|
|
||||||
(even if generally more consistent). The difference in rendering is in the range of
|
|
||||||
half a pixel, but that can lead to issues like some lines now look blurrier or more
|
|
||||||
transparent. All Dear ImGui widgets should appear identical or better.
|
|
||||||
|
|
||||||
The rendering of common shapes was optimized when the shapes fall on integer coordinates
|
|
||||||
(which is most of the UI). This includes skipping anti-aliasing when not needed, or
|
|
||||||
using textures instead of tessellated geometry to draw round corners.
|
|
||||||
The varying code-paths are designed to look indistinguishable from each others.
|
|
||||||
|
|
||||||
New rendering code fixes some inconsistencies between graphics APIs
|
|
||||||
(e.g. DirectX vs OpenGL) which are using different diamond exits rules.
|
|
||||||
New code should work precisely the same regardless of which graphics API is used
|
|
||||||
(note that using _StrokeLegacy mode can lead to the same old inconsistencies).
|
|
||||||
|
|
||||||
New rendering code also deals better with animating thickness and rounding
|
|
||||||
(integer values are recommended).
|
|
||||||
|
|
||||||
While the current version doesn't make lots of visible use of the new features and
|
|
||||||
facilities, they are among the pillars that will make it easier to create prettier
|
|
||||||
contents, both for custom rendering and future versions of the library.
|
|
||||||
|
|
||||||
Use `ImDrawFlags_StrokeLegacy` mode to emulate old rendering:
|
|
||||||
- Per-primitive: draw_list->AddLine(..., ..., ImDrawFlags_StrokeLegacy);
|
|
||||||
- For a given scope: draw_list->PushDrawFlag(ImDrawFlags_StrokeLegacy, true); draw_list->AddLine(...); draw_list->PopDrawFlag();
|
|
||||||
- Globally: ImGui::Checkbox("DefaultsToStrokeLegacy", &io.ConfigDebugDrawListDefaultsToStrokeLegacy); // Map to a checkbox
|
|
||||||
- Globally: io.ConfigDebugDrawListDefaultsToStrokeLegacy = io.KeyShift; // Map on Shift
|
|
||||||
|
|
||||||
Don't panic!
|
|
||||||
Many applications will not notice any difference! You will more likely see
|
|
||||||
differences if you used lots of direct `ImDrawList` calls for custom rendering.
|
|
||||||
|
|
||||||
Credits for ImDrawList changes in 1.93.0:
|
|
||||||
- main work courtesy of @memononen.
|
|
||||||
- additional work/reviewing/guidance by @ocornut.
|
|
||||||
- with legacy bits from @thedmd, @potocpav.
|
|
||||||
Other credits marked below, or @ocornut when omitted.
|
|
||||||
|
|
||||||
Refer to our guides:
|
|
||||||
- ImDrawList Vector Rendering Reference
|
|
||||||
https://github.com/ocornut/imgui/wiki/Draw-List
|
|
||||||
(includes a precise list of differences between 1.92.9 and 1.93.0).
|
|
||||||
- ImDrawList 1.92.9 vs 1.93.0 Interactive Testbed
|
|
||||||
https://www.dearimgui.com/docs/drawlist_v193
|
|
||||||
(interactively compare differences between 1.92.9 and 1.93.0 + commentary)
|
|
||||||
(downloadable HTML file, may be used offline)
|
|
||||||
- Pixel Perfect Anti-aliased Rendering
|
|
||||||
https://github.com/ocornut/imgui/wiki/Pixel-Perfect-Rendering
|
|
||||||
- How Anti-aliased Polyline Rendering is Implemented
|
|
||||||
https://github.com/ocornut/imgui/wiki/Polyline-Rendering
|
|
||||||
- Discussion topic:
|
|
||||||
https://github.com/ocornut/imgui/issues/9504
|
|
||||||
(if you have a problem to discuss, please open a new issue)
|
|
||||||
|
|
||||||
Breaking Changes:
|
|
||||||
|
|
||||||
- ImDrawList:
|
|
||||||
- AddLine(): removed the (+0.5f,+0.5f) offset that was sneakily added to input coordinates. (#9504)
|
|
||||||
- This fixes inconsistencies in the API and matches the PathXXX API.
|
|
||||||
- By default, stroke thickness extends on both side of the given segment.
|
|
||||||
e.g for a "pixel-perfect" looking line with thickness=1.0f, coords should be passed as center of each ends of the line.
|
|
||||||
- Use `ImDrawFlags_StrokeLegacy` to use old offset if required. Or you can apply the offset manually!
|
|
||||||
- Generally better, simple and faster to use `AddLineH()`, `AddLineV()` functions added in 1.92.8.
|
|
||||||
READ IF YOU ARE MINDFUL OF PIXEL-PERFECTNESS IN YOUR CUSTOM RENDERING/WIDGETS:
|
|
||||||
- TRANSITION GUIDE FOR AXIS-ALIGNED LINES:
|
|
||||||
- When switching from legacy `AddLine()` values to `AddLineV()`, `AddLineH()` you can keep same inputs coordinates as before:
|
|
||||||
- Old `AddLine({x, y1}, {x, y2}, col)` --> `AddLineV(x, y1, y2, col);` // Vertical line.
|
|
||||||
- Old `AddLine({x1, y}, {x2, y}, col)` --> `AddLineH(x1, x2, y, col);` // Horizontal line.
|
|
||||||
- This will be equivalent and faster for thickness=1.0f lines.
|
|
||||||
- Since `AddLine()` use default stroke pos Center and `AddLineV()`, `AddLineH()` use Inside, thickness>1.0f strokes will differ.
|
|
||||||
Using `ImDrawFlags_StrokeCenter` will match old result more closely (aka look centered),
|
|
||||||
but is more likely to look blurry as it already did before.
|
|
||||||
- Read table below about StrokePos and the "Pixel-Perfect Rendering" guide if you care about pixel-perfect lines.
|
|
||||||
- TRANSITION GUIDE FOR DIAGONAL LINES:
|
|
||||||
- Your lines will appear offset by -0.5f pixels on each axis.
|
|
||||||
Being anti-aliased diagonal lines, they won't look particularly better or worse, just slightly offset.
|
|
||||||
It'll likely only be noticeable if you carefully combined them with other primitives for a pixel-perfect result.
|
|
||||||
- Old `AddLine({x1, y1}, {x2, y2}, col)` --> `AddLine({x1 + 0.5f, y1 + 0.5f}, {x2+ 0.5f, y2 + 0.5f}, col);` // Same
|
|
||||||
or use `ImDrawFlags_StrokeLegacy` --> `AddLine({x1, y1}, {x2, y2}, col, thickness, ImDrawFlags_StrokeLegacy);` // Offset by +0.5f + disable AA ends.
|
|
||||||
This reapplies the old offset, and should get you exactly the same result you previously
|
|
||||||
got for thickness=1.0f lines. But said result were previously sometimes ambiguous and
|
|
||||||
renderer-dependent. (#3116, #3258, #2441)
|
|
||||||
- Old code did not support anti-aliased ends, which could create gaps when rendering shapes out
|
|
||||||
of multiple contiguous lines instead of using `AddPolyline()`. There is a possibility that you
|
|
||||||
legacy code added fudge offsets here and there; which may not be necessary anymore if you use
|
|
||||||
`_AALineEnds`, or if you combine rendering of contiguous lines using `AddPolyline()`.
|
|
||||||
- AddRect(), AddCircle(), AddNgon(), AddEllipse(), AddTriangle(), AddQuad(): defaulting to "inside" stroke.
|
|
||||||
- All closed shapes with thickness=1.0f will appear identical.
|
|
||||||
- The difference for thickness>1.0f shapes may be minimal since very large strokes
|
|
||||||
were not well supported for widgets, but stroke will default inside widgets.
|
|
||||||
- AddCircle(), AddNgon(): removed -0.5f offset added to radius.
|
|
||||||
- This fixes inconsistencies in the API.
|
|
||||||
- Use `ImDrawFlags_StrokeLegacy` to use old method if required. Or you can apply the offset manually!
|
|
||||||
- AddRectFilled(): non-integer coordinates will now display anti-aliased edges.
|
|
||||||
Previously, non-integer coordinates rendered with aliased edges snapped by the
|
|
||||||
rasterizer. (#6971)
|
|
||||||
- AddRect(), AddRectFilled(): rectangles with inverted coordinates won't be visible
|
|
||||||
unless using `ImDrawFlags_StrokeLegacy` mode. With inverted coordinates (min > max):
|
|
||||||
- Legacy `AddRect()` rounding off -> visible but incorrect outer size.
|
|
||||||
- Legacy `AddRect()` rounding on -> visible but very glitchy.
|
|
||||||
- Legacy `AddRectFilled()` rounding off -> visible and correct.
|
|
||||||
- Legacy `AddRectFilled()` rounding on -> visible but very glitchy.
|
|
||||||
- Use `ImDrawFlags_StrokeLegacy` to use old rendering for cases without rounding, or fix coordinates.
|
|
||||||
- Merged `ImDrawListFlags` into `ImDrawFlags`. `ImDrawListFlags` was rarely used directly
|
|
||||||
and generally setup by the ImGui context.
|
|
||||||
- `ImDrawListFlags_AntiAliasedLines` -> `ImDrawFlags_AALines`
|
|
||||||
- `ImDrawListFlags_AntiAliasedFill` -> `ImDrawFlags_AAFill`
|
|
||||||
- `ImDrawListFlags_AllowVtxOffset` -> `ImDrawFlags_UseVtxOffset`
|
|
||||||
- `ImDrawListFlags_TextNoPixelSnap` -> `ImDrawFlags_TextNoPixelSnap`
|
|
||||||
Unifying them allows easily using them for both per-primitives and scope alterations.
|
|
||||||
Kept redirection enums (will obsolete).
|
|
||||||
- Renamed all `ImDrawFlags_RoundCornersXXX` flags to `ImDrawFlags_RoundXXX`.
|
|
||||||
- `ImDrawFlags_RoundCornersAll` -> `ImDrawFlags_RoundAll`
|
|
||||||
- `ImDrawFlags_RoundCornersNone` -> `ImDrawFlags_RoundNone`
|
|
||||||
- `ImDrawFlags_RoundCornersTopLeft` -> `ImDrawFlags_RoundTopLeft`
|
|
||||||
- `ImDrawFlags_RoundCornersTopRight` -> `ImDrawFlags_RoundTopRight`
|
|
||||||
- `ImDrawFlags_RoundCornersBottomLeft` -> `ImDrawFlags_RoundBottomLeft`
|
|
||||||
- `ImDrawFlags_RoundCornersBottomRight` -> `ImDrawFlags_RoundBottomRight`
|
|
||||||
- `ImDrawFlags_RoundCornersTop` -> `ImDrawFlags_RoundTop`
|
|
||||||
- `ImDrawFlags_RoundCornersBottom` -> `ImDrawFlags_RoundBottom`
|
|
||||||
- `ImDrawFlags_RoundCornersLeft` -> `ImDrawFlags_RoundLeft`
|
|
||||||
- `ImDrawFlags_RoundCornersRight` -> `ImDrawFlags_RoundRight`
|
|
||||||
- `ImDrawFlags_RoundCornersMask_` -> `ImDrawFlags_RoundMask_`
|
|
||||||
Kept redirection enums (will obsolete).
|
|
||||||
- Marked `ImDrawListFlags_AntiAliasedLinesUseTex` and `style.AntiAliasedLinesUseTex` as
|
|
||||||
obsolete, as the new line rendering code always uses textures.
|
|
||||||
- Enabling `ImFontAtlasFlags_NoBakedLines` in the font atlas will now disable support for
|
|
||||||
anti-aliased lines by clearing `style.AntiAliasedLines`/`style.AntiAliasedLineEnds`.
|
|
||||||
- Style: obsoleted `style.CurveTessellationTol` (default 1.25) which was in Pixels² unit in
|
|
||||||
favor of `style.CurveTessellationMaxError` (default 1.12) which is in Pixels unit. It is
|
|
||||||
easier to tweak + this allows us to easily scale error threshold on high density screens.
|
|
||||||
- style.CurveTessellationMaxError == sqrtf(style.CurveTessellationTol).
|
|
||||||
- ImGuiTextFilter: removed `float width` parameter of `Draw(const char* filter, float width)`:
|
|
||||||
prefer using `SetNextItemWidth(float)` which is standard. Kept inline redirection function.
|
|
||||||
- Fonts: renamed `AddRemapChar()` to `AddRemapCodepoint()` (rarely used, marked internal).
|
|
||||||
(#609, #5748, #9559)
|
|
||||||
- Backends:
|
|
||||||
- DirectX12: Removed support for legacy `ImGui_ImplDX12_Init()` signature, which was
|
|
||||||
obsoleted in 1.91.6 (December 2014), because it needed to forcefully disable support
|
|
||||||
for `ImGuiBackendFlags_RendererHasTextures`. Use the new signature! (#9487)
|
|
||||||
- OpenGL3: Does not attempt to read `GL_CLIP_ORIGIN` by default as the detection is
|
|
||||||
sub-optimal and not reliable on some setup. Use `ImGui_ImplOpenGL3_SetClipOrigin(0)`
|
|
||||||
to enable auto-detection, or e.g. `ImGui_ImplOpenGL3_SetClipOrigin(GL_UPPER_LEFT)`.
|
|
||||||
|
|
||||||
Other Changes:
|
|
||||||
|
|
||||||
- Style:
|
|
||||||
- StyleColorsDark(): minor refresh of the default style to look more modern:
|
|
||||||
- Changed WindowBg to use a slightly greyer value and removed opacity.
|
|
||||||
- Changed FrameBg values to use a dark black to make frames stand out better.
|
|
||||||
- Tweak TextDisabled, TableHeaderBg, TableBorders to match altered WindowBg.
|
|
||||||
- StyleColorsLight(): inverted `ImGuiCol_TitleBgXXX` colors so that the selected
|
|
||||||
window title bar appears brighter.
|
|
||||||
- ImDrawList:
|
|
||||||
- Added flags to specify stroke position in all `ImDrawList` stroking functions: (#9504) [@memononen]
|
|
||||||
- `ImDrawFlags_StrokeInside` (default for Rect, Circle/Ellipse, Triangle, Quad, Ngon + AddLineH, AddLineV)
|
|
||||||
- `ImDrawFlags_StrokeCenter` (default for Line, Polyline, Beziers, Paths function)
|
|
||||||
- `ImDrawFlags_StrokeCenterBiased` (center w/ bias for pixel perfect alignment)
|
|
||||||
- `ImDrawFlags_StrokeOutside`
|
|
||||||
- `ImDrawFlags_StrokeLegacy` (match old behavior)
|
|
||||||
- Legacy mode may be set as default for a given scope using `PushDrawFlag(ImDrawFlags_StrokeLegacy, true)`.
|
|
||||||
- Legacy code was generally applying +0.50f offsets which meant that,
|
|
||||||
- with thickness=1.0f: the stroke would appear inside.
|
|
||||||
- with thickness>1.0f: the stroke would start expanding on both sides but starting from that small initial offset.
|
|
||||||
- with thickness>1.0f for even integer values, the stroke would look blurry.
|
|
||||||
- TL;DR; the logic didn't make much sense for thickness>1.0f.
|
|
||||||
- Defaulting to Inside for closed shapes ensure that rectangles and lines are
|
|
||||||
never blurry, regardless of thickness, as long as input coordinates/sizes
|
|
||||||
are integers. (#9359) Recap:
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
Thickness Legacy Inside Outside Center CenterBiased
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
1.0f sharp sharp sharp blurry sharp
|
|
||||||
2.0f blurry sharp sharp sharp sharp
|
|
||||||
3.0f sharp sharp sharp blurry sharp
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
- Read our Wiki guides for more details!
|
|
||||||
https://github.com/ocornut/imgui/wiki/Draw-List
|
|
||||||
- And interactive 1.92.9 vs 1.93.0 comparing testbed:
|
|
||||||
https://www.dearimgui.com/docs/drawlist_v193
|
|
||||||
- AddPolyline(), PathStroke(), AddTriangle(): the algorithm to render lines got overhauled.
|
|
||||||
(#9504, #2183, #2964, #7972 + #9360, #6331, #4250, #4091) [@memononen]
|
|
||||||
- Generally fixed rendering of thick strokes/paths.
|
|
||||||
- The new stroke expansion now uses corner miter calculation, which keeps thickness along
|
|
||||||
the line segments consistent. If the corner becomes too sharp, it will be beveled to
|
|
||||||
avoid long spikes at corners.
|
|
||||||
- There are also some robustness measures for the case where the line thickness is larger
|
|
||||||
than the features being drawn.
|
|
||||||
- Rendering artifacts are still possible when the path features are smaller than line thickness,
|
|
||||||
but the artifacts should be more localized. The new implementation attempted to favor simple
|
|
||||||
implementation and robustness over the corner case accuracy.
|
|
||||||
- All functions: new rendering code fixes some inconsistencies between graphics APIs
|
|
||||||
(e.g. DirectX vs OpenGL) which are using different diamond exits rules. New code should
|
|
||||||
work precisely the same regardless of graphics API. (#3116, #3258, #2441) [@memononen]
|
|
||||||
- Debug: added `io.ConfigDebugDrawListDefaultsToStrokeLegacy` to facilitate comparing old/new
|
|
||||||
behaviors. This is equivalent to calling `PushDrawFlag(ImDrawFlags_StrokeLegacy, true)`
|
|
||||||
on every drawlists.
|
|
||||||
Suggested uses, e.g.
|
|
||||||
- `io.ConfigDebugDrawListDefaultsToStrokeLegacy = io.KeyShift; // Map on holding Shift`
|
|
||||||
- `ImGui::Checkbox("DefaultsToStrokeLegacy", &io.ConfigDebugDrawListDefaultsToStrokeLegacy);`
|
|
||||||
- Added `ImDrawFlags_AALineEnds` flag to enable anti-aliased line ends.
|
|
||||||
- Most noticeable for thick lines.
|
|
||||||
- Also helps fill minor gaps if combining multiple individual lines. For best looking
|
|
||||||
continuous lines you should use AddPolyline(), it creates joins between line segments
|
|
||||||
to avoid any gaps.
|
|
||||||
- Added `style.AntiAliasedLineEnds` in ImGui to set default state.
|
|
||||||
- This is disabled by default! Enabling AA Ends by default would be more "correct",
|
|
||||||
but since it is very slightly slower and increases vertex/index data we decided
|
|
||||||
to not enable it by default.
|
|
||||||
This keeps situations such as "throw tens of thousands of lines at ImDrawList"
|
|
||||||
optimal. You can opt-in for a given shape or in a scope using `PushDrawFlag()`.
|
|
||||||
- Added `ImDrawFlags_JoinMiter` flag to disable using beveled corner.
|
|
||||||
- Closer to legacy rendering and slightly faster, but corners sharper than
|
|
||||||
90 degrees may expand far out.
|
|
||||||
- Automatically used by AddRect(), AddCircle(), AddNgon(), AddEllipse() functions
|
|
||||||
since we know that the input path does not contain sharper corners.
|
|
||||||
- Added `ImDrawFlags_CapSquare` flag to extend lines ends using square caps. (#9360)
|
|
||||||
- AddConvexPolyFilled()/PathFillConvex(): improved to handle input geometry more robustly.
|
|
||||||
The rendering of sharp corners was improved. Earlier there were issues with sharp corners
|
|
||||||
either creating long spikes, or messing up the adjacent edge's anti-aliasing. Now the
|
|
||||||
anti-aliasing fringe calculation is more consistent, and sharp corners get beveled to
|
|
||||||
avoid spikes. There might still be issues when the smallest extent of a long thin polygon
|
|
||||||
is less than a pixel. Also supports `ImDrawFlags_JoinMiter`, to facilitate matching
|
|
||||||
a stroke using the same flag.
|
|
||||||
- `AddRect()`, `AddRectFilled()`: various optimizations for rounded rectangles. (#1962, #9504)
|
|
||||||
- Integer-aligned coordinates and thicknesses will automatically use baked textures,
|
|
||||||
saving on both CPU and vertex/index data.
|
|
||||||
- Enabled by default. Use `ImFontAtlasFlags_NoBakedRoundCorners` to disable baking
|
|
||||||
round corners in font atlas.
|
|
||||||
- Added `ImDrawFlags_UseTexForRoundCorners` flag to enable in scope or per-shape.
|
|
||||||
Added for consistency and debugging, not really needed in practice.
|
|
||||||
- `AddCircle()`, `AddCircleFilled()`: fixed large circles being under-tessellated
|
|
||||||
(when above ~140 with default CircleTessellationMaxError).
|
|
||||||
- Improved debug-build performance in various locations.
|
|
||||||
- Improved minor mismatches when overlapping strokes and filled shapes.
|
|
||||||
For example, when using inside strokes,
|
|
||||||
- `AddRect()` and `AddRectFilled()` with rounding now overlap better. (#3656)
|
|
||||||
- `AddCircle()` and `AddCircleFilled()` now overlap better.
|
|
||||||
- Added `ImDrawList::PushDrawFlag()`/`PopDrawFlag()` to alter certain flags for a
|
|
||||||
scope and a given `ImDrawList`. (#9489)
|
|
||||||
- e.g. `PushDrawFlag(ImDrawFlags_StrokeLegacy, true);` enforce legacy tweaks.
|
|
||||||
- About `ImDrawFlags_StrokeLegacy`:
|
|
||||||
- This is designed to emulate old behavior:
|
|
||||||
- Most shapes use `ImDrawFlags_StrokeCenter`.
|
|
||||||
- AddLine() add +0.5f,+0.5f offset to position.
|
|
||||||
- AddRect() and AddRectFilled() allow inverted positions.
|
|
||||||
- AddRectFilled() has no AA when passed non-integer coordinates.
|
|
||||||
- AddCircle(), AddNgon() add a -0.5f offset to radius.
|
|
||||||
- Closed shapes use miter corners.
|
|
||||||
- Lines don't have anti-aliased ends.
|
|
||||||
- But there are known difference between legacy code and ImDrawFlags_StrokeLegacy:
|
|
||||||
- Thick shapes with acute angles will now preserve thickness better,
|
|
||||||
which may make them appear as protruding a little more.
|
|
||||||
- About disabling anti-aliasing:
|
|
||||||
- Disabling anti-aliasing is now emulated by applying different UV coordinates.
|
|
||||||
- It does not result in a performance increase or vertex/index data decrease any more
|
|
||||||
(however the tendency is that the new code behaves better than old code).
|
|
||||||
- But may be a useful stylistic choice in some circumstances.
|
|
||||||
- Many thick shapes had broken corners with old no-AA code, and the old no-AA code
|
|
||||||
was wildly different from the AA code. Not the case any more. (#288)
|
|
||||||
- Per-viewport FramebufferScale for Apple/Retina screen is applied to draw lists:
|
|
||||||
- AA Fringe is scaled accordingly. (#9577)
|
|
||||||
- Circle and Curves tessellation error are scaled accordingly.
|
|
||||||
- Reworked assert in `PushTexture()` to allow convenience grace period of using a
|
|
||||||
texture that was queue for destroy during the frame. Make it safe to stick to
|
|
||||||
an existing texture during the frame. (#9528, #8465)
|
|
||||||
- Added optional `platform_io.DrawCallback_SetSamplerFromTex` standard backend-agnostic
|
|
||||||
draw callback for requesting to use the sampler associated already associated to a texture.
|
|
||||||
Currently only supported by the OpenGL2/3 and SDLRenderer3 backend. (#9378)
|
|
||||||
- Fixed dangling `ImDrawList::_OwnerName` when using animated label. (#9552) [@ubi-dcastonguay]
|
|
||||||
- Mixed Values:
|
|
||||||
- Added `ImGuiItemFlags_MixedValue` flag for representing mixed/indeterminate values.
|
|
||||||
Supported by: Checkbox(), RadioButton(), DragXXX(), SliderXXX(), InputXXX(), ColorXXX()
|
|
||||||
and Combo() functions.
|
|
||||||
The scoped flag is designed for usage by advanced property editors. (#5518, #5677, #6865)
|
|
||||||
- Drags, Sliders:
|
|
||||||
- Ongoing drags may be cancelled using Right-Click, Escape or Gamepad Triangle.
|
|
||||||
Cancelling reverts to the initial value. (#8564, #9534)
|
|
||||||
- Fixed an overflow using `ImGuiSliderFlags_Logarithmic` with S32/S64 types which
|
|
||||||
leads to clamped interactions. (#9526, #3361, #1823, #1316, #642) [@lailoken]
|
|
||||||
- TreeNode:
|
|
||||||
- Fixed issues/asserts with 32+ deep trees when using ImGuiTreeNodeFlags_DrawLinesXXX
|
|
||||||
features or other features requiring stack storage. (#9509) [@lasrod]
|
|
||||||
- TabBar:
|
|
||||||
- Improved scroll target when clicking a Tab that is larger than the scrolling
|
|
||||||
section width.
|
|
||||||
- Using <> scrolling buttons while the selected Tab is at either end of the
|
|
||||||
section mid-section but not fully visible always makes it fully visible
|
|
||||||
(before eventually selecting a Tab in the leading/trailing section).
|
|
||||||
- Tables:
|
|
||||||
- Fixed a bug restoring correct .ini columns order when table use is Sortable
|
|
||||||
but had no user changes. (regression from 1.92.9). (#9519, #9108)
|
|
||||||
- Fixed a bug tracking topology changes (insert new columns in the middle)
|
|
||||||
when the table is not _Reorderable: new columns would be ordered incorrectly.
|
|
||||||
(#9570, #9108, #9572) [@lailoken]
|
|
||||||
- InputText:
|
|
||||||
- Fixed a crash in some cases when using Home key in a WordWrap+ReadOnly field. (#9561)
|
|
||||||
- Selectable:
|
|
||||||
- Fixed `ImGuiSelectableFlags_SelectOnNav` triggering during NavInit.
|
|
||||||
- Fonts:
|
|
||||||
- Reworked `AddFontDefault()` to use `io.DisplayFrameBufferScale` as part of the heuristic
|
|
||||||
to select `AddFontDefaultVector()` by default, effectively using ProggyForever instead of
|
|
||||||
ProggyClean on most Apple/Retina setups by default.
|
|
||||||
- Added `ImFont::AddRemapCodepointToGlyphIndex()` allowing to access glyphs that are not
|
|
||||||
mapped to codepoints. (#9559, #5647, #609, #5748, #8466)
|
|
||||||
- imgui_freetype: Fixed blurriness rendering `AddFontDefaultVector()`. Caused by a
|
|
||||||
non-pixel aligned offset caused by `ExtraSizeScale`. (#9348, #9233) [@redpartizan, @RDMCz]
|
|
||||||
- (Internal) ImFontLoader: reworked `FontSrcContainsGlyph`, `FontBakedLoadGlyph` signatures
|
|
||||||
to take raw glyph index instead of codepoint. Added `FontSrcGetGlyphIndexFromCodepoint`.
|
|
||||||
(#9559, #5647, #9540, #8466, #8465)
|
|
||||||
- Added `IMGUI_DISABLE_STB_TRUETYPE` to completely omit the stb_truetype loader
|
|
||||||
code + stb_truetype.h code. (#9573)
|
|
||||||
- ColorEdit:
|
|
||||||
- ColorButton, ColorEdit, ColorPicker: cancel-out alpha caused by `BeginDisabled()` so
|
|
||||||
disabled color buttons have the same color as non-disabled oness. (#9511)
|
|
||||||
- ColorButton: fixed issues/inconsistencies with checkerboard rendering when combining
|
|
||||||
color alpha and global style alpha. (#9511) [@enjmiah, @ocornut]
|
|
||||||
- Popups:
|
|
||||||
- Amended context menu right-click opening code to check that the right-click
|
|
||||||
hasn't been owned by another items. This is more correct and also necessary
|
|
||||||
to avoid Drags/Sliders cancelling also triggering a cancel menu. (#8564, #9534)
|
|
||||||
- Reworked `GetMousePosOnOpeningCurrentPopup()` to be legal to call within the
|
|
||||||
BeginPopup/EndPopup scope of a popup which was just closed. (#9551) [@jkunstwald]
|
|
||||||
- ImGuiTextFilter:
|
|
||||||
- Added support for space as an "and" filter, which is the standard. (#2435, #30)
|
|
||||||
e.g. w/ filter 'hello world' (without quotes) both words needs to be in input data.
|
|
||||||
- Added support for double-quoted "xxx" blocks to e.g. match words sequences. (#2435)
|
|
||||||
e.g. w/ filter "hello world" the exact sequence needs to be in input data.
|
|
||||||
- Fixed filtering when mixing "include" and "-exclude" keyword so that an "-exclude"
|
|
||||||
match always filters out. (#2435) [@kudaba, @ocornut]
|
|
||||||
- Added `DrawWithHint()` function. (#6206, #6395, #6447)
|
|
||||||
- Added a "incl -excl" hint by default when the search field is empty. (#6206, #6395, #6447)
|
|
||||||
- Widgets:
|
|
||||||
- Checkbox, Menus: check marks use anti-aliased ends.
|
|
||||||
- Tweaked rendering in various locations to avoid blurriness:
|
|
||||||
- Windows: title-bar and menu-bar border (when thickness>1.0f).
|
|
||||||
- SeparatorText: border (when thickness>1.0f).
|
|
||||||
- Tree: hierarchy lines (when thickness>1.0f).
|
|
||||||
- InputText: input caret (when thickness>1.0f).
|
|
||||||
- TabBar: selected overline border (when thickness>1.0f).
|
|
||||||
- Misc:
|
|
||||||
- Fixed `GetBackgroundDrawList()`/`GetForegroundDrawList()` not being properly reset
|
|
||||||
every frame when accumulated session time is very large (e.g. a few days). [@lailoken]
|
|
||||||
- Added `IM_NODEBUGSTEP` helper to tag functions with `__declspec(non_user_code)` (MSVC)
|
|
||||||
or `[[gnu::artificial]]` (Clang/GCC) in order to provide a hint to debuggers to skip
|
|
||||||
trivial functions when stepping into.
|
|
||||||
- Tagged various trivial functions using `IM_NODEBUGSTEP`: `ImVec2()`, `ImVec4()` etc.
|
|
||||||
and various operators.
|
|
||||||
- Fixed strict aliasing violation in `ImHashData()` affecting Clang 23 + SSE 4.2 + -flto.
|
|
||||||
Could manifest as `ImFontAtlasBakedGetId()` computation omitting font size from
|
|
||||||
the hashed data. (#9557, #9560) [@sthalik]
|
|
||||||
- IO: restore default clipboard/ime/shell platform handlers on `ClearPlatformHandlers()`, fixing
|
|
||||||
issues switching backends mid-session to one relying on default. (#9537, #8945, #2769) [@lstalmir]
|
|
||||||
- Demo:
|
|
||||||
- Added `Widgets->Mixed Values` section. (#5518, #5677, #6865)
|
|
||||||
- Custom Rendering section: exposed new flags; showcasing overlapping strokes
|
|
||||||
and filled shapes; added an option to animate thickness; added new shapes
|
|
||||||
to showcase new rendering features that previously hit limitations.
|
|
||||||
- Style Editor: fixed style/colors combo box applying style when opening Combo.
|
|
||||||
- Backends:
|
|
||||||
- QNX: added QNX Screen backend. (#9492) [@mgorchak-blackberry]
|
|
||||||
- Metal, Metal4: added support for rendering inside a render pass with multiple color
|
|
||||||
attachments (e.g. when merged with other passes): we render to the first color attachment
|
|
||||||
and leave the other ones untouched. (#9574) [@tqjxlm]
|
|
||||||
- OpenGL2, OpenGL3: added support for `platform_io.DrawCallback_SetSamplerFromTex` draw
|
|
||||||
callback to request using the sampler associated already associated to a texture. (#9378)
|
|
||||||
- OpenGL2, OpenGL3: fixed `DrawCallback_ResetRenderState` handler not resetting all states
|
|
||||||
in the glTexParameter() path. (#9378)
|
|
||||||
- OpenGL3: added `ImGui_ImplOpenGL3_SetClipOrigin()` to specify origin between
|
|
||||||
`GL_LOWER_LEFT` (new default), `GL_UPPER_LEFT` and `0` (autodetect, old default).
|
|
||||||
- OpenGL3: avoid querying `glGetIntegerv(GL_CLIP_ORIGIN)` multiple times when using
|
|
||||||
when using default and using `DrawCallback_ResetRenderState`, at it appear to stall
|
|
||||||
some drivers. (#2186, #3998, #3146, #3143, #8640)
|
|
||||||
- SDL2: fixed querying framebuffer scale/density when using Metal without
|
|
||||||
going through a SDL_Renderer. (#5592) [@lailoken]
|
|
||||||
- SDLRenderer3: restore any temporarily modified texture scale modes at the of `RenderDrawData()`. (#9378)
|
|
||||||
- SDLRenderer3: expose CurrentScaleMode in ImGui_ImplSDLRenderer3_RenderState. (#9543, #9378) [@Clownacy]
|
|
||||||
- SDLRenderer3: added support for `platform_io.DrawCallback_SetSamplerFromTex` draw callback to request
|
|
||||||
using the sampler associated already associated to a texture via `SDL_SetTextureScaleMode()`. (#9378)
|
|
||||||
It is equivalent to setting `render_state->CurrentScaleMode = SDL_SCALEMODE_INVALID`.
|
|
||||||
Note: this callback is only supported by selected rendering backends: most other graphics API
|
|
||||||
don't have the equivalent of `SDL_SetTextureScaleMode()` and the callback won't work with them.
|
|
||||||
- Vulkan: added for support for multiple Vulkan contexts with custom loaders. (#6616) [@lstalmir]
|
|
||||||
- Vulkan: added support for rendering inside a render pass with multiple color attachments
|
|
||||||
(e.g. when merged with other passes): we render to the first color attachment and leave the
|
|
||||||
other ones untouched. (#9574) [@tqjxlm]
|
|
||||||
- WebGPU: fixed passing non-integer sizes to `wgpuRenderPassEncoderSetViewport()`
|
|
||||||
when `FramebufferScale` is >1.0f. (#9515, #8628) [@WayU]
|
|
||||||
- WebGPU: update to build with wgpu-native 29.0+. (#9377, #9532, #9530) [@lucascompython, @ivan-enzhaev]
|
|
||||||
- Examples:
|
|
||||||
- All: all examples now default to use a little bit of rounding (`FrameRounding` and `GrabRounding`).
|
|
||||||
- MSVC: disabled /JMC in Visual Studio projects (unnecessary overhead).
|
|
||||||
- GLFW/SDL2/SDL3+WebGPU: fixed running with wgpu-native missing `wgpuInstanceWaitAny()`. (#9377)
|
|
||||||
- GLFW/SDL2/SDL3+WebGPU: better select surface format. (#9576) [@ypujante]
|
|
||||||
- GLFW+Metal: fixed mistakenly calling `ImGui_ImplGlfw_InitForOpenGL()`, which
|
|
||||||
broke multi-viewport support. (#9564) [@ypujante]
|
|
||||||
- SDL2+Metal: create Metal context without using a `SDL_Renderer`.
|
|
||||||
- QNX+OpenGL3, QNX+Vulkan: added QNX Screen examples. (#9492) [@mgorchak-blackberry]
|
|
||||||
- OSX+OpenGL3: added example_apple_opengl3/ (OSX/Cocoa + OpenGL 3.2 Core profile).
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.92.9b (Released 2026-07-31)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.92.9b
|
|
||||||
|
|
||||||
Changes:
|
|
||||||
|
|
||||||
- DragXXX, SliderXXX: fixed a regression in 1.92.9 where clicking a previously
|
|
||||||
Ctrl+Clicked field would flick it to text edit mode for a frame. (#9476, #701)
|
|
||||||
- Tables:
|
|
||||||
- Fixed Y2 position of lower horizontal border (ImGuiTableFlags_BordersOuterH)
|
|
||||||
being off by one pixel when vertical ones are not also enabled. [@thedmd]
|
|
||||||
- Fixed X position of angled borders being off by half a pixel. [@thedmd]
|
|
||||||
- ImDrawData: fixed a regression in 1.92.9 where legacy `ImDrawData::CmdListsCount` was always 0.
|
|
||||||
Prefer using `ImDrawData::CmdList.Size` anyway.
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.92.9 (Released 2026-07-25)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.92.9
|
|
||||||
|
|
||||||
Breaking Changes:
|
|
||||||
|
|
||||||
- DragXXX, SliderXXX, InputScalar: with `ImGuiItemFlags_LiveEditOnInputScalar` now
|
|
||||||
defaulting to being disabled: inputting a value with the keyboard doesn't write
|
|
||||||
intermediate values to the backing variable. (#9476)
|
|
||||||
Before: DragFloat() with user typing "123" --> write back 1, then 12, then 123.
|
|
||||||
After: DragFloat() with user typing "123" --> write back 123 when validated/unfocused.
|
|
||||||
You can enable the flag back for a given scope if needed by specific widget/behavior.
|
|
||||||
Read below for details.
|
|
||||||
- TreeNode: commented out legacy name `ImGuiTreeNodeFlags_SpanTextWidth` which
|
|
||||||
was obsoleted in 1.90.7 (May 2024). Use `ImGuiTreeNodeFlags_SpanLabelWidth`.
|
|
||||||
- ColorEdit: obsoleted SetColorEditOptions() function added in 1.51 (June 2017) in favor
|
|
||||||
of directly poking to io.ConfigColorEditFlags. More consistent and easier to discover.
|
|
||||||
- Drag and Drop: commented out legacy name `ImGuiDragDropFlags_SourceAutoExpirePayload`
|
|
||||||
which obsoleted in 1.90.9 (July 2024). Use `ImGuiDragDropFlags_PayloadAutoExpire`.
|
|
||||||
- ImDrawData: marked `CmdListsCount` as obsolete (technically was obsoleted in 1.89.8).
|
|
||||||
Before: `draw_data->CmdListsCount`, After: `draw_data->CmdLists.Size`.
|
|
||||||
|
|
||||||
Other Changes:
|
|
||||||
|
|
||||||
- LiveEdit on/off: added `ImGuiItemFlags_LiveEditOnInputText` and `ImGuiItemFlags_LiveEditOnInputScalar`
|
|
||||||
flags to configure the timing of applying edits of backing variables when typing
|
|
||||||
values using a keyboard.
|
|
||||||
(#9476, #701, #3936, #3946, #5904, #6284, #8149, #8065, #8665, #9117, #9299, #700, #1351,
|
|
||||||
#1875, #2060, #2215, #2380, #2550, #3083, #3338, #3556, #4373, #4714, #4885, #5184,
|
|
||||||
#5777, #6707, #6766, #8004, #8303, #8915, #9308)
|
|
||||||
- ImGuiItemFlags_LiveEditOnInputText is enabled by default (same as before):
|
|
||||||
- The expectation is that for strings/text, enabling LiveEdit is a better default.
|
|
||||||
- ImGuiItemFlags_LiveEditOnInputScalar is disabled by default (new behavior):
|
|
||||||
- The expectation is that for numeric/scalars values, disabling LiveEdit is a better default.
|
|
||||||
- Until now:
|
|
||||||
- Edits where always applied immediately to backing variable, which is equivalent
|
|
||||||
to the `ImGuiItemFlags_LiveEditXXX` flags being enabled.
|
|
||||||
- Typing '123' in an integer field would output successively 1, 12 then 123.
|
|
||||||
- Most uses of `IsItemDeactivatedAfterEdit()` or `ImGuiInputTextFlags_EnterReturnsTrue`
|
|
||||||
were actually workarounds for this issue. Advanced applications would typically
|
|
||||||
use `IsItemDeactivatedAfterEdit()` to distinguish transactions.
|
|
||||||
Workarounds often required a backing store for scalar values, and there were
|
|
||||||
also a few niggles related to `IsItemDeactivatedAfterEdit()` when using +/-
|
|
||||||
buttons of an `InputInt()` widgets.
|
|
||||||
- Many of those situations can now be naturally simplified when disabling
|
|
||||||
`ImGuiItemFlags_LiveEditOnInputScalar` is disabled.
|
|
||||||
- The new flags allows disabling this behavior selectively for strings fields
|
|
||||||
such as `InputText()` vs scalar fields: `SliderInt()`, `InputFloat()`, etc.
|
|
||||||
- When LiveEdit is disabled, edits are applied when pressing enter, tabbing out,
|
|
||||||
clearing a field or deactivating due to a focus loss.
|
|
||||||
- The flag may be altered programmatically, e.g. for the entire frame scope:
|
|
||||||
NewFrame();
|
|
||||||
PushItemFlag(ImGuiItemFlags_LiveEditOnInputScalar, true); // Enable for scalars for the whole frame
|
|
||||||
....
|
|
||||||
PopItemFlag();
|
|
||||||
EndFrame();
|
|
||||||
Or for a specific widget:
|
|
||||||
PushItemFlag(ImGuiItemFlags_LiveEditOnInput, true); // Enable for one widget
|
|
||||||
SliderInt(...);
|
|
||||||
PopItemFlag();
|
|
||||||
- We intentionally are not adding `io.ConfigLiveEditXXX` fields to dictate the
|
|
||||||
default value of each `ImGuiItemFlags_LiveEditXXX`, because this is not expected
|
|
||||||
to be a user preference but a programmer/widget preferences.
|
|
||||||
And we strive to make the toolkit consistent.
|
|
||||||
- Windows:
|
|
||||||
- Clicking on a window's empty-space to move/focus a window checks
|
|
||||||
for lack of mouse button ownership. This gives an additional opportunity
|
|
||||||
for user code to bypass it without using a clickable item. (#9382)
|
|
||||||
- Clicking on a window's empty-space to move/focus a window checks
|
|
||||||
for lack of queued focus request. (#9382)
|
|
||||||
- Fixed double-click collapse toggle not owning the mouse button. If a
|
|
||||||
`SetNextWindowPos()` with pivot was queued in the same frame, the second
|
|
||||||
click could trigger another item in the same window. (#9439) [@Cleroth]
|
|
||||||
- Popups:
|
|
||||||
- Added bool return value to `OpenPopup()`, `OpenPopupOnItemClick()` functions
|
|
||||||
to notify when the popup was just opened. (#9429)
|
|
||||||
- InputText:
|
|
||||||
- Added `style.InputTextCursorSize` to configure cursor/caret thickness. (#7031, #9409)
|
|
||||||
It is automatically scaled by `style.ScaleAllSizes()`.
|
|
||||||
- Reworked `io.ConfigInputTextEnterKeepActive` mode so that pressing
|
|
||||||
Ctrl+Enter or Shift+Enter still allows to deactivate. (#9239)
|
|
||||||
- Tables:
|
|
||||||
- Redesigned/rewrote code to reconcile columns and settings on topology changes. (#9108)
|
|
||||||
- When a column label is passed to TableSetupColumn(), the underlying identifier
|
|
||||||
is used to match live columns data and .ini settings data when changing.
|
|
||||||
This makes it possible to add/remove columns from a table without losing
|
|
||||||
neither live data neither .ini settings data.
|
|
||||||
- PS: Note that this is distinct from toggling column visibility or reordering
|
|
||||||
columns, which was always possible. The new matching makes it easier to create
|
|
||||||
tables that are entirely customized by user or code, without losing state.
|
|
||||||
- Columns without identifiers or with duplicate identifiers are matched
|
|
||||||
sequentially, matching old behavior.
|
|
||||||
- Column ID are stored in .ini file.
|
|
||||||
- Code is being tested both for live topology changes and for loading .ini
|
|
||||||
data with mismatched topology.
|
|
||||||
- Context Menu: added a "Reset" sub-menu with a "Reset Visibility" option.
|
|
||||||
(which is greyed out when using default settings)
|
|
||||||
- Headers: fixed label being clipped early to reserve space for a sort marker
|
|
||||||
even when no sort marker is displayed. Auto-fitting a column still accounts
|
|
||||||
for the possible marker, so that sorting after an auto-fit doesn't clip the label.
|
|
||||||
- Multi-Select:
|
|
||||||
- Reworked `ImGuiMultiSelectFlags_NoAutoSelect` as it carried side-effects that
|
|
||||||
were hardcoded/designed to use multi-selection on checkboxes. (#9391)
|
|
||||||
Specifically removed those undocumented behaviors from `_NoAutoSelect`:
|
|
||||||
- Clicking a selected/checked item always unselect/uncheck.
|
|
||||||
- Shift+Click inverts targets value and copy to range.
|
|
||||||
- Shift+Keyboard copy selection source value to range.
|
|
||||||
Those behaviors are still happening on checkboxes used within multi-selection.
|
|
||||||
- Fonts:
|
|
||||||
- Added `IMGUI_DISABLE_DEFAULT_FONT_BITMAP`/`IMGUI_DISABLE_DEFAULT_FONT_VECTOR` to
|
|
||||||
disable embedding either fonts separately. (#9407)
|
|
||||||
- Tweak `CalcTextSize()` awkward width rounding/ceiling code to reduce floating-point
|
|
||||||
precision issues altering the result by 1 even at relatively small width. (#791)
|
|
||||||
- Better document the fact that `ImFontAtlas::Clear()`/`ClearFonts()` functions are
|
|
||||||
unlikely to be useful nowadays. Better recover to an edge case of mistakenly
|
|
||||||
calling `ClearFonts()` during rendering.
|
|
||||||
- Fixed an issue where passing a manually created ImFontAtlas to CreateContext() would
|
|
||||||
incorrectly destroy it in `DestroyContext()` when ref-count gets back to zero. (#9426)
|
|
||||||
- Destroying an ImGui context using a `ImFontAtlas` checks that the later has no references.
|
|
||||||
- Nav:
|
|
||||||
- Fixed context menu activation with gamepad erroneously testing for _NavEnableKeyboard
|
|
||||||
instead of _NavEnableGamepad. (#9454, #8803, #9270) [@Clownacy]
|
|
||||||
- TreeNode:
|
|
||||||
- Fixed nav cursor rendering with rounding even though tree nodes don't have it. (#7589)
|
|
||||||
- Inputs:
|
|
||||||
- Added `GetItemClickedCountWithSingleClickDelay()` helper for easy disambiguation
|
|
||||||
between single-click and double-click for actions that needs single-click to do
|
|
||||||
something other than selection. (#8337)
|
|
||||||
- Returns 1 on single-click but delayed by io.MouseSingleClickDelay.
|
|
||||||
- Returns 2 on double-click, and 2+ on subsequent repeated clicks.
|
|
||||||
- Added `io.MouseSingleClickDelay` to configure default delayed single click delay when
|
|
||||||
using `GetItemClickedCountWithSingleClickDelay()` or `IsMouseReleasedWithDelay()`. (#8337)
|
|
||||||
Note that `io.MouseSingleClickDelay` is always `> io.MouseDoubleClickTime`.
|
|
||||||
- ColorEdit:
|
|
||||||
- Added `io.ConfigColorEditFlags` to read/modify current color edit/picker settings.
|
|
||||||
- ColorPicker: added `ImGuiColorEditFlags_PickerNoRotate` to disable rotation of the
|
|
||||||
S/V triangle when in `ImGuiColorEditFlags_PickerHueWheel` mode. (#9337) [@SeanTheBuilder1]
|
|
||||||
Likely best passed to `style.ColorEditFlags` to setup globally and once.
|
|
||||||
- ColorButton: small rendering tweak/optimization for the alpha checkerboard.
|
|
||||||
- Style:
|
|
||||||
- Added style.MenuItemRounding, ImGuiStyleVar_MenuItemRounding. (#7589, #9375, #9453)
|
|
||||||
- Added style.SelectableRounding, ImGuiStyleVar_SelectableRounding. (#7589, #9375, #9453)
|
|
||||||
The use of this is discouraged because it can easily create problems rendering e.g.
|
|
||||||
contiguous selection.
|
|
||||||
- Scale the NavCursor border thickness when using large values with `ScallAllSizes()`.
|
|
||||||
- Settings:
|
|
||||||
- Windows/Tables settings entries can now record the last used date in YYYYMMDD format,
|
|
||||||
allowing tools to run to e.g. delete entries that haven't been used in X months. (#9460)
|
|
||||||
- Added `bool io.ConfigIniSettingsSaveLastUsedDate` to disable saving that info. (#9460)
|
|
||||||
- Added `int io.ConfigIniSettingsAutoDiscardMonths` to enable a mode where unused settings
|
|
||||||
are automatically discard after xx months. (#9460)
|
|
||||||
- Added a trimming tool under Metrics->Settings, along with a yet-unexposed function.
|
|
||||||
- The current system date is fed through `ImGuiPlatformIO::Platform_SessionDate`,
|
|
||||||
which is automatically set by a call to time() done during context creation. (#9460)
|
|
||||||
- Added `IMGUI_DISABLE_TIME_FUNCTIONS` to disable setting platform_io.Platform_SessionDate.
|
|
||||||
A custom backend may still set it manually. (#9460)
|
|
||||||
- DrawList:
|
|
||||||
- Minor optimization to `AddLine()`, `AddLineH()`, `AddLineV()` functions. (#4091)
|
|
||||||
- Added `ImDrawListFlags_TextNoPixelSnap` to disable snapping of AddText()
|
|
||||||
coordinates for a given scope. (#3437, #9417, #2291)
|
|
||||||
- Demo:
|
|
||||||
- Extract 'Widgets->Tree Nodes->Selectable Nodes' out of the 'Advanced'
|
|
||||||
demo for clarity (manual reimplementation of basic selection).
|
|
||||||
- Debug Tools:
|
|
||||||
- Added `IM_DEBUG_BREAK()` handler for GCC+AArch64/ARM64. [@tom-seddon]
|
|
||||||
- Backends:
|
|
||||||
- Android:
|
|
||||||
- Clear mouse position on touch release (`AMOTION_EVENT_ACTION_UP`) to prevent
|
|
||||||
items from staying in hovered state. (#6627, #9474) [@Turtle-PB]
|
|
||||||
- Metal4:
|
|
||||||
- Added new Metal 4 backend (forked from Metal 3 backend). (#9458, #9451) [@AmelieHeinrich]
|
|
||||||
- Added Metal-cpp support enabled with `IMGUI_IMPL_METAL_CPP` define. (#9461) [@MERL10N]
|
|
||||||
- OpenGL2:
|
|
||||||
- Backup and restore `GL_UNPACK_ROW_LENGTH` and `GL_UNPACK_ALIGNMENT` when updating texture
|
|
||||||
to avoid altering caller GL state. (#8802, #9473) [@Turtle-PB]
|
|
||||||
- OpenGL3:
|
|
||||||
- GLSL version detection assume GLSL 410 when GL context is 4.1.
|
|
||||||
Fixes an issue running on macOS with Wine. [#9427, #6577) [@perminovVS]
|
|
||||||
- Expose selected render state in `ImGui_ImplOpenGL3_RenderState`, allowing to
|
|
||||||
dynamically select between use of `glBindSampler()` and `glTexParameter()`. (#9378)
|
|
||||||
- Backup and restore `GL_UNPACK_ROW_LENGTH` and `GL_UNPACK_ALIGNMENT` when updating texture
|
|
||||||
to avoid altering caller GL state. (#8802, #9473) [@Turtle-PB]
|
|
||||||
- SDL2:
|
|
||||||
- Restore SDL_StartTextInput()/SDL_StopTextInput() in IME handler for on-screen keyboard
|
|
||||||
support on Android. (#7636, #9474) [@Turtle-PB]
|
|
||||||
- SDLRenderer3:
|
|
||||||
- Fixed sampler change which didn't work on all graphics backends. (#7616, #9470, #9378)
|
|
||||||
- Fixed default sampler not being Linear. Regression in 1.92.8. (#7616, #9470, #9378) [@ShiroKSH]
|
|
||||||
- Win32:
|
|
||||||
- Uses `SetProcessDpiAwarenessContext()` instead of `SetThreadDpiAwarenessContext()`
|
|
||||||
when available, fixing OpenGL DPI scaling issues as e.g. NVIDIA drivers tends
|
|
||||||
to spawn multiple-thread to manage OpenGL. (#9403)
|
|
||||||
- Examples:
|
|
||||||
- Android: update to AGP 9.2.0 to support Gradle 9.6.0.
|
|
||||||
- Apple+Metal4: added new example. (#9465, #9451) [@hoffstadt]
|
|
||||||
- OpenGL3+GLFW/SDL2/SDL3: allow Wine compatibility by passing empty GLSL version
|
|
||||||
string to ImGui_ImplOpenGL3_Init() to let backend decide of a GLSL version based
|
|
||||||
on actual GL version obtained. (#9427, #6577) [@perminovVS]
|
|
||||||
- OpenGL3+Win32: rework context creation to allow Wine compatibility. (#9427, #6577) [@perminovVS]
|
|
||||||
- SDL2/SDL3: use `SDL_GetWindowSizeInPixels()` to create frame-buffers. Fixes issues
|
|
||||||
with non-fractional framebuffer size on Wayland. (#8761, #9124) [@billtran1632001]
|
|
||||||
- SDL3+Metal4: added new example. (#9458, #9451) [@AmelieHeinrich]
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.92.8 (Released 2026-05-12)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.92.8
|
|
||||||
|
|
||||||
Breaking Changes:
|
|
||||||
|
|
||||||
- DrawList: swapped the last two arguments of `AddRect()`, `AddPolyline()`, `PathStroke()`.
|
|
||||||
- Before: `void ImDrawList::AddRect(ImVec2 p_min, ImVec2 p_max, ImU32 col, float rounding = 0.0f, ImDrawFlags flags = 0, float thickness = 1.0f);`
|
|
||||||
- After: `void ImDrawList::AddRect(ImVec2 p_min, ImVec2 p_max, ImU32 col, float rounding = 0.0f, float thickness = 1.0f, ImDrawFlags flags = 0);`
|
|
||||||
- Before: `void ImDrawList::AddPolyline(const ImVec2* points, int num_points, ImU32 col, ImDrawFlags flags, float thickness);`
|
|
||||||
- After: `void ImDrawList::AddPolyline(const ImVec2* points, int num_points, ImU32 col, float thickness, ImDrawFlags flags = 0);`
|
|
||||||
- Before: `void ImDrawList::PathStroke(ImU32 col, ImDrawFlags flags = 0, float thickness = 1.0f);`
|
|
||||||
- After: `void ImDrawList::PathStroke(ImU32 col, float thickness = 1.0f, ImDrawFlags flags = 0);`
|
|
||||||
Added inline redirection functions when IMGUI_DISABLE_OBSOLETE_FUNCTIONS is off.
|
|
||||||
Marked the old functions are =delete when IMGUI_DISABLE_OBSOLETE_FUNCTIONS is on, to allow for better type-checking.
|
|
||||||
Effectively the typical call site is changing from:
|
|
||||||
- Before: `window->DrawList->AddRect(p_min, p_max, color, rounding, ImDrawFlags_None, border_size);`
|
|
||||||
- After: `window->DrawList->AddRect(p_min, p_max, color, rounding, border_size);`
|
|
||||||
Notes:
|
|
||||||
- Users of C++ and other languages with type-checking will be notified at compile-time of any mistakes.
|
|
||||||
- Users of high-level bindings or languages with no type-checking will be notified at runtime via an assert for invalid flags value.
|
|
||||||
If you are a binding maintainer consider doing something to facilitate transition or error detection.
|
|
||||||
- This is perhaps the worst breaking change in our history :( but it makes ImDrawList function signatures consistent.
|
|
||||||
As we are aiming to add flags and features to variety of ImDrawList functions, that consistency becomes more important.
|
|
||||||
The new order is also more convenient as `flags` are less frequently used than `thickness` in real code.
|
|
||||||
- As a general policy in Dear ImGui, all our flags default to 0 so ImDrawFlags_None was likely written 0 in some call sites.
|
|
||||||
- Consider adding `#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in your imconfig.h, even temporarily, to clean up legacy code.
|
|
||||||
- Reminder: you do NOT need to specify `ImDrawFlags_RoundCornersAll` for rounding, it is already the default!
|
|
||||||
- DrawList: obsoleted `ImDrawCallback_ResetRenderState` in favor of using `ImGui::GetPlatformIO().DrawCallback_ResetRenderState`,
|
|
||||||
which is part of our new standard draw callbacks. (#9378)
|
|
||||||
Redirecting the earlier value into the later one when set, so both old and new code should work.
|
|
||||||
- DrawList: changed value of `ImDrawFlags_Closed`. It was previously advertised as "always == 1" when introduced
|
|
||||||
in 1.82 (2021/02), in order to facilitate backward compatibility with the legacy `bool closed` flag. This
|
|
||||||
guarantee has been removed. The bit is reserved, and `AddPolyline()`, `PathStroke()` will assert when it is used.
|
|
||||||
- Backends:
|
|
||||||
- Vulkan: redesigned to use separate ImageView + Sampler instead of Combined Image Sampler. (#914)
|
|
||||||
This change allows us to facilitate changing samplers, in line with other backends. [@yaz0r, @ocornut]
|
|
||||||
- When creating your own descriptor pool (instead of letting backend creates its own):
|
|
||||||
- Before: need at least `IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE` descriptors of type `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER`.
|
|
||||||
- After: need at least `IMGUI_IMPL_VULKAN_MINIMUM_SAMPLED_IMAGE_POOL_SIZE` descriptors of type `VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE`.
|
|
||||||
+ `IMGUI_IMPL_VULKAN_MINIMUM_SAMPLER_POOL_SIZE` descriptors of type `VK_DESCRIPTOR_TYPE_SAMPLER`.
|
|
||||||
- When registering custom textures: changed ImGui_ImplVulkan_AddTexture() signature to remove Sampler.
|
|
||||||
- Before: `ImGui_ImplVulkan_AddTexture(VkSampler, VkImageView, VkImageLayout)`
|
|
||||||
- After: `ImGui_ImplVulkan_AddTexture(VkImageView, VkImageLayout)`
|
|
||||||
- Kept inline redirection function that ignores the sampler (will obsolete).
|
|
||||||
- DirectX10, DirectX11, SDLGPU3, Vulkan: removed samplers from `ImGui_ImplXXXX_RenderState`.
|
|
||||||
Prefer to use backend-agnostic DrawCallback_SetSamplerLinear which works everywhere! (#9378)
|
|
||||||
If there is a legit need/request for them or any render state we can always add them back.
|
|
||||||
- OpenGL3: the new sampler support system prioritize using glBindSampler() when available,
|
|
||||||
which would override glTexParameter() settings you may have set on custom textures. (#9378)
|
|
||||||
|
|
||||||
Other Changes:
|
|
||||||
|
|
||||||
- DrawList:
|
|
||||||
- Added room in `ImGuiPlatformIO` for standard backend-agnostic draw callbacks. Those callbacks
|
|
||||||
are setup/provided by the backend and available in most of our standard backends.
|
|
||||||
They allow backend-agnostic code from e.g. switching to a Nearest/Point sampler without
|
|
||||||
messing with custom Renderer-specific callbacks.
|
|
||||||
platform_io.DrawCallback_ResetRenderState; // Request to reset the graphics/render state.
|
|
||||||
platform_io.DrawCallback_SetSamplerLinear; // Request to set current texture sampling to Linear
|
|
||||||
platform_io.DrawCallback_SetSamplerNearest; // Request to set current texture sampling to Nearest/Point
|
|
||||||
Note that some backends might not support all callbacks.
|
|
||||||
(#9378, #9371, #3590, #8926, #2973, #7485, #7468, #6969, #5118, #7616, #9173, #8322, #7230,
|
|
||||||
#5999, #6452, #5156, #7342, #7592, #7511)
|
|
||||||
- Made `AddCallback()` user data default to Null for convenience.
|
|
||||||
- Added `AddLineH()`, `AddLineV()` helpers to draw horizontal and vertical lines. [@memononen]
|
|
||||||
The new functions are more optimal and will be part of a larger effort in 1.93 to fix
|
|
||||||
inconsistencies and improve the DrawList API. In the current API, `AddLine()` adds a "magic" +0.5f
|
|
||||||
offset and then center the line, whereas AddLineH()/AddLineV() use the right side of the line to expand.
|
|
||||||
For thickness=1.0f lines this is equivalent:
|
|
||||||
`AddLine({10,3}, {20,3}, ...)` --> `AddLineH(x1=10, x2=20, y=3, ...)`.
|
|
||||||
`AddLine({3,10}, {3,20}, ...)` --> `AddLineV(x=3, y1=10, y2=20, ...)`.
|
|
||||||
For larger integer thickness, AddLine() will center but may be blurry, AddLineH()/AddLineV()
|
|
||||||
will expand "inside" (to the right side) and will always be sharp.
|
|
||||||
A subsequent release will expand on those concepts and add new options.
|
|
||||||
- InputText:
|
|
||||||
- InputTextMultiline: fixed an issue processing deactivation logic when an active
|
|
||||||
multi-line edit is clipped due to being out of view.
|
|
||||||
- Fixed a crash when toggling ReadOnly while active. (#9354)
|
|
||||||
- `CharFilter` callback event sets CursorPos/SelectionStart/SelectionEnd. (#816)
|
|
||||||
- Tables:
|
|
||||||
- Fixed issues reporting ideal size to parent window/container: (#9352, #7651)
|
|
||||||
- When both scrollbars are visible but only one of ScrollX/ScrollY was explicitly requested.
|
|
||||||
- When vertical scrollbar was not at the top, the computation was often incorrect.
|
|
||||||
- Windows:
|
|
||||||
- Fixed a single-axis auto-resizing feedback loop issue with nested containers
|
|
||||||
and varying scrollbar visibility. (#9352)
|
|
||||||
- Detect and report error when calling End() instead of EndPopup() on a popup. (#9351)
|
|
||||||
- Child windows with only `ImGuiChildFlags_AutoResizeY` flag keep using the proportional
|
|
||||||
default `ItemWidth`. (#9355)
|
|
||||||
- Using mouse wheel to scroll takes and keeps ownership of the corresponding keys
|
|
||||||
(e.g. `ImGuiKey_MouseWheelY`) while a wheeling window is locked. (#2604, #3795)
|
|
||||||
- InputInt, InputFloat, InputScalar:
|
|
||||||
- Reinstated `ImGuiInputTextFlags_EnterReturnsTrue` support which was removed in 1.91.4.
|
|
||||||
(#8665, #9299, #8065, #3946, #6284, #9117)
|
|
||||||
- Fixed the fact that it didn't return true when validating same value.
|
|
||||||
- Fixed losing value when tabbing out or losing focus.
|
|
||||||
- Made it that pressing +/- step buttons also return true, which is in line
|
|
||||||
with 1.91.4 behavior.
|
|
||||||
- In a majority of cases you should use `IsItemDeactivatedAfterEdit()` instead,
|
|
||||||
but it still has a few edge cases flaws (to be addressed soon).
|
|
||||||
- Allow passing a format string that does not display the scalar value.
|
|
||||||
Parsing input with default format for the type. (#9385) [@FireFox2000000]
|
|
||||||
- Multi-Select:
|
|
||||||
- Fixed an issue using Multi-Select within a Table causing column width measurement to
|
|
||||||
be invalid when trailing column contents is not submitted in the last row. (#9341, #8250)
|
|
||||||
- Fixed an issue using Multi-Select within a Table with the right-most column visible,
|
|
||||||
which could lead to an extra vertical offset in the Header row. (#8250)
|
|
||||||
- Multi-Select + Box-Select:
|
|
||||||
- Fixed an issue using `ImGuiMultiSelectFlags_BoxSelect1d` mode while scrolling.
|
|
||||||
Notably, using mouse wheel while holding a box-selection could lead items close to windows
|
|
||||||
edges from not being correctly unselected. (#7994, #8250, #7821, #7850, #7970)
|
|
||||||
- Improved dirty/unclip rectangle logic for `ImGuiMultiSelectFlags_BoxSelect2d`.
|
|
||||||
- Fixed an issue using `ImGuiMultiSelectFlags_BoxSelect2d` mode, where
|
|
||||||
items out of view wouldn't be properly selected while scrolling while mouse cursor
|
|
||||||
is hovering outside of selection scope. (#7994, #1861, #6518)
|
|
||||||
- Fixed an issue where items out of horizontal view would sometimes lead
|
|
||||||
to incorrect merging of sequential selection requests while also scrolling fast
|
|
||||||
enough to overlap multiple rows during a frame. (#7994, #1861, #6518)
|
|
||||||
- Fixed an issue using `ImGuiMultiSelectFlags_BoxSelect2d` mode in a Table
|
|
||||||
while relying on the `TableNextColumn()` return value to perform coarse clipping. (#7994)
|
|
||||||
- Disabled merging consecutive selection requests as we have no reliable
|
|
||||||
way of detecting if user has submitted all consecutive items without clipping gaps,
|
|
||||||
and `ImGuiSelectionUserData` is technically opaque storage. (#7994, #1861)
|
|
||||||
(we will probably bring this back as a minor optimization if we have a way to for
|
|
||||||
user to tell us `ImGuiSelectionUserData` are indices)
|
|
||||||
- Fixes for using across nested child windows. (#8364)
|
|
||||||
- Box-Select + Clipper: fixed an issue selecting items while scrolling while a clipper
|
|
||||||
active. (#7994, #8250, #7821, #7850, #7970)
|
|
||||||
- Box-Select + Tables: fixed an issue using box-selection in a tables with
|
|
||||||
items straying out of columns boundaries. (#7994, #2221)
|
|
||||||
- Box-Select + Tables: fixed an issue when calling `BeginMultiSelect()` in a table
|
|
||||||
before layout has been locked (first row or headers row submitted). (#8250)
|
|
||||||
- Menus:
|
|
||||||
- BeginMenu()/MenuItem(): fixed accidental triggering of child menu items when
|
|
||||||
opening a menu inside a small host window forcing the child menu window to be
|
|
||||||
repositioned under the mouse cursor. (#8233, #9394)
|
|
||||||
Done by reworking `BeginMenu()`/`MenuItem()`: they previously avoiding taking
|
|
||||||
ActiveID + key/click ownership (in order to allow releasing button on another item).
|
|
||||||
Now they take them and release them once the mouse is moved outside item boundaries.
|
|
||||||
- Inputs:
|
|
||||||
- SetItemKeyOwner(): return true if ownership has been requested, which typically
|
|
||||||
needs to to checked for gating further tests. This is important as the function
|
|
||||||
may fail. (#456, #2637, #2620, #2891, #3370, #3724, #4828, #5108, #5242, #5641)
|
|
||||||
- SetItemKeyOwner(): does not set ownership is key is already taken. Effectively
|
|
||||||
this makes using `SetItemKeyOwner(ImGuiKey_MouseWheelY)` over an item work as
|
|
||||||
expected while not having item react if a scroll wheel is actively in progress.
|
|
||||||
May be subject to further redesign, e.g. conditional flags. Feedback welcome!
|
|
||||||
- Style:
|
|
||||||
- Checkbox: added `ImGuiCol_CheckboxSelectedBg` to change or accentuate the
|
|
||||||
background color of checked/mixed checkboxes. (#9392)
|
|
||||||
- Added `ImGuiStyleVar_DragDropTargetRounding`. (#9056)
|
|
||||||
- Fixed vertical scrollbar top coordinates when using thick borders on windows
|
|
||||||
with no title bar and no menu bar. (#9366)
|
|
||||||
- Fonts:
|
|
||||||
- imgui_freetype: add FreeType headers & compiled version in 'About Dear ImGui' details.
|
|
||||||
- Assert when using MergeMode with an explicit size over a target font with an implicit
|
|
||||||
size, as scale factor are likely erroneous. (#9361)
|
|
||||||
- Clipper:
|
|
||||||
- Improved error reporting when misusing the clipper inside a table (prioritize
|
|
||||||
reporting the common clipper error over a table sanity check assert). (#9350)
|
|
||||||
- Tweaked assert triggering when first item height measurement fails, and made it
|
|
||||||
a better recoverable error. (#9350)
|
|
||||||
- Misc:
|
|
||||||
- Minor optimization: reduce redundant label scanning in common widgets.
|
|
||||||
- Added missing Test Engine hooks for `PlotLines()`, `PlotHistogram()`, `VSliderXXX()`
|
|
||||||
and `TableHeader()` functions.
|
|
||||||
- Demo:
|
|
||||||
- Added simple demo for a scrollable/zoomable image viewer with a grid.
|
|
||||||
Available in `Examples->Image Viewer` and `Widgets->Images`.
|
|
||||||
- Backends:
|
|
||||||
- Added support for new standardized draw callbacks in most backends: (#9378)
|
|
||||||
- Allegro5: Reset n/a n/a
|
|
||||||
- DX9: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- DX10: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- DX11: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- DX12: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- Metal: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- OpenGL2: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- OpenGL3+: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- SDLGPU3: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- SDLRenderer2: Reset n/a n/a
|
|
||||||
- SDLRenderer3: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- Vulkan: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
- WebGPU: Reset SetSamplerLinear SetSamplerNearest
|
|
||||||
(Vulkan backend by @yaz0r, Metal by @ssh4net, others by @ocornut)
|
|
||||||
- GLFW: added a Win32-specific implementation of `ImGui_ImplGlfw_GetContentScaleXXXX`
|
|
||||||
functions for legacy GLFW 3.2. (#9003)
|
|
||||||
- Metal: avoid redundant vertex buffer bind in `SetupRenderState()`, which leads
|
|
||||||
to validation issue. (#9343) [@Hunam6]
|
|
||||||
- Metal: use a dedicated `bufferCacheLock` to avoid crashing when `bufferCache` is
|
|
||||||
replaced by a new object while being used for `@synchronize()`. (#9367) [@andygrundman]
|
|
||||||
- SDL2: made `ImGui_ImplSDL2_GetContentScaleForWindow()`/`ImGui_ImplSDL2_GetContentScaleForDisplay()`
|
|
||||||
helpers return a minimum of 1.0f, as some Linux setup seems to report <1.0f value
|
|
||||||
and this breaks scaling border size. (#9369)
|
|
||||||
- WebGPU: rework choice/detection of using WGSL/SPIR-V shader on WGVK. (#9316, #9246, #9257, #9387)
|
|
||||||
- Examples:
|
|
||||||
- Update VS toolset in all .vcxproj from VS2015 (v140) to VS2017 (v141). The later is the
|
|
||||||
first that supports vcpkg. Onward we will likely stop testing building the library with VS2015.
|
|
||||||
- GLFW+Vulkan, SDL2+Vulkan, SDL3+Vulkan, Win32+Vulkan: reworked to create a descriptor pool with:
|
|
||||||
- `IMGUI_IMPL_VULKAN_MINIMUM_SAMPLED_IMAGE_POOL_SIZE` descriptors of type `VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE`.
|
|
||||||
- `IMGUI_IMPL_VULKAN_MINIMUM_SAMPLER_POOL_SIZE` descriptors of type `VK_DESCRIPTOR_TYPE_SAMPLER`.
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.92.7 (Released 2026-04-02)
|
VERSION 1.92.7 (Released 2026-04-02)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@ -1614,7 +694,7 @@ Other Changes:
|
|||||||
not available. (#5924, #5562)
|
not available. (#5924, #5562)
|
||||||
- SDL3+DirectX11: Added SDL3+DirectX11 example. (#8956, #8957) [@tomaz82]
|
- SDL3+DirectX11: Added SDL3+DirectX11 example. (#8956, #8957) [@tomaz82]
|
||||||
- Win32+DirectX12: Rework synchronization logic. (#8961) [@RT2Code]
|
- Win32+DirectX12: Rework synchronization logic. (#8961) [@RT2Code]
|
||||||
- Made examples' main.cpp consistent with returning 1 on error.
|
- Made examples's main.cpp consistent with returning 1 on error.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@ -2125,7 +1205,7 @@ Non-breaking Fonts/Textures related changes:
|
|||||||
- Fonts: ImFontAtlas::AddFontXXX() can fail more gracefully if error handling is configured
|
- Fonts: ImFontAtlas::AddFontXXX() can fail more gracefully if error handling is configured
|
||||||
to not assert (this will be better exposed via future font flags).
|
to not assert (this will be better exposed via future font flags).
|
||||||
- Fonts: added style.FontScaleBase scaling factor (previously called io.FontGlobalScale).
|
- Fonts: added style.FontScaleBase scaling factor (previously called io.FontGlobalScale).
|
||||||
- Fonts: added style.FontScaleDpi scaling factor. This is designed to be changed on
|
- Fonts: added style.FontScaleDpi scaling factor. This is designed to be be changed on
|
||||||
per-monitor/per-viewport basis, which `io.ConfigDpiScaleFonts` does automatically.
|
per-monitor/per-viewport basis, which `io.ConfigDpiScaleFonts` does automatically.
|
||||||
(which is why it is separate from FontScaleBase).
|
(which is why it is separate from FontScaleBase).
|
||||||
- Fonts: added optional font_size parameter to ImGui::PushFont() function.
|
- Fonts: added optional font_size parameter to ImGui::PushFont() function.
|
||||||
@ -3280,7 +2360,7 @@ Other changes:
|
|||||||
- Backends: Vulkan: Remove Volk/ from volk.h #include directives. (#7722, #6582, #4854)
|
- Backends: Vulkan: Remove Volk/ from volk.h #include directives. (#7722, #6582, #4854)
|
||||||
[@martin-ejdestig]
|
[@martin-ejdestig]
|
||||||
- Examples: SDL3: Remove use of SDL_HINT_IME_NATIVE_UI since new SDL_HINT_IME_IMPLEMENTED_UI
|
- Examples: SDL3: Remove use of SDL_HINT_IME_NATIVE_UI since new SDL_HINT_IME_IMPLEMENTED_UI
|
||||||
values has a more suitable default for our case.
|
values has a more suitable default for our case case.
|
||||||
- Examples: GLFW+Vulkan, SDL+Vulkan: handle swap chain resize even without Vulkan
|
- Examples: GLFW+Vulkan, SDL+Vulkan: handle swap chain resize even without Vulkan
|
||||||
returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671)
|
returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671)
|
||||||
[@AndreiNego, @ocornut]
|
[@AndreiNego, @ocornut]
|
||||||
@ -4056,10 +3136,8 @@ Breaking changes:
|
|||||||
input queue. This is automatically cleared by io.ClearInputKeys(). (#4921)
|
input queue. This is automatically cleared by io.ClearInputKeys(). (#4921)
|
||||||
- ImDrawData: CmdLists[] array is now owned, changed from 'ImDrawList**' to
|
- ImDrawData: CmdLists[] array is now owned, changed from 'ImDrawList**' to
|
||||||
'ImVector<ImDrawList*>'. Majority of users shouldn't be affected, but you
|
'ImVector<ImDrawList*>'. Majority of users shouldn't be affected, but you
|
||||||
cannot compare to NULL nor reassign manually anymore. (#6406, #4879, #1878)
|
cannot compare to NULL nor reassign manually anymore.
|
||||||
- Allocation count are identical.
|
Instead use AddDrawList(). Allocation count are identical. (#6406, #4879, #1878)
|
||||||
- Use `draw_data->CmdLists.Size` instead of `draw_list->CmdListsCount`!
|
|
||||||
- Use `AddDrawList()` to add to a `ImDrawData`.
|
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
|
|
||||||
@ -5233,7 +4311,7 @@ Other Changes:
|
|||||||
- ColorPicker4: Fixed picker being unable to select exact 1.0f color when dragging toward the edges
|
- ColorPicker4: Fixed picker being unable to select exact 1.0f color when dragging toward the edges
|
||||||
of the SV square (previously picked 0.999989986f). (#3517) [@rokups]
|
of the SV square (previously picked 0.999989986f). (#3517) [@rokups]
|
||||||
- Menus: Fixed vertical alignments of MenuItem() calls within a menu bar (broken in 1.84). (#4538)
|
- Menus: Fixed vertical alignments of MenuItem() calls within a menu bar (broken in 1.84). (#4538)
|
||||||
- Menus: Improve closing logic when moving diagonally in empty space between parent and child menus to
|
- Menus: Improve closing logic when moving diagonally in empty between between parent and child menus to
|
||||||
accommodate for varying font size and dpi.
|
accommodate for varying font size and dpi.
|
||||||
- Menus: Fixed crash when navigating left inside a child window inside a sub-menu. (#4510).
|
- Menus: Fixed crash when navigating left inside a child window inside a sub-menu. (#4510).
|
||||||
- Menus: Fixed an assertion happening in some situations when closing nested menus (broken in 1.83). (#4640)
|
- Menus: Fixed an assertion happening in some situations when closing nested menus (broken in 1.83). (#4640)
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
## Index
|
## Index
|
||||||
|
|
||||||
- [Getting Started & General Advice](#getting-started--general-advice)
|
- [Getting Started & General Advice](#getting-started--general-advice)
|
||||||
- [Using "Issues" for almost everything!](using-issues-for-almost-everything)
|
- [Issues vs Discussions](#issues-vs-discussions)
|
||||||
- [How to open an Issue](#how-to-open-an-issue)
|
- [How to open an Issue](#how-to-open-an-issue)
|
||||||
- [How to open a Pull Request](#how-to-open-a-pull-request)
|
- [How to open a Pull Request](#how-to-open-a-pull-request)
|
||||||
- [Copyright / Contributor License Agreement](#copyright--contributor-license-agreement)
|
- [Copyright / Contributor License Agreement](#copyright--contributor-license-agreement)
|
||||||
@ -23,20 +23,18 @@
|
|||||||
- If you get a crash or assert, use a debugger to locate the line triggering it and read the comments around.
|
- If you get a crash or assert, use a debugger to locate the line triggering it and read the comments around.
|
||||||
- Please don't be a [Help Vampire](https://slash7.com/2006/12/22/vampires/).
|
- Please don't be a [Help Vampire](https://slash7.com/2006/12/22/vampires/).
|
||||||
|
|
||||||
## Using "Issues" for almost everything!
|
## 'Issues' vs 'Discussions'
|
||||||
|
|
||||||
We are happy to use 'Issues' for many type of open-ended questions.
|
We are happy to use 'Issues' for many type of open-ended questions. We are encouraging 'Issues' becoming an enormous, centralized and cross-referenced database of Dear ImGui contents.
|
||||||
We are encouraging 'Issues' becoming an enormous, centralized and cross-referenced database of Dear ImGui contents.
|
|
||||||
|
|
||||||
- Need help using the API? Open an Issue!
|
Only if you:
|
||||||
- Want to suggest a feature? Open an Issue!
|
|
||||||
- etc.
|
|
||||||
|
|
||||||
ONLY IN THOSE CASE you can use the [Discussions forums](https://github.com/ocornut/imgui/discussions)
|
|
||||||
- Cannot BUILD or LINK examples.
|
- Cannot BUILD or LINK examples.
|
||||||
- Cannot BUILD, or LINK, or RUN Dear ImGui in your application or custom engine.
|
- Cannot BUILD, or LINK, or RUN Dear ImGui in your application or custom engine.
|
||||||
|
- Cannot LOAD a font.
|
||||||
|
|
||||||
If Dear ImGui is successfully showing in your app and you have used Dear ImGui before, you can open an Issue. Any form of discussions is welcome as a new Issue.
|
Then please [use the Discussions forums](https://github.com/ocornut/imgui/discussions) instead of opening an issue.
|
||||||
|
|
||||||
|
If Dear ImGui is successfully showing in your app and you have used Dear ImGui before, you can open an Issue. Any form of discussions is welcome as a new issue.
|
||||||
|
|
||||||
## How to open an issue
|
## How to open an issue
|
||||||
|
|
||||||
|
|||||||
@ -60,20 +60,16 @@ Android + OpenGL3 (ES) example. <BR>
|
|||||||
|
|
||||||
[example_apple_metal/](https://github.com/ocornut/imgui/tree/master/examples/example_apple_metal/) <BR>
|
[example_apple_metal/](https://github.com/ocornut/imgui/tree/master/examples/example_apple_metal/) <BR>
|
||||||
OSX & iOS + Metal example. <BR>
|
OSX & iOS + Metal example. <BR>
|
||||||
= main.mm + imgui_impl_osx.mm + imgui_impl_metal.mm <BR>
|
= main.m + imgui_impl_osx.mm + imgui_impl_metal.mm <BR>
|
||||||
It is based on the "cross-platform" game template provided with Xcode as of Xcode 9.
|
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 backends.
|
||||||
[example_apple_metal4/](https://github.com/ocornut/imgui/blob/master/examples/example_apple_metal4/) <BR>
|
You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.)
|
||||||
OSX & iOS + Metal4 example, Mac only. <BR>
|
|
||||||
= main.mm + imgui_impl_osx.mm + imgui_impl_metal4.mm <BR>
|
|
||||||
|
|
||||||
[example_apple_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_apple_opengl2/) <BR>
|
[example_apple_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_apple_opengl2/) <BR>
|
||||||
OSX + OpenGL2 example. <BR>
|
OSX + OpenGL2 example. <BR>
|
||||||
= main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp <BR>
|
= main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp <BR>
|
||||||
|
(NB: imgui_impl_osx.mm is currently not as feature complete as other platforms backends.
|
||||||
[example_apple_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_apple_opengl3/) <BR>
|
You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.)
|
||||||
OSX + OpenGL3 example. <BR>
|
|
||||||
= main.mm + imgui_impl_osx.mm + imgui_impl_opengl3.cpp <BR>
|
|
||||||
|
|
||||||
[example_glfw_wgpu/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_wgpu/) <BR>
|
[example_glfw_wgpu/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_wgpu/) <BR>
|
||||||
GLFW + WebGPU example. Supports Emscripten (web), Dawn (native), WGPU (native). <BR>
|
GLFW + WebGPU example. Supports Emscripten (web), Dawn (native), WGPU (native). <BR>
|
||||||
@ -119,16 +115,6 @@ Because this application doesn't create a window nor a graphic context, there's
|
|||||||
Please note that imgui_impl_null itself is a rather empty backend. We provide it for consistency but
|
Please note that imgui_impl_null itself is a rather empty backend. We provide it for consistency but
|
||||||
it is similarly easy to create a skeleton application without the null backend.
|
it is similarly easy to create a skeleton application without the null backend.
|
||||||
|
|
||||||
[example_qnx_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_qnx_opengl3/) <BR>
|
|
||||||
QNX Screen + OpenGL ES 3 example. <BR>
|
|
||||||
= main.cpp + imgui_impl_qnx.cpp + imgui_impl_opengl3.cpp <BR>
|
|
||||||
Uses the QNX recursive make build system and compiles the OpenGL3 renderer with `IMGUI_IMPL_OPENGL_ES3`.
|
|
||||||
|
|
||||||
[example_qnx_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_qnx_vulkan/) <BR>
|
|
||||||
QNX Screen + Vulkan example using `VK_QNX_screen_surface`. <BR>
|
|
||||||
= main.cpp + imgui_impl_qnx.cpp + imgui_impl_vulkan.cpp <BR>
|
|
||||||
Uses the QNX recursive make build system and the Vulkan backend's example helper structures.
|
|
||||||
|
|
||||||
[example_sdl2_directx11/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl2_directx11/) <BR>
|
[example_sdl2_directx11/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl2_directx11/) <BR>
|
||||||
SDL2 + DirectX11 example, Windows only. <BR>
|
SDL2 + DirectX11 example, Windows only. <BR>
|
||||||
= main.cpp + imgui_impl_sdl2.cpp + imgui_impl_dx11.cpp <BR>
|
= main.cpp + imgui_impl_sdl2.cpp + imgui_impl_dx11.cpp <BR>
|
||||||
@ -178,10 +164,6 @@ SDL3 + DirectX11 examples, Windows only. <BR>
|
|||||||
SDL3 + Metal example, Mac only. <BR>
|
SDL3 + Metal example, Mac only. <BR>
|
||||||
= main.cpp + imgui_impl_sdl3.cpp + imgui_impl_metal.mm <BR>
|
= main.cpp + imgui_impl_sdl3.cpp + imgui_impl_metal.mm <BR>
|
||||||
|
|
||||||
[example_sdl3_metal4/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl3_metal/) <BR>
|
|
||||||
SDL3 + Metal4 example, Mac only. <BR>
|
|
||||||
= main.cpp + imgui_impl_sdl3.cpp + imgui_impl_metal4.mm <BR>
|
|
||||||
|
|
||||||
[example_sdl3_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl3_opengl3/) <BR>
|
[example_sdl3_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl3_opengl3/) <BR>
|
||||||
SDL3 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example. <BR>
|
SDL3 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example. <BR>
|
||||||
= main.cpp + imgui_impl_sdl3.cpp + imgui_impl_opengl3.cpp <BR>
|
= main.cpp + imgui_impl_sdl3.cpp + imgui_impl_opengl3.cpp <BR>
|
||||||
|
|||||||
124
docs/FAQ.md
124
docs/FAQ.md
@ -9,58 +9,42 @@ or view this file with any Markdown viewer.
|
|||||||
|
|
||||||
## Index
|
## Index
|
||||||
|
|
||||||
### Basics
|
| **Q&A: Basics** |
|
||||||
|
:---------------------------------------------------------- |
|
||||||
|
| [Where is the documentation?](#q-where-is-the-documentation) |
|
||||||
|
| [What is this library called?](#q-what-is-this-library-called) |
|
||||||
|
| [What is the difference between Dear ImGui and traditional UI toolkits?](#q-what-is-the-difference-between-dear-imgui-and-traditional-ui-toolkits) |
|
||||||
|
| [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 my application?](#q-how-can-i-tell-whether-to-dispatch-mousekeyboard-to-dear-imgui-or-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) |
|
||||||
|
| [How can I create my own backend?](#q-how-can-i-create-my-own-backend)
|
||||||
|
| [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** |
|
||||||
|
| **[About the ID Stack system...](#q-about-the-id-stack-system)**<br>**[How can I have multiple widgets with the same label?](#q-how-can-i-have-multiple-widgets-with-the-same-label) (using `##` or `PushID()`)**<br>**[How can I have widgets with an empty label?](#q-how-can-i-have-widgets-with-an-empty-label) (using `##`)**<br>**[How can I animate the label of an existing widget?](#q-how-can-i-change-the-label-of-an-existing-widget) (using `###`)**<br>**[General description of the label and ID Stack system.](#general-description-of-the-label-and-id-stack-system)** |
|
||||||
|
| [How can I display an image?](#q-how-can-i-display-an-image)<br>[What are ImTextureID/ImTextureRef?](#q-what-are-imtextureidimtextureref)|
|
||||||
|
| [How can I use maths operators with ImVec2?](#q-how-can-i-use-maths-operators-with-imvec2) |
|
||||||
|
| [How can I use my own maths types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-maths-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) |
|
||||||
|
|
||||||
- [Where is the documentation?](#q-where-is-the-documentation)
|
|
||||||
- [What is this library called?](#q-what-is-this-library-called)
|
|
||||||
- [What is the difference between Dear ImGui and traditional UI toolkits?](#q-what-is-the-difference-between-dear-imgui-and-traditional-ui-toolkits)
|
|
||||||
- [Which version should I get?](#q-which-version-should-i-get)
|
|
||||||
|
|
||||||
### Integration
|
|
||||||
|
|
||||||
- **[How to get started?](#q-how-to-get-started)**
|
|
||||||
- **[How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?](#q-how-can-i-tell-whether-to-dispatch-mousekeyboard-to-dear-imgui-or-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)
|
|
||||||
- [How can I create my own backend?](#q-how-can-i-create-my-own-backend)
|
|
||||||
- [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)
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
- **[About the ID Stack system...](#q-about-the-id-stack-system)**
|
|
||||||
- **[How can I have multiple widgets with the same label?](#q-how-can-i-have-multiple-widgets-with-the-same-label) (using `##` or `PushID()`)**
|
|
||||||
- **[How can I have widgets with an empty label?](#q-how-can-i-have-widgets-with-an-empty-label) (using `##`)**
|
|
||||||
- **[How can I make a label dynamic?](#q-how-can-i-make-a-label-dynamic) (using `###`)**
|
|
||||||
- **[General description of the label and ID Stack system.](#general-description-of-the-label-and-id-stack-system)**
|
|
||||||
- [How can I display an image?](#q-how-can-i-display-an-image), [What are ImTextureID/ImTextureRef?](#q-what-are-imtextureidimtextureref)
|
|
||||||
- [How can I use maths operators with ImVec2?](#q-how-can-i-use-maths-operators-with-imvec2)
|
|
||||||
- [How can I use my own maths types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-maths-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)
|
|
||||||
- [About Multi-Threading](#about-multi-threading)
|
|
||||||
|
|
||||||
### 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)
|
|
||||||
|
|
||||||
### 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)
|
|
||||||
|
|
||||||
### Community
|
|
||||||
|
|
||||||
- [How can I help?](#q-how-can-i-help)
|
|
||||||
|
|
||||||
--------
|
|
||||||
|
|
||||||
# Q&A: Basics
|
# Q&A: Basics
|
||||||
|
|
||||||
@ -101,17 +85,16 @@ Here's a very simplified comparison between the approach taken by Dear ImGui vs
|
|||||||
|--------------------------|--------------------------|
|
|--------------------------|--------------------------|
|
||||||
| UI fully issued on every update. | UI issued once then later modified. |
|
| UI fully issued on every update. | UI issued once then later modified. |
|
||||||
| UI layout is fully dynamic and can change at any time.<BR>UI is generally emitted programmatically, which empowers reflecting a dynamic set of data. | UI layout is mostly static.<BR>UI may be emitted programmatically or from data created by offline tools. UI need extra code to evolve, which is often tedious and error-prone if it needs to be reflecting dynamic data and systems. |
|
| UI layout is fully dynamic and can change at any time.<BR>UI is generally emitted programmatically, which empowers reflecting a dynamic set of data. | UI layout is mostly static.<BR>UI may be emitted programmatically or from data created by offline tools. UI need extra code to evolve, which is often tedious and error-prone if it needs to be reflecting dynamic data and systems. |
|
||||||
| UI system is optimized for the worst case and designed to be optimal even under frequent changes. | UI system is optimized for the case where nothing changes. Performances tends to degrade when anything changes. |
|
| Application can submit UI based on arbitrary logic and then forget about it. | Application needs more bookkeeping of UI elements. |
|
||||||
| Application can submit UI based on arbitrary logic without bookkeeping all aspects of that logic. | Application needs more bookkeeping of UI elements. |
|
|
||||||
| UI library stores minimal amounts of data. At one point in time, it typically doesn't know or remember which other widgets are displayed and which widgets are coming next. As a result, certain layout features (alignment, resizing) are not as easy to implement or require ad-hoc code. | UI library stores entire widgets tree and state. UI library can use this retained data to easily layout things. |
|
| UI library stores minimal amounts of data. At one point in time, it typically doesn't know or remember which other widgets are displayed and which widgets are coming next. As a result, certain layout features (alignment, resizing) are not as easy to implement or require ad-hoc code. | UI library stores entire widgets tree and state. UI library can use this retained data to easily layout things. |
|
||||||
| UI code may be added anywhere.<BR>You can even create UI to edit a local variable! | UI code needs to be added in dedicated spots. |
|
| UI code may be added anywhere.<BR>You can even create UI to edit a local variable! | UI code needs to be added in dedicated spots. |
|
||||||
| UI layout/logic/action/data bindings are all nearby in the code. | UI layout/logic/action/data bindings in distinct functions, files or formats. |
|
| UI layout/logic/action/data bindings are all nearby in the code. | UI layout/logic/action/data bindings in distinct functions, files or formats. |
|
||||||
| Data is naturally always synchronized. | Use callback/signal/slot for synchronizing data (error-prone). |
|
| Data is naturally always synchronized. | Use callback/signal/slot for synchronizing data (error-prone). |
|
||||||
| API is simple and easy to learn. In particular, doing basic things is very easy.<BR>Attractive to more programmers. | API is more complex and specialized.<BR>Tends to require specialized programmers. |
|
| API is simple and easy to learn. In particular, doing basic things is very easy. | API is more complex and specialized. |
|
||||||
| API is low-level. Few abstractions, uses raw language types and your existing data. | API are higher-level. More abstractions, advanced language features. |
|
| API is low-level (raw language types). | API are higher-level (more abstractions, advanced language features). |
|
||||||
| Less fancy look and feel. But keeps improving :) | Standard look and feel. |
|
| Less fancy look and feel. | Standard look and feel. |
|
||||||
| Compile yourself. Easy to debug, hack, modify, study. | Mostly use precompiled libraries. Compiling, modifying or studying is daunting if not impossible. |
|
| Compile yourself. Easy to debug, hack, modify, study. | Mostly use precompiled libraries. Compiling, modifying or studying is daunting if not impossible. |
|
||||||
| Run on every platform (incl. web, consoles, mobiles, legacy systems). | Run on major desktop platforms. |
|
| Run on every platform. | Run on limited desktop platforms. |
|
||||||
|
|
||||||
Idiomatic Dear ImGui code:
|
Idiomatic Dear ImGui code:
|
||||||
```cpp
|
```cpp
|
||||||
@ -570,8 +553,8 @@ typedef ImU64 ImTextureID; // Default: store up to 64-bits (any pointer or inte
|
|||||||
// Store a ImTextureID _or_ a ImTextureData*.
|
// Store a ImTextureID _or_ a ImTextureData*.
|
||||||
struct ImTextureRef
|
struct ImTextureRef
|
||||||
{
|
{
|
||||||
ImTextureRef() { _TexData = nullptr; _TexID = ImTextureID_Invalid; }
|
ImTextureRef() { _TexData = NULL; _TexID = ImTextureID_Invalid; }
|
||||||
ImTextureRef(ImTextureID tex_id) { _TexData = nullptr; _TexID = tex_id; }
|
ImTextureRef(ImTextureID tex_id) { _TexData = NULL; _TexID = tex_id; }
|
||||||
inline ImTextureID GetTexID() const { return _TexData ? _TexData->TexID : _TexID; }
|
inline ImTextureID GetTexID() const { return _TexData ? _TexData->TexID : _TexID; }
|
||||||
|
|
||||||
// Members (either are set, never both!)
|
// Members (either are set, never both!)
|
||||||
@ -589,7 +572,7 @@ struct ImTextureRef
|
|||||||
We intentionally do not provide an `ImTextureRef` constructor for this: we don't expect this to be frequently useful to the end-user, and it would be erroneously called by many legacy code.
|
We intentionally do not provide an `ImTextureRef` constructor for this: we don't expect this to be frequently useful to the end-user, and it would be erroneously called by many legacy code.
|
||||||
- There is no constructor to create a `ImTextureRef` from a `ImTextureData*` as we don't expect this to be useful to the end-user, and it would be erroneously called by many legacy code.
|
- There is no constructor to create a `ImTextureRef` from a `ImTextureData*` as we don't expect this to be useful to the end-user, and it would be erroneously called by many legacy code.
|
||||||
- If you want to bind the current atlas when using custom rectangles, you can use `io.Fonts->TexRef`.
|
- If you want to bind the current atlas when using custom rectangles, you can use `io.Fonts->TexRef`.
|
||||||
- Binding generators for languages such as C (which don't have constructors), should provide a helper, e.g. `inline ImTextureRef ImTextureRefFromID(ImTextureID tex_id) { ImTextureRef tex_ref = { ._TexData = nullptr, .TexID = tex_id }; return tex_ref; }`
|
- Binding generators for languages such as C (which don't have constructors), should provide a helper, e.g. `inline ImTextureRef ImTextureRefFromID(ImTextureID tex_id) { ImTextureRef tex_ref = { ._TexData = NULL, .TexID = tex_id }; return tex_ref; }`
|
||||||
|
|
||||||
**Please read documentations or tutorials on your graphics API to understand how to display textures on the screen before moving onward.**
|
**Please read documentations or tutorials on your graphics API to understand how to display textures on the screen before moving onward.**
|
||||||
|
|
||||||
@ -683,7 +666,6 @@ This way you will be able to use your own types everywhere, e.g. passing `MyVect
|
|||||||
---
|
---
|
||||||
|
|
||||||
### Q: 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 std::string and std::vector)?
|
||||||
|
|
||||||
- Being highly portable (backends/bindings for several languages, frameworks, programming styles, obscure or older platforms/compilers), and aiming for compatibility & performance suitable for every modern real-time game engine, 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.
|
- Being highly portable (backends/bindings for several languages, frameworks, programming styles, obscure or older platforms/compilers), and aiming for compatibility & performance suitable for every modern real-time game engine, 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 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
|
- To use combo boxes and list boxes with `std::vector` or any other data structure: the `BeginCombo()/EndCombo()` API
|
||||||
@ -703,10 +685,6 @@ One possible implementation of a helper to facilitate printf-style building of s
|
|||||||
This is a small helper where you can instance strings with configurable local buffers length. Many game engines will
|
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.
|
provide similar or better string helpers.
|
||||||
|
|
||||||
Using string views:
|
|
||||||
|
|
||||||
- String view types such as `std::string_view` may be used with the [feature/string_view](https://github.com/ocornut/imgui/tree/features/string_view) branch. This branch is actively maintained and supported. Please provide feedback if you use it. We are waiting for a good moment to merge it.
|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -747,20 +725,6 @@ ImGui::End();
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### About Multi-Threading
|
|
||||||
|
|
||||||
A same Dear ImGui context may be not used from multiple threads in parallel.
|
|
||||||
|
|
||||||
If you want to use a same context within parallel tasks for occasional debug purpose, consider using a lock.
|
|
||||||
|
|
||||||
If you want to submit contents from a main/update thread but render Dear ImGui output in a dedicated render thread, you'll need to stage `ImDrawData` and texture requests. See the `ImDrawDataSnapshot` and `ImTextureQueue` helpers in [imgui_threaded_rendering](https://github.com/ocornut/imgui_club#imgui_threaded_rendering). Also see topics with [label: multi-threading](https://github.com/ocornut/imgui/issues?q=label%3Amulti-threading).
|
|
||||||
|
|
||||||
If you use multiple Dear ImGui contexts and want to use them from multiple threads, you need to `#define GImGui` to become a TLS variable (see details near the definition of `GImGui`. If you need to display multiple contexts simultaneously, consider using [imgui_multicontext_compositor](https://github.com/ocornut/imgui_club#imgui_multicontext_compositor). Also see topics with [label: multi-contexts](https://github.com/ocornut/imgui/issues?q=label%3Amulti-contexts).
|
|
||||||
|
|
||||||
There is a script/patch to make the API take an explicit context pointer: [#5856](https://github.com/ocornut/imgui/pull/5856). It is presently unmaintained and likely to easy to update. It has been decided that the change is not currently worth applying to main-line but maybe will be in a future version.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Q&A: Fonts, Text
|
# Q&A: Fonts, Text
|
||||||
|
|
||||||
### Q: How should I handle DPI in my application?
|
### Q: How should I handle DPI in my application?
|
||||||
@ -780,7 +744,7 @@ style.FontScaleDpi = 2.0f;
|
|||||||
|
|
||||||
To change font size:
|
To change font size:
|
||||||
```cpp
|
```cpp
|
||||||
ImGui::PushFont(nullptr, 42.0f); // This will be multiplied by style.FontScaleDpi
|
ImGui::PushFont(NULL, 42.0f); // This will be multiplied by style.FontScaleDpi
|
||||||
```
|
```
|
||||||
To change font and font size:
|
To change font and font size:
|
||||||
```cpp
|
```cpp
|
||||||
|
|||||||
@ -77,17 +77,6 @@ Some solutions:
|
|||||||
You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win!
|
You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win!
|
||||||
- Set `io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;` to disable rounding the texture height to the next power of two.
|
- Set `io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;` to disable rounding the texture height to the next power of two.
|
||||||
|
|
||||||
### (5) Reduce texture resizes/copy on startup
|
|
||||||
|
|
||||||
🆕 Since 1.92, the ImFontAtlas is initially created using a 512x128 texture, then grows as glyphs and fonts are used. Atlas growth leads to alloc+copy, and both the old and new sized textures are present in memory for a short time (typically one frame). If you use known fonts and want to reduce initial growth, you may set `TexMinWidth` and `TexMinHeight` during initializaton.
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
ImFontAtlas* atlas = io.Fonts;
|
|
||||||
atlas->TexMinWidth = 1024;
|
|
||||||
atlas->TexMinHeight = 1024;
|
|
||||||
atlas->AddFont(...);
|
|
||||||
```
|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
@ -96,7 +85,7 @@ atlas->AddFont(...);
|
|||||||
|
|
||||||
v1.92 introduces a newer, dynamic font system. It requires backend to support the `ImGuiBackendFlags_HasTextures` feature:
|
v1.92 introduces a newer, dynamic font system. It requires backend to support the `ImGuiBackendFlags_HasTextures` feature:
|
||||||
- Users of icons, Asian and non-English languages do not need to pre-build all glyphs ahead of time. Saving on loading time, memory, and also reducing issues with missing glyphs. Specifying glyph ranges is not needed anymore.
|
- Users of icons, Asian and non-English languages do not need to pre-build all glyphs ahead of time. Saving on loading time, memory, and also reducing issues with missing glyphs. Specifying glyph ranges is not needed anymore.
|
||||||
- `PushFont(nullptr, new_size)` may be used anytime to change font size.
|
- `PushFont(NULL, new_size)` may be used anytime to change font size.
|
||||||
- Packing custom rectangles is more convenient as pixels may be written to immediately.
|
- Packing custom rectangles is more convenient as pixels may be written to immediately.
|
||||||
- Any update to fonts previously required backend specific calls to re-upload the texture, and said calls were not portable across backends. It is now possible to scale fonts etc. in a way that doesn't require you to make backend-specific calls.
|
- Any update to fonts previously required backend specific calls to re-upload the texture, and said calls were not portable across backends. It is now possible to scale fonts etc. in a way that doesn't require you to make backend-specific calls.
|
||||||
- It is possible to plug a custom loader/backend to any font source.
|
- It is possible to plug a custom loader/backend to any font source.
|
||||||
|
|||||||
@ -43,7 +43,7 @@ Dear ImGui is particularly suited to integration in game engines (for tooling),
|
|||||||
|
|
||||||
**Backends for a variety of graphics API and rendering platforms** are provided in the [backends/](https://github.com/ocornut/imgui/tree/master/backends) folder, along with example applications in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui.
|
**Backends for a variety of graphics API and rendering platforms** are provided in the [backends/](https://github.com/ocornut/imgui/tree/master/backends) folder, along with example applications in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui.
|
||||||
|
|
||||||
C++20 users wishing to use a module may use the [stripe2933/imgui-module](https://github.com/stripe2933/imgui-module) third-party extension.
|
C++20 users wishing to use a module may the use [stripe2933/imgui-module](https://github.com/stripe2933/imgui-module) third-party extension.
|
||||||
|
|
||||||
See the [Getting Started & Integration](#getting-started--integration) section of this document for more details.
|
See the [Getting Started & Integration](#getting-started--integration) section of this document for more details.
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcas
|
|||||||
- [imgui_explorer](https://pthom.github.io/imgui_explorer): Web version of the demo w/ source code browser, courtesy of [@pthom](https://github.com/pthom).
|
- [imgui_explorer](https://pthom.github.io/imgui_explorer): Web version of the demo w/ source code browser, courtesy of [@pthom](https://github.com/pthom).
|
||||||
|
|
||||||
You should be able to build the examples from sources. 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:
|
You should be able to build the examples from sources. 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-20261015-win32.zip](https://www.dearimgui.com/binaries/imgui-demo-binaries-20261015-win32.zip) (Win32, 1.93.0, built 2026/10/15, master) or [older binaries](https://www.dearimgui.com/binaries).
|
- [imgui-demo-binaries-20260225.zip](https://www.dearimgui.com/binaries/imgui-demo-binaries-20260225.zip) (Windows, 1.92.6, built 2026/02/25, master) or [older binaries](https://www.dearimgui.com/binaries).
|
||||||
|
|
||||||
### Gallery
|
### Gallery
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ Integrating Dear ImGui within your custom engine is a matter of mainly 1) wiring
|
|||||||
- Generally, **make sure to spend time reading the [FAQ](https://www.dearimgui.com/faq), comments, and the examples applications!**
|
- Generally, **make sure to spend time reading the [FAQ](https://www.dearimgui.com/faq), comments, and the examples applications!**
|
||||||
|
|
||||||
Officially maintained backends (in repository):
|
Officially maintained backends (in repository):
|
||||||
- Renderers: DirectX9, DirectX10, DirectX11, DirectX12, Metal 3/4, OpenGL/ES/ES2, SDL_GPU, SDL_Renderer2/3, Vulkan, WebGPU.
|
- Renderers: DirectX9, DirectX10, DirectX11, DirectX12, Metal, OpenGL/ES/ES2, SDL_GPU, SDL_Renderer2/3, Vulkan, WebGPU.
|
||||||
- Platforms: GLFW, SDL2/SDL3, Win32, Glut, OSX, Android.
|
- Platforms: GLFW, SDL2/SDL3, Win32, Glut, OSX, Android.
|
||||||
- Frameworks: Allegro5, Emscripten.
|
- Frameworks: Allegro5, Emscripten.
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
# Security Policy
|
|
||||||
|
|
||||||
Dear ImGui is primarily designed for developer tools and technical applications running trusted code and trusted data.
|
|
||||||
|
|
||||||
Given that the library was not designed as a hardened security boundary against hostile or intentionally malformed inputs:
|
|
||||||
consider not using it in a context where a crash (through e.g. intentionally malformed inputs) could lead to privilege elevation.
|
|
||||||
E.g. running in a privileged process and interacting with non-privileged clients feeding code or data to Dear ImGui.
|
|
||||||
|
|
||||||
Dear ImGui development efforts are focused on improving developer experience, usability, correctness, and robustness in real-world applications.
|
|
||||||
We will do our best to reduce e.g. crashes caused by common programmer mistakes.
|
|
||||||
|
|
||||||
However, the project does not specifically focus on adversarial fuzzing scenarios, allocation-failure hardening, or highly artificial edge cases that are unlikely to occur in normal usage.
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
|
||||||
|
|
||||||
Considering the above policy, most things may be reported in GitHub Issues.
|
|
||||||
If you have a reason to disclose privately, please reach out to the contact address listed in README.
|
|
||||||
@ -2,14 +2,12 @@ dear imgui
|
|||||||
ISSUES & TODO LIST
|
ISSUES & TODO LIST
|
||||||
|
|
||||||
Issue numbers (#) refer to GitHub issues listed at https://github.com/ocornut/imgui/issues/XXXX
|
Issue numbers (#) refer to GitHub issues listed at https://github.com/ocornut/imgui/issues/XXXX
|
||||||
|
|
||||||
THIS LIST IS NOT WELL MAINTAINED. MOST OF THE WORK HAPPENS ON GITHUB NOWADAYS.
|
THIS LIST IS NOT WELL MAINTAINED. MOST OF THE WORK HAPPENS ON GITHUB NOWADAYS.
|
||||||
|
|
||||||
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).
|
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.
|
It's mostly a bunch of personal notes, probably incomplete. Feel free to query if you have any questions.
|
||||||
|
|
||||||
- doc: checklist app to verify backends/integration of imgui (test inputs, rendering, callback, etc.).
|
|
||||||
- doc: add a proper documentation system (maybe relying on automation? #435)
|
- doc: add a proper documentation system (maybe relying on automation? #435)
|
||||||
|
- doc: checklist app to verify backends/integration of imgui (test inputs, rendering, callback, etc.).
|
||||||
- doc/tips: tips of the day: website? applet in imgui_club?
|
- doc/tips: tips of the day: website? applet in imgui_club?
|
||||||
|
|
||||||
- window: preserve/restore relative focus ordering (persistent or not), and e.g. of multiple reappearing windows (#2304) -> also see docking reference to same #.
|
- window: preserve/restore relative focus ordering (persistent or not), and e.g. of multiple reappearing windows (#2304) -> also see docking reference to same #.
|
||||||
@ -31,9 +29,9 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
- 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, trying to click behind a modal).
|
- window/tabbing: add a way to signify that a window or docked window requires attention (e.g. blinking title bar, trying to click behind a modal).
|
||||||
- window/id_stack: add e.g. window->GetIDFromPath() with support for leading / and ../ (#1390, #331) -> model from test engine.
|
- window/id_stack: add e.g. window->GetIDFromPath() with support for leading / and ../ (#1390, #331) -> model from test engine.
|
||||||
|
! scrolling: exposing horizontal scrolling with Shift+Wheel even when scrollbar is disabled expose lots of issues (#2424, #1463)
|
||||||
! scrolling: exposing horizontal scrolling with Shift+Wheel even when scrollbar is disabled expose various issues (#2424, #1463)
|
|
||||||
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
- 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: forward mouse wheel scrolling to parent window when at the edge of scrolling limits? (useful for listbox,tables?)
|
||||||
- scrolling/style: shadows on scrollable areas to denote that there is more contents (see e.g. DaVinci Resolve ui)
|
- scrolling/style: shadows on scrollable areas to denote that there is more contents (see e.g. DaVinci Resolve ui)
|
||||||
|
|
||||||
@ -53,32 +51,38 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc. (#395)
|
- 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: clean up widgets internal toward exposing everything and stabilizing imgui_internals.h.
|
||||||
- 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: 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: alignment options in style (e.g. center Selectable, Right-Align within Button, etc.) #1260
|
||||||
- widgets: activate by identifier (trigger button, focus given id)
|
- widgets: activate by identifier (trigger button, focus given id)
|
||||||
- widgets: custom glyph/shapes replacements for stock shapes. (also #6090 #2431 #2235 #6517)
|
- widgets: custom glyph/shapes replacements for stock shapes. (also #6090 #2431 #2235 #6517)
|
||||||
- widgets: coloredit: keep reporting as active when picker is on?
|
- 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.
|
- 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: using (size.x == 0.0f) and (SelectableTextAlign.x > 0.0f) followed by SameLine() is currently not supported.
|
||||||
- selectable: generic BeginSelectable()/EndSelectable() mechanism. (work out alongside range-select branch)
|
- selectable: generic BeginSelectable()/EndSelectable() mechanism. (work out alongside range-select branch)
|
||||||
- selectable: a way to visualize partial/mixed selection (e.g. parent tree node has children with mixed selection)
|
- selectable: a way to visualize partial/mixed selection (e.g. parent tree node has children with mixed selection)
|
||||||
|
|
||||||
- input text: flag to disable live update of the user buffer (also applies to float/int text input) (#701)
|
|
||||||
- input text: preserve scrolling when unfocused?
|
- input text: preserve scrolling when unfocused?
|
||||||
- input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
|
- 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 nullptr if not active (available in internals)
|
||||||
|
- 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: hover tooltip could show unclamped text
|
||||||
- input text: support for INSERT key to toggle overwrite mode. currently disabled because stb_textedit behavior is unsatisfactory on multi-line. (#2863)
|
- input text: support for INSERT key to toggle overwrite mode. currently disabled because stb_textedit behavior is unsatisfactory on multi-line. (#2863)
|
||||||
- input text: option to Tab after an Enter validation.
|
- input text: option to Tab after an Enter validation.
|
||||||
- input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
|
- 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: 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: 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: allow centering/positioning text so that ctrl+clicking Drag or Slider keeps the textual value at the same pixel position.
|
||||||
- input text: decorrelate display layout from inputs with custom template - e.g. what's the easiest way to implement a nice IP/Mac address input editor?
|
- input text: decorrelate display layout from inputs with custom template - e.g. what's the easiest way to implement a nice IP/Mac address input editor?
|
||||||
- input text: callback system (global) so user can plug in an expression evaluator easily. (#1691)
|
- 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: 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 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 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: 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: Shift+TAB with ImGuiInputTextFlags_AllowTabInput could eat preceding blanks, up to tab_count.
|
||||||
|
- 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 copy/cut without selection (copy/cut current line?)
|
- input text multi-line: support for copy/cut without selection (copy/cut current line?)
|
||||||
- input text multi-line: line numbers? status bar? (follow up on #200)
|
- 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: 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)
|
||||||
@ -107,7 +111,11 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
!- color: the color conversion helpers/types are a mess and needs sorting out.
|
!- 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
|
- 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. --> promote using ImPlot
|
||||||
|
- (plot: deleted all other todo lines on 2023-06-28)
|
||||||
|
|
||||||
- clipper: ability to disable the clipping through a simple flag/bool.
|
- 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)
|
- clipper: horizontal clipping support. (#2580)
|
||||||
|
|
||||||
- separator: expose flags (#759)
|
- separator: expose flags (#759)
|
||||||
@ -133,19 +141,22 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- knob: rotating knob widget (#942)
|
- knob: rotating knob widget (#942)
|
||||||
- drag float: support for reversed drags (min > max) (removed is_locked, also see fdc526e)
|
- drag float: support for reversed drags (min > max) (removed is_locked, also see fdc526e)
|
||||||
- drag float: up/down axis
|
- 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)
|
- drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits)
|
||||||
|
|
||||||
- combo: a way/helper to customize the combo preview (#1658) -> experimental BeginComboPreview()
|
- combo: a way/helper to customize the combo preview (#1658) -> experimental BeginComboPreview()
|
||||||
- combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203)
|
- combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203)
|
||||||
|
- listbox: multiple selection (WIP range-select branch)
|
||||||
- listbox: unselect option (#1208)
|
- 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 range-select branch)
|
||||||
- listbox: user may want to initial scroll to focus on the one selected value?
|
- listbox: user may want to initial scroll to focus on the one selected value?
|
||||||
- listbox: disable capturing mouse wheel if the listbox has no scrolling. (#1681)
|
- listbox: disable capturing mouse wheel if the listbox has no scrolling. (#1681)
|
||||||
- listbox: scrolling should track modified selection.
|
- listbox: scrolling should track modified selection.
|
||||||
- listbox: future api should allow to enable horizontal scrolling (#2510)
|
- 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)
|
!- 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: 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. (#402)
|
- 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: 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: clicking outside (to close popup) and holding shouldn't drag window below.
|
||||||
- popups: add variant using global identifier similar to Begin/End (#402)
|
- popups: add variant using global identifier similar to Begin/End (#402)
|
||||||
@ -187,7 +198,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- style: FramePadding could be different for up vs down (#584)
|
- 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: 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: 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 (#4722, #1223) ~ 2 bg colors for each fill? tricky with rounded shapes and using textures for corners.
|
- 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.
|
- style editor: color child window height expressed in multiple of line height.
|
||||||
|
|
||||||
- log: improve logging of ArrowButton, ListBox, TabItem
|
- log: improve logging of ArrowButton, ListBox, TabItem
|
||||||
@ -203,6 +214,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb)
|
- filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb)
|
||||||
|
|
||||||
- drag and drop: focus drag target window on hold (even without open)
|
- drag and drop: focus drag target window on hold (even without open)
|
||||||
|
- 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: 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: 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 preview tooltip to be submitted from a different place than the drag source. (#1725)
|
||||||
@ -235,6 +247,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- font: make it easier to submit own bitmap font (same texture, another texture?). (#2127, #2575)
|
- font: make it easier to submit own bitmap font (same texture, another texture?). (#2127, #2575)
|
||||||
- font: MemoryTTF taking ownership confusing/not obvious, maybe default should be opposite?
|
- 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: 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: demonstrate use of ImFontGlyphRangesBuilder.
|
||||||
- font/draw: vertical and/or rotated text renderer (#705) - vertical is easier clipping wise
|
- 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: 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). also see #3349.
|
- font/draw: better reserve policy for large horizontal block of text (shouldn't reserve for all clipped lines). also see #3349.
|
||||||
@ -260,11 +273,12 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- nav: NavFlattened: ESC on a flattened child should select something.
|
- 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: broken: in typical usage scenario, the items of a fully clipped child are currently not considered to enter into 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: NavFlattened: cannot access menu-bar of a flattened child window with Alt/menu key (not a very common use case..).
|
||||||
|
- nav: simulate right-click or context activation? (SHIFT+F10, keyboard Menu key?)
|
||||||
- nav/popup: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys, default validation button, etc.
|
- nav/popup: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys, default validation button, etc.
|
||||||
- nav/treenode: left within a tree node block as a fallback (ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default?)
|
- 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: 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: 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: 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: 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 nullptr focus. Could save NavWindow at the time of being focused, similarly to what popup do?
|
- nav/menus: main menu bar currently cannot restore a nullptr 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/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?
|
||||||
@ -283,6 +297,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- 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: 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: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?)
|
||||||
- misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682)
|
- misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682)
|
||||||
|
- misc: use more size_t in public api?
|
||||||
- misc: support for string view/range instead of char* would e.g. facilitate usage with Rust (#683, #3038, WIP string_view branch)
|
- misc: support for string view/range instead of char* would e.g. facilitate usage with Rust (#683, #3038, WIP string_view branch)
|
||||||
|
|
||||||
- demo: demonstrate using PushStyleVar() in more details.
|
- demo: demonstrate using PushStyleVar() in more details.
|
||||||
@ -300,7 +315,8 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- backends: opengl: could use a single vertex buffer and glBufferSubData for uploads?
|
- backends: opengl: could use a single vertex buffer and glBufferSubData for uploads?
|
||||||
- backends: opengl: explicitly disable GL_STENCIL_TEST in bindings.
|
- backends: opengl: explicitly disable GL_STENCIL_TEST in bindings.
|
||||||
- backends: vulkan: viewport: support for synchronized swapping of multiple swap chains.
|
- backends: vulkan: viewport: support for synchronized swapping of multiple swap chains.
|
||||||
- backends: emscripten: dedicated backend? (#8178, #9120, eg. https://github.com/floooh/sokol-samples/blob/master/html5/imgui-emsc.cc#L42)
|
- backends: bgfx: https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0
|
||||||
|
- backends: emscripten: 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)
|
||||||
|
|
||||||
- bindings: ways to use clang ast dump to generate bindings or helpers for bindings? (e.g. clang++ -Xclang -ast-dump=json imgui.h) (--> use https://github.com/dearimgui/dear_bindings)
|
- bindings: ways to use clang ast dump to generate bindings or helpers for bindings? (e.g. clang++ -Xclang -ast-dump=json imgui.h) (--> use https://github.com/dearimgui/dear_bindings)
|
||||||
|
|
||||||
|
|||||||
@ -28,27 +28,27 @@
|
|||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
@ -92,7 +92,6 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -108,7 +107,6 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@ -42,24 +42,21 @@ int main(int, char**)
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplAllegro5_Init(display);
|
ImGui_ImplAllegro5_Init(display);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application)
|
alias(libs.plugins.android.application)
|
||||||
|
alias(libs.plugins.kotlin.android)
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@ -24,6 +25,9 @@ android {
|
|||||||
sourceCompatibility JavaVersion.VERSION_11
|
sourceCompatibility JavaVersion.VERSION_11
|
||||||
targetCompatibility JavaVersion.VERSION_11
|
targetCompatibility JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '11'
|
||||||
|
}
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
path file('../../CMakeLists.txt')
|
path file('../../CMakeLists.txt')
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "9.2.0"
|
agp = "8.12.0"
|
||||||
kotlin = "2.3.21"
|
kotlin = "2.0.21"
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|||||||
@ -144,12 +144,8 @@ void Init(struct android_app* app)
|
|||||||
io.IniFilename = g_IniFilename.c_str();;
|
io.IniFilename = g_IniFilename.c_str();;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplAndroid_Init(g_App->window);
|
ImGui_ImplAndroid_Init(g_App->window);
|
||||||
@ -157,18 +153,20 @@ void Init(struct android_app* app)
|
|||||||
|
|
||||||
// Setup scaling
|
// Setup scaling
|
||||||
float main_scale = 2.0f;
|
float main_scale = 2.0f;
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
style.FontScaleDpi = main_scale; // Set initial font scale.
|
style.FontScaleDpi = main_scale; // Set initial font scale.
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
// - Android: The TTF files have to be placed into the assets/ directory (android/app/src/main/assets), we use our GetAssetData() helper to retrieve them.
|
// - Android: The TTF files have to be placed into the assets/ directory (android/app/src/main/assets), we use our GetAssetData() helper to retrieve them.
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
|
|
||||||
|
|||||||
@ -62,24 +62,21 @@
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup Renderer backend
|
// Setup Renderer backend
|
||||||
ImGui_ImplMetal_Init(_device);
|
ImGui_ImplMetal_Init(_device);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||||
@ -111,6 +108,7 @@
|
|||||||
|
|
||||||
#if TARGET_OS_OSX
|
#if TARGET_OS_OSX
|
||||||
ImGui_ImplOSX_Init(self.view);
|
ImGui_ImplOSX_Init(self.view);
|
||||||
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,22 +270,6 @@
|
|||||||
|
|
||||||
@implementation AppDelegate
|
@implementation AppDelegate
|
||||||
|
|
||||||
-(void)applicationDidFinishLaunching:(NSNotification *)notification
|
|
||||||
{
|
|
||||||
NSMenu* mainMenuBar = [[NSMenu alloc] init];
|
|
||||||
NSMenu* appMenu = [[NSMenu alloc] initWithTitle:@"Dear ImGui OSX+Metal Example"];
|
|
||||||
NSMenuItem* quitMenuItem = [appMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
|
|
||||||
[quitMenuItem setTarget:NSApp];
|
|
||||||
[quitMenuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand];
|
|
||||||
|
|
||||||
NSMenuItem* appMenuItem = [[NSMenuItem alloc] init];
|
|
||||||
[appMenuItem setSubmenu:appMenu];
|
|
||||||
[mainMenuBar addItem:appMenuItem];
|
|
||||||
[NSApp setMainMenu:mainMenuBar];
|
|
||||||
|
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
|
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
@ -302,7 +284,6 @@
|
|||||||
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable
|
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:NO];
|
defer:NO];
|
||||||
self.window.title = @"Dear ImGui OSX+Metal Example";
|
|
||||||
self.window.contentViewController = rootViewController;
|
self.window.contentViewController = rootViewController;
|
||||||
[self.window center];
|
[self.window center];
|
||||||
[self.window makeKeyAndOrderFront:self];
|
[self.window makeKeyAndOrderFront:self];
|
||||||
@ -350,6 +331,7 @@ int main(int, const char**)
|
|||||||
AppDelegate *appDelegate = [[AppDelegate alloc] init]; // creates window
|
AppDelegate *appDelegate = [[AppDelegate alloc] init]; // creates window
|
||||||
[NSApp setDelegate:appDelegate];
|
[NSApp setDelegate:appDelegate];
|
||||||
|
|
||||||
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
# Makefile for example_apple_metal4, for macOS only (**not iOS**)
|
|
||||||
CXX = clang++
|
|
||||||
EXE = example_apple_metal4
|
|
||||||
IMGUI_DIR = ../../
|
|
||||||
SOURCES = main.mm
|
|
||||||
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
|
|
||||||
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_osx.mm $(IMGUI_DIR)/backends/imgui_impl_metal4.mm
|
|
||||||
|
|
||||||
CXXFLAGS = -std=c++11 -ObjC++ -fobjc-arc -Wall -Wextra -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
|
|
||||||
FRAMEWORKS = -framework AppKit -framework Metal -framework MetalKit -framework QuartzCore -framework GameController
|
|
||||||
|
|
||||||
all: $(EXE)
|
|
||||||
|
|
||||||
$(EXE): $(SOURCES)
|
|
||||||
$(CXX) $(CXXFLAGS) $^ $(FRAMEWORKS) -o $@
|
|
||||||
|
|
||||||
run: all
|
|
||||||
./$(EXE)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(EXE) *.o
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
# iOS / OSX Metal4 example
|
|
||||||
|
|
||||||
## Introduction
|
|
||||||
|
|
||||||
This example shows how to integrate Dear ImGui with Metal4. It is based on the "cross-platform" game template provided with Xcode as of Xcode 9.
|
|
||||||
|
|
||||||
Consider basing your work off the example_glfw_metal/ or example_sdl2_metal/ examples. They are better supported and will be portable unlike this one.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,535 +0,0 @@
|
|||||||
// !$*UTF8*$!
|
|
||||||
{
|
|
||||||
archiveVersion = 1;
|
|
||||||
classes = {
|
|
||||||
};
|
|
||||||
objectVersion = 54;
|
|
||||||
objects = {
|
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
|
||||||
050450AB2768052600AB6805 /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
|
|
||||||
050450AD276863B000AB6805 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 050450AC276863B000AB6805 /* QuartzCore.framework */; };
|
|
||||||
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05318E0E274C397200A8DE2E /* GameController.framework */; };
|
|
||||||
05A275442773BEA20084EF39 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05A275432773BEA20084EF39 /* QuartzCore.framework */; };
|
|
||||||
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 */; };
|
|
||||||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
|
|
||||||
8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8309BD8E253CCAAA0045E2A1 /* UIKit.framework */; };
|
|
||||||
8309BDA5253CCC070045E2A1 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDA0253CCBC10045E2A1 /* main.mm */; };
|
|
||||||
8309BDA8253CCC080045E2A1 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDA0253CCBC10045E2A1 /* main.mm */; };
|
|
||||||
8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal4.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal4.mm */; };
|
|
||||||
8309BDBE253CCCB60045E2A1 /* imgui_impl_metal4.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal4.mm */; };
|
|
||||||
8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */; };
|
|
||||||
8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8309BDC5253CCCFE0045E2A1 /* AppKit.framework */; };
|
|
||||||
8309BDFC253CDAB30045E2A1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8309BDF7253CDAAE0045E2A1 /* LaunchScreen.storyboard */; };
|
|
||||||
8309BE04253CDAB60045E2A1 /* MainMenu.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8309BDFA253CDAAE0045E2A1 /* MainMenu.storyboard */; };
|
|
||||||
83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E420EB46B900295997 /* Metal.framework */; };
|
|
||||||
83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E620EB46BD00295997 /* MetalKit.framework */; };
|
|
||||||
83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EA20EB471700295997 /* MetalKit.framework */; };
|
|
||||||
83BBE9ED20EB471700295997 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EB20EB471700295997 /* Metal.framework */; };
|
|
||||||
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 */
|
|
||||||
050450AC276863B000AB6805 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
|
||||||
05318E0E274C397200A8DE2E /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
|
|
||||||
05A2754027728F5B0084EF39 /* imgui_impl_metal4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_metal4.h; path = ../../backends/imgui_impl_metal4.h; sourceTree = "<group>"; };
|
|
||||||
05A2754127728F5B0084EF39 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../backends/imgui_impl_osx.h; sourceTree = "<group>"; };
|
|
||||||
05A275432773BEA20084EF39 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; };
|
|
||||||
07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = "<group>"; };
|
|
||||||
07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = "<group>"; };
|
|
||||||
5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = "<group>"; };
|
|
||||||
8307E7C420E9F9C900473790 /* example_apple_metal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example_apple_metal.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
||||||
8307E7DA20E9F9C900473790 /* example_apple_metal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example_apple_metal.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
||||||
8309BD8E253CCAAA0045E2A1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
|
|
||||||
8309BDA0253CCBC10045E2A1 /* main.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
|
|
||||||
8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal4.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_metal4.mm; path = ../../backends/imgui_impl_metal4.mm; sourceTree = "<group>"; };
|
|
||||||
8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../../backends/imgui_impl_osx.mm; sourceTree = "<group>"; };
|
|
||||||
8309BDC5253CCCFE0045E2A1 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
|
||||||
8309BDF7253CDAAE0045E2A1 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
|
|
||||||
8309BDF8253CDAAE0045E2A1 /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = "<group>"; };
|
|
||||||
8309BDFA253CDAAE0045E2A1 /* MainMenu.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = MainMenu.storyboard; sourceTree = "<group>"; };
|
|
||||||
8309BDFB253CDAAE0045E2A1 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-macOS.plist"; sourceTree = "<group>"; };
|
|
||||||
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; };
|
|
||||||
83BBEA0020EB54E700295997 /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = "<group>"; };
|
|
||||||
83BBEA0120EB54E700295997 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = "<group>"; };
|
|
||||||
83BBEA0220EB54E700295997 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = "<group>"; };
|
|
||||||
83BBEA0320EB54E700295997 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = "<group>"; };
|
|
||||||
83BBEA0420EB54E700295997 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
|
||||||
8307E7C120E9F9C900473790 /* Frameworks */ = {
|
|
||||||
isa = PBXFrameworksBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
05A275442773BEA20084EF39 /* QuartzCore.framework in Frameworks */,
|
|
||||||
8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */,
|
|
||||||
83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */,
|
|
||||||
83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
8307E7D720E9F9C900473790 /* Frameworks */ = {
|
|
||||||
isa = PBXFrameworksBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
050450AD276863B000AB6805 /* QuartzCore.framework in Frameworks */,
|
|
||||||
8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */,
|
|
||||||
83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */,
|
|
||||||
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */,
|
|
||||||
83BBE9ED20EB471700295997 /* Metal.framework in Frameworks */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXFrameworksBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
|
||||||
8307E7B520E9F9C700473790 = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
83BBE9F020EB544400295997 /* imgui */,
|
|
||||||
8309BD9E253CCBA70045E2A1 /* example */,
|
|
||||||
8307E7C520E9F9C900473790 /* Products */,
|
|
||||||
83BBE9E320EB46B800295997 /* Frameworks */,
|
|
||||||
);
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
8307E7C520E9F9C900473790 /* Products */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
8307E7C420E9F9C900473790 /* example_apple_metal.app */,
|
|
||||||
8307E7DA20E9F9C900473790 /* example_apple_metal.app */,
|
|
||||||
);
|
|
||||||
name = Products;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
8309BD9E253CCBA70045E2A1 /* example */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
8309BDF6253CDAAE0045E2A1 /* iOS */,
|
|
||||||
8309BDF9253CDAAE0045E2A1 /* macOS */,
|
|
||||||
8309BDA0253CCBC10045E2A1 /* main.mm */,
|
|
||||||
);
|
|
||||||
name = example;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
8309BDF6253CDAAE0045E2A1 /* iOS */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
8309BDF7253CDAAE0045E2A1 /* LaunchScreen.storyboard */,
|
|
||||||
8309BDF8253CDAAE0045E2A1 /* Info-iOS.plist */,
|
|
||||||
);
|
|
||||||
path = iOS;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
8309BDF9253CDAAE0045E2A1 /* macOS */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
8309BDFA253CDAAE0045E2A1 /* MainMenu.storyboard */,
|
|
||||||
8309BDFB253CDAAE0045E2A1 /* Info-macOS.plist */,
|
|
||||||
);
|
|
||||||
path = macOS;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
83BBE9E320EB46B800295997 /* Frameworks */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
050450AC276863B000AB6805 /* QuartzCore.framework */,
|
|
||||||
05A275432773BEA20084EF39 /* QuartzCore.framework */,
|
|
||||||
05318E0E274C397200A8DE2E /* GameController.framework */,
|
|
||||||
8309BDC5253CCCFE0045E2A1 /* AppKit.framework */,
|
|
||||||
8309BD8E253CCAAA0045E2A1 /* UIKit.framework */,
|
|
||||||
83BBE9EE20EB471C00295997 /* ModelIO.framework */,
|
|
||||||
83BBE9EB20EB471700295997 /* Metal.framework */,
|
|
||||||
83BBE9EA20EB471700295997 /* MetalKit.framework */,
|
|
||||||
83BBE9E820EB46C100295997 /* ModelIO.framework */,
|
|
||||||
83BBE9E620EB46BD00295997 /* MetalKit.framework */,
|
|
||||||
83BBE9E420EB46B900295997 /* Metal.framework */,
|
|
||||||
);
|
|
||||||
name = Frameworks;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
83BBE9F020EB544400295997 /* imgui */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
5079822D257677DB0038A28D /* imgui_tables.cpp */,
|
|
||||||
05A2754027728F5B0084EF39 /* imgui_impl_metal4.h */,
|
|
||||||
8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal4.mm */,
|
|
||||||
05A2754127728F5B0084EF39 /* imgui_impl_osx.h */,
|
|
||||||
8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */,
|
|
||||||
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 = "<group>";
|
|
||||||
};
|
|
||||||
/* 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 = {
|
|
||||||
BuildIndependentTargetsInParallel = YES;
|
|
||||||
LastUpgradeCheck = 1530;
|
|
||||||
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 = (
|
|
||||||
8309BDFC253CDAB30045E2A1 /* LaunchScreen.storyboard in Resources */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
8307E7D820E9F9C900473790 /* Resources */ = {
|
|
||||||
isa = PBXResourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
8309BE04253CDAB60045E2A1 /* MainMenu.storyboard in Resources */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXResourcesBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin PBXSourcesBuildPhase section */
|
|
||||||
8307E7C020E9F9C900473790 /* Sources */ = {
|
|
||||||
isa = PBXSourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal4.mm in Sources */,
|
|
||||||
83BBEA0920EB54E700295997 /* imgui.cpp in Sources */,
|
|
||||||
83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */,
|
|
||||||
83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */,
|
|
||||||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */,
|
|
||||||
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */,
|
|
||||||
8309BDA5253CCC070045E2A1 /* main.mm in Sources */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
8307E7D620E9F9C900473790 /* Sources */ = {
|
|
||||||
isa = PBXSourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
8309BDBE253CCCB60045E2A1 /* imgui_impl_metal4.mm in Sources */,
|
|
||||||
8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */,
|
|
||||||
83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */,
|
|
||||||
83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */,
|
|
||||||
83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */,
|
|
||||||
050450AB2768052600AB6805 /* imgui_tables.cpp in Sources */,
|
|
||||||
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */,
|
|
||||||
8309BDA8253CCC080045E2A1 /* main.mm in Sources */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXSourcesBuildPhase 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
|
||||||
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;
|
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
||||||
ENABLE_TESTABILITY = YES;
|
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
|
||||||
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;
|
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = 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 = 12.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";
|
|
||||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../**";
|
|
||||||
};
|
|
||||||
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 = 12.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";
|
|
||||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../**";
|
|
||||||
VALIDATE_PRODUCT = YES;
|
|
||||||
};
|
|
||||||
name = Release;
|
|
||||||
};
|
|
||||||
8307E7F420E9F9C900473790 /* Debug */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
CODE_SIGN_IDENTITY = "-";
|
|
||||||
CODE_SIGN_STYLE = Automatic;
|
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEVELOPMENT_TEAM = "";
|
|
||||||
INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist";
|
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
|
||||||
"$(inherited)",
|
|
||||||
"@executable_path/../Frameworks",
|
|
||||||
);
|
|
||||||
MACOSX_DEPLOYMENT_TARGET = 26.0;
|
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-macos";
|
|
||||||
PRODUCT_NAME = example_apple_metal;
|
|
||||||
SDKROOT = macosx;
|
|
||||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../**";
|
|
||||||
};
|
|
||||||
name = Debug;
|
|
||||||
};
|
|
||||||
8307E7F520E9F9C900473790 /* Release */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
CODE_SIGN_IDENTITY = "-";
|
|
||||||
CODE_SIGN_STYLE = Automatic;
|
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
|
||||||
DEAD_CODE_STRIPPING = YES;
|
|
||||||
DEVELOPMENT_TEAM = "";
|
|
||||||
INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist";
|
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
|
||||||
"$(inherited)",
|
|
||||||
"@executable_path/../Frameworks",
|
|
||||||
);
|
|
||||||
MACOSX_DEPLOYMENT_TARGET = 26.0;
|
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-macos";
|
|
||||||
PRODUCT_NAME = example_apple_metal;
|
|
||||||
SDKROOT = macosx;
|
|
||||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../**";
|
|
||||||
};
|
|
||||||
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 */;
|
|
||||||
}
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
||||||
<key>CFBundleExecutable</key>
|
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
|
||||||
<string>6.0</string>
|
|
||||||
<key>CFBundleName</key>
|
|
||||||
<string>imgui</string>
|
|
||||||
<key>CFBundlePackageType</key>
|
|
||||||
<string>APPL</string>
|
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>1.0</string>
|
|
||||||
<key>CFBundleVersion</key>
|
|
||||||
<string>1</string>
|
|
||||||
<key>LSRequiresIPhoneOS</key>
|
|
||||||
<true/>
|
|
||||||
<key>UILaunchStoryboardName</key>
|
|
||||||
<string>LaunchScreen</string>
|
|
||||||
<key>UIRequiredDeviceCapabilities</key>
|
|
||||||
<array>
|
|
||||||
<string>armv7</string>
|
|
||||||
<string>metal</string>
|
|
||||||
</array>
|
|
||||||
<key>UIRequiresFullScreen</key>
|
|
||||||
<true/>
|
|
||||||
<key>UIStatusBarHidden</key>
|
|
||||||
<true/>
|
|
||||||
<key>UISupportedInterfaceOrientations</key>
|
|
||||||
<array>
|
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
||||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
|
||||||
</array>
|
|
||||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
|
||||||
<array>
|
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
|
||||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
|
||||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
|
||||||
<dependencies>
|
|
||||||
<deployment identifier="iOS"/>
|
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
|
|
||||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
|
||||||
</dependencies>
|
|
||||||
<scenes>
|
|
||||||
<!--View Controller-->
|
|
||||||
<scene sceneID="EHf-IW-A2E">
|
|
||||||
<objects>
|
|
||||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
|
||||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
|
||||||
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
|
|
||||||
<color key="backgroundColor" red="0.27843137254901962" green="0.36078431372549019" blue="0.50196078431372548" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
|
|
||||||
</view>
|
|
||||||
</viewController>
|
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
|
||||||
</objects>
|
|
||||||
<point key="canvasLocation" x="53" y="375"/>
|
|
||||||
</scene>
|
|
||||||
</scenes>
|
|
||||||
</document>
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
||||||
<key>CFBundleExecutable</key>
|
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
|
||||||
<key>CFBundleIconFile</key>
|
|
||||||
<string></string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
|
||||||
<string>6.0</string>
|
|
||||||
<key>CFBundleName</key>
|
|
||||||
<string>imgui</string>
|
|
||||||
<key>CFBundlePackageType</key>
|
|
||||||
<string>APPL</string>
|
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>1.0</string>
|
|
||||||
<key>CFBundleVersion</key>
|
|
||||||
<string>1</string>
|
|
||||||
<key>LSMinimumSystemVersion</key>
|
|
||||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
|
||||||
<key>NSMainStoryboardFile</key>
|
|
||||||
<string>MainMenu</string>
|
|
||||||
<key>NSPrincipalClass</key>
|
|
||||||
<string>NSApplication</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
@ -1,93 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
|
||||||
<dependencies>
|
|
||||||
<deployment identifier="macosx"/>
|
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17156"/>
|
|
||||||
</dependencies>
|
|
||||||
<scenes>
|
|
||||||
<!--Application-->
|
|
||||||
<scene sceneID="JPo-4y-FX3">
|
|
||||||
<objects>
|
|
||||||
<application id="hnw-xV-0zn" sceneMemberID="viewController">
|
|
||||||
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
|
|
||||||
<items>
|
|
||||||
<menuItem title="ImGui" id="1Xt-HY-uBw">
|
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
|
||||||
<menu key="submenu" title="ImGui" systemMenu="apple" id="uQy-DD-JDr">
|
|
||||||
<items>
|
|
||||||
<menuItem title="Services" id="NMo-om-nkz">
|
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
|
||||||
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
|
|
||||||
</menuItem>
|
|
||||||
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
|
|
||||||
<menuItem title="Hide" keyEquivalent="h" id="Olw-nP-bQN">
|
|
||||||
<connections>
|
|
||||||
<action selector="hide:" target="Ady-hI-5gd" id="PnN-Uc-m68"/>
|
|
||||||
</connections>
|
|
||||||
</menuItem>
|
|
||||||
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
|
|
||||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
|
||||||
<connections>
|
|
||||||
<action selector="hideOtherApplications:" target="Ady-hI-5gd" id="VT4-aY-XCT"/>
|
|
||||||
</connections>
|
|
||||||
</menuItem>
|
|
||||||
<menuItem title="Show All" id="Kd2-mp-pUS">
|
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
|
||||||
<connections>
|
|
||||||
<action selector="unhideAllApplications:" target="Ady-hI-5gd" id="Dhg-Le-xox"/>
|
|
||||||
</connections>
|
|
||||||
</menuItem>
|
|
||||||
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
|
|
||||||
<menuItem title="Quit" keyEquivalent="q" id="4sb-4s-VLi">
|
|
||||||
<connections>
|
|
||||||
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
|
|
||||||
</connections>
|
|
||||||
</menuItem>
|
|
||||||
</items>
|
|
||||||
</menu>
|
|
||||||
</menuItem>
|
|
||||||
<menuItem title="View" id="H8h-7b-M4v">
|
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
|
||||||
<menu key="submenu" title="View" id="HyV-fh-RgO">
|
|
||||||
<items>
|
|
||||||
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
|
|
||||||
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
|
|
||||||
<connections>
|
|
||||||
<action selector="toggleFullScreen:" target="Ady-hI-5gd" id="dU3-MA-1Rq"/>
|
|
||||||
</connections>
|
|
||||||
</menuItem>
|
|
||||||
</items>
|
|
||||||
</menu>
|
|
||||||
</menuItem>
|
|
||||||
<menuItem title="Window" id="aUF-d1-5bR">
|
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
|
||||||
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
|
|
||||||
<items>
|
|
||||||
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
|
|
||||||
<connections>
|
|
||||||
<action selector="performMiniaturize:" target="Ady-hI-5gd" id="VwT-WD-YPe"/>
|
|
||||||
</connections>
|
|
||||||
</menuItem>
|
|
||||||
<menuItem title="Zoom" id="R4o-n2-Eq4">
|
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
|
||||||
<connections>
|
|
||||||
<action selector="performZoom:" target="Ady-hI-5gd" id="DIl-cC-cCs"/>
|
|
||||||
</connections>
|
|
||||||
</menuItem>
|
|
||||||
</items>
|
|
||||||
</menu>
|
|
||||||
</menuItem>
|
|
||||||
</items>
|
|
||||||
</menu>
|
|
||||||
<connections>
|
|
||||||
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
|
|
||||||
</connections>
|
|
||||||
</application>
|
|
||||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
|
|
||||||
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
|
|
||||||
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
|
||||||
</objects>
|
|
||||||
<point key="canvasLocation" x="-362" y="-38"/>
|
|
||||||
</scene>
|
|
||||||
</scenes>
|
|
||||||
</document>
|
|
||||||
@ -1,384 +0,0 @@
|
|||||||
// Dear ImGui: standalone example application for OSX + Metal.
|
|
||||||
|
|
||||||
// Learn about Dear ImGui:
|
|
||||||
// - FAQ https://dearimgui.com/faq
|
|
||||||
// - Getting Started https://dearimgui.com/getting-started
|
|
||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
#if TARGET_OS_OSX
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#else
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#import <Metal/Metal.h>
|
|
||||||
#import <MetalKit/MetalKit.h>
|
|
||||||
|
|
||||||
#include "imgui.h"
|
|
||||||
#include "imgui_impl_metal4.h"
|
|
||||||
#if TARGET_OS_OSX
|
|
||||||
#include "imgui_impl_osx.h"
|
|
||||||
@interface AppViewController : NSViewController<NSWindowDelegate>
|
|
||||||
@end
|
|
||||||
#else
|
|
||||||
@interface AppViewController : UIViewController
|
|
||||||
@end
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@interface AppViewController () <MTKViewDelegate>
|
|
||||||
@property (nonatomic, readonly) MTKView *mtkView;
|
|
||||||
@property (nonatomic, strong) id <MTLDevice> device;
|
|
||||||
@property (nonatomic, strong) id <MTL4CommandQueue> commandQueue;
|
|
||||||
@property (nonatomic, strong) id <MTL4CommandAllocator> commandAllocator;
|
|
||||||
@end
|
|
||||||
|
|
||||||
#define FRAMES_IN_FLIGHT 2
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
// AppViewController
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@implementation AppViewController
|
|
||||||
|
|
||||||
-(instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
|
|
||||||
{
|
|
||||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
||||||
|
|
||||||
_device = MTLCreateSystemDefaultDevice();
|
|
||||||
_commandQueue = [_device newMTL4CommandQueue];
|
|
||||||
_commandAllocator = [_device newCommandAllocator];
|
|
||||||
|
|
||||||
if (!self.device)
|
|
||||||
{
|
|
||||||
NSLog(@"Metal is not supported");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
|
||||||
// FIXME: This example doesn't have proper cleanup...
|
|
||||||
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
|
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
|
||||||
//ImGui::StyleColorsLight();
|
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
|
||||||
|
|
||||||
// Setup Renderer backend
|
|
||||||
ImGui_ImplMetal4_Init(_device, _commandQueue, FRAMES_IN_FLIGHT);
|
|
||||||
|
|
||||||
// Load Fonts
|
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
|
||||||
// - 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->AddFontDefaultVector();
|
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf");
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf");
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf");
|
|
||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf");
|
|
||||||
//IM_ASSERT(font != nullptr);
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(MTKView *)mtkView
|
|
||||||
{
|
|
||||||
return (MTKView *)self.view;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)loadView
|
|
||||||
{
|
|
||||||
self.view = [[MTKView alloc] initWithFrame:CGRectMake(0, 0, 1200, 800)];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)viewDidLoad
|
|
||||||
{
|
|
||||||
[super viewDidLoad];
|
|
||||||
|
|
||||||
self.mtkView.device = self.device;
|
|
||||||
self.mtkView.delegate = self;
|
|
||||||
|
|
||||||
#if TARGET_OS_OSX
|
|
||||||
ImGui_ImplOSX_Init(self.view);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
-(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);
|
|
||||||
[self.commandAllocator reset];
|
|
||||||
|
|
||||||
id<MTL4CommandBuffer> commandBuffer = [self.device newCommandBuffer];
|
|
||||||
[commandBuffer beginCommandBufferWithAllocator:self.commandAllocator];
|
|
||||||
|
|
||||||
MTL4RenderPassDescriptor* renderPassDescriptor = view.currentMTL4RenderPassDescriptor;
|
|
||||||
if (renderPassDescriptor == nil)
|
|
||||||
{
|
|
||||||
[commandBuffer endCommandBuffer];
|
|
||||||
[self.commandQueue commit:&commandBuffer count:1];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
|
||||||
static int frameIndex = 0;
|
|
||||||
ImGui_ImplMetal4_NewFrame(renderPassDescriptor, frameIndex);
|
|
||||||
frameIndex++;
|
|
||||||
frameIndex = (frameIndex + 1) % FRAMES_IN_FLIGHT;
|
|
||||||
|
|
||||||
#if TARGET_OS_OSX
|
|
||||||
ImGui_ImplOSX_NewFrame(view);
|
|
||||||
#endif
|
|
||||||
ImGui::NewFrame();
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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 create 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 / io.Framerate, io.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();
|
|
||||||
|
|
||||||
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
|
||||||
id <MTL4RenderCommandEncoder> renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
|
|
||||||
[renderEncoder pushDebugGroup:@"Dear ImGui rendering"];
|
|
||||||
ImGui_ImplMetal4_RenderDrawData(draw_data, commandBuffer, renderEncoder);
|
|
||||||
[renderEncoder popDebugGroup];
|
|
||||||
[renderEncoder endEncoding];
|
|
||||||
|
|
||||||
// Present
|
|
||||||
[commandBuffer endCommandBuffer];
|
|
||||||
[self.commandQueue waitForDrawable:view.currentDrawable];
|
|
||||||
[self.commandQueue commit:&commandBuffer count:1];
|
|
||||||
[self.commandQueue signalDrawable:view.currentDrawable];
|
|
||||||
[view.currentDrawable present];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)mtkView:(MTKView*)view drawableSizeWillChange:(CGSize)size
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
// Input processing
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#if TARGET_OS_OSX
|
|
||||||
|
|
||||||
- (void)viewWillAppear
|
|
||||||
{
|
|
||||||
[super viewWillAppear];
|
|
||||||
self.view.window.delegate = self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)windowWillClose:(NSNotification *)notification
|
|
||||||
{
|
|
||||||
ImGui_ImplMetal4_Shutdown();
|
|
||||||
ImGui_ImplOSX_Shutdown();
|
|
||||||
ImGui::DestroyContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// 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.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);
|
|
||||||
io.AddMousePosEvent(touchLocation.x, touchLocation.y);
|
|
||||||
|
|
||||||
BOOL hasActiveTouch = NO;
|
|
||||||
for (UITouch *touch in event.allTouches)
|
|
||||||
{
|
|
||||||
if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled)
|
|
||||||
{
|
|
||||||
hasActiveTouch = YES;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
io.AddMouseButtonEvent(0, hasActiveTouch);
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; }
|
|
||||||
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; }
|
|
||||||
-(void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; }
|
|
||||||
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
// AppDelegate
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#if TARGET_OS_OSX
|
|
||||||
|
|
||||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
|
||||||
@property (nonatomic, strong) NSWindow *window;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation AppDelegate
|
|
||||||
|
|
||||||
-(void)applicationDidFinishLaunching:(NSNotification *)notification
|
|
||||||
{
|
|
||||||
NSMenu* mainMenuBar = [[NSMenu alloc] init];
|
|
||||||
NSMenu* appMenu = [[NSMenu alloc] initWithTitle:@"Dear ImGui OSX+Metal4 Example"];
|
|
||||||
NSMenuItem* quitMenuItem = [appMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
|
|
||||||
[quitMenuItem setTarget:NSApp];
|
|
||||||
[quitMenuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand];
|
|
||||||
|
|
||||||
NSMenuItem* appMenuItem = [[NSMenuItem alloc] init];
|
|
||||||
[appMenuItem setSubmenu:appMenu];
|
|
||||||
[mainMenuBar addItem:appMenuItem];
|
|
||||||
[NSApp setMainMenu:mainMenuBar];
|
|
||||||
|
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
|
|
||||||
{
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(instancetype)init
|
|
||||||
{
|
|
||||||
if (self = [super init])
|
|
||||||
{
|
|
||||||
NSViewController *rootViewController = [[AppViewController alloc] initWithNibName:nil bundle:nil];
|
|
||||||
self.window = [[NSWindow alloc] initWithContentRect:NSZeroRect
|
|
||||||
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable
|
|
||||||
backing:NSBackingStoreBuffered
|
|
||||||
defer:NO];
|
|
||||||
self.window.title = @"Dear ImGui OSX+Metal4 Example";
|
|
||||||
self.window.contentViewController = rootViewController;
|
|
||||||
[self.window center];
|
|
||||||
[self.window makeKeyAndOrderFront:self];
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
|
||||||
@property (strong, nonatomic) UIWindow *window;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation AppDelegate
|
|
||||||
|
|
||||||
-(BOOL)application:(UIApplication *)application
|
|
||||||
didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey,id> *)launchOptions
|
|
||||||
{
|
|
||||||
UIViewController *rootViewController = [[AppViewController alloc] init];
|
|
||||||
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
|
|
||||||
self.window.rootViewController = rootViewController;
|
|
||||||
[self.window makeKeyAndVisible];
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
// Application main() function
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#if TARGET_OS_OSX
|
|
||||||
|
|
||||||
int main(int, const char**)
|
|
||||||
{
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
[NSApplication sharedApplication];
|
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
||||||
|
|
||||||
AppDelegate *appDelegate = [[AppDelegate alloc] init]; // creates window
|
|
||||||
[NSApp setDelegate:appDelegate];
|
|
||||||
|
|
||||||
[NSApp run];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
|
||||||
{
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -6,7 +6,6 @@
|
|||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#define GL_SILENCE_DEPRECATION
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <OpenGL/gl.h>
|
#import <OpenGL/gl.h>
|
||||||
#import <OpenGL/glu.h>
|
#import <OpenGL/glu.h>
|
||||||
@ -33,7 +32,7 @@
|
|||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
GLint swapInterval = 1;
|
GLint swapInterval = 1;
|
||||||
[[self openGLContext] setValues:&swapInterval forParameter:NSOpenGLContextParameterSwapInterval];
|
[[self openGLContext] setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
|
||||||
if (swapInterval == 0)
|
if (swapInterval == 0)
|
||||||
NSLog(@"Error: Cannot set swap interval.");
|
NSLog(@"Error: Cannot set swap interval.");
|
||||||
#endif
|
#endif
|
||||||
@ -50,12 +49,8 @@
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplOSX_Init(self);
|
ImGui_ImplOSX_Init(self);
|
||||||
@ -63,12 +58,13 @@
|
|||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||||
@ -134,8 +130,8 @@
|
|||||||
ImDrawData* draw_data = ImGui::GetDrawData();
|
ImDrawData* draw_data = ImGui::GetDrawData();
|
||||||
|
|
||||||
[[self openGLContext] makeCurrentContext];
|
[[self openGLContext] makeCurrentContext];
|
||||||
GLsizei width = (GLsizei)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f);
|
GLsizei width = (GLsizei)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
GLsizei height = (GLsizei)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
GLsizei height = (GLsizei)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
@ -191,14 +187,19 @@
|
|||||||
-(void)setupMenu
|
-(void)setupMenu
|
||||||
{
|
{
|
||||||
NSMenu* mainMenuBar = [[NSMenu alloc] init];
|
NSMenu* mainMenuBar = [[NSMenu alloc] init];
|
||||||
NSMenu* appMenu = [[NSMenu alloc] initWithTitle:@"Dear ImGui OSX+OpenGL2 Example"];
|
NSMenu* appMenu;
|
||||||
NSMenuItem* quitMenuItem = [appMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
|
NSMenuItem* menuItem;
|
||||||
[quitMenuItem setTarget:NSApp];
|
|
||||||
[quitMenuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand];
|
|
||||||
|
|
||||||
NSMenuItem* appMenuItem = [[NSMenuItem alloc] init];
|
appMenu = [[NSMenu alloc] initWithTitle:@"Dear ImGui OSX+OpenGL2 Example"];
|
||||||
[appMenuItem setSubmenu:appMenu];
|
menuItem = [appMenu addItemWithTitle:@"Quit Dear ImGui OSX+OpenGL2 Example" action:@selector(terminate:) keyEquivalent:@"q"];
|
||||||
[mainMenuBar addItem:appMenuItem];
|
[menuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand];
|
||||||
|
|
||||||
|
menuItem = [[NSMenuItem alloc] init];
|
||||||
|
[menuItem setSubmenu:appMenu];
|
||||||
|
|
||||||
|
[mainMenuBar addItem:menuItem];
|
||||||
|
|
||||||
|
appMenu = nil;
|
||||||
[NSApp setMainMenu:mainMenuBar];
|
[NSApp setMainMenu:mainMenuBar];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +210,10 @@
|
|||||||
|
|
||||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
-(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
|
// Menu
|
||||||
[self setupMenu];
|
[self setupMenu];
|
||||||
|
|
||||||
@ -232,8 +237,6 @@
|
|||||||
NSLog(@"No OpenGL Context!");
|
NSLog(@"No OpenGL Context!");
|
||||||
|
|
||||||
[view initialize];
|
[view initialize];
|
||||||
|
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -242,17 +245,14 @@
|
|||||||
// Application main() function
|
// Application main() function
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
int main(int, const char**)
|
int main(int argc, const char* argv[])
|
||||||
{
|
{
|
||||||
@autoreleasepool
|
@autoreleasepool
|
||||||
{
|
{
|
||||||
[NSApplication sharedApplication];
|
NSApp = [NSApplication sharedApplication];
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
AppDelegate* delegate = [[AppDelegate alloc] init];
|
||||||
|
[[NSApplication sharedApplication] setDelegate:delegate];
|
||||||
AppDelegate* appDelegate = [[AppDelegate alloc] init];
|
|
||||||
[NSApp setDelegate:appDelegate];
|
|
||||||
|
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
}
|
}
|
||||||
return 0;
|
return NSApplicationMain(argc, argv);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
# Makefile for example_apple_opengl3, for macOS only (**not iOS**)
|
|
||||||
CXX = clang++
|
|
||||||
EXE = example_apple_opengl3
|
|
||||||
IMGUI_DIR = ../../
|
|
||||||
SOURCES = main.mm
|
|
||||||
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
|
|
||||||
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_osx.mm $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
|
|
||||||
|
|
||||||
CXXFLAGS = -std=c++11 -ObjC++ -fobjc-arc -Wall -Wextra -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
|
|
||||||
FRAMEWORKS = -framework Cocoa -framework OpenGL -framework GameController
|
|
||||||
|
|
||||||
all: $(EXE)
|
|
||||||
|
|
||||||
$(EXE): $(SOURCES)
|
|
||||||
$(CXX) $(CXXFLAGS) $(SOURCES) -o $(EXE) $(FRAMEWORKS)
|
|
||||||
|
|
||||||
run: all
|
|
||||||
./$(EXE)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(EXE) *.o
|
|
||||||
@ -1,334 +0,0 @@
|
|||||||
// !$*UTF8*$!
|
|
||||||
{
|
|
||||||
archiveVersion = 1;
|
|
||||||
classes = {
|
|
||||||
};
|
|
||||||
objectVersion = 48;
|
|
||||||
objects = {
|
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
|
||||||
05E31B59274EF0700083FCB6 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05E31B57274EF0360083FCB6 /* GameController.framework */; };
|
|
||||||
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_opengl3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A99E20B034280036BA46 /* imgui_impl_opengl3.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 */; };
|
|
||||||
50798230257677FD0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822F257677FC0038A28D /* imgui_tables.cpp */; };
|
|
||||||
/* 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 */
|
|
||||||
05E31B57274EF0360083FCB6 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
|
|
||||||
07A82EDA213941D00078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = "<group>"; };
|
|
||||||
4080A96B20B029B00036BA46 /* example_osx_opengl3 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = example_osx_opengl3; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
||||||
4080A98A20B02CD90036BA46 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = SOURCE_ROOT; };
|
|
||||||
4080A99E20B034280036BA46 /* imgui_impl_opengl3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_opengl3.cpp; path = ../../backends/imgui_impl_opengl3.cpp; sourceTree = "<group>"; };
|
|
||||||
4080A99F20B034280036BA46 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../../backends/imgui_impl_osx.mm; sourceTree = "<group>"; };
|
|
||||||
4080A9A020B034280036BA46 /* imgui_impl_opengl3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_opengl3.h; path = ../../backends/imgui_impl_opengl3.h; sourceTree = "<group>"; };
|
|
||||||
4080A9A120B034280036BA46 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../backends/imgui_impl_osx.h; sourceTree = "<group>"; };
|
|
||||||
4080A9A320B034280036BA46 /* imgui_impl_opengl3_loader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_opengl3_loader.h; path = ../../backends/imgui_impl_opengl3_loader.h; sourceTree = "<group>"; };
|
|
||||||
4080A9A520B0343C0036BA46 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = "<group>"; };
|
|
||||||
4080A9A620B0343C0036BA46 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = "<group>"; };
|
|
||||||
4080A9A720B0343C0036BA46 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = "<group>"; };
|
|
||||||
4080A9A820B0343C0036BA46 /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = "<group>"; };
|
|
||||||
4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = "<group>"; };
|
|
||||||
4080A9AC20B0343C0036BA46 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = "<group>"; };
|
|
||||||
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; };
|
|
||||||
5079822F257677FC0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
|
||||||
4080A96820B029B00036BA46 /* Frameworks */ = {
|
|
||||||
isa = PBXFrameworksBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
4080A9B520B034EA0036BA46 /* OpenGL.framework in Frameworks */,
|
|
||||||
4080A9B320B034E40036BA46 /* Cocoa.framework in Frameworks */,
|
|
||||||
05E31B59274EF0700083FCB6 /* GameController.framework in Frameworks */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXFrameworksBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
|
||||||
4080A96220B029B00036BA46 = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
5079822F257677FC0038A28D /* imgui_tables.cpp */,
|
|
||||||
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_opengl3.cpp */,
|
|
||||||
4080A9A020B034280036BA46 /* imgui_impl_opengl3.h */,
|
|
||||||
4080A9A320B034280036BA46 /* imgui_impl_opengl3_loader.h */,
|
|
||||||
4080A9A120B034280036BA46 /* imgui_impl_osx.h */,
|
|
||||||
4080A99F20B034280036BA46 /* imgui_impl_osx.mm */,
|
|
||||||
4080A98A20B02CD90036BA46 /* main.mm */,
|
|
||||||
4080A96C20B029B00036BA46 /* Products */,
|
|
||||||
4080A9B120B034E40036BA46 /* Frameworks */,
|
|
||||||
);
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
4080A96C20B029B00036BA46 /* Products */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
4080A96B20B029B00036BA46 /* example_osx_opengl3 */,
|
|
||||||
);
|
|
||||||
name = Products;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
4080A9B120B034E40036BA46 /* Frameworks */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
05E31B57274EF0360083FCB6 /* GameController.framework */,
|
|
||||||
4080A9B420B034EA0036BA46 /* OpenGL.framework */,
|
|
||||||
4080A9B220B034E40036BA46 /* Cocoa.framework */,
|
|
||||||
);
|
|
||||||
name = Frameworks;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
/* End PBXGroup section */
|
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
|
||||||
4080A96A20B029B00036BA46 /* example_osx_opengl3 */ = {
|
|
||||||
isa = PBXNativeTarget;
|
|
||||||
buildConfigurationList = 4080A97220B029B00036BA46 /* Build configuration list for PBXNativeTarget "example_osx_opengl3" */;
|
|
||||||
buildPhases = (
|
|
||||||
4080A96720B029B00036BA46 /* Sources */,
|
|
||||||
4080A96820B029B00036BA46 /* Frameworks */,
|
|
||||||
4080A96920B029B00036BA46 /* CopyFiles */,
|
|
||||||
);
|
|
||||||
buildRules = (
|
|
||||||
);
|
|
||||||
dependencies = (
|
|
||||||
);
|
|
||||||
name = example_osx_opengl3;
|
|
||||||
productName = example_osx_opengl3;
|
|
||||||
productReference = 4080A96B20B029B00036BA46 /* example_osx_opengl3 */;
|
|
||||||
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_opengl3" */;
|
|
||||||
compatibilityVersion = "Xcode 8.0";
|
|
||||||
developmentRegion = en;
|
|
||||||
hasScannedForEncodings = 0;
|
|
||||||
knownRegions = (
|
|
||||||
en,
|
|
||||||
);
|
|
||||||
mainGroup = 4080A96220B029B00036BA46;
|
|
||||||
productRefGroup = 4080A96C20B029B00036BA46 /* Products */;
|
|
||||||
projectDirPath = "";
|
|
||||||
projectRoot = "";
|
|
||||||
targets = (
|
|
||||||
4080A96A20B029B00036BA46 /* example_osx_opengl3 */,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
/* 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_opengl3.cpp in Sources */,
|
|
||||||
4080A9B020B0347A0036BA46 /* imgui_impl_osx.mm in Sources */,
|
|
||||||
4080A9AE20B0343C0036BA46 /* imgui.cpp in Sources */,
|
|
||||||
50798230257677FD0038A28D /* imgui_tables.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.13;
|
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
||||||
USER_HEADER_SEARCH_PATHS = ../..;
|
|
||||||
};
|
|
||||||
name = Debug;
|
|
||||||
};
|
|
||||||
4080A97420B029B00036BA46 /* Release */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
CODE_SIGN_STYLE = Automatic;
|
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
||||||
USER_HEADER_SEARCH_PATHS = ../..;
|
|
||||||
};
|
|
||||||
name = Release;
|
|
||||||
};
|
|
||||||
/* End XCBuildConfiguration section */
|
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
|
||||||
4080A96620B029B00036BA46 /* Build configuration list for PBXProject "example_apple_opengl3" */ = {
|
|
||||||
isa = XCConfigurationList;
|
|
||||||
buildConfigurations = (
|
|
||||||
4080A97020B029B00036BA46 /* Debug */,
|
|
||||||
4080A97120B029B00036BA46 /* Release */,
|
|
||||||
);
|
|
||||||
defaultConfigurationIsVisible = 0;
|
|
||||||
defaultConfigurationName = Release;
|
|
||||||
};
|
|
||||||
4080A97220B029B00036BA46 /* Build configuration list for PBXNativeTarget "example_osx_opengl3" */ = {
|
|
||||||
isa = XCConfigurationList;
|
|
||||||
buildConfigurations = (
|
|
||||||
4080A97320B029B00036BA46 /* Debug */,
|
|
||||||
4080A97420B029B00036BA46 /* Release */,
|
|
||||||
);
|
|
||||||
defaultConfigurationIsVisible = 0;
|
|
||||||
defaultConfigurationName = Release;
|
|
||||||
};
|
|
||||||
/* End XCConfigurationList section */
|
|
||||||
};
|
|
||||||
rootObject = 4080A96320B029B00036BA46 /* Project object */;
|
|
||||||
}
|
|
||||||
@ -1,259 +0,0 @@
|
|||||||
// Dear ImGui: standalone example application for OSX + OpenGL3
|
|
||||||
|
|
||||||
// Learn about Dear ImGui:
|
|
||||||
// - FAQ https://dearimgui.com/faq
|
|
||||||
// - Getting Started https://dearimgui.com/getting-started
|
|
||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
|
||||||
|
|
||||||
#define GL_SILENCE_DEPRECATION
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#import <OpenGL/gl3.h>
|
|
||||||
|
|
||||||
#include "imgui.h"
|
|
||||||
#include "imgui_impl_opengl3.h"
|
|
||||||
#include "imgui_impl_osx.h"
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
// AppView
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@interface AppView : NSOpenGLView
|
|
||||||
{
|
|
||||||
NSTimer* animationTimer;
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation AppView
|
|
||||||
|
|
||||||
-(void)prepareOpenGL
|
|
||||||
{
|
|
||||||
[super prepareOpenGL];
|
|
||||||
|
|
||||||
#ifndef DEBUG
|
|
||||||
GLint swapInterval = 1;
|
|
||||||
[[self openGLContext] setValues:&swapInterval forParameter:NSOpenGLContextParameterSwapInterval];
|
|
||||||
if (swapInterval == 0)
|
|
||||||
NSLog(@"Error: Cannot set swap interval.");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)initialize
|
|
||||||
{
|
|
||||||
// Setup Dear ImGui context
|
|
||||||
// FIXME: This example doesn't have proper cleanup...
|
|
||||||
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
|
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
|
||||||
//ImGui::StyleColorsLight();
|
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
|
||||||
[[self openGLContext] makeCurrentContext]; // ImGui_ImplOpenGL3_Init() requires a current GL context.
|
|
||||||
ImGui_ImplOSX_Init(self);
|
|
||||||
ImGui_ImplOpenGL3_Init();
|
|
||||||
|
|
||||||
// Load Fonts
|
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
|
||||||
// - 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->AddFontDefaultVector();
|
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf");
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf");
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf");
|
|
||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf");
|
|
||||||
//IM_ASSERT(font != nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)updateAndDrawDemoView
|
|
||||||
{
|
|
||||||
// Start the Dear ImGui frame
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
|
||||||
ImGui_ImplOSX_NewFrame(self);
|
|
||||||
ImGui::NewFrame();
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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 create 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 / io.Framerate, io.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();
|
|
||||||
|
|
||||||
[[self openGLContext] makeCurrentContext];
|
|
||||||
GLsizei width = (GLsizei)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x + 0.5f);
|
|
||||||
GLsizei height = (GLsizei)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y + 0.5f);
|
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_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 { [super reshape]; [[self openGLContext] update]; [self updateAndDrawDemoView]; }
|
|
||||||
-(void)drawRect:(NSRect)bounds { [self updateAndDrawDemoView]; }
|
|
||||||
-(void)animationTimerFired:(NSTimer*)timer { [self setNeedsDisplay:YES]; }
|
|
||||||
-(void)dealloc { animationTimer = nil; }
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
// AppDelegate
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
|
||||||
@property (nonatomic, readonly) NSWindow* window;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation AppDelegate
|
|
||||||
@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 + 800.0);
|
|
||||||
|
|
||||||
_window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES];
|
|
||||||
[_window setTitle:@"Dear ImGui OSX+OpenGL3 Example"];
|
|
||||||
[_window setAcceptsMouseMovedEvents:YES];
|
|
||||||
[_window setOpaque:YES];
|
|
||||||
[_window makeKeyAndOrderFront:NSApp];
|
|
||||||
|
|
||||||
return _window;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)setupMenu
|
|
||||||
{
|
|
||||||
NSMenu* mainMenuBar = [[NSMenu alloc] init];
|
|
||||||
NSMenu* appMenu = [[NSMenu alloc] initWithTitle:@"Dear ImGui OSX+OpenGL3 Example"];
|
|
||||||
NSMenuItem* quitMenuItem = [appMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
|
|
||||||
[quitMenuItem setTarget:NSApp];
|
|
||||||
[quitMenuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand];
|
|
||||||
|
|
||||||
NSMenuItem* appMenuItem = [[NSMenuItem alloc] init];
|
|
||||||
[appMenuItem setSubmenu:appMenu];
|
|
||||||
[mainMenuBar addItem:appMenuItem];
|
|
||||||
[NSApp setMainMenu:mainMenuBar];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)dealloc
|
|
||||||
{
|
|
||||||
_window = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
|
||||||
{
|
|
||||||
// Menu
|
|
||||||
[self setupMenu];
|
|
||||||
|
|
||||||
NSOpenGLPixelFormatAttribute attrs[] =
|
|
||||||
{
|
|
||||||
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
|
|
||||||
NSOpenGLPFADoubleBuffer,
|
|
||||||
NSOpenGLPFADepthSize, 32,
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
|
|
||||||
AppView* view = [[AppView 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!");
|
|
||||||
|
|
||||||
[view initialize];
|
|
||||||
|
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
// Application main() function
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int main(int, const char**)
|
|
||||||
{
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
[NSApplication sharedApplication];
|
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
||||||
|
|
||||||
AppDelegate* appDelegate = [[AppDelegate alloc] init];
|
|
||||||
[NSApp setDelegate:appDelegate];
|
|
||||||
|
|
||||||
[NSApp run];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@ -46,14 +46,11 @@ int main(int, char**)
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup scaling
|
// Setup scaling
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
||||||
|
|
||||||
@ -61,17 +58,18 @@ int main(int, char**)
|
|||||||
id <MTLCommandQueue> commandQueue = [device newCommandQueue];
|
id <MTLCommandQueue> commandQueue = [device newCommandQueue];
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOther(window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
ImGui_ImplMetal_Init(device);
|
ImGui_ImplMetal_Init(device);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
@REM Build for Visual Studio compiler. First run vcvars32.bat (x86) or vcvars64.bat (x64).
|
|
||||||
|
|
||||||
@REM Detect target architecture (VS 2015 uses Platform, unset for native x86; VS 2017+ uses VSCMD_ARG_TGT_ARCH).
|
|
||||||
@set TARGET_ARCH=%VSCMD_ARG_TGT_ARCH%
|
|
||||||
@if not defined TARGET_ARCH if "%VisualStudioVersion%"=="14.0" (set TARGET_ARCH=x86& if defined Platform set TARGET_ARCH=%Platform%)
|
|
||||||
@if /I "%TARGET_ARCH%"=="x86" goto arch_ok
|
|
||||||
@if /I "%TARGET_ARCH%"=="x64" goto arch_ok
|
|
||||||
@echo Unsupported or uninitialized compiler environment. First run vcvars32.bat (x86) or vcvars64.bat (x64).
|
|
||||||
@exit /b 1
|
|
||||||
|
|
||||||
:arch_ok
|
|
||||||
@set OUT_EXE=example_glfw_opengl2
|
|
||||||
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include
|
|
||||||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
|
|
||||||
@set LIBS=glfw3.lib opengl32.lib gdi32.lib shell32.lib
|
|
||||||
@if /I "%TARGET_ARCH%"=="x86" set LIBS=%LIBS% /LIBPATH:..\libs\glfw\lib-vc2010-32
|
|
||||||
@if /I "%TARGET_ARCH%"=="x64" set LIBS=%LIBS% /LIBPATH:..\libs\glfw\lib-vc2010-64
|
|
||||||
|
|
||||||
@set OUT_DIR=Debug
|
|
||||||
mkdir %OUT_DIR%
|
|
||||||
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
|
||||||
8
examples/example_glfw_opengl2/build_win32.bat
Normal file
8
examples/example_glfw_opengl2/build_win32.bat
Normal file
@ -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_glfw_opengl2
|
||||||
|
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include
|
||||||
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
|
||||||
|
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
|
||||||
|
mkdir %OUT_DIR%
|
||||||
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
@ -28,27 +28,27 @@
|
|||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
@ -92,7 +92,6 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -108,7 +107,6 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@ -55,14 +55,11 @@ int main(int, char**)
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup scaling
|
// Setup scaling
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
||||||
|
|
||||||
@ -72,12 +69,13 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
@REM Build for Visual Studio compiler. First run vcvars32.bat (x86) or vcvars64.bat (x64).
|
|
||||||
|
|
||||||
@REM Detect target architecture (VS 2015 uses Platform, unset for native x86; VS 2017+ uses VSCMD_ARG_TGT_ARCH).
|
|
||||||
@set TARGET_ARCH=%VSCMD_ARG_TGT_ARCH%
|
|
||||||
@if not defined TARGET_ARCH if "%VisualStudioVersion%"=="14.0" (set TARGET_ARCH=x86& if defined Platform set TARGET_ARCH=%Platform%)
|
|
||||||
@if /I "%TARGET_ARCH%"=="x86" goto arch_ok
|
|
||||||
@if /I "%TARGET_ARCH%"=="x64" goto arch_ok
|
|
||||||
@echo Unsupported or uninitialized compiler environment. First run vcvars32.bat (x86) or vcvars64.bat (x64).
|
|
||||||
@exit /b 1
|
|
||||||
|
|
||||||
:arch_ok
|
|
||||||
@set OUT_EXE=example_glfw_opengl3
|
|
||||||
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include
|
|
||||||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp
|
|
||||||
@set LIBS=glfw3.lib opengl32.lib gdi32.lib shell32.lib
|
|
||||||
@if /I "%TARGET_ARCH%"=="x86" set LIBS=%LIBS% /LIBPATH:..\libs\glfw\lib-vc2010-32
|
|
||||||
@if /I "%TARGET_ARCH%"=="x64" set LIBS=%LIBS% /LIBPATH:..\libs\glfw\lib-vc2010-64
|
|
||||||
|
|
||||||
@set OUT_DIR=Debug
|
|
||||||
mkdir %OUT_DIR%
|
|
||||||
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
|
||||||
8
examples/example_glfw_opengl3/build_win32.bat
Normal file
8
examples/example_glfw_opengl3/build_win32.bat
Normal file
@ -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_glfw_opengl3
|
||||||
|
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include
|
||||||
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp
|
||||||
|
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
|
||||||
|
mkdir %OUT_DIR%
|
||||||
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
@ -28,27 +28,27 @@
|
|||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
@ -92,7 +92,6 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -108,7 +107,6 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@ -41,26 +41,29 @@ int main(int, char**)
|
|||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// Select GL version + let the backend select a GLSL version
|
// Decide GL+GLSL versions
|
||||||
const char* glsl_version = nullptr;
|
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
// GL ES 2.0 + GLSL 100 (WebGL 1.0)
|
// GL ES 2.0 + GLSL 100 (WebGL 1.0)
|
||||||
|
const char* glsl_version = "#version 100";
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
// GL ES 3.0 + GLSL 300 es (WebGL 2.0)
|
// GL ES 3.0 + GLSL 300 es (WebGL 2.0)
|
||||||
|
const char* glsl_version = "#version 300 es";
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
// GL 3.2 + generally GLSL 150
|
// GL 3.2 + GLSL 150
|
||||||
|
const char* glsl_version = "#version 150";
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
|
||||||
#else
|
#else
|
||||||
// GL 3.0 + generally GLSL 130
|
// GL 3.0 + GLSL 130
|
||||||
|
const char* glsl_version = "#version 130";
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
|
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
|
||||||
@ -83,14 +86,11 @@ int main(int, char**)
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup scaling
|
// Setup scaling
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
||||||
|
|
||||||
@ -103,13 +103,14 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
@REM Build for Visual Studio compiler. First run vcvars32.bat (x86) or vcvars64.bat (x64).
|
|
||||||
|
|
||||||
@REM Detect target architecture (VS 2015 uses Platform, unset for native x86; VS 2017+ uses VSCMD_ARG_TGT_ARCH).
|
|
||||||
@set TARGET_ARCH=%VSCMD_ARG_TGT_ARCH%
|
|
||||||
@if not defined TARGET_ARCH if "%VisualStudioVersion%"=="14.0" (set TARGET_ARCH=x86& if defined Platform set TARGET_ARCH=%Platform%)
|
|
||||||
@if /I "%TARGET_ARCH%"=="x86" goto arch_ok
|
|
||||||
@if /I "%TARGET_ARCH%"=="x64" goto arch_ok
|
|
||||||
@echo Unsupported or uninitialized compiler environment. First run vcvars32.bat (x86) or vcvars64.bat (x64).
|
|
||||||
@exit /b 1
|
|
||||||
|
|
||||||
:arch_ok
|
|
||||||
@set OUT_EXE=example_glfw_vulkan
|
|
||||||
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I %VULKAN_SDK%\include
|
|
||||||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
|
|
||||||
@set LIBS=glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
|
|
||||||
@if /I "%TARGET_ARCH%"=="x86" set LIBS=%LIBS% /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32
|
|
||||||
@if /I "%TARGET_ARCH%"=="x64" set LIBS=%LIBS% /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib
|
|
||||||
|
|
||||||
@set OUT_DIR=Debug
|
|
||||||
mkdir %OUT_DIR%
|
|
||||||
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
|
||||||
|
|
||||||
@set OUT_DIR=Release
|
|
||||||
mkdir %OUT_DIR%
|
|
||||||
cl /nologo /Zi /MD /utf-8 /Ox /Oi %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
|
||||||
14
examples/example_glfw_vulkan/build_win32.bat
Normal file
14
examples/example_glfw_vulkan/build_win32.bat
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
||||||
|
|
||||||
|
@set OUT_EXE=example_glfw_vulkan
|
||||||
|
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I %VULKAN_SDK%\include
|
||||||
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
|
||||||
|
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
|
||||||
|
|
||||||
|
@set OUT_DIR=Debug
|
||||||
|
mkdir %OUT_DIR%
|
||||||
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|
||||||
|
@set OUT_DIR=Release
|
||||||
|
mkdir %OUT_DIR%
|
||||||
|
cl /nologo /Zi /MD /utf-8 /Ox /Oi %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
14
examples/example_glfw_vulkan/build_win64.bat
Normal file
14
examples/example_glfw_vulkan/build_win64.bat
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
@REM Build for Visual Studio compiler. Run your copy of vcvars64.bat or vcvarsall.bat to setup 64-bit command-line compiler.
|
||||||
|
|
||||||
|
@set OUT_EXE=example_glfw_vulkan
|
||||||
|
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I %VULKAN_SDK%\include
|
||||||
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
|
||||||
|
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
|
||||||
|
|
||||||
|
@set OUT_DIR=Debug
|
||||||
|
mkdir %OUT_DIR%
|
||||||
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|
||||||
|
@set OUT_DIR=Release
|
||||||
|
mkdir %OUT_DIR%
|
||||||
|
cl /nologo /Zi /MD /utf-8 /Ox /Oi %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
@ -28,27 +28,27 @@
|
|||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
@ -93,7 +93,6 @@
|
|||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -110,7 +109,6 @@
|
|||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@ -193,8 +193,7 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
{
|
{
|
||||||
VkDescriptorPoolSize pool_sizes[] =
|
VkDescriptorPoolSize pool_sizes[] =
|
||||||
{
|
{
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, IMGUI_IMPL_VULKAN_MINIMUM_SAMPLED_IMAGE_POOL_SIZE },
|
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE },
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLER, IMGUI_IMPL_VULKAN_MINIMUM_SAMPLER_POOL_SIZE },
|
|
||||||
};
|
};
|
||||||
VkDescriptorPoolCreateInfo pool_info = {};
|
VkDescriptorPoolCreateInfo pool_info = {};
|
||||||
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||||
@ -392,14 +391,11 @@ int main(int, char**)
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup scaling
|
// Setup scaling
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
||||||
|
|
||||||
@ -425,12 +421,13 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
# Building for desktop with Dawn:
|
||||||
|
# 1. git clone https://github.com/google/dawn dawn
|
||||||
|
# 2. cmake -B build -DIMGUI_DAWN_DIR=dawn
|
||||||
|
# 3. cmake --build build
|
||||||
|
# The resulting binary will be found at one of the following locations:
|
||||||
|
# * build/example_glfw_wgpu[.exe] or build/Debug/example_glfw_wgpu[.exe]
|
||||||
|
|
||||||
# Building for desktop with WGPU-Native:
|
# Building for desktop with WGPU-Native:
|
||||||
# 1. download WGPU-Native autogenerated binary modules for your platform/compiler from: https://github.com/gfx-rs/wgpu-native/releases
|
# 1. download WGPU-Native autogenerated binary modules for your platform/compiler from: https://github.com/gfx-rs/wgpu-native/releases
|
||||||
# 2. unzip the downloaded file in your_preferred_folder
|
# 2. unzip the downloaded file in your_preferred_folder
|
||||||
@ -6,15 +13,8 @@
|
|||||||
# The resulting binary will be found at one of the following locations:
|
# The resulting binary will be found at one of the following locations:
|
||||||
# * build/example_glfw_wgpu[.exe] or build/Debug/example_glfw_wgpu[.exe]
|
# * build/example_glfw_wgpu[.exe] or build/Debug/example_glfw_wgpu[.exe]
|
||||||
|
|
||||||
# Building for desktop with Dawn: (VERY LONG TO BUILD)
|
# Building for desktop with WGVK (MUCH EASIER)
|
||||||
# 1. git clone https://github.com/google/dawn dawn
|
# 1. git clone https://github.com/manuel5975p/WGVK dawn
|
||||||
# 2. cmake -B build -DIMGUI_DAWN_DIR=dawn
|
|
||||||
# 3. cmake --build build
|
|
||||||
# The resulting binary will be found at one of the following locations:
|
|
||||||
# * build/example_glfw_wgpu[.exe] or build/Debug/example_glfw_wgpu[.exe]
|
|
||||||
|
|
||||||
# Building for desktop with WGVK:
|
|
||||||
# 1. git clone https://github.com/manuel5975p/WGVK wgvk
|
|
||||||
# 2. cmake -B build -DIMGUI_WGVK_DIR=wgvk
|
# 2. cmake -B build -DIMGUI_WGVK_DIR=wgvk
|
||||||
# 3. cmake --build build
|
# 3. cmake --build build
|
||||||
# The resulting binary will be found at one of the following locations:
|
# The resulting binary will be found at one of the following locations:
|
||||||
@ -29,7 +29,7 @@
|
|||||||
# 4. emrun build/index.html
|
# 4. emrun build/index.html
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.22) # Dawn requires CMake >= 3.22
|
cmake_minimum_required(VERSION 3.22) # Dawn requires CMake >= 3.22
|
||||||
project(example_glfw_wgpu C CXX)
|
project(imgui_example_glfw_wgpu C CXX)
|
||||||
|
|
||||||
set(IMGUI_EXECUTABLE example_glfw_wgpu)
|
set(IMGUI_EXECUTABLE example_glfw_wgpu)
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20) # Dawn requires C++20
|
set(CMAKE_CXX_STANDARD 17) # Dawn requires C++17
|
||||||
|
|
||||||
# Dear ImGui
|
# Dear ImGui
|
||||||
set(IMGUI_DIR ../../)
|
set(IMGUI_DIR ../../)
|
||||||
@ -146,28 +146,6 @@ else() # Native/Desktop build
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(IMGUI_WGVK_DIR)
|
if(IMGUI_WGVK_DIR)
|
||||||
find_package(Vulkan REQUIRED)
|
|
||||||
set(WGVK_PLATFORM_LIBS)
|
|
||||||
set(WGVK_PLATFORM_DEFS)
|
|
||||||
if(WIN32)
|
|
||||||
list(APPEND WGVK_PLATFORM_DEFS SUPPORT_WIN32_SURFACE=1)
|
|
||||||
elseif(APPLE)
|
|
||||||
list(APPEND WGVK_PLATFORM_DEFS SUPPORT_METAL_SURFACE=1)
|
|
||||||
elseif(UNIX)
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_check_modules(WAYLAND_CLIENT QUIET wayland-client)
|
|
||||||
if(WAYLAND_CLIENT_FOUND)
|
|
||||||
list(APPEND WGVK_PLATFORM_DEFS SUPPORT_WAYLAND_SURFACE=1)
|
|
||||||
list(APPEND WGVK_PLATFORM_LIBS ${WAYLAND_CLIENT_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
find_package(X11 QUIET)
|
|
||||||
if(X11_FOUND)
|
|
||||||
list(APPEND WGVK_PLATFORM_DEFS SUPPORT_XLIB_SURFACE=1)
|
|
||||||
list(APPEND WGVK_PLATFORM_LIBS X11::X11)
|
|
||||||
endif()
|
|
||||||
list(APPEND WGVK_PLATFORM_LIBS m dl pthread)
|
|
||||||
endif()
|
|
||||||
set(LIBRARIES glfw Vulkan::Vulkan ${WGVK_PLATFORM_LIBS})
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -209,7 +187,6 @@ if(NOT EMSCRIPTEN) # WegGPU-Native settings
|
|||||||
if(IMGUI_WGVK_DIR)
|
if(IMGUI_WGVK_DIR)
|
||||||
target_sources(${IMGUI_EXECUTABLE} PRIVATE ${IMGUI_WGVK_DIR}/src/wgvk.c)
|
target_sources(${IMGUI_EXECUTABLE} PRIVATE ${IMGUI_WGVK_DIR}/src/wgvk.c)
|
||||||
target_compile_definitions(${IMGUI_EXECUTABLE} PUBLIC "IMGUI_IMPL_WEBGPU_BACKEND_WGVK")
|
target_compile_definitions(${IMGUI_EXECUTABLE} PUBLIC "IMGUI_IMPL_WEBGPU_BACKEND_WGVK")
|
||||||
target_compile_definitions(${IMGUI_EXECUTABLE} PRIVATE ${WGVK_PLATFORM_DEFS})
|
|
||||||
target_include_directories(${IMGUI_EXECUTABLE} PUBLIC ${IMGUI_WGVK_DIR}/include)
|
target_include_directories(${IMGUI_EXECUTABLE} PUBLIC ${IMGUI_WGVK_DIR}/include)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
target_compile_options(${IMGUI_EXECUTABLE} PUBLIC /std:clatest /experimental:c11atomics)
|
target_compile_options(${IMGUI_EXECUTABLE} PUBLIC /std:clatest /experimental:c11atomics)
|
||||||
|
|||||||
@ -89,14 +89,11 @@ int main(int, char**)
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup scaling
|
// Setup scaling
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
||||||
|
|
||||||
@ -114,13 +111,14 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
#ifndef IMGUI_DISABLE_FILE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_FILE_FUNCTIONS
|
||||||
@ -292,16 +290,6 @@ int main(int, char**)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WGPUTextureFormat SelectSurfaceFormat(const WGPUSurfaceCapabilities& capabilities)
|
|
||||||
{
|
|
||||||
const WGPUTextureFormat preferredFormats[] = { WGPUTextureFormat_BGRA8Unorm, WGPUTextureFormat_RGBA8Unorm, WGPUTextureFormat_BGRA8UnormSrgb, WGPUTextureFormat_RGBA8UnormSrgb };
|
|
||||||
for (WGPUTextureFormat preferredFormat : preferredFormats)
|
|
||||||
for (size_t n = 0; n < capabilities.formatCount; n++)
|
|
||||||
if (capabilities.formats[n] == preferredFormat)
|
|
||||||
return preferredFormat;
|
|
||||||
return capabilities.formatCount > 0 ? capabilities.formats[0] : WGPUTextureFormat_Undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN)
|
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN)
|
||||||
static WGPUAdapter RequestAdapter(wgpu::Instance& instance)
|
static WGPUAdapter RequestAdapter(wgpu::Instance& instance)
|
||||||
{
|
{
|
||||||
@ -356,25 +344,29 @@ static WGPUDevice RequestDevice(wgpu::Instance& instance, wgpu::Adapter& adapter
|
|||||||
static void handle_request_adapter(WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, void* userdata1, void* userdata2)
|
static void handle_request_adapter(WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, void* userdata1, void* userdata2)
|
||||||
{
|
{
|
||||||
IM_UNUSED(userdata2);
|
IM_UNUSED(userdata2);
|
||||||
if (status != WGPURequestAdapterStatus_Success)
|
if (status == WGPURequestAdapterStatus_Success)
|
||||||
{
|
{
|
||||||
printf("Request_adapter status=%#.8x message=%.*s\n", status, (int)message.length, message.data);
|
WGPUAdapter* extAdapter = (WGPUAdapter*)userdata1;
|
||||||
return;
|
*extAdapter = adapter;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Request_adapter status=%#.8x message=%.*s\n", status, (int) message.length, message.data);
|
||||||
}
|
}
|
||||||
WGPUAdapter* extAdapter = (WGPUAdapter*)userdata1;
|
|
||||||
*extAdapter = adapter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_request_device(WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, void* userdata1, void* userdata2)
|
static void handle_request_device(WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, void* userdata1, void* userdata2)
|
||||||
{
|
{
|
||||||
IM_UNUSED(userdata2);
|
IM_UNUSED(userdata2);
|
||||||
if (status != WGPURequestDeviceStatus_Success)
|
if (status == WGPURequestDeviceStatus_Success)
|
||||||
{
|
{
|
||||||
printf("Request_device status=%#.8x message=%.*s\n", status, (int)message.length, message.data);
|
WGPUDevice* extDevice = (WGPUDevice*)userdata1;
|
||||||
return;
|
*extDevice = device;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Request_device status=%#.8x message=%.*s\n", status, (int) message.length, message.data);
|
||||||
}
|
}
|
||||||
WGPUDevice* extDevice = (WGPUDevice*)userdata1;
|
|
||||||
*extDevice = device;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WGPUAdapter RequestAdapter(WGPUInstance& instance)
|
static WGPUAdapter RequestAdapter(WGPUInstance& instance)
|
||||||
@ -388,10 +380,8 @@ static WGPUAdapter RequestAdapter(WGPUInstance& instance)
|
|||||||
adapterCallbackInfo.userdata1 = &local_adapter;
|
adapterCallbackInfo.userdata1 = &local_adapter;
|
||||||
|
|
||||||
WGPUFuture future = wgpuInstanceRequestAdapter(instance, &adapter_options, adapterCallbackInfo);
|
WGPUFuture future = wgpuInstanceRequestAdapter(instance, &adapter_options, adapterCallbackInfo);
|
||||||
#if !defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
|
|
||||||
WGPUFutureWaitInfo waitInfo = { future, false };
|
WGPUFutureWaitInfo waitInfo = { future, false };
|
||||||
wgpuInstanceWaitAny(instance, 1, &waitInfo, ~0ull);
|
wgpuInstanceWaitAny(instance, 1, &waitInfo, ~0ull);
|
||||||
#endif
|
|
||||||
IM_ASSERT(local_adapter && "Error on Adapter request");
|
IM_ASSERT(local_adapter && "Error on Adapter request");
|
||||||
return local_adapter;
|
return local_adapter;
|
||||||
}
|
}
|
||||||
@ -403,20 +393,15 @@ static WGPUDevice RequestDevice(WGPUInstance& instance, WGPUAdapter& adapter)
|
|||||||
deviceCallbackInfo.mode = WGPUCallbackMode_WaitAnyOnly;
|
deviceCallbackInfo.mode = WGPUCallbackMode_WaitAnyOnly;
|
||||||
deviceCallbackInfo.callback = handle_request_device;
|
deviceCallbackInfo.callback = handle_request_device;
|
||||||
deviceCallbackInfo.userdata1 = &local_device;
|
deviceCallbackInfo.userdata1 = &local_device;
|
||||||
|
|
||||||
WGPUFuture future = wgpuAdapterRequestDevice(adapter, nullptr, deviceCallbackInfo);
|
WGPUFuture future = wgpuAdapterRequestDevice(adapter, nullptr, deviceCallbackInfo);
|
||||||
#if !defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
|
|
||||||
WGPUFutureWaitInfo waitInfo = { future, false };
|
WGPUFutureWaitInfo waitInfo = { future, false };
|
||||||
wgpuInstanceWaitAny(instance, 1, &waitInfo, ~0ull);
|
wgpuInstanceWaitAny(instance, 1, &waitInfo, ~0ull);
|
||||||
#else
|
|
||||||
IM_UNUSED(instance);
|
|
||||||
#endif
|
|
||||||
IM_ASSERT(local_device && "Error on Device request");
|
IM_ASSERT(local_device && "Error on Device request");
|
||||||
return local_device;
|
return local_device;
|
||||||
}
|
}
|
||||||
#endif // IMGUI_IMPL_WEBGPU_BACKEND_WGPU
|
#endif // IMGUI_IMPL_WEBGPU_BACKEND_WGPU
|
||||||
|
|
||||||
static bool InitWGPU(GLFWwindow* window)
|
bool InitWGPU(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
WGPUTextureFormat preferred_fmt = WGPUTextureFormat_Undefined; // acquired from SurfaceCapabilities
|
WGPUTextureFormat preferred_fmt = WGPUTextureFormat_Undefined; // acquired from SurfaceCapabilities
|
||||||
|
|
||||||
@ -452,7 +437,8 @@ static bool InitWGPU(GLFWwindow* window)
|
|||||||
|
|
||||||
WGPUSurfaceCapabilities surface_capabilities = {};
|
WGPUSurfaceCapabilities surface_capabilities = {};
|
||||||
wgpuSurfaceGetCapabilities(wgpu_surface, adapter.Get(), &surface_capabilities);
|
wgpuSurfaceGetCapabilities(wgpu_surface, adapter.Get(), &surface_capabilities);
|
||||||
preferred_fmt = SelectSurfaceFormat(surface_capabilities);
|
|
||||||
|
preferred_fmt = surface_capabilities.formats[0];
|
||||||
|
|
||||||
// WGPU backend: Adapter and Device acquisition, Surface creation
|
// WGPU backend: Adapter and Device acquisition, Surface creation
|
||||||
#elif defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) || defined(IMGUI_IMPL_WEBGPU_BACKEND_WGVK)
|
#elif defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) || defined(IMGUI_IMPL_WEBGPU_BACKEND_WGVK)
|
||||||
@ -464,7 +450,7 @@ static bool InitWGPU(GLFWwindow* window)
|
|||||||
|
|
||||||
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
|
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
|
||||||
wgpuSetLogCallback(
|
wgpuSetLogCallback(
|
||||||
[](WGPULogLevel level, WGPUStringView msg, void*) { fprintf(stderr, "%s: %.*s\n", ImGui_ImplWGPU_GetLogLevelName(level), (int)msg.length, msg.data); }, nullptr
|
[](WGPULogLevel level, WGPUStringView msg, void* userdata) { fprintf(stderr, "%s: %.*s\n", ImGui_ImplWGPU_GetLogLevelName(level), (int)msg.length, msg.data); }, nullptr
|
||||||
);
|
);
|
||||||
wgpuSetLogLevel(WGPULogLevel_Warn);
|
wgpuSetLogLevel(WGPULogLevel_Warn);
|
||||||
#endif
|
#endif
|
||||||
@ -481,7 +467,8 @@ static bool InitWGPU(GLFWwindow* window)
|
|||||||
|
|
||||||
WGPUSurfaceCapabilities surface_capabilities = {};
|
WGPUSurfaceCapabilities surface_capabilities = {};
|
||||||
wgpuSurfaceGetCapabilities(wgpu_surface, adapter, &surface_capabilities);
|
wgpuSurfaceGetCapabilities(wgpu_surface, adapter, &surface_capabilities);
|
||||||
preferred_fmt = SelectSurfaceFormat(surface_capabilities);
|
|
||||||
|
preferred_fmt = surface_capabilities.formats[0];
|
||||||
#endif // IMGUI_IMPL_WEBGPU_BACKEND_WGPU
|
#endif // IMGUI_IMPL_WEBGPU_BACKEND_WGPU
|
||||||
|
|
||||||
wgpu_surface_configuration.presentMode = WGPUPresentMode_Fifo;
|
wgpu_surface_configuration.presentMode = WGPUPresentMode_Fifo;
|
||||||
@ -561,7 +548,7 @@ WGPUSurface CreateWGPUSurface(const WGPUInstance& instance, GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
create_info.System = "win32";
|
create_info.System = "win32";
|
||||||
create_info.RawWindow = (void*)glfwGetWin32Window(window);
|
create_info.RawWindow = (void*)glfwGetWin32Window(window);
|
||||||
create_info.RawInstance = (void*)::GetModuleHandle(nullptr);
|
create_info.RawInstance = (void*)::GetModuleHandle(NULL);
|
||||||
return ImGui_ImplWGPU_CreateWGPUSurfaceHelper(&create_info);
|
return ImGui_ImplWGPU_CreateWGPUSurfaceHelper(&create_info);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -28,27 +28,27 @@
|
|||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
@ -92,7 +92,6 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@ -108,7 +107,6 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@ -63,12 +63,8 @@ int main(int argc, char** argv)
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
// FIXME: Consider reworking this example to install our own GLUT funcs + forward calls ImGui_ImplGLUT_XXX ones, instead of using ImGui_ImplGLUT_InstallFuncs().
|
// FIXME: Consider reworking this example to install our own GLUT funcs + forward calls ImGui_ImplGLUT_XXX ones, instead of using ImGui_ImplGLUT_InstallFuncs().
|
||||||
@ -84,12 +80,13 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefaultVector();
|
//io.Fonts->AddFontDefaultVector();
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
//io.Fonts->AddFontDefaultBitmap();
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat, vcvars64.bat, or vcvarsall.bat to setup command-line compiler.
|
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
||||||
mkdir Debug
|
mkdir Debug
|
||||||
cl /nologo /Zi /MD /utf-8 /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib imm32.lib
|
cl /nologo /Zi /MD /utf-8 /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib imm32.lib
|
||||||
@ -21,34 +21,33 @@
|
|||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{1A0BF63C-18EF-4BAE-A8DA-055481B11F5D}</ProjectGuid>
|
<ProjectGuid>{1A0BF63C-18EF-4BAE-A8DA-055481B11F5D}</ProjectGuid>
|
||||||
<RootNamespace>example_win32_directx11</RootNamespace>
|
<RootNamespace>example_win32_directx11</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
@ -88,13 +87,11 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</AdditionalDependencies>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
@ -104,13 +101,11 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</AdditionalDependencies>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
@ -128,9 +123,8 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</AdditionalDependencies>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
@ -148,9 +142,8 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</AdditionalDependencies>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
|||||||
@ -16,14 +16,6 @@ int main(int, char**)
|
|||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
|
||||||
//ImGui::StyleColorsLight();
|
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
ImGui_ImplNullPlatform_Init();
|
ImGui_ImplNullPlatform_Init();
|
||||||
ImGui_ImplNullRender_Init();
|
ImGui_ImplNullRender_Init();
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +0,0 @@
|
|||||||
LIST=OS
|
|
||||||
include recurse.mk
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
# Dear ImGui QNX Screen + OpenGL ES 3 example
|
|
||||||
|
|
||||||
This example uses:
|
|
||||||
|
|
||||||
- `imgui_impl_qnx.cpp` as the QNX Screen platform backend
|
|
||||||
- `imgui_impl_opengl3.cpp` as the renderer backend
|
|
||||||
- EGL to create an OpenGL ES 3 context and Screen window surface
|
|
||||||
|
|
||||||
`imgui_impl_opengl3.cpp` supports desktop OpenGL and OpenGL ES. On QNX this
|
|
||||||
example compiles it with `IMGUI_IMPL_OPENGL_ES3` and uses `#version 300 es`.
|
|
||||||
No separate Screen/OpenGL renderer backend is required.
|
|
||||||
|
|
||||||
## Build
|
|
||||||
|
|
||||||
Load the QNX SDP environment, then run:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cd examples/example_qnx_opengl3
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
The QNX recursive make files build for the CPUs enabled in your SDP
|
|
||||||
configuration and install the program as `example_qnx_opengl3`.
|
|
||||||
|
|
||||||
## Input
|
|
||||||
|
|
||||||
The application polls its `screen_context_t` event queue and forwards every
|
|
||||||
non-`SCREEN_EVENT_NONE` event to `ImGui_ImplQNX_ProcessEvent()`.
|
|
||||||
Escape exits the example.
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
ifndef QCONFIG
|
|
||||||
QCONFIG=qconfig.mk
|
|
||||||
endif
|
|
||||||
include $(QCONFIG)
|
|
||||||
|
|
||||||
NAME=example_qnx_opengl3
|
|
||||||
|
|
||||||
SRCS = \
|
|
||||||
main.cpp \
|
|
||||||
imgui.cpp \
|
|
||||||
imgui_demo.cpp \
|
|
||||||
imgui_draw.cpp \
|
|
||||||
imgui_tables.cpp \
|
|
||||||
imgui_widgets.cpp \
|
|
||||||
imgui_impl_qnx.cpp \
|
|
||||||
imgui_impl_opengl3.cpp
|
|
||||||
|
|
||||||
EXTRA_SRCVPATH += $(PROJECT_ROOT)/../.. $(PROJECT_ROOT)/../../backends
|
|
||||||
EXTRA_INCVPATH += $(PROJECT_ROOT)/../.. $(PROJECT_ROOT)/../../backends
|
|
||||||
|
|
||||||
CXXFLAGS += -std=gnu++11 -DIMGUI_IMPL_OPENGL_ES3
|
|
||||||
LIBS += EGL GLESv2 screen m
|
|
||||||
|
|
||||||
INSTALLDIR=$(firstword $(INSTALLDIR_$(OS)) usr/bin)
|
|
||||||
|
|
||||||
define PINFO
|
|
||||||
PINFO DESCRIPTION=Dear ImGui QNX Screen and OpenGL ES 3 example
|
|
||||||
endef
|
|
||||||
|
|
||||||
include $(MKFILES_ROOT)/qmacros.mk
|
|
||||||
include $(MKFILES_ROOT)/qtargets.mk
|
|
||||||
@ -1,309 +0,0 @@
|
|||||||
// Dear ImGui: standalone example application for QNX Screen + OpenGL ES 3
|
|
||||||
|
|
||||||
// Learn about Dear ImGui:
|
|
||||||
// - FAQ https://dearimgui.com/faq
|
|
||||||
// - Getting Started https://dearimgui.com/getting-started
|
|
||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
|
||||||
|
|
||||||
#include "imgui.h"
|
|
||||||
#include "imgui_impl_qnx.h"
|
|
||||||
#include "imgui_impl_opengl3.h"
|
|
||||||
#include <stdio.h> // printf, fprintf
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/keycodes.h>
|
|
||||||
#include <screen/screen.h>
|
|
||||||
#include <EGL/egl.h>
|
|
||||||
#include <GLES3/gl3.h>
|
|
||||||
|
|
||||||
#ifndef EGL_OPENGL_ES3_BIT
|
|
||||||
#ifdef EGL_OPENGL_ES3_BIT_KHR
|
|
||||||
#define EGL_OPENGL_ES3_BIT EGL_OPENGL_ES3_BIT_KHR
|
|
||||||
#else
|
|
||||||
#define EGL_OPENGL_ES3_BIT 0x0040
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct QNXWindow
|
|
||||||
{
|
|
||||||
screen_context_t Context = nullptr;
|
|
||||||
screen_window_t Window = nullptr;
|
|
||||||
screen_event_t Event = nullptr;
|
|
||||||
EGLDisplay Display = EGL_NO_DISPLAY;
|
|
||||||
EGLContext GLContext = EGL_NO_CONTEXT;
|
|
||||||
EGLSurface GLSurface = EGL_NO_SURFACE;
|
|
||||||
int Size[2] = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Forward declarations of helper functions
|
|
||||||
bool CreateQNXWindow(QNXWindow* window);
|
|
||||||
void DestroyQNXWindow(QNXWindow* window);
|
|
||||||
bool ProcessQNXEvents(QNXWindow* window);
|
|
||||||
|
|
||||||
// Main code
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
// Setup QNX Screen and EGL
|
|
||||||
QNXWindow window;
|
|
||||||
if (!CreateQNXWindow(&window))
|
|
||||||
{
|
|
||||||
DestroyQNXWindow(&window);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GL ES 3.0 + GLSL 300 es
|
|
||||||
const char* glsl_version = "#version 300 es";
|
|
||||||
float main_scale = 1.0f;
|
|
||||||
|
|
||||||
// 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
|
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::StyleColorsDark();
|
|
||||||
//ImGui::StyleColorsLight();
|
|
||||||
//style.FontSizeBase = 16.0f; // Default to 13.0f when unspecified, which allows crisp legacy font for non-4K screens.
|
|
||||||
style.FrameRounding = 3.0f;
|
|
||||||
style.GrabRounding = 3.0f;
|
|
||||||
|
|
||||||
// Setup scaling
|
|
||||||
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
|
||||||
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
|
||||||
ImGui_ImplQNX_Init(window.Context, window.Window);
|
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
|
||||||
|
|
||||||
// Load Fonts
|
|
||||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
|
||||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a threshold.
|
|
||||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
|
||||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
|
||||||
// - 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->AddFontDefaultVector();
|
|
||||||
//io.Fonts->AddFontDefaultBitmap();
|
|
||||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf");
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf");
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf");
|
|
||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf");
|
|
||||||
//IM_ASSERT(font != nullptr);
|
|
||||||
|
|
||||||
// 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, or clear/overwrite your copy of the mouse data.
|
|
||||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
|
||||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
|
||||||
if (!ProcessQNXEvents(&window))
|
|
||||||
done = true;
|
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
|
||||||
ImGui_ImplQNX_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 create 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 / io.Framerate, io.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.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
||||||
eglSwapBuffers(window.Display, window.GLSurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
|
||||||
ImGui_ImplQNX_Shutdown();
|
|
||||||
ImGui::DestroyContext();
|
|
||||||
|
|
||||||
DestroyQNXWindow(&window);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper functions
|
|
||||||
|
|
||||||
bool CreateQNXWindow(QNXWindow* window)
|
|
||||||
{
|
|
||||||
if (screen_create_context(&window->Context, 0) != 0 ||
|
|
||||||
screen_create_window(&window->Window, window->Context) != 0 ||
|
|
||||||
screen_create_event(&window->Event) != 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "QNX Screen initialization failed: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A newly created QNX Screen window reports the fullscreen dimensions.
|
|
||||||
if (screen_get_window_property_iv(window->Window, SCREEN_PROPERTY_SIZE, window->Size) != 0 || window->Size[0] <= 0 || window->Size[1] <= 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Failed to obtain QNX Screen window size: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_OPENGL_ES3 | SCREEN_USAGE_NATIVE;
|
|
||||||
const int transparency = SCREEN_TRANSPARENCY_NONE;
|
|
||||||
const int swap_interval = 1;
|
|
||||||
if (screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_USAGE, &usage) != 0 ||
|
|
||||||
screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_SIZE, window->Size) != 0 ||
|
|
||||||
screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_TRANSPARENCY, &transparency) != 0 ||
|
|
||||||
screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_SWAP_INTERVAL, &swap_interval) != 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Failed to configure QNX Screen window: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
window->Display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
|
||||||
if (window->Display == EGL_NO_DISPLAY || eglInitialize(window->Display, nullptr, nullptr) != EGL_TRUE || eglBindAPI(EGL_OPENGL_ES_API) != EGL_TRUE)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "EGL initialization failed: 0x%04x\n", eglGetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const EGLint config_attributes[] =
|
|
||||||
{
|
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
|
|
||||||
EGL_RED_SIZE, 8,
|
|
||||||
EGL_GREEN_SIZE, 8,
|
|
||||||
EGL_BLUE_SIZE, 8,
|
|
||||||
EGL_ALPHA_SIZE, 8,
|
|
||||||
EGL_DEPTH_SIZE, 24,
|
|
||||||
EGL_STENCIL_SIZE, 8,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
EGLConfig config = nullptr;
|
|
||||||
EGLint config_count = 0;
|
|
||||||
if (eglChooseConfig(window->Display, config_attributes, &config, 1, &config_count) != EGL_TRUE || config_count == 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "eglChooseConfig() failed: 0x%04x\n", eglGetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLint native_visual = 0;
|
|
||||||
if (eglGetConfigAttrib(window->Display, config, EGL_NATIVE_VISUAL_ID, &native_visual) != EGL_TRUE ||
|
|
||||||
screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_FORMAT, &native_visual) != 0 ||
|
|
||||||
screen_create_window_buffers(window->Window, 2) != 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Failed to create QNX Screen buffers: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const EGLint context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
|
|
||||||
window->GLContext = eglCreateContext(window->Display, config, EGL_NO_CONTEXT, context_attributes);
|
|
||||||
window->GLSurface = eglCreateWindowSurface(window->Display, config, window->Window, nullptr);
|
|
||||||
if (window->GLContext == EGL_NO_CONTEXT || window->GLSurface == EGL_NO_SURFACE ||
|
|
||||||
eglMakeCurrent(window->Display, window->GLSurface, window->GLSurface, window->GLContext) != EGL_TRUE ||
|
|
||||||
eglSwapInterval(window->Display, 1) != EGL_TRUE)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "EGL context creation failed: 0x%04x\n", eglGetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int visible = 1;
|
|
||||||
if (screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_VISIBLE, &visible) != 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Failed to show QNX Screen window: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DestroyQNXWindow(QNXWindow* window)
|
|
||||||
{
|
|
||||||
if (window->Display != EGL_NO_DISPLAY)
|
|
||||||
{
|
|
||||||
eglMakeCurrent(window->Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
if (window->GLSurface != EGL_NO_SURFACE)
|
|
||||||
eglDestroySurface(window->Display, window->GLSurface);
|
|
||||||
if (window->GLContext != EGL_NO_CONTEXT)
|
|
||||||
eglDestroyContext(window->Display, window->GLContext);
|
|
||||||
eglTerminate(window->Display);
|
|
||||||
}
|
|
||||||
if (window->Event != nullptr)
|
|
||||||
screen_destroy_event(window->Event);
|
|
||||||
if (window->Window != nullptr)
|
|
||||||
screen_destroy_window(window->Window);
|
|
||||||
if (window->Context != nullptr)
|
|
||||||
screen_destroy_context(window->Context);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProcessQNXEvents(QNXWindow* window)
|
|
||||||
{
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (screen_get_event(window->Context, window->Event, 0) != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int type = SCREEN_EVENT_NONE;
|
|
||||||
if (screen_get_event_property_iv(window->Event, SCREEN_PROPERTY_TYPE, &type) != 0)
|
|
||||||
return false;
|
|
||||||
if (type == SCREEN_EVENT_NONE)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
ImGui_ImplQNX_ProcessEvent(window->Event);
|
|
||||||
if (type == SCREEN_EVENT_CLOSE)
|
|
||||||
return false;
|
|
||||||
if (type == SCREEN_EVENT_KEYBOARD)
|
|
||||||
{
|
|
||||||
int flags = 0;
|
|
||||||
int key_cap = 0;
|
|
||||||
if (screen_get_event_property_iv(window->Event, SCREEN_PROPERTY_FLAGS, &flags) == 0 &&
|
|
||||||
screen_get_event_property_iv(window->Event, SCREEN_PROPERTY_KEY_CAP, &key_cap) == 0 &&
|
|
||||||
(flags & SCREEN_FLAG_KEY_DOWN) != 0 && key_cap == KEYCODE_ESCAPE)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
LIST=CPU
|
|
||||||
ifndef QRECURSE
|
|
||||||
QRECURSE=recurse.mk
|
|
||||||
ifdef QCONFIG
|
|
||||||
QRDIR=$(dir $(QCONFIG))
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
include $(QRDIR)$(QRECURSE)
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
LIST=VARIANT
|
|
||||||
ifndef QRECURSE
|
|
||||||
QRECURSE=recurse.mk
|
|
||||||
ifdef QCONFIG
|
|
||||||
QRDIR=$(dir $(QCONFIG))
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
include $(QRDIR)$(QRECURSE)
|
|
||||||
@ -1 +0,0 @@
|
|||||||
include ../../../common.mk
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
LIST=VARIANT
|
|
||||||
ifndef QRECURSE
|
|
||||||
QRECURSE=recurse.mk
|
|
||||||
ifdef QCONFIG
|
|
||||||
QRDIR=$(dir $(QCONFIG))
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
include $(QRDIR)$(QRECURSE)
|
|
||||||
@ -1 +0,0 @@
|
|||||||
include ../../../common.mk
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
LIST=OS
|
|
||||||
include recurse.mk
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
# Dear ImGui QNX Screen + Vulkan example
|
|
||||||
|
|
||||||
This example uses:
|
|
||||||
|
|
||||||
- `imgui_impl_qnx.cpp` as the QNX Screen platform backend
|
|
||||||
- the unmodified `imgui_impl_vulkan.cpp` renderer backend
|
|
||||||
- `vkCreateScreenSurfaceQNX()` and `VK_QNX_screen_surface`
|
|
||||||
|
|
||||||
No separate Screen/Vulkan renderer backend is required. The QNX-specific work
|
|
||||||
is limited to the Screen platform backend, native window setup, and Vulkan WSI
|
|
||||||
surface creation.
|
|
||||||
|
|
||||||
## Build
|
|
||||||
|
|
||||||
Load the QNX SDP environment, then run:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cd examples/example_qnx_vulkan
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
The build defines `VK_USE_PLATFORM_SCREEN_QNX` and links `libvulkan` and
|
|
||||||
`libscreen`.
|
|
||||||
|
|
||||||
## Input and resize
|
|
||||||
|
|
||||||
The application forwards Screen input events to `ImGui_ImplQNX_ProcessEvent()`.
|
|
||||||
It recreates the Vulkan swapchain when the Screen window size changes or Vulkan
|
|
||||||
reports `VK_ERROR_OUT_OF_DATE_KHR` / `VK_SUBOPTIMAL_KHR`. Escape exits.
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user