mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-25 09:06:35 +00:00
This commit is contained in:
parent
2cbc0f1287
commit
3e8eebfbec
@ -564,7 +564,13 @@ static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport)
|
|||||||
ImGuiViewportDataDx11* data = IM_NEW(ImGuiViewportDataDx11)();
|
ImGuiViewportDataDx11* data = IM_NEW(ImGuiViewportDataDx11)();
|
||||||
viewport->RendererUserData = data;
|
viewport->RendererUserData = data;
|
||||||
|
|
||||||
HWND hwnd = (HWND)viewport->PlatformHandle;
|
// When using SDL, PlatformHandleRaw will be the HWND (because PlatformHandle would be the SDL_Window)
|
||||||
|
// If not using SDL, PlatformHandleRaw will be null and PlatformHandle will contain the HWND
|
||||||
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
if (hwnd == 0)
|
||||||
|
{
|
||||||
|
hwnd = (HWND)viewport->PlatformHandle;
|
||||||
|
}
|
||||||
IM_ASSERT(hwnd != 0);
|
IM_ASSERT(hwnd != 0);
|
||||||
|
|
||||||
// Create swap chain
|
// Create swap chain
|
||||||
|
@ -456,6 +456,16 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
|
|||||||
if (use_opengl && backup_context)
|
if (use_opengl && backup_context)
|
||||||
SDL_GL_MakeCurrent(data->Window, backup_context);
|
SDL_GL_MakeCurrent(data->Window, backup_context);
|
||||||
viewport->PlatformHandle = (void*)data->Window;
|
viewport->PlatformHandle = (void*)data->Window;
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// save the window handle for render that needs it (directX)
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
if (SDL_GetWindowWMInfo(data->Window, &info))
|
||||||
|
{
|
||||||
|
viewport->PlatformHandleRaw = info.info.win.window;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
|
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
3
imgui.h
3
imgui.h
@ -2399,11 +2399,12 @@ struct ImGuiViewport
|
|||||||
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.)
|
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.)
|
||||||
void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context)
|
void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context)
|
||||||
void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GlfwWindow*, SDL_Window*)
|
void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GlfwWindow*, SDL_Window*)
|
||||||
|
void* PlatformHandleRaw; // void* to hold the platfor-native windows handle (e.g. the HWND) when using an abstraction layer like SDL (where PlatformHandle would be a SDL_Window*)
|
||||||
bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)
|
bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)
|
||||||
bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)
|
bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)
|
||||||
bool PlatformRequestResize; // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size)
|
bool PlatformRequestResize; // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size)
|
||||||
|
|
||||||
ImGuiViewport() { ID = 0; Flags = 0; DpiScale = 0.0f; DrawData = NULL; ParentViewportId = 0; RendererUserData = PlatformUserData = PlatformHandle = NULL; PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
|
ImGuiViewport() { ID = 0; Flags = 0; DpiScale = 0.0f; DrawData = NULL; ParentViewportId = 0; RendererUserData = PlatformUserData = PlatformHandle = PlatformHandleRaw = NULL; PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
|
||||||
~ImGuiViewport() { IM_ASSERT(PlatformUserData == NULL && RendererUserData == NULL); }
|
~ImGuiViewport() { IM_ASSERT(PlatformUserData == NULL && RendererUserData == NULL); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user