Skip to content

Commit 9ab0b66

Browse files
committed
Backends: fixed comment to state that ImGuiViewport::PlaformHandle is used to store SDL's WindowID, not SDL_Window*. (#7853)
Amend 2d99052
1 parent dd89bb1 commit 9ab0b66

9 files changed

+19
-19
lines changed

backends/imgui_impl_dx10.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ static void ImGui_ImplDX10_CreateWindow(ImGuiViewport* viewport)
638638
ImGui_ImplDX10_ViewportData* vd = IM_NEW(ImGui_ImplDX10_ViewportData)();
639639
viewport->RendererUserData = vd;
640640

641-
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
641+
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL's WindowID).
642642
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
643643
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
644644
IM_ASSERT(hwnd != 0);

backends/imgui_impl_dx11.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport)
670670
ImGui_ImplDX11_ViewportData* vd = IM_NEW(ImGui_ImplDX11_ViewportData)();
671671
viewport->RendererUserData = vd;
672672

673-
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
673+
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL's WindowID).
674674
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
675675
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
676676
IM_ASSERT(hwnd != 0);

backends/imgui_impl_dx12.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ static void ImGui_ImplDX12_CreateWindow(ImGuiViewport* viewport)
919919
ImGui_ImplDX12_ViewportData* vd = IM_NEW(ImGui_ImplDX12_ViewportData)(bd->numFramesInFlight);
920920
viewport->RendererUserData = vd;
921921

922-
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
922+
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL's WindowID).
923923
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
924924
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
925925
IM_ASSERT(hwnd != 0);

backends/imgui_impl_dx9.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ static void ImGui_ImplDX9_CreateWindow(ImGuiViewport* viewport)
460460
ImGui_ImplDX9_ViewportData* vd = IM_NEW(ImGui_ImplDX9_ViewportData)();
461461
viewport->RendererUserData = vd;
462462

463-
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
463+
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL's WindowID).
464464
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
465465
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
466466
IM_ASSERT(hwnd != 0);

backends/imgui_impl_glfw.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1050,10 +1050,10 @@ void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* c
10501050
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
10511051
//--------------------------------------------------------------------------------------------------------
10521052

1053-
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
1053+
// Helper structure we store in the void* PlatformUserData field of each ImGuiViewport to easily retrieve our backend data.
10541054
struct ImGui_ImplGlfw_ViewportData
10551055
{
1056-
GLFWwindow* Window;
1056+
GLFWwindow* Window; // Stored in ImGuiViewport::PlatformHandle
10571057
bool WindowOwned;
10581058
int IgnoreWindowPosEventFrame;
10591059
int IgnoreWindowSizeEventFrame;

backends/imgui_impl_sdl2.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
141141
struct ImGui_ImplSDL2_Data
142142
{
143143
SDL_Window* Window;
144-
Uint32 WindowID;
144+
Uint32 WindowID; // Stored in ImGuiViewport::PlatformHandle. Use SDL_GetWindowFromID() to get SDL_Window* from Uint32 WindowID.
145145
SDL_Renderer* Renderer;
146146
Uint64 Time;
147147
char* ClipboardTextData;
@@ -951,16 +951,16 @@ void ImGui_ImplSDL2_NewFrame()
951951
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
952952
//--------------------------------------------------------------------------------------------------------
953953

954-
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
954+
// Helper structure we store in the void* PlatformUserData field of each ImGuiViewport to easily retrieve our backend data.
955955
struct ImGui_ImplSDL2_ViewportData
956956
{
957957
SDL_Window* Window;
958-
Uint32 WindowID;
958+
Uint32 WindowID; // Stored in ImGuiViewport::PlatformHandle. Use SDL_GetWindowFromID() to get SDL_Window* from Uint32 WindowID.
959959
bool WindowOwned;
960960
SDL_GLContext GLContext;
961961

962-
ImGui_ImplSDL2_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
963-
~ImGui_ImplSDL2_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
962+
ImGui_ImplSDL2_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
963+
~ImGui_ImplSDL2_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
964964
};
965965

966966
static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)

backends/imgui_impl_sdl3.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -902,17 +902,17 @@ void ImGui_ImplSDL3_NewFrame()
902902
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
903903
//--------------------------------------------------------------------------------------------------------
904904

905-
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
905+
// Helper structure we store in the void* PlatformUserData field of each ImGuiViewport to easily retrieve our backend data.
906906
struct ImGui_ImplSDL3_ViewportData
907907
{
908908
SDL_Window* Window;
909909
SDL_Window* ParentWindow;
910-
Uint32 WindowID;
910+
Uint32 WindowID; // Stored in ImGuiViewport::PlatformHandle. Use SDL_GetWindowFromID() to get SDL_Window* from Uint32 WindowID.
911911
bool WindowOwned;
912912
SDL_GLContext GLContext;
913913

914-
ImGui_ImplSDL3_ViewportData() { Window = ParentWindow = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
915-
~ImGui_ImplSDL3_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
914+
ImGui_ImplSDL3_ViewportData() { Window = ParentWindow = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
915+
~ImGui_ImplSDL3_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
916916
};
917917

918918
static SDL_Window* ImGui_ImplSDL3_GetSDLWindowFromViewportID(ImGuiID viewport_id)

backends/imgui_impl_win32.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1046,10 +1046,10 @@ void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd)
10461046
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
10471047
//--------------------------------------------------------------------------------------------------------
10481048

1049-
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
1049+
// Helper structure we store in the void* PlatformUserData field of each ImGuiViewport to easily retrieve our backend data.
10501050
struct ImGui_ImplWin32_ViewportData
10511051
{
1052-
HWND Hwnd;
1052+
HWND Hwnd; // Stored in ImGuiViewport::PlatformHandle + PlatformHandleRaw
10531053
HWND HwndParent;
10541054
bool HwndOwned;
10551055
DWORD DwStyle;

imgui.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3679,8 +3679,8 @@ struct ImGuiViewport
36793679
// The library never uses those fields, they are merely storage to facilitate backend implementation.
36803680
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function.
36813681
void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function.
3682-
void* PlatformHandle; // void* to hold higher-level, platform window handle (e.g. HWND, GLFWWindow*, SDL_Window*), for FindViewportByPlatformHandle().
3683-
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms), when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
3682+
void* PlatformHandle; // void* to hold higher-level, platform window handle (e.g. HWND for Win32 backend, Uint32 WindowID for SDL, GLFWWindow* for GLFW), for FindViewportByPlatformHandle().
3683+
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (always HWND on Win32 platform, unused for other platforms).
36843684
bool PlatformWindowCreated; // Platform window has been created (Platform_CreateWindow() has been called). This is false during the first frame where a viewport is being created.
36853685
bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)
36863686
bool PlatformRequestResize; // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size)

0 commit comments

Comments
 (0)