mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-05 04:28:47 +02:00
Viewport, Platform: Refactored platform interface. Removed need to use imgui_internal.h in backends. Split viewport into public facing ImGuiViewport and internal structure. Exposing enough data to provide custom tweaked renderers. Renamed handlers, fixed lots of inconsistencies. (#1542, #1042)
This commit is contained in:
@ -208,7 +208,9 @@ int main(int, char**)
|
||||
ImGui::Render();
|
||||
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
ImGui::RenderAdditionalViewports();
|
||||
// Update and Render additional Platform Windows
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindows();
|
||||
|
||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||
|
@ -226,7 +226,9 @@ int main(int, char**)
|
||||
ImGui::Render();
|
||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
ImGui::RenderAdditionalViewports();
|
||||
// Update and Render additional Platform Windows
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindows();
|
||||
|
||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||
|
@ -401,7 +401,9 @@ int main(int, char**)
|
||||
|
||||
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
|
||||
|
||||
ImGui::RenderAdditionalViewports();
|
||||
// Update and Render additional Platform Windows
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindows();
|
||||
|
||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||
|
@ -11,7 +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 ImGuiRendererInterface.
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-XX-XX: DirectX10: 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_ImplDX10_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
@ -498,12 +498,9 @@ void ImGui_ImplDX10_NewFrame()
|
||||
ImGui_ImplDX10_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
// Platform Windows
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "imgui_internal.h" // ImGuiViewport
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataDx10
|
||||
{
|
||||
@ -514,7 +511,7 @@ struct ImGuiPlatformDataDx10
|
||||
~ImGuiPlatformDataDx10() { IM_ASSERT(SwapChain == NULL && RTView == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplDX10_CreateViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplDX10_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx10* data = IM_NEW(ImGuiPlatformDataDx10)();
|
||||
viewport->RendererUserData = data;
|
||||
@ -551,7 +548,7 @@ static void ImGui_ImplDX10_CreateViewport(ImGuiViewport* viewport)
|
||||
}
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX10_DestroyViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplDX10_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataDx10* data = (ImGuiPlatformDataDx10*)viewport->RendererUserData)
|
||||
{
|
||||
@ -566,7 +563,7 @@ static void ImGui_ImplDX10_DestroyViewport(ImGuiViewport* viewport)
|
||||
viewport->RendererUserData = NULL;
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX10_ResizeViewport(ImGuiViewport* viewport, ImVec2 size)
|
||||
static void ImGui_ImplDX10_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataDx10* data = (ImGuiPlatformDataDx10*)viewport->RendererUserData;
|
||||
if (data->RTView)
|
||||
@ -591,7 +588,7 @@ static void ImGui_ImplDX10_RenderViewport(ImGuiViewport* viewport)
|
||||
g_pd3dDevice->OMSetRenderTargets(1, &data->RTView, NULL);
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
g_pd3dDevice->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
||||
ImGui_ImplDX10_RenderDrawData(&viewport->DrawData);
|
||||
ImGui_ImplDX10_RenderDrawData(viewport->DrawData);
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX10_SwapBuffers(ImGuiViewport* viewport)
|
||||
@ -602,18 +599,16 @@ static void ImGui_ImplDX10_SwapBuffers(ImGuiViewport* viewport)
|
||||
|
||||
void ImGui_ImplDX10_InitPlatformInterface()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.RendererInterface.CreateViewport = ImGui_ImplDX10_CreateViewport;
|
||||
io.RendererInterface.DestroyViewport = ImGui_ImplDX10_DestroyViewport;
|
||||
io.RendererInterface.ResizeViewport = ImGui_ImplDX10_ResizeViewport;
|
||||
io.RendererInterface.RenderViewport = ImGui_ImplDX10_RenderViewport;
|
||||
io.RendererInterface.SwapBuffers = ImGui_ImplDX10_SwapBuffers;
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Renderer_CreateWindow = ImGui_ImplDX10_CreateWindow;
|
||||
platform_io.Renderer_DestroyWindow = ImGui_ImplDX10_DestroyWindow;
|
||||
platform_io.Renderer_SetWindowSize = ImGui_ImplDX10_SetWindowSize;
|
||||
platform_io.Renderer_RenderWindow = ImGui_ImplDX10_RenderViewport;
|
||||
platform_io.Renderer_SwapBuffers = ImGui_ImplDX10_SwapBuffers;
|
||||
}
|
||||
|
||||
void ImGui_ImplDX10_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGui::DestroyViewportsRendererData(ImGui::GetCurrentContext());
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
||||
ImGui::DestroyPlatformWindows();
|
||||
}
|
||||
|
||||
|
@ -11,7 +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 ImGuiRendererInterface.
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-XX-XX: DirectX11: 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_ImplDX11_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
@ -507,11 +507,9 @@ void ImGui_ImplDX11_NewFrame()
|
||||
ImGui_ImplDX11_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
// Platform Windows
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "imgui_internal.h" // ImGuiViewport
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataDx11
|
||||
{
|
||||
@ -522,12 +520,11 @@ struct ImGuiPlatformDataDx11
|
||||
~ImGuiPlatformDataDx11() { IM_ASSERT(SwapChain == NULL && RTView == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplDX11_CreateViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx11* data = IM_NEW(ImGuiPlatformDataDx11)();
|
||||
viewport->RendererUserData = data;
|
||||
|
||||
// FIXME-PLATFORM
|
||||
HWND hwnd = (HWND)viewport->PlatformHandle;
|
||||
IM_ASSERT(hwnd != 0);
|
||||
|
||||
@ -559,7 +556,7 @@ static void ImGui_ImplDX11_CreateViewport(ImGuiViewport* viewport)
|
||||
}
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX11_DestroyViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplDX11_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)viewport->RendererUserData)
|
||||
{
|
||||
@ -574,7 +571,7 @@ static void ImGui_ImplDX11_DestroyViewport(ImGuiViewport* viewport)
|
||||
viewport->RendererUserData = NULL;
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX11_ResizeViewport(ImGuiViewport* viewport, ImVec2 size)
|
||||
static void ImGui_ImplDX11_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)viewport->RendererUserData;
|
||||
if (data->RTView)
|
||||
@ -592,14 +589,14 @@ static void ImGui_ImplDX11_ResizeViewport(ImGuiViewport* viewport, ImVec2 size)
|
||||
}
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX11_RenderViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplDX11_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)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))
|
||||
g_pd3dDeviceContext->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
||||
ImGui_ImplDX11_RenderDrawData(&viewport->DrawData);
|
||||
ImGui_ImplDX11_RenderDrawData(viewport->DrawData);
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX11_SwapBuffers(ImGuiViewport* viewport)
|
||||
@ -608,20 +605,17 @@ static void ImGui_ImplDX11_SwapBuffers(ImGuiViewport* viewport)
|
||||
data->SwapChain->Present(0, 0); // Present without vsync
|
||||
}
|
||||
|
||||
void ImGui_ImplDX11_InitPlatformInterface()
|
||||
static void ImGui_ImplDX11_InitPlatformInterface()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.RendererInterface.CreateViewport = ImGui_ImplDX11_CreateViewport;
|
||||
io.RendererInterface.DestroyViewport = ImGui_ImplDX11_DestroyViewport;
|
||||
io.RendererInterface.ResizeViewport = ImGui_ImplDX11_ResizeViewport;
|
||||
io.RendererInterface.RenderViewport = ImGui_ImplDX11_RenderViewport;
|
||||
io.RendererInterface.SwapBuffers = ImGui_ImplDX11_SwapBuffers;
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Renderer_CreateWindow = ImGui_ImplDX11_CreateWindow;
|
||||
platform_io.Renderer_DestroyWindow = ImGui_ImplDX11_DestroyWindow;
|
||||
platform_io.Renderer_SetWindowSize = ImGui_ImplDX11_SetWindowSize;
|
||||
platform_io.Renderer_RenderWindow = ImGui_ImplDX11_RenderWindow;
|
||||
platform_io.Renderer_SwapBuffers = ImGui_ImplDX11_SwapBuffers;
|
||||
}
|
||||
|
||||
void ImGui_ImplDX11_ShutdownPlatformInterface()
|
||||
static void ImGui_ImplDX11_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGui::DestroyViewportsRendererData(ImGui::GetCurrentContext());
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
||||
ImGui::DestroyPlatformWindows();
|
||||
}
|
||||
|
||||
|
@ -634,11 +634,9 @@ void ImGui_ImplDX12_NewFrame(ID3D12GraphicsCommandList* command_list)
|
||||
g_pd3dCommandList = command_list;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
// Platform Windows
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "imgui_internal.h" // ImGuiViewport
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataDx12
|
||||
{
|
||||
@ -648,7 +646,7 @@ struct ImGuiPlatformDataDx12
|
||||
~ImGuiPlatformDataDx12() { IM_ASSERT(SwapChain == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplDX12_CreateViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplDX12_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx12* data = IM_NEW(ImGuiPlatformDataDx12)();
|
||||
viewport->RendererUserData = data;
|
||||
@ -688,7 +686,7 @@ static void ImGui_ImplDX12_CreateViewport(ImGuiViewport* viewport)
|
||||
*/
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX12_DestroyViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplDX12_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataDx12* data = (ImGuiPlatformDataDx12*)viewport->RendererUserData)
|
||||
{
|
||||
@ -706,11 +704,11 @@ static void ImGui_ImplDX12_DestroyViewport(ImGuiViewport* viewport)
|
||||
viewport->RendererUserData = NULL;
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX12_ResizeViewport(ImGuiViewport* viewport, int w, int h)
|
||||
static void ImGui_ImplDX12_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataDx12* data = (ImGuiPlatformDataDx12*)viewport->RendererUserData;
|
||||
IM_ASSERT(0);
|
||||
(void)data; (void)w; (void)h;
|
||||
(void)data; (void)size;
|
||||
/*
|
||||
if (data->RTView)
|
||||
{
|
||||
@ -720,7 +718,7 @@ static void ImGui_ImplDX12_ResizeViewport(ImGuiViewport* viewport, int w, int h)
|
||||
if (data->SwapChain)
|
||||
{
|
||||
ID3D11Texture2D* pBackBuffer = NULL;
|
||||
data->SwapChain->ResizeBuffers(0, w, h, DXGI_FORMAT_UNKNOWN, 0);
|
||||
data->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
||||
data->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &data->RTView);
|
||||
pBackBuffer->Release();
|
||||
@ -728,7 +726,7 @@ static void ImGui_ImplDX12_ResizeViewport(ImGuiViewport* viewport, int w, int h)
|
||||
*/
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX12_RenderViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplDX12_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx12* data = (ImGuiPlatformDataDx12*)viewport->RendererUserData;
|
||||
IM_ASSERT(0);
|
||||
@ -739,7 +737,7 @@ static void ImGui_ImplDX12_RenderViewport(ImGuiViewport* viewport)
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
g_pd3dDeviceContext->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
||||
*/
|
||||
ImGui_ImplDX12_RenderDrawData(&viewport->DrawData);
|
||||
ImGui_ImplDX12_RenderDrawData(viewport->DrawData);
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX12_SwapBuffers(ImGuiViewport* viewport)
|
||||
@ -754,18 +752,15 @@ static void ImGui_ImplDX12_SwapBuffers(ImGuiViewport* viewport)
|
||||
|
||||
void ImGui_ImplDX12_InitPlatformInterface()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.RendererInterface.CreateViewport = ImGui_ImplDX12_CreateViewport;
|
||||
io.RendererInterface.DestroyViewport = ImGui_ImplDX12_DestroyViewport;
|
||||
io.RendererInterface.ResizeViewport = ImGui_ImplDX12_ResizeViewport;
|
||||
io.RendererInterface.RenderViewport = ImGui_ImplDX12_RenderViewport;
|
||||
io.RendererInterface.SwapBuffers = ImGui_ImplDX12_SwapBuffers;
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Renderer_CreateWindow = ImGui_ImplDX12_CreateWindow;
|
||||
platform_io.Renderer_DestroyWindow = ImGui_ImplDX12_DestroyWindow;
|
||||
platform_io.Renderer_SetWindowSize = ImGui_ImplDX12_SetWindowSize;
|
||||
platform_io.Renderer_RenderWindow = ImGui_ImplDX12_RenderWindow;
|
||||
platform_io.Renderer_SwapBuffers = ImGui_ImplDX12_SwapBuffers;
|
||||
}
|
||||
|
||||
void ImGui_ImplDX12_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGui::DestroyViewportsRendererData(ImGui::GetCurrentContext());
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
||||
ImGui::DestroyPlatformWindows();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,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 ImGuiPlatformInterface
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-XX-XX: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||
@ -25,14 +25,13 @@
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_glfw.h"
|
||||
#include "imgui_internal.h" // FIXME-PLATFORM
|
||||
|
||||
// GLFW
|
||||
#include <GLFW/glfw3.h>
|
||||
#ifdef _WIN32
|
||||
#undef APIENTRY
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#include <GLFW/glfw3native.h> // for glfwGetWin32Window
|
||||
#include <GLFW/glfw3native.h> // for glfwGetWin32Window
|
||||
#endif
|
||||
#ifdef GLFW_HOVERED
|
||||
#define GLFW_HAS_GLFW_HOVERED 1
|
||||
@ -209,10 +208,10 @@ static void ImGui_ImplGlfw_UpdateMouse()
|
||||
g_MouseJustPressed[i] = false;
|
||||
}
|
||||
|
||||
const ImVector<ImGuiViewport*>& viewports = ImGui::GetViewports();
|
||||
for (int n = 0; n < viewports.Size; n++)
|
||||
ImGuiPlatformData* platform_data = ImGui::GetPlatformData();
|
||||
for (int n = 0; n < platform_data->Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewport* viewport = viewports[n];
|
||||
ImGuiViewport* viewport = platform_data->Viewports[n];
|
||||
GLFWwindow* window = (GLFWwindow*)viewport->PlatformHandle;
|
||||
IM_ASSERT(window != NULL);
|
||||
if (glfwGetWindowAttrib(window, GLFW_FOCUSED))
|
||||
@ -330,7 +329,7 @@ static void ImGui_ImplGlfw_WindowSizeCallback(GLFWwindow* window, int, int)
|
||||
viewport->PlatformRequestResize = true;
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_CreateViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = IM_NEW(ImGuiPlatformDataGlfw)();
|
||||
viewport->PlatformUserData = data;
|
||||
@ -349,7 +348,7 @@ static void ImGui_ImplGlfw_CreateViewport(ImGuiViewport* viewport)
|
||||
glfwSetWindowSizeCallback(data->Window, ImGui_ImplGlfw_WindowSizeCallback);
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_DestroyViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData)
|
||||
{
|
||||
@ -449,7 +448,7 @@ static void ImGui_ImplGlfw_SetWindowTitle(ImGuiViewport* viewport, const char* t
|
||||
glfwSetWindowTitle(data->Window, title);
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_RenderViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplGlfw_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataGlfw* data = (ImGuiPlatformDataGlfw*)viewport->PlatformUserData;
|
||||
if (g_ClientApi == GlfwClientApi_OpenGL)
|
||||
@ -491,19 +490,19 @@ static int ImGui_ImplGlfw_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_inst
|
||||
static void ImGui_ImplGlfw_InitPlatformInterface()
|
||||
{
|
||||
// Register platform interface (will be coupled with a renderer interface)
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.PlatformInterface.CreateViewport = ImGui_ImplGlfw_CreateViewport;
|
||||
io.PlatformInterface.DestroyViewport = ImGui_ImplGlfw_DestroyViewport;
|
||||
io.PlatformInterface.ShowWindow = ImGui_ImplGlfw_ShowWindow;
|
||||
io.PlatformInterface.SetWindowPos = ImGui_ImplGlfw_SetWindowPos;
|
||||
io.PlatformInterface.GetWindowPos = ImGui_ImplGlfw_GetWindowPos;
|
||||
io.PlatformInterface.SetWindowSize = ImGui_ImplGlfw_SetWindowSize;
|
||||
io.PlatformInterface.GetWindowSize = ImGui_ImplGlfw_GetWindowSize;
|
||||
io.PlatformInterface.SetWindowTitle = ImGui_ImplGlfw_SetWindowTitle;
|
||||
io.PlatformInterface.RenderViewport = ImGui_ImplGlfw_RenderViewport;
|
||||
io.PlatformInterface.SwapBuffers = ImGui_ImplGlfw_SwapBuffers;
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Platform_CreateWindow = ImGui_ImplGlfw_CreateWindow;
|
||||
platform_io.Platform_DestroyWindow = ImGui_ImplGlfw_DestroyWindow;
|
||||
platform_io.Platform_ShowWindow = ImGui_ImplGlfw_ShowWindow;
|
||||
platform_io.Platform_SetWindowPos = ImGui_ImplGlfw_SetWindowPos;
|
||||
platform_io.Platform_GetWindowPos = ImGui_ImplGlfw_GetWindowPos;
|
||||
platform_io.Platform_SetWindowSize = ImGui_ImplGlfw_SetWindowSize;
|
||||
platform_io.Platform_GetWindowSize = ImGui_ImplGlfw_GetWindowSize;
|
||||
platform_io.Platform_SetWindowTitle = ImGui_ImplGlfw_SetWindowTitle;
|
||||
platform_io.Platform_RenderWindow = ImGui_ImplGlfw_RenderWindow;
|
||||
platform_io.Platform_SwapBuffers = ImGui_ImplGlfw_SwapBuffers;
|
||||
#if GLFW_HAS_VULKAN
|
||||
io.PlatformInterface.CreateVkSurface = ImGui_ImplGlfw_CreateVkSurface;
|
||||
platform_io.Platform_CreateVkSurface = ImGui_ImplGlfw_CreateVkSurface;
|
||||
#endif
|
||||
|
||||
// Register main window handle
|
||||
@ -516,8 +515,4 @@ static void ImGui_ImplGlfw_InitPlatformInterface()
|
||||
|
||||
static void ImGui_ImplGlfw_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
main_viewport->PlatformHandle = NULL;
|
||||
memset(&io.PlatformInterface, 0, sizeof(io.PlatformInterface));
|
||||
}
|
||||
|
@ -323,13 +323,11 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
// Platform Windows
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "imgui_internal.h" // ImGuiViewport
|
||||
|
||||
static void ImGui_ImplOpenGL3_RenderViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplOpenGL3_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
{
|
||||
@ -337,18 +335,16 @@ static void ImGui_ImplOpenGL3_RenderViewport(ImGuiViewport* viewport)
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
ImGui_ImplOpenGL3_RenderDrawData(&viewport->DrawData);
|
||||
ImGui_ImplOpenGL3_RenderDrawData(viewport->DrawData);
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_InitPlatformInterface()
|
||||
static void ImGui_ImplOpenGL3_InitPlatformInterface()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.RendererInterface.RenderViewport = ImGui_ImplOpenGL3_RenderViewport;
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
|
||||
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGui::DestroyViewportsRendererData(ImGui::GetCurrentContext());
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
||||
ImGui::DestroyPlatformWindows();
|
||||
}
|
||||
|
@ -12,7 +12,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 ImGuiPlatformInterface
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-XX-XX: Misc: ImGui_ImplSDL2_Init() now takes a SDL_GLContext parameter.
|
||||
// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
@ -27,7 +27,6 @@
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_sdl2.h"
|
||||
#include "imgui_internal.h" // FIXME-PLATFORM
|
||||
|
||||
// SDL
|
||||
#include <SDL.h>
|
||||
@ -271,9 +270,9 @@ void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
// Platform Windows
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiPlatformDataSDL2
|
||||
{
|
||||
@ -285,7 +284,7 @@ struct ImGuiPlatformDataSDL2
|
||||
~ImGuiPlatformDataSDL2() { IM_ASSERT(Window == NULL && GLContext == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplSDL2_CreateViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = IM_NEW(ImGuiPlatformDataSDL2)();
|
||||
viewport->PlatformUserData = data;
|
||||
@ -319,7 +318,7 @@ static void ImGui_ImplSDL2_CreateViewport(ImGuiViewport* viewport)
|
||||
viewport->PlatformHandle = (void*)data->Window;
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_DestroyViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData)
|
||||
{
|
||||
@ -401,7 +400,7 @@ static void ImGui_ImplSDL2_SetWindowTitle(ImGuiViewport* viewport, const char* t
|
||||
SDL_SetWindowTitle(data->Window, title);
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_RenderViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplSDL2_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataSDL2* data = (ImGuiPlatformDataSDL2*)viewport->PlatformUserData;
|
||||
if (data->GLContext)
|
||||
@ -434,21 +433,22 @@ static int ImGui_ImplSDL2_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_inst
|
||||
static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context)
|
||||
{
|
||||
// Register platform interface (will be coupled with a renderer interface)
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.PlatformInterface.CreateViewport = ImGui_ImplSDL2_CreateViewport;
|
||||
io.PlatformInterface.DestroyViewport = ImGui_ImplSDL2_DestroyViewport;
|
||||
io.PlatformInterface.ShowWindow = ImGui_ImplSDL2_ShowWindow;
|
||||
io.PlatformInterface.SetWindowPos = ImGui_ImplSDL2_SetWindowPos;
|
||||
io.PlatformInterface.GetWindowPos = ImGui_ImplSDL2_GetWindowPos;
|
||||
io.PlatformInterface.SetWindowSize = ImGui_ImplSDL2_SetWindowSize;
|
||||
io.PlatformInterface.GetWindowSize = ImGui_ImplSDL2_GetWindowSize;
|
||||
io.PlatformInterface.SetWindowTitle = ImGui_ImplSDL2_SetWindowTitle;
|
||||
io.PlatformInterface.RenderViewport = ImGui_ImplSDL2_RenderViewport;
|
||||
io.PlatformInterface.SwapBuffers = ImGui_ImplSDL2_SwapBuffers;
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Platform_CreateWindow = ImGui_ImplSDL2_CreateWindow;
|
||||
platform_io.Platform_DestroyWindow = ImGui_ImplSDL2_DestroyWindow;
|
||||
platform_io.Platform_ShowWindow = ImGui_ImplSDL2_ShowWindow;
|
||||
platform_io.Platform_SetWindowPos = ImGui_ImplSDL2_SetWindowPos;
|
||||
platform_io.Platform_GetWindowPos = ImGui_ImplSDL2_GetWindowPos;
|
||||
platform_io.Platform_SetWindowSize = ImGui_ImplSDL2_SetWindowSize;
|
||||
platform_io.Platform_GetWindowSize = ImGui_ImplSDL2_GetWindowSize;
|
||||
platform_io.Platform_SetWindowTitle = ImGui_ImplSDL2_SetWindowTitle;
|
||||
platform_io.Platform_RenderWindow = ImGui_ImplSDL2_RenderWindow;
|
||||
platform_io.Platform_SwapBuffers = ImGui_ImplSDL2_SwapBuffers;
|
||||
#if SDL_HAS_VULKAN
|
||||
io.PlatformInterface.CreateVkSurface = ImGui_ImplSDL2_CreateVkSurface;
|
||||
platform_io.Platform_CreateVkSurface = ImGui_ImplSDL2_CreateVkSurface;
|
||||
#endif
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= SDL_HAS_WINDOW_OPACITY ? ImGuiConfigFlags_PlatformHasWindowAlpha : 0;
|
||||
|
||||
// Register main window handle
|
||||
@ -463,6 +463,4 @@ static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_g
|
||||
|
||||
static void ImGui_ImplSDL2_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(&io.PlatformInterface, 0, sizeof(io.PlatformInterface));
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_vulkan.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// Vulkan data
|
||||
static const VkAllocationCallbacks* g_Allocator = NULL;
|
||||
@ -714,10 +715,7 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass rend
|
||||
ImGui_ImplVulkan_CreateDeviceObjects();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_RendererHasViewports;
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||
{
|
||||
IM_ASSERT(io.PlatformInterface.CreateVkSurface != NULL);
|
||||
ImGui_ImplVulkan_InitPlatformInterface();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -734,7 +732,6 @@ void ImGui_ImplVulkan_NewFrame()
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Miscellaneous Vulkan Helpers
|
||||
// (Those are currently not strictly needed by the binding, but will be once if we support multi-viewports)
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h> // malloc
|
||||
@ -1049,11 +1046,10 @@ void ImGui_ImplVulkanH_DestroyWindowData(VkInstance instance, VkDevice device, I
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// Platform Windows (OPTIONAL/EXPERIMENTAL)
|
||||
// Platform Interface (Optional, for multi-viewport support)
|
||||
// FIXME-PLATFORM: Vulkan support unfinished
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "imgui_internal.h" // ImGuiViewport
|
||||
|
||||
struct ImGuiPlatformDataVulkan
|
||||
{
|
||||
ImGui_ImplVulkan_WindowData WindowData;
|
||||
@ -1062,15 +1058,15 @@ struct ImGuiPlatformDataVulkan
|
||||
~ImGuiPlatformDataVulkan() { }
|
||||
};
|
||||
|
||||
static void ImGui_ImplVulkan_CreateViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataVulkan* data = IM_NEW(ImGuiPlatformDataVulkan)();
|
||||
viewport->RendererUserData = data;
|
||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||
|
||||
// Create surface
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
VkResult err = (VkResult)io.PlatformInterface.CreateVkSurface(viewport, (ImU64)g_Instance, (const void*)g_Allocator, (ImU64*)&wd->Surface);
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
VkResult err = (VkResult)platform_io.Platform_CreateVkSurface(viewport, (ImU64)g_Instance, (const void*)g_Allocator, (ImU64*)&wd->Surface);
|
||||
check_vk_result(err);
|
||||
|
||||
// Check for WSI support
|
||||
@ -1097,7 +1093,7 @@ static void ImGui_ImplVulkan_CreateViewport(ImGuiViewport* viewport)
|
||||
ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, wd, g_Allocator, (int)viewport->Size.x, (int)viewport->Size.y);
|
||||
}
|
||||
|
||||
static void ImGui_ImplVulkan_DestroyViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplVulkan_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataVulkan* data = (ImGuiPlatformDataVulkan*)viewport->RendererUserData)
|
||||
{
|
||||
@ -1107,7 +1103,7 @@ static void ImGui_ImplVulkan_DestroyViewport(ImGuiViewport* viewport)
|
||||
viewport->RendererUserData = NULL;
|
||||
}
|
||||
|
||||
static void ImGui_ImplVulkan_ResizeViewport(ImGuiViewport* viewport, ImVec2 size)
|
||||
static void ImGui_ImplVulkan_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||
{
|
||||
ImGuiPlatformDataVulkan* data = (ImGuiPlatformDataVulkan*)viewport->RendererUserData;
|
||||
if (data == NULL) // This is NULL for the main viewport (which is left to the user/app to handle)
|
||||
@ -1116,7 +1112,7 @@ static void ImGui_ImplVulkan_ResizeViewport(ImGuiViewport* viewport, ImVec2 size
|
||||
ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &data->WindowData, g_Allocator, (int)size.x, (int)size.y);
|
||||
}
|
||||
|
||||
static void ImGui_ImplVulkan_RenderViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataVulkan* data = (ImGuiPlatformDataVulkan*)viewport->RendererUserData;
|
||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||
@ -1160,7 +1156,7 @@ static void ImGui_ImplVulkan_RenderViewport(ImGuiViewport* viewport)
|
||||
}
|
||||
}
|
||||
|
||||
ImGui_ImplVulkan_RenderDrawData(wd->Frames[wd->FrameIndex].CommandBuffer, &viewport->DrawData);
|
||||
ImGui_ImplVulkan_RenderDrawData(wd->Frames[wd->FrameIndex].CommandBuffer, viewport->DrawData);
|
||||
|
||||
{
|
||||
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[wd->FrameIndex];
|
||||
@ -1210,18 +1206,17 @@ static void ImGui_ImplVulkan_SwapBuffers(ImGuiViewport* viewport)
|
||||
|
||||
void ImGui_ImplVulkan_InitPlatformInterface()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
IM_ASSERT(io.PlatformInterface.CreateVkSurface != NULL);
|
||||
io.RendererInterface.CreateViewport = ImGui_ImplVulkan_CreateViewport;
|
||||
io.RendererInterface.DestroyViewport = ImGui_ImplVulkan_DestroyViewport;
|
||||
io.RendererInterface.ResizeViewport = ImGui_ImplVulkan_ResizeViewport;
|
||||
io.RendererInterface.RenderViewport = ImGui_ImplVulkan_RenderViewport;
|
||||
io.RendererInterface.SwapBuffers = ImGui_ImplVulkan_SwapBuffers;
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||
IM_ASSERT(platform_io.Platform_CreateVkSurface != NULL && "Platform needs to setup the CreateVkSurface handler.");
|
||||
platform_io.Renderer_CreateWindow = ImGui_ImplVulkan_CreateWindow;
|
||||
platform_io.Renderer_DestroyWindow = ImGui_ImplVulkan_DestroyWindow;
|
||||
platform_io.Renderer_SetWindowSize = ImGui_ImplVulkan_SetWindowSize;
|
||||
platform_io.Renderer_RenderWindow = ImGui_ImplVulkan_RenderWindow;
|
||||
platform_io.Renderer_SwapBuffers = ImGui_ImplVulkan_SwapBuffers;
|
||||
}
|
||||
|
||||
void ImGui_ImplVulkan_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGui::DestroyViewportsRendererData(ImGui::GetCurrentContext());
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
||||
ImGui::DestroyPlatformWindows();
|
||||
}
|
||||
|
@ -7,10 +7,8 @@
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "imgui_internal.h" // FIXME-PLATFORM
|
||||
|
||||
// CHANGELOG
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformInterface
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
|
||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||
// 2018-02-06: Inputs: Honoring the io.WantMoveMouse by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
|
||||
@ -363,7 +361,7 @@ struct ImGuiPlatformDataWin32
|
||||
~ImGuiPlatformDataWin32() { IM_ASSERT(Hwnd == NULL); }
|
||||
};
|
||||
|
||||
static void ImGui_ImplWin32_CreateViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplWin32_CreateWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataWin32* data = IM_NEW(ImGuiPlatformDataWin32)();
|
||||
viewport->PlatformUserData = data;
|
||||
@ -393,7 +391,7 @@ static void ImGui_ImplWin32_CreateViewport(ImGuiViewport* viewport)
|
||||
viewport->PlatformHandle = data->Hwnd;
|
||||
}
|
||||
|
||||
static void ImGui_ImplWin32_DestroyViewport(ImGuiViewport* viewport)
|
||||
static void ImGui_ImplWin32_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (ImGuiPlatformDataWin32* data = (ImGuiPlatformDataWin32*)viewport->PlatformUserData)
|
||||
{
|
||||
@ -523,16 +521,16 @@ static void ImGui_ImplWin32_InitPlatformInterface()
|
||||
::RegisterClassEx(&wcex);
|
||||
|
||||
// Register platform interface (will be coupled with a renderer interface)
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.PlatformInterface.CreateViewport = ImGui_ImplWin32_CreateViewport;
|
||||
io.PlatformInterface.DestroyViewport = ImGui_ImplWin32_DestroyViewport;
|
||||
io.PlatformInterface.ShowWindow = ImGui_ImplWin32_ShowWindow;
|
||||
io.PlatformInterface.SetWindowPos = ImGui_ImplWin32_SetWindowPos;
|
||||
io.PlatformInterface.GetWindowPos = ImGui_ImplWin32_GetWindowPos;
|
||||
io.PlatformInterface.SetWindowSize = ImGui_ImplWin32_SetWindowSize;
|
||||
io.PlatformInterface.GetWindowSize = ImGui_ImplWin32_GetWindowSize;
|
||||
io.PlatformInterface.SetWindowTitle = ImGui_ImplWin32_SetWindowTitle;
|
||||
io.PlatformInterface.GetWindowDpiScale = ImGui_ImplWin32_GetWindowDpiScale;
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Platform_CreateWindow = ImGui_ImplWin32_CreateWindow;
|
||||
platform_io.Platform_DestroyWindow = ImGui_ImplWin32_DestroyWindow;
|
||||
platform_io.Platform_ShowWindow = ImGui_ImplWin32_ShowWindow;
|
||||
platform_io.Platform_SetWindowPos = ImGui_ImplWin32_SetWindowPos;
|
||||
platform_io.Platform_GetWindowPos = ImGui_ImplWin32_GetWindowPos;
|
||||
platform_io.Platform_SetWindowSize = ImGui_ImplWin32_SetWindowSize;
|
||||
platform_io.Platform_GetWindowSize = ImGui_ImplWin32_GetWindowSize;
|
||||
platform_io.Platform_SetWindowTitle = ImGui_ImplWin32_SetWindowTitle;
|
||||
platform_io.Platform_GetWindowDpiScale = ImGui_ImplWin32_GetWindowDpiScale;
|
||||
|
||||
// Register main window handle
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
@ -544,8 +542,5 @@ static void ImGui_ImplWin32_InitPlatformInterface()
|
||||
|
||||
static void ImGui_ImplWin32_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(&io.PlatformInterface, 0, sizeof(io.PlatformInterface));
|
||||
|
||||
::UnregisterClass(_T("ImGui Platform"), ::GetModuleHandle(NULL));
|
||||
}
|
||||
|
@ -106,13 +106,13 @@ int main(int, char**)
|
||||
}
|
||||
|
||||
// Rendering
|
||||
ImGui::Render();
|
||||
int display_w, display_h;
|
||||
glfwGetFramebufferSize(window, &display_w, &display_h);
|
||||
glViewport(0, 0, display_w, display_h);
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
@ -115,16 +115,18 @@ int main(int, char**)
|
||||
}
|
||||
|
||||
// Rendering
|
||||
ImGui::Render();
|
||||
int display_w, display_h;
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwGetFramebufferSize(window, &display_w, &display_h);
|
||||
glViewport(0, 0, display_w, display_h);
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
ImGui::RenderAdditionalViewports();
|
||||
// Update and Render additional Platform Windows
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindows();
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapBuffers(window);
|
||||
|
@ -131,7 +131,10 @@ int main(int, char**)
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
ImGui::RenderAdditionalViewports();
|
||||
|
||||
// Update and Render additional Platform Windows
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindows();
|
||||
|
||||
SDL_GL_MakeCurrent(window, gl_context);
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
@ -468,7 +468,11 @@ int main(int, char**)
|
||||
ImGui::Render();
|
||||
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||
FrameRender(wd);
|
||||
ImGui::RenderAdditionalViewports();
|
||||
|
||||
// Update and Render additional Platform Windows
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindows();
|
||||
|
||||
FramePresent(wd);
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,11 @@ int main(int, char**)
|
||||
ImGui::Render();
|
||||
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||
FrameRender(wd);
|
||||
ImGui::RenderAdditionalViewports();
|
||||
|
||||
// Update and Render additional Platform Windows
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindows();
|
||||
|
||||
FramePresent(wd);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user