mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Viewport: Misc comments following user feedbacks..
This commit is contained in:
parent
9d0bc3f9ab
commit
a71d3c8cb3
@ -144,11 +144,14 @@ int main(int, char**)
|
|||||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Update and Render additional Platform Windows
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
|
GLFWwindow* backup_current_context = glfwGetCurrentContext();
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindowsDefault();
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(backup_current_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
@ -189,11 +189,14 @@ int main(int, char**)
|
|||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Update and Render additional Platform Windows
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
|
GLFWwindow* backup_current_context = glfwGetCurrentContext();
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindowsDefault();
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(backup_current_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
@ -147,11 +147,15 @@ int main(int, char**)
|
|||||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Update and Render additional Platform Windows
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
|
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
|
||||||
|
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindowsDefault();
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
SDL_GL_MakeCurrent(window, gl_context);
|
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
|
@ -188,11 +188,15 @@ int main(int, char**)
|
|||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Update and Render additional Platform Windows
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
|
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
|
||||||
|
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
|
||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindowsDefault();
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
SDL_GL_MakeCurrent(window, gl_context);
|
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
|
@ -3812,10 +3812,12 @@ void ImGui::EndFrame()
|
|||||||
viewport->LastPos = viewport->Pos;
|
viewport->LastPos = viewport->Pos;
|
||||||
if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0.0f || viewport->Size.y <= 0.0f)
|
if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0.0f || viewport->Size.y <= 0.0f)
|
||||||
continue;
|
continue;
|
||||||
if (viewport->Window && !IsWindowActiveAndVisible(viewport->Window))
|
if (viewport->Window && !IsWindowActiveAndVisible(viewport->Window)) // Will be destroyed in UpdatePlatformWindows()
|
||||||
continue;
|
continue;
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
IM_ASSERT(viewport->Window != NULL);
|
IM_ASSERT(viewport->Window != NULL);
|
||||||
|
|
||||||
|
// Add to user-facing list
|
||||||
g.PlatformIO.Viewports.push_back(viewport);
|
g.PlatformIO.Viewports.push_back(viewport);
|
||||||
}
|
}
|
||||||
g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because UpdatePlatformWindows() won't do it and may not even be called
|
g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because UpdatePlatformWindows() won't do it and may not even be called
|
||||||
@ -7680,11 +7682,9 @@ void ImGui::UpdatePlatformWindows()
|
|||||||
DestroyPlatformWindow(viewport);
|
DestroyPlatformWindow(viewport);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (viewport->LastFrameActive < g.FrameCount)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// New windows that appears directly in a new viewport won't always have a size on their first frame
|
// New windows that appears directly in a new viewport won't always have a size on their first frame
|
||||||
if (viewport->Size.x <= 0 || viewport->Size.y <= 0)
|
if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0 || viewport->Size.y <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Update common viewport flags for owned viewports
|
// Update common viewport flags for owned viewports
|
||||||
|
@ -651,6 +651,7 @@ enum ImGuiViewportFlagsPrivate_
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!)
|
// ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!)
|
||||||
|
// Note that every instance of ImGuiViewport is in fact a ImGuiViewportP.
|
||||||
struct ImGuiViewportP : public ImGuiViewport
|
struct ImGuiViewportP : public ImGuiViewport
|
||||||
{
|
{
|
||||||
int Idx;
|
int Idx;
|
||||||
|
Loading…
Reference in New Issue
Block a user