Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add glfw wgpu desktop and multiviewport support #7132

Closed
wants to merge 100 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
6fda112
Create WGPU structure for multiviewports
Zelif Dec 12, 2023
e7b5f87
Adding Multiviewport to WGPU
Zelif Dec 12, 2023
e5cf10b
Update imgui_impl_wgpu.cpp
Zelif Dec 15, 2023
62cfa98
Update imgui_impl_wgpu.cpp
Zelif Dec 15, 2023
fff4391
Add Cmake files
Zelif Dec 15, 2023
ad666db
Update example_emscripten_wgpu demo
Zelif Dec 15, 2023
b271eff
Update CMakeLists.txt
Zelif Dec 15, 2023
82d92aa
Fix memory leak when rendering window
Zelif Dec 28, 2023
e92aa28
Fix memory leak in render function
Zelif Dec 28, 2023
c770f20
Merge branch 'docking' into Add-glfw-wgpu-example
Zelif Dec 28, 2023
3de52f8
Update index.html
Zelif Dec 28, 2023
44c7dfc
Menus, Popup: Amend c3f8f4d for static analyzer warning ("condition a…
ocornut Feb 27, 2024
0573513
Windows: Scrollbar visibility decision uses current size when both si…
ocornut Feb 28, 2024
c623669
Added link to crawlable wiki
ocornut Feb 28, 2024
04f4001
Docs: added a mini wiki index in main source files.
ocornut Feb 29, 2024
1ff90c5
ImDrawList: add PathFillConcave(), AddConcavePolyFilled() (#760)
thedmd Jan 3, 2024
fbf45ad
ImDrawList: add PathFillConcave(), AddConcavePolyFilled(): amends (#760)
ocornut Jan 9, 2024
6b7358e
InputText: adding clarifying note about ImGuiInputTextCallbackData::B…
ocornut Mar 4, 2024
65dc67f
Windows: Double-click to collapse may be disabled via key-ownership m…
ocornut Mar 5, 2024
fd75685
Merge branch 'master' into docking
ocornut Mar 5, 2024
fc570ac
Examples: WGPU: fixed initialization of WGPURenderPassColorAttachment…
kevle Mar 6, 2024
286cd5b
Internals, InputText: removed ImGuiInputSource_Clipboard. (#4005)
ocornut Mar 7, 2024
3c435c0
Inputs: (Breaking) More formally obsoleted GetKeyIndex() when IMGUI_D…
ocornut Mar 8, 2024
da29b77
Backends: SDL3: Fix leak of SDL_GetGamepads() return value (#7381)
edmonds Mar 11, 2024
9d9ca37
Docking: Fix C++26 zealous warnings (#7383, #7089)
ocornut Mar 11, 2024
adcc321
Revert "Docking: Fix C++26 zealous warnings (#7383, #7089)" + Disable…
ocornut Mar 11, 2024
40df3db
Tweaking terminology
ocornut Mar 17, 2024
0a1f5b9
Demo: Two minor fixes (unchecked BeginTooltip + incorrect height cons…
cfillion Mar 18, 2024
868facf
ImDrawList: (Breaking) merge float radius_x/radius_y parameters into …
cfillion Mar 18, 2024
085781f
Merge branch 'master' into docking
ocornut Mar 19, 2024
8be48a4
Backends: WebGPU: Avoid using -1u literal (#7436)
eliemichel Mar 25, 2024
38ddfb2
Tables: Angled headers: fixed border hit box extending beyond non-scr…
cfillion Mar 18, 2024
29ff159
Tables: Angled headers: fixed borders not moving back up after TableA…
cfillion Mar 18, 2024
f080228
Tables: Angled headers: fixed table contents overflowing when a list …
cfillion Mar 18, 2024
cf4c10b
Style: added ImGuiStyleVar_TabBorderSize, ImGuiStyleVar_TableAngledHe…
cfillion Mar 17, 2024
5c5ae80
Comments
ocornut Mar 26, 2024
37b37fc
DrawList: Allow AddText() to accept null ranges. (#3615, 7391)
ocornut Mar 27, 2024
976dc23
Windows: extend outer resize borders to the edges when there are no c…
cfillion Mar 25, 2024
515b437
Child windows: look at the parent window's flags to decide whether to…
cfillion Mar 25, 2024
742e534
Child Windows: adjust resizing limits to match window padding rather …
ocornut Mar 27, 2024
9638c28
Internals: adding ImGuiNavMoveFlags_NoClearActiveId even though there…
ocornut Mar 27, 2024
25a492f
ProgressBar: Fixed passing fraction==NaN from leading to a crash. (#7…
ocornut Mar 29, 2024
d3c3514
Tables: Fixed auto-width columns when using synced-instances of same …
ocornut Mar 29, 2024
9a2b598
ListBox: Fixed text-baseline offset when using SameLine()+Text() afte…
ocornut Apr 3, 2024
0bf134a
Refactor moving ID stack functions to their own section.
ocornut Apr 3, 2024
f959c41
Refactor moving ID stack functions to their own section (part 2)
ocornut Apr 3, 2024
e7712ff
Out of courtesy/consistency move all the DebugHookIdInfo compares int…
ocornut Apr 3, 2024
4f9ba19
Drags, Sliders, Inputs: Reactivated decimal point replacement for Sli…
GamingMinds-DanielC Mar 11, 2024
231cbee
Version 1.90.5
ocornut Apr 11, 2024
1db579d
Merge branch 'master' into docking
ocornut Apr 11, 2024
f790d51
Silent zealous/stupid warning introduced by Clang 16 (shipping with V…
ocornut Apr 12, 2024
76bc1b8
Extracted part of NewFrame() into SetupDrawListSharedData() for docum…
ocornut Apr 15, 2024
3caa79c
Version 1.90.6 WIP
ocornut Apr 15, 2024
c1743ee
Docking: when io.ConfigDockingWithShift is enabled, fixed help toolti…
ocornut Apr 15, 2024
dad1689
Examples: SDL3: amend for removal of SDL_RENDERER_ACCELERATED.
ocornut Apr 15, 2024
fab96a6
Backends: SDL3: Re-enable calling SDL_StartTextInput()/SDL_StopTextIn…
Green-Sky Mar 28, 2024
daecfff
Text, DrawList: Improved handling of long single-line wrapped text. (…
ocornut Apr 15, 2024
b475309
Fonts: Fixed font ascent and descent calculation when a font hits exa…
GamingMinds-DanielC Mar 14, 2024
f9df6bf
Examples: GLFW+WebGPU: added support for WebGPU-native/Dawn (#7435, #…
eliasdaler Mar 24, 2024
80a5fdb
Examples: GLFW+WebGPU: Fixed condition for when to recreate swapchain…
JulesFouchy Apr 5, 2024
648278c
Examples: GLFW+WebGPU: Amends. (#7435, #7132)
ocornut Apr 16, 2024
7b8107e
Examples: GLFW+WebGPU: Rename example_emscripten_wgpu/ to example_glf…
ocornut Apr 16, 2024
4cb0fe3
Merge branch 'master' into docking
ocornut Apr 16, 2024
9ec299e
Backends: OpenGL: Detect ES3 contexts on desktop based on version str…
ocornut Apr 16, 2024
eba46cb
Drag and Drop: assert when nesting BeginDragDropSource() and BeginDr…
ocornut Apr 17, 2024
361432a
TreeNode: fixed layout so that TreeNode("") or TreeNode("##HiddenLabe…
ocornut Apr 18, 2024
fa0120e
Windows: Fixed subsequent Begin() append calls from setting last item…
ocornut Apr 18, 2024
b555984
Merge branch 'master' into docking
ocornut Apr 18, 2024
07e8ff9
Backends: Win32: Fixed a warning + moved header cruft below Changelog.
ocornut Apr 18, 2024
b720c0f
Backends: Vulkan: Added convenience support for Volk via IMGUI_IMPL_V…
ocornut Apr 19, 2024
da18fcb
Internals: ensure ButtonBehavior() is called with non 0 id.
ocornut Apr 23, 2024
baaaaea
Demo: tweak TreeNode demo.
ocornut Apr 24, 2024
b8a44b1
TreeNode: added ImGuiTreeNodeFlags_SpanTextWidth. (#6937)
dimateos Oct 17, 2023
c895e98
ProgressBar: added indeterminate mode by passing an animated negative…
gan74 Apr 24, 2024
913151c
Demo: move progress bars to their own section.
ocornut Apr 24, 2024
a60387a
Backends: GLFW: Add define guards for glfw native defines. (#7536)
fknfilewalker Apr 29, 2024
6ef4f67
ImDrawList: moved cold fields lower in the structure so hot fields ar…
ocornut Apr 30, 2024
50b2ff0
ImGuiIO: moved IMGUI_DISABLE_OBSOLETE_KEYIO block lower in the struct…
ocornut Apr 30, 2024
5717f0a
Merge branch 'master' into docking
ocornut Apr 30, 2024
558c57a
Fixed static analyzer warning "Pointer to local array 'overlay_buf' i…
ocornut Apr 30, 2024
9d6818d
Docking: comments, clairfy why we store style override on dragged win…
ocornut Apr 30, 2024
49e70e6
Backends: Vulkan: Stripped misleading leftover of ImGui_ImplVulkanH_W…
ocornut Apr 30, 2024
ebb8d78
Backends: Vulkan: Create a custom pipeline for secondary viewports. (…
skaman Apr 12, 2023
b30df88
Table: Angled Headers: internal refactor to facilitate changing angle…
ocornut Apr 30, 2024
4bb7567
Tables: Angled headers: fixed multi-line label display when angle is …
ocornut May 2, 2024
fc4d818
Tables: Angled headers: added TableAngledHeadersTextAlign, ImGuiStyle…
thedmd Apr 30, 2024
6ebbecc
Realign assignments.
ocornut May 3, 2024
0c9c12c
InnerClipRect use ImFloor() matching docking branch (fix c41868531 fo…
ocornut May 3, 2024
0b30947
Windows: Changed default ClipRect to extend to windows' left and righ…
ocornut May 3, 2024
2f2d507
Merge branch 'master' into docking
ocornut May 3, 2024
f5d1852
Viewports: fixed outer-right edge of MenuBar clipping rectangle off b…
cfillion May 3, 2024
9a7f1b1
Added MultiViewport WebGPU
Zelif May 4, 2024
8d08e0b
Updated wgpu example for multiviewport
Zelif May 4, 2024
ecdae77
Add Cmake files
Zelif Dec 15, 2023
6cd66dd
Update example_emscripten_wgpu demo
Zelif Dec 15, 2023
ec89c07
Update CMakeLists.txt
Zelif Dec 15, 2023
a3abb1f
Fix memory leak in render function
Zelif Dec 28, 2023
80d21d0
Update index.html
Zelif Dec 28, 2023
69730ea
Removed old Files
Zelif May 4, 2024
8ff415b
Merge branch 'Add-glfw-wgpu-example' of https://github.com/Zelif/imgu…
Zelif May 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,12 @@ jobs:
popd
make -C examples/example_sdl2_opengl3 -f Makefile.emscripten

- name: Build example_emscripten_wgpu
- name: Build example_glfw_wgpu
run: |
pushd emsdk-master
source ./emsdk_env.sh
popd
make -C examples/example_emscripten_wgpu -f Makefile.emscripten
make -C examples/example_glfw_wgpu -f Makefile.emscripten

Android:
runs-on: ubuntu-22.04
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ examples/*.o.tmp
examples/*.out.js
examples/*.out.wasm
examples/example_glfw_opengl3/web/*
examples/example_glfw_wgpu/web/*
examples/example_glfw_wgpu/external/*
examples/example_sdl2_opengl3/web/*
examples/example_emscripten_wgpu/web/*

## JetBrains IDE artifacts
.idea
Expand Down
4 changes: 4 additions & 0 deletions backends/imgui_impl_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@

#ifdef _WIN32
#undef APIENTRY
#ifndef GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WIN32
#endif
#include <GLFW/glfw3native.h> // for glfwGetWin32Window()
#endif
#ifdef __APPLE__
#ifndef GLFW_EXPOSE_NATIVE_COCOA
#define GLFW_EXPOSE_NATIVE_COCOA
#endif
#include <GLFW/glfw3native.h> // for glfwGetCocoaWindow()
#endif

Expand Down
43 changes: 21 additions & 22 deletions backends/imgui_impl_opengl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-04-16: OpenGL: Detect ES3 contexts on desktop based on version string, to e.g. avoid calling glPolygonMode() on them. (#7447)
// 2024-01-09: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" and variants, fixing regression on distros missing a symlink.
// 2023-11-08: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" instead of "libGL.so.1", accommodating for NetBSD systems having only "libGL.so.3" available. (#6983)
// 2023-10-05: OpenGL: Rename symbols in our internal loader so that LTO compilation with another copy of gl3w is possible. (#6875, #6668, #4445)
Expand Down Expand Up @@ -179,9 +180,10 @@
#endif

// Desktop GL 2.0+ has extension and glPolygonMode() which GL ES and WebGL don't have..
// A desktop ES context can technically compile fine with our loader, so we also perform a runtime checks
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
#define IMGUI_IMPL_OPENGL_HAS_EXTENSIONS // has glGetIntegerv(GL_NUM_EXTENSIONS)
#define IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE // has glPolygonMode()
#define IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE // may have glPolygonMode()
#endif

// Desktop GL 2.1+ and GL ES 3.0+ have glBindBuffer() with GL_PIXEL_UNPACK_BUFFER target.
Expand Down Expand Up @@ -232,6 +234,7 @@ struct ImGui_ImplOpenGL3_Data
unsigned int VboHandle, ElementsHandle;
GLsizeiptr VertexBufferSize;
GLsizeiptr IndexBufferSize;
bool HasPolygonMode;
bool HasClipOrigin;
bool UseBufferSubData;

Expand Down Expand Up @@ -300,16 +303,13 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
bd->GlProfileIsES2 = true;
#else
// Desktop or GLES 3
const char* gl_version_str = (const char*)glGetString(GL_VERSION);
GLint major = 0;
GLint minor = 0;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
if (major == 0 && minor == 0)
{
// Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>"
const char* gl_version = (const char*)glGetString(GL_VERSION);
sscanf(gl_version, "%d.%d", &major, &minor);
}
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);
#if defined(GL_CONTEXT_PROFILE_MASK)
if (bd->GlVersion >= 320)
Expand All @@ -319,6 +319,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)

#if defined(IMGUI_IMPL_OPENGL_ES3)
bd->GlProfileIsES3 = true;
#else
if (strncmp(gl_version_str, "OpenGL ES 3", 11) == 0)
bd->GlProfileIsES3 = true;
#endif

bd->UseBufferSubData = false;
Expand All @@ -333,7 +336,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
#endif

#ifdef IMGUI_IMPL_OPENGL_DEBUG
printf("GlVersion = %d\nGlProfileIsCompat = %d\nGlProfileMask = 0x%X\nGlProfileIsES2 = %d, GlProfileIsES3 = %d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", bd->GlVersion, bd->GlProfileIsCompat, bd->GlProfileMask, bd->GlProfileIsES2, bd->GlProfileIsES3, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG]
printf("GlVersion = %d, \"%s\"\nGlProfileIsCompat = %d\nGlProfileMask = 0x%X\nGlProfileIsES2 = %d, GlProfileIsES3 = %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
Expand Down Expand Up @@ -366,6 +369,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
glGetIntegerv(GL_TEXTURE_BINDING_2D, &current_texture);

// Detect extensions we support
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
bd->HasPolygonMode = (!bd->GlProfileIsES2 && !bd->GlProfileIsES3);
#endif
bd->HasClipOrigin = (bd->GlVersion >= 450);
#ifdef IMGUI_IMPL_OPENGL_HAS_EXTENSIONS
GLint num_extensions = 0;
Expand Down Expand Up @@ -423,8 +429,9 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
if (bd->GlVersion >= 310)
glDisable(GL_PRIMITIVE_RESTART);
#endif
#ifdef IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
if (bd->HasPolygonMode)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
#endif

// Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
Expand Down Expand Up @@ -512,8 +519,8 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
#endif
#ifdef IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
GLint last_polygon_mode[2]; if (bd->HasPolygonMode) { glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode); }
#endif
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
Expand Down Expand Up @@ -651,18 +658,10 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
if (bd->GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); }
#endif

#ifdef IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
if (bd->GlVersion <= 310 || bd->GlProfileIsCompat)
{
glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]);
glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
}
else
{
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
}
#endif // IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
if (bd->HasPolygonMode) { if (bd->GlVersion <= 310 || bd->GlProfileIsCompat) { glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]); } else { glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]); } }
#endif // IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE

glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
Expand Down
6 changes: 3 additions & 3 deletions backends/imgui_impl_opengl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();

// Specific OpenGL ES versions
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
// Configuration flags to add in your imconfig file:
//#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)

// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
Expand Down
9 changes: 8 additions & 1 deletion backends/imgui_impl_sdl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Issues:
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
// [ ] Platform: IME SUPPORT IS BROKEN IN SDL3 BECAUSE INPUTS GETS SENT TO BOTH APP AND IME + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.

// 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.
Expand All @@ -26,6 +26,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-04-15: Inputs: Re-enable calling SDL_StartTextInput()/SDL_StopTextInput() as SDL3 no longer enables it by default and should play nicer with IME.
// 2024-02-13: Inputs: Fixed gamepad support. Handle gamepad disconnection. Added ImGui_ImplSDL3_SetGamepadMode().
// 2023-11-13: Updated for recent SDL3 API changes.
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
Expand Down Expand Up @@ -129,6 +130,11 @@ static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlat
r.w = 1;
r.h = (int)data->InputLineHeight;
SDL_SetTextInputRect(&r);
SDL_StartTextInput();
}
else
{
SDL_StopTextInput();
}
}

Expand Down Expand Up @@ -701,6 +707,7 @@ static void ImGui_ImplSDL3_UpdateGamepads()
if (bd->GamepadMode == ImGui_ImplSDL3_GamepadMode_AutoFirst)
break;
}
SDL_free(sdl_gamepads);
bd->WantUpdateGamepadsList = false;
}

Expand Down
1 change: 1 addition & 0 deletions backends/imgui_impl_sdl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
// [ ] Platform: IME SUPPORT IS BROKEN IN SDL3 BECAUSE INPUTS GETS SENT TO BOTH APP AND IME + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.

// 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.
Expand Down
27 changes: 16 additions & 11 deletions backends/imgui_impl_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-04-19: Vulkan: Added convenience support for Volk via IMGUI_IMPL_VULKAN_USE_VOLK define (you can also use IMGUI_IMPL_VULKAN_NO_PROTOTYPES + wrap Volk via ImGui_ImplVulkan_LoadFunctions().)
// 2024-02-14: *BREAKING CHANGE*: Moved RenderPass parameter from ImGui_ImplVulkan_Init() function to ImGui_ImplVulkan_InitInfo structure. Not required when using dynamic rendering.
// 2024-02-12: *BREAKING CHANGE*: Dynamic rendering now require filling PipelineRenderingCreateInfo structure.
// 2024-01-19: Vulkan: Fixed vkAcquireNextImageKHR() validation errors in VulkanSDK 1.3.275 by allocating one extra semaphore than in-flight frames. (#7236)
Expand Down Expand Up @@ -111,12 +112,13 @@ void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_devi

// Vulkan prototypes for use with custom loaders
// (see description of IMGUI_IMPL_VULKAN_NO_PROTOTYPES in imgui_impl_vulkan.h
#ifdef VK_NO_PROTOTYPES
#if defined(VK_NO_PROTOTYPES) && !defined(VOLK_H_)
#define IMGUI_IMPL_VULKAN_USE_LOADER
static bool g_FunctionsLoaded = false;
#else
static bool g_FunctionsLoaded = true;
#endif
#ifdef VK_NO_PROTOTYPES
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
#define IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_MAP_MACRO) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \
Expand Down Expand Up @@ -194,7 +196,7 @@ static bool g_FunctionsLoaded = true;
#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func;
IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_DEF)
#undef IMGUI_VULKAN_FUNC_DEF
#endif // VK_NO_PROTOTYPES
#endif // IMGUI_IMPL_VULKAN_USE_LOADER

#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
static PFN_vkCmdBeginRenderingKHR ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR;
Expand Down Expand Up @@ -242,7 +244,8 @@ struct ImGui_ImplVulkan_Data
VkPipelineCreateFlags PipelineCreateFlags;
VkDescriptorSetLayout DescriptorSetLayout;
VkPipelineLayout PipelineLayout;
VkPipeline Pipeline;
VkPipeline Pipeline; // pipeline for main render pass (created by app)
VkPipeline PipelineForViewports; // pipeline for secondary viewports (created by backend)
VkShaderModule ShaderModuleVert;
VkShaderModule ShaderModuleFrag;

Expand Down Expand Up @@ -1069,15 +1072,16 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
if (bd->DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayout, v->Allocator); bd->DescriptorSetLayout = 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->PipelineForViewports) { vkDestroyPipeline(v->Device, bd->PipelineForViewports, v->Allocator); bd->PipelineForViewports = VK_NULL_HANDLE; }
}

bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data)
{
// Load function pointers
// You can use the default Vulkan loader using:
// ImGui_ImplVulkan_LoadFunctions([](const char* function_name, void*) { return vkGetInstanceProcAddr(your_vk_isntance, function_name); });
// But this would be equivalent to not setting VK_NO_PROTOTYPES.
#ifdef VK_NO_PROTOTYPES
// But this would be roughly equivalent to not setting VK_NO_PROTOTYPES.
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
#define IMGUI_VULKAN_FUNC_LOAD(func) \
func = reinterpret_cast<decltype(func)>(loader_func(#func, user_data)); \
if (func == nullptr) \
Expand Down Expand Up @@ -1106,7 +1110,7 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
if (info->UseDynamicRendering)
{
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
#ifndef VK_NO_PROTOTYPES
#ifndef IMGUI_IMPL_VULKAN_USE_LOADER
ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR = reinterpret_cast<PFN_vkCmdBeginRenderingKHR>(vkGetInstanceProcAddr(info->Instance, "vkCmdBeginRenderingKHR"));
ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR = reinterpret_cast<PFN_vkCmdEndRenderingKHR>(vkGetInstanceProcAddr(info->Instance, "vkCmdEndRenderingKHR"));
#endif
Expand Down Expand Up @@ -1431,8 +1435,6 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
wd->ImageCount = 0;
if (wd->RenderPass)
vkDestroyRenderPass(device, wd->RenderPass, allocator);
if (wd->Pipeline)
vkDestroyPipeline(device, wd->Pipeline, allocator);

// If min image count was not specified, request different count of images dependent on selected present mode
if (min_image_count == 0)
Expand Down Expand Up @@ -1602,7 +1604,6 @@ void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui
IM_FREE(wd->FrameSemaphores);
wd->Frames = nullptr;
wd->FrameSemaphores = nullptr;
vkDestroyPipeline(device, wd->Pipeline, allocator);
vkDestroyRenderPass(device, wd->RenderPass, allocator);
vkDestroySwapchainKHR(device, wd->Swapchain, allocator);
vkDestroySurfaceKHR(instance, wd->Surface, allocator);
Expand Down Expand Up @@ -1690,6 +1691,10 @@ static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
wd->UseDynamicRendering = v->UseDynamicRendering;
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, wd, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount);
vd->WindowOwned = true;

// Create pipeline (shared by all secondary viewports)
if (bd->PipelineForViewports == VK_NULL_HANDLE)
ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &bd->PipelineForViewports, 0);
}

static void ImGui_ImplVulkan_DestroyWindow(ImGuiViewport* viewport)
Expand Down Expand Up @@ -1804,7 +1809,7 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
}
}

ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, wd->Pipeline);
ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, bd->PipelineForViewports);

{
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
Expand Down