mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-20 23:06:36 +00:00
Viewport, Examples: Renamed types used by examples. (#1542)
This commit is contained in:
parent
46b61427e1
commit
0e09032750
@ -502,18 +502,18 @@ void ImGui_ImplDX10_NewFrame()
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataDx10
|
||||
struct ImGuiViewportDataDx10
|
||||
{
|
||||
IDXGISwapChain* SwapChain;
|
||||
ID3D10RenderTargetView* RTView;
|
||||
|
||||
ImGuiPlatformDataDx10() { SwapChain = NULL; RTView = NULL; }
|
||||
~ImGuiPlatformDataDx10() { IM_ASSERT(SwapChain == NULL && RTView == NULL); }
|
||||
ImGuiViewportDataDx10() { SwapChain = NULL; RTView = NULL; }
|
||||
~ImGuiViewportDataDx10() { IM_ASSERT(SwapChain == NULL && RTView == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplDX10_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx10* data = IM_NEW(ImGuiPlatformDataDx10)();
|
||||
ImGuiViewportDataDx10* data = IM_NEW(ImGuiViewportDataDx10)();
|
||||
viewport->RendererUserData = data;
|
||||
|
||||
// FIXME-PLATFORM
|
||||
@ -550,7 +550,7 @@ static void ImGui_ImplDX10_CreateWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplDX10_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataDx10* data = (ImGuiPlatformDataDx10*)viewport->RendererUserData)
|
||||
if (ImGuiViewportDataDx10* data = (ImGuiViewportDataDx10*)viewport->RendererUserData)
|
||||
{
|
||||
if (data->SwapChain)
|
||||
data->SwapChain->Release();
|
||||
@ -565,7 +565,7 @@ static void ImGui_ImplDX10_DestroyWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplDX10_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataDx10* data = (ImGuiPlatformDataDx10*)viewport->RendererUserData;
|
||||
ImGuiViewportDataDx10* data = (ImGuiViewportDataDx10*)viewport->RendererUserData;
|
||||
if (data->RTView)
|
||||
{
|
||||
data->RTView->Release();
|
||||
@ -583,7 +583,7 @@ static void ImGui_ImplDX10_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
|
||||
static void ImGui_ImplDX10_RenderViewport(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx10* data = (ImGuiPlatformDataDx10*)viewport->RendererUserData;
|
||||
ImGuiViewportDataDx10* data = (ImGuiViewportDataDx10*)viewport->RendererUserData;
|
||||
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
g_pd3dDevice->OMSetRenderTargets(1, &data->RTView, NULL);
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
@ -593,7 +593,7 @@ static void ImGui_ImplDX10_RenderViewport(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplDX10_SwapBuffers(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx10* data = (ImGuiPlatformDataDx10*)viewport->RendererUserData;
|
||||
ImGuiViewportDataDx10* data = (ImGuiViewportDataDx10*)viewport->RendererUserData;
|
||||
data->SwapChain->Present(0, 0); // Present without vsync
|
||||
}
|
||||
|
||||
|
@ -511,18 +511,18 @@ void ImGui_ImplDX11_NewFrame()
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataDx11
|
||||
struct ImGuiViewportDataDx11
|
||||
{
|
||||
IDXGISwapChain* SwapChain;
|
||||
ID3D11RenderTargetView* RTView;
|
||||
|
||||
ImGuiPlatformDataDx11() { SwapChain = NULL; RTView = NULL; }
|
||||
~ImGuiPlatformDataDx11() { IM_ASSERT(SwapChain == NULL && RTView == NULL); }
|
||||
ImGuiViewportDataDx11() { SwapChain = NULL; RTView = NULL; }
|
||||
~ImGuiViewportDataDx11() { IM_ASSERT(SwapChain == NULL && RTView == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx11* data = IM_NEW(ImGuiPlatformDataDx11)();
|
||||
ImGuiViewportDataDx11* data = IM_NEW(ImGuiViewportDataDx11)();
|
||||
viewport->RendererUserData = data;
|
||||
|
||||
HWND hwnd = (HWND)viewport->PlatformHandle;
|
||||
@ -558,7 +558,7 @@ static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplDX11_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)viewport->RendererUserData)
|
||||
if (ImGuiViewportDataDx11* data = (ImGuiViewportDataDx11*)viewport->RendererUserData)
|
||||
{
|
||||
if (data->SwapChain)
|
||||
data->SwapChain->Release();
|
||||
@ -573,7 +573,7 @@ static void ImGui_ImplDX11_DestroyWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplDX11_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)viewport->RendererUserData;
|
||||
ImGuiViewportDataDx11* data = (ImGuiViewportDataDx11*)viewport->RendererUserData;
|
||||
if (data->RTView)
|
||||
{
|
||||
data->RTView->Release();
|
||||
@ -591,7 +591,7 @@ static void ImGui_ImplDX11_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
|
||||
static void ImGui_ImplDX11_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)viewport->RendererUserData;
|
||||
ImGuiViewportDataDx11* data = (ImGuiViewportDataDx11*)viewport->RendererUserData;
|
||||
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
g_pd3dDeviceContext->OMSetRenderTargets(1, &data->RTView, NULL);
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
@ -601,7 +601,7 @@ static void ImGui_ImplDX11_RenderWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplDX11_SwapBuffers(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)viewport->RendererUserData;
|
||||
ImGuiViewportDataDx11* data = (ImGuiViewportDataDx11*)viewport->RendererUserData;
|
||||
data->SwapChain->Present(0, 0); // Present without vsync
|
||||
}
|
||||
|
||||
|
@ -638,17 +638,17 @@ void ImGui_ImplDX12_NewFrame(ID3D12GraphicsCommandList* command_list)
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataDx12
|
||||
struct ImGuiViewportDataDx12
|
||||
{
|
||||
IDXGISwapChain3* SwapChain;
|
||||
|
||||
ImGuiPlatformDataDx12() { SwapChain = NULL; }
|
||||
~ImGuiPlatformDataDx12() { IM_ASSERT(SwapChain == NULL); }
|
||||
ImGuiViewportDataDx12() { SwapChain = NULL; }
|
||||
~ImGuiViewportDataDx12() { IM_ASSERT(SwapChain == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplDX12_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx12* data = IM_NEW(ImGuiPlatformDataDx12)();
|
||||
ImGuiViewportDataDx12* data = IM_NEW(ImGuiViewportDataDx12)();
|
||||
viewport->RendererUserData = data;
|
||||
IM_ASSERT(0);
|
||||
|
||||
@ -688,7 +688,7 @@ static void ImGui_ImplDX12_CreateWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplDX12_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataDx12* data = (ImGuiPlatformDataDx12*)viewport->RendererUserData)
|
||||
if (ImGuiViewportDataDx12* data = (ImGuiViewportDataDx12*)viewport->RendererUserData)
|
||||
{
|
||||
IM_ASSERT(0);
|
||||
/*
|
||||
@ -706,7 +706,7 @@ static void ImGui_ImplDX12_DestroyWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplDX12_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataDx12* data = (ImGuiPlatformDataDx12*)viewport->RendererUserData;
|
||||
ImGuiViewportDataDx12* data = (ImGuiViewportDataDx12*)viewport->RendererUserData;
|
||||
IM_ASSERT(0);
|
||||
(void)data; (void)size;
|
||||
/*
|
||||
@ -728,7 +728,7 @@ static void ImGui_ImplDX12_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
|
||||
static void ImGui_ImplDX12_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx12* data = (ImGuiPlatformDataDx12*)viewport->RendererUserData;
|
||||
ImGuiViewportDataDx12* data = (ImGuiViewportDataDx12*)viewport->RendererUserData;
|
||||
IM_ASSERT(0);
|
||||
(void)data;
|
||||
/*
|
||||
@ -742,7 +742,7 @@ static void ImGui_ImplDX12_RenderWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplDX12_SwapBuffers(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx12* data = (ImGuiPlatformDataDx12*)viewport->RendererUserData;
|
||||
ImGuiViewportDataDx12* data = (ImGuiViewportDataDx12*)viewport->RendererUserData;
|
||||
IM_ASSERT(0);
|
||||
(void)data;
|
||||
/*
|
||||
|
@ -302,13 +302,13 @@ void ImGui_ImplGlfw_NewFrame()
|
||||
// Platform Windows
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataGlfw
|
||||
struct ImGuiViewportDataGlfw
|
||||
{
|
||||
GLFWwindow* Window;
|
||||
bool WindowOwned;
|
||||
|
||||
ImGuiPlatformDataGlfw() { Window = NULL; WindowOwned = false; }
|
||||
~ImGuiPlatformDataGlfw() { IM_ASSERT(Window == NULL); }
|
||||
ImGuiViewportDataGlfw() { Window = NULL; WindowOwned = false; }
|
||||
~ImGuiViewportDataGlfw() { IM_ASSERT(Window == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplGlfw_WindowCloseCallback(GLFWwindow* window)
|
||||
@ -331,7 +331,7 @@ static void ImGui_ImplGlfw_WindowSizeCallback(GLFWwindow* window, int, int)
|
||||
|
||||
static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = IM_NEW(ImGuiPlatformDataGlfw)();
|
||||
ImGuiViewportDataGlfw* data = IM_NEW(ImGuiViewportDataGlfw)();
|
||||
viewport->PlatformUserData = data;
|
||||
|
||||
// GLFW 3.2 unfortunately always set focus on glfwCreateWindow() if GLFW_VISIBLE is set, regardless of GLFW_FOCUSED
|
||||
@ -350,7 +350,7 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData)
|
||||
if (ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData)
|
||||
{
|
||||
#if GLFW_HAS_GLFW_HOVERED
|
||||
HWND hwnd = glfwGetWin32Window(data->Window);
|
||||
@ -380,7 +380,7 @@ static LRESULT CALLBACK WndProcNoInputs(HWND hWnd, UINT msg, WPARAM wParam, LPAR
|
||||
|
||||
static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
|
||||
#if defined(_WIN32)
|
||||
// GLFW hack: Hide icon from task bar
|
||||
@ -416,7 +416,7 @@ static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport)
|
||||
|
||||
static ImVec2 ImGui_ImplGlfw_GetWindowPos(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
int x = 0, y = 0;
|
||||
glfwGetWindowPos(data->Window, &x, &y);
|
||||
return ImVec2((float)x, (float)y);
|
||||
@ -424,13 +424,13 @@ static ImVec2 ImGui_ImplGlfw_GetWindowPos(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplGlfw_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
glfwSetWindowPos(data->Window, (int)pos.x, (int)pos.y);
|
||||
}
|
||||
|
||||
static ImVec2 ImGui_ImplGlfw_GetWindowSize(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
int w = 0, h = 0;
|
||||
glfwGetWindowSize(data->Window, &w, &h);
|
||||
return ImVec2((float)w, (float)h);
|
||||
@ -438,26 +438,26 @@ static ImVec2 ImGui_ImplGlfw_GetWindowSize(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplGlfw_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
glfwSetWindowSize(data->Window, (int)size.x, (int)size.y);
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
glfwSetWindowTitle(data->Window, title);
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
if (g_ClientApi == GlfwClientApi_OpenGL)
|
||||
glfwMakeContextCurrent(data->Window);
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_SwapBuffers(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
if (g_ClientApi == GlfwClientApi_OpenGL)
|
||||
glfwSwapBuffers(data->Window);
|
||||
}
|
||||
@ -480,7 +480,7 @@ enum VkResult { VK_RESULT_MAX_ENUM = 0x7FFFFFFF };
|
||||
extern "C" { extern GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); }
|
||||
static int ImGui_ImplGlfw_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataGlfw* data = (ImGuiViewportDataGlfw*)viewport->PlatformUserData;
|
||||
IM_ASSERT(g_ClientApi == GlfwClientApi_Vulkan);
|
||||
VkResult err = glfwCreateWindowSurface((VkInstance)vk_instance, data->Window, (const VkAllocationCallbacks*)vk_allocator, (VkSurfaceKHR*)out_vk_surface);
|
||||
return (int)err;
|
||||
@ -507,7 +507,7 @@ static void ImGui_ImplGlfw_InitPlatformInterface()
|
||||
|
||||
// Register main window handle
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
ImGuiPlatformDataGlfw* data = IM_NEW(ImGuiPlatformDataGlfw)();
|
||||
ImGuiViewportDataGlfw* data = IM_NEW(ImGuiViewportDataGlfw)();
|
||||
data->Window = g_Window;
|
||||
data->WindowOwned = false;
|
||||
main_viewport->PlatformUserData = data;
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-XX-XX: OpenGL: Offset projection matrix and clipping rectangle by draw_data->DisplayPos (which will be non-zero for multi-viewport applications).
|
||||
// 2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplOpenGL3_Init() so user can override the GLSL version e.g. "#version 150".
|
||||
// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
|
||||
// 2018-XX-XX: OpenGL: Offset projection matrix and clipping rectangle by draw_data->DisplayPos (which will be non-zero for multi-viewport applications).
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150.
|
||||
// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
|
||||
|
@ -274,25 +274,25 @@ void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataSDL2
|
||||
struct ImGuiViewportDataSDL2
|
||||
{
|
||||
SDL_Window* Window;
|
||||
Uint32 WindowID;
|
||||
SDL_GLContext GLContext;
|
||||
|
||||
ImGuiPlatformDataSDL2() { Window = NULL; WindowID = 0; GLContext = NULL; }
|
||||
~ImGuiPlatformDataSDL2() { IM_ASSERT(Window == NULL && GLContext == NULL); }
|
||||
ImGuiViewportDataSDL2() { Window = NULL; WindowID = 0; GLContext = NULL; }
|
||||
~ImGuiViewportDataSDL2() { IM_ASSERT(Window == NULL && GLContext == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = IM_NEW(ImGuiPlatformDataSDL2)();
|
||||
ImGuiViewportDataSDL2* data = IM_NEW(ImGuiViewportDataSDL2)();
|
||||
viewport->PlatformUserData = data;
|
||||
|
||||
// Share GL resources with main context
|
||||
// FIXME-PLATFORM
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
ImGuiPlatformDataSDL2* main_viewport_data = (ImGuiPlatformDataSDL2*)main_viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* main_viewport_data = (ImGuiViewportDataSDL2*)main_viewport->PlatformUserData;
|
||||
|
||||
bool use_opengl = (main_viewport_data->GLContext != NULL);
|
||||
SDL_GLContext backup_context = NULL;
|
||||
@ -320,7 +320,7 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData)
|
||||
if (ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData)
|
||||
{
|
||||
if (data->GLContext)
|
||||
SDL_GL_DeleteContext(data->GLContext);
|
||||
@ -335,7 +335,7 @@ static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplSDL2_ShowWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
#if defined(_WIN32)
|
||||
SDL_SysWMinfo info;
|
||||
SDL_VERSION(&info.version);
|
||||
@ -368,7 +368,7 @@ static void ImGui_ImplSDL2_ShowWindow(ImGuiViewport* viewport)
|
||||
|
||||
static ImVec2 ImGui_ImplSDL2_GetWindowPos(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
int x = 0, y = 0;
|
||||
SDL_GetWindowPosition(data->Window, &x, &y);
|
||||
return ImVec2((float)x, (float)y);
|
||||
@ -376,13 +376,13 @@ static ImVec2 ImGui_ImplSDL2_GetWindowPos(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplSDL2_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
SDL_SetWindowPosition(data->Window, (int)pos.x, (int)pos.y);
|
||||
}
|
||||
|
||||
static ImVec2 ImGui_ImplSDL2_GetWindowSize(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
int w = 0, h = 0;
|
||||
SDL_GetWindowSize(data->Window, &w, &h);
|
||||
return ImVec2((float)w, (float)h);
|
||||
@ -390,26 +390,26 @@ static ImVec2 ImGui_ImplSDL2_GetWindowSize(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplSDL2_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
SDL_SetWindowSize(data->Window, (int)size.x, (int)size.y);
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
SDL_SetWindowTitle(data->Window, title);
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
if (data->GLContext)
|
||||
SDL_GL_MakeCurrent(data->Window, data->GLContext);
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_SwapBuffers(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
if (data->GLContext)
|
||||
{
|
||||
SDL_GL_MakeCurrent(data->Window, data->GLContext);
|
||||
@ -423,7 +423,7 @@ static void ImGui_ImplSDL2_SwapBuffers(ImGuiViewport* viewport)
|
||||
#include <SDL_vulkan.h>
|
||||
static int ImGui_ImplSDL2_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataSDL2* data = (ImGuiViewportDataSDL2*)viewport->PlatformUserData;
|
||||
(void)vk_allocator;
|
||||
SDL_bool ret = SDL_Vulkan_CreateSurface(data->Window, (VkInstance)vk_instance, (VkSurfaceKHR*)out_vk_surface);
|
||||
return ret ? 0 : 1; // ret ? VK_SUCCESS : VK_NOT_READY
|
||||
@ -453,7 +453,7 @@ static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_g
|
||||
|
||||
// Register main window handle
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
ImGuiPlatformDataSDL2* data = IM_NEW(ImGuiPlatformDataSDL2)();
|
||||
ImGuiViewportDataSDL2* data = IM_NEW(ImGuiViewportDataSDL2)();
|
||||
data->Window = window;
|
||||
data->WindowID = SDL_GetWindowID(window);
|
||||
data->GLContext = sdl_gl_context;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-03-03: Vulkan: Various refactor, created a couple of ImGui_ImplVulkanH_XXX helper that the example can use and that viewport support will use.
|
||||
// 2018-03-01: Vulkan: Renamed ImGui_ImplVulkan_Init_Info to ImGui_ImplVulkan_InitInfo and fields to match more closely Vulkan terminology.
|
||||
// 2018-02-18: Vulkan: Offset projection matrix and clipping rectangle by draw_data->DisplayPos (which will be non-zero for multi-viewport applications).
|
||||
@ -1050,17 +1051,17 @@ void ImGui_ImplVulkanH_DestroyWindowData(VkInstance instance, VkDevice device, I
|
||||
// FIXME-PLATFORM: Vulkan support unfinished
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataVulkan
|
||||
struct ImGuiViewportDataVulkan
|
||||
{
|
||||
ImGui_ImplVulkan_WindowData WindowData;
|
||||
|
||||
ImGuiPlatformDataVulkan() { }
|
||||
~ImGuiPlatformDataVulkan() { }
|
||||
ImGuiViewportDataVulkan() { }
|
||||
~ImGuiViewportDataVulkan() { }
|
||||
};
|
||||
|
||||
static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataVulkan* data = IM_NEW(ImGuiPlatformDataVulkan)();
|
||||
ImGuiViewportDataVulkan* data = IM_NEW(ImGuiViewportDataVulkan)();
|
||||
viewport->RendererUserData = data;
|
||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||
|
||||
@ -1095,7 +1096,7 @@ static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplVulkan_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataVulkan* data = (ImGuiPlatformDataVulkan*)viewport->RendererUserData)
|
||||
if (ImGuiViewportDataVulkan* data = (ImGuiViewportDataVulkan*)viewport->RendererUserData)
|
||||
{
|
||||
ImGui_ImplVulkanH_DestroyWindowData(g_Instance, g_Device, &data->WindowData, g_Allocator);
|
||||
IM_DELETE(data);
|
||||
@ -1105,7 +1106,7 @@ static void ImGui_ImplVulkan_DestroyWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplVulkan_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataVulkan* data = (ImGuiPlatformDataVulkan*)viewport->RendererUserData;
|
||||
ImGuiViewportDataVulkan* data = (ImGuiViewportDataVulkan*)viewport->RendererUserData;
|
||||
if (data == NULL) // This is NULL for the main viewport (which is left to the user/app to handle)
|
||||
return;
|
||||
data->WindowData.ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
|
||||
@ -1114,7 +1115,7 @@ static void ImGui_ImplVulkan_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
|
||||
static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataVulkan* data = (ImGuiPlatformDataVulkan*)viewport->RendererUserData;
|
||||
ImGuiViewportDataVulkan* data = (ImGuiViewportDataVulkan*)viewport->RendererUserData;
|
||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||
VkResult err;
|
||||
|
||||
@ -1185,7 +1186,7 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplVulkan_SwapBuffers(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataVulkan* data = (ImGuiPlatformDataVulkan*)viewport->RendererUserData;
|
||||
ImGuiViewportDataVulkan* data = (ImGuiViewportDataVulkan*)viewport->RendererUserData;
|
||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||
|
||||
VkResult err;
|
||||
|
@ -351,19 +351,19 @@ float ImGui_ImplWin32_GetDpiScaleForRect(int x1, int y1, int x2, int y2)
|
||||
// Platform Windows
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataWin32
|
||||
struct ImGuiViewportDataWin32
|
||||
{
|
||||
HWND Hwnd;
|
||||
DWORD DwStyle;
|
||||
DWORD DwExStyle;
|
||||
|
||||
ImGuiPlatformDataWin32() { Hwnd = NULL; DwStyle = DwExStyle = 0; }
|
||||
~ImGuiPlatformDataWin32() { IM_ASSERT(Hwnd == NULL); }
|
||||
ImGuiViewportDataWin32() { Hwnd = NULL; DwStyle = DwExStyle = 0; }
|
||||
~ImGuiViewportDataWin32() { IM_ASSERT(Hwnd == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplWin32_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataWin32* data = IM_NEW(ImGuiPlatformDataWin32)();
|
||||
ImGuiViewportDataWin32* data = IM_NEW(ImGuiViewportDataWin32)();
|
||||
viewport->PlatformUserData = data;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@ -393,7 +393,7 @@ static void ImGui_ImplWin32_CreateWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplWin32_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataWin32* data = (ImGuiPlatformDataWin32*)viewport->PlatformUserData)
|
||||
if (ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData)
|
||||
{
|
||||
if (::GetCapture() == data->Hwnd)
|
||||
{
|
||||
@ -411,7 +411,7 @@ static void ImGui_ImplWin32_DestroyWindow(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplWin32_ShowWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataWin32* data = (ImGuiPlatformDataWin32*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData;
|
||||
IM_ASSERT(data->Hwnd != 0);
|
||||
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||
::ShowWindow(data->Hwnd, SW_SHOWNA);
|
||||
@ -421,7 +421,7 @@ static void ImGui_ImplWin32_ShowWindow(ImGuiViewport* viewport)
|
||||
|
||||
static ImVec2 ImGui_ImplWin32_GetWindowPos(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataWin32* data = (ImGuiPlatformDataWin32*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData;
|
||||
IM_ASSERT(data->Hwnd != 0);
|
||||
POINT pos = { 0, 0 };
|
||||
::ClientToScreen(data->Hwnd, &pos);
|
||||
@ -430,7 +430,7 @@ static ImVec2 ImGui_ImplWin32_GetWindowPos(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplWin32_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||
{
|
||||
ImGuiPlatformDataWin32* data = (ImGuiPlatformDataWin32*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData;
|
||||
IM_ASSERT(data->Hwnd != 0);
|
||||
RECT rect = { (LONG)pos.x, (LONG)pos.y, (LONG)pos.x, (LONG)pos.y };
|
||||
::AdjustWindowRectEx(&rect, data->DwStyle, FALSE, data->DwExStyle);
|
||||
@ -439,7 +439,7 @@ static void ImGui_ImplWin32_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||
|
||||
static ImVec2 ImGui_ImplWin32_GetWindowSize(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataWin32* data = (ImGuiPlatformDataWin32*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData;
|
||||
IM_ASSERT(data->Hwnd != 0);
|
||||
RECT rect;
|
||||
::GetClientRect(data->Hwnd, &rect);
|
||||
@ -448,7 +448,7 @@ static ImVec2 ImGui_ImplWin32_GetWindowSize(ImGuiViewport* viewport)
|
||||
|
||||
static void ImGui_ImplWin32_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataWin32* data = (ImGuiPlatformDataWin32*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData;
|
||||
IM_ASSERT(data->Hwnd != 0);
|
||||
RECT rect = { 0, 0, (LONG)size.x, (LONG)size.y };
|
||||
::AdjustWindowRectEx(&rect, data->DwStyle, FALSE, data->DwExStyle); // Client to Screen
|
||||
@ -457,14 +457,14 @@ static void ImGui_ImplWin32_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
|
||||
static void ImGui_ImplWin32_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||
{
|
||||
ImGuiPlatformDataWin32* data = (ImGuiPlatformDataWin32*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData;
|
||||
IM_ASSERT(data->Hwnd != 0);
|
||||
::SetWindowTextA(data->Hwnd, title);
|
||||
}
|
||||
|
||||
static float ImGui_ImplWin32_GetWindowDpiScale(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataWin32* data = (ImGuiPlatformDataWin32*)viewport->PlatformUserData;
|
||||
ImGuiViewportDataWin32* data = (ImGuiViewportDataWin32*)viewport->PlatformUserData;
|
||||
if (data && data->Hwnd)
|
||||
return ImGui_ImplWin32_GetDpiScaleForHwnd(data->Hwnd);
|
||||
|
||||
@ -534,7 +534,7 @@ static void ImGui_ImplWin32_InitPlatformInterface()
|
||||
|
||||
// Register main window handle
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
ImGuiPlatformDataWin32* data = IM_NEW(ImGuiPlatformDataWin32)();
|
||||
ImGuiViewportDataWin32* data = IM_NEW(ImGuiViewportDataWin32)();
|
||||
data->Hwnd = g_hWnd;
|
||||
main_viewport->PlatformUserData = data;
|
||||
main_viewport->PlatformHandle = (void*)data->Hwnd;
|
||||
|
Loading…
Reference in New Issue
Block a user