mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Viewport: Renamed RenderPlatformWindows() to RenderPlatformWindowsDefault(), tweaked examples and emphasis optional Viewport code path. (#1542)
This commit is contained in:
parent
0cad274b87
commit
9d8bc79025
@ -208,9 +208,12 @@ int main(int, char**)
|
|||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Update and Render additional Platform Windows (when ImGuiConfigFlags_EnableViewports is enabled)
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||||
|
{
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindows(NULL, NULL);
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
|
@ -226,9 +226,12 @@ int main(int, char**)
|
|||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Update and Render additional Platform Windows (when ImGuiConfigFlags_EnableViewports is enabled)
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||||
|
{
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindows(NULL, NULL);
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
|
@ -401,9 +401,12 @@ int main(int, char**)
|
|||||||
|
|
||||||
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
|
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
|
||||||
|
|
||||||
// Update and Render additional Platform Windows (when ImGuiConfigFlags_EnableViewports is enabled)
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||||
|
{
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindows(NULL, NULL);
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
|
@ -117,9 +117,12 @@ int main(int, char**)
|
|||||||
//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.
|
//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_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Update and Render additional Platform Windows (when ImGuiConfigFlags_EnableViewports is enabled)
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||||
|
{
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindows(NULL, NULL);
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
@ -124,9 +124,12 @@ int main(int, char**)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Update and Render additional Platform Windows (when ImGuiConfigFlags_EnableViewports is enabled)
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||||
|
{
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindows(NULL, NULL);
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
@ -132,9 +132,12 @@ int main(int, char**)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Update and Render additional Platform Windows (when ImGuiConfigFlags_EnableViewports is enabled)
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||||
|
{
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindows(NULL, NULL);
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_MakeCurrent(window, gl_context);
|
SDL_GL_MakeCurrent(window, gl_context);
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
|
@ -469,9 +469,12 @@ int main(int, char**)
|
|||||||
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
FrameRender(wd);
|
FrameRender(wd);
|
||||||
|
|
||||||
// Update and Render additional Platform Windows (when ImGuiConfigFlags_EnableViewports is enabled)
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||||
|
{
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindows(NULL, NULL);
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
FramePresent(wd);
|
FramePresent(wd);
|
||||||
}
|
}
|
||||||
|
@ -479,9 +479,12 @@ int main(int, char**)
|
|||||||
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
FrameRender(wd);
|
FrameRender(wd);
|
||||||
|
|
||||||
// Update and Render additional Platform Windows (when ImGuiConfigFlags_EnableViewports is enabled)
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
|
||||||
|
{
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindows(NULL, NULL);
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
FramePresent(wd);
|
FramePresent(wd);
|
||||||
}
|
}
|
||||||
|
@ -3602,7 +3602,7 @@ void ImGui::UpdatePlatformWindows()
|
|||||||
// MySwapBufferFunction(data->Viewports[i], my_args);
|
// MySwapBufferFunction(data->Viewports[i], my_args);
|
||||||
//
|
//
|
||||||
// Note how we intentionally skip the main viewport (index 0) which is generally rendered as part of our main application.
|
// Note how we intentionally skip the main viewport (index 0) which is generally rendered as part of our main application.
|
||||||
void ImGui::RenderPlatformWindows(void* platform_render_arg, void* renderer_render_arg)
|
void ImGui::RenderPlatformWindowsDefault(void* platform_render_arg, void* renderer_render_arg)
|
||||||
{
|
{
|
||||||
if (!(ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_EnableViewports))
|
if (!(ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_EnableViewports))
|
||||||
return;
|
return;
|
||||||
|
6
imgui.h
6
imgui.h
@ -551,7 +551,7 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiPlatformData* GetPlatformData(); // List of viewports. Viewport 0 is always the main viewport, followed by the secondary viewports.
|
IMGUI_API ImGuiPlatformData* GetPlatformData(); // List of viewports. Viewport 0 is always the main viewport, followed by the secondary viewports.
|
||||||
IMGUI_API ImGuiViewport* GetMainViewport(); // GetPlatformData()->MainViewport
|
IMGUI_API ImGuiViewport* GetMainViewport(); // GetPlatformData()->MainViewport
|
||||||
IMGUI_API void UpdatePlatformWindows(); // Call in main loop. Create/Destroy/Resize platform windows so there's one for each viewport
|
IMGUI_API void UpdatePlatformWindows(); // Call in main loop. Create/Destroy/Resize platform windows so there's one for each viewport
|
||||||
IMGUI_API void RenderPlatformWindows(void* platform_render_arg, void* renderer_render_arg); // Call in main loop. Call RenderWindow/SwapBuffers from the ImGuiPlatformIO structure. May be reimplemented by user.
|
IMGUI_API void RenderPlatformWindowsDefault(void* platform_render_arg = NULL, void* renderer_render_arg = NULL); // Call in main loop. Call RenderWindow/SwapBuffers from the ImGuiPlatformIO structure. May be reimplemented by user.
|
||||||
IMGUI_API void DestroyPlatformWindows(); // (Optional) Call in back-end shutdown if you need to close Platform Windows before imgui shutdown.
|
IMGUI_API void DestroyPlatformWindows(); // (Optional) Call in back-end shutdown if you need to close Platform Windows before imgui shutdown.
|
||||||
IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle);
|
IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle);
|
||||||
|
|
||||||
@ -1878,8 +1878,8 @@ struct ImFont
|
|||||||
// This is designed so we can mix and match two imgui_impl_xxxx files, one for the Platform (~ Windowing), one for Renderer.
|
// This is designed so we can mix and match two imgui_impl_xxxx files, one for the Platform (~ Windowing), one for Renderer.
|
||||||
// Custom engine back-ends will often provide both Platform and Renderer interfaces and thus may not need to use all functions.
|
// Custom engine back-ends will often provide both Platform and Renderer interfaces and thus may not need to use all functions.
|
||||||
// Platform functions are typically called before their Renderer counterpart, apart from Destroy which are called the other way.
|
// Platform functions are typically called before their Renderer counterpart, apart from Destroy which are called the other way.
|
||||||
// RenderPlatformWindows() basically iterate secondary viewports and call Platform+Renderer's RenderWindow then Platform+Renderer's SwapBuffers,
|
// RenderPlatformWindowsDefault() basically iterate secondary viewports and call Platform+Renderer's RenderWindow then Platform+Renderer's SwapBuffers,
|
||||||
// You may skip using RenderPlatformWindows() and call your functions yourself if you need specific behavior for your multi-window rendering.
|
// You may skip using RenderPlatformWindowsDefault() and call your draw/swap functions yourself if you need specific behavior for your multi-window rendering.
|
||||||
struct ImGuiPlatformIO
|
struct ImGuiPlatformIO
|
||||||
{
|
{
|
||||||
// Platform (e.g. Win32, GLFW, SDL2)
|
// Platform (e.g. Win32, GLFW, SDL2)
|
||||||
|
Loading…
Reference in New Issue
Block a user