mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-04 15:11:05 +01:00 
			
		
		
		
	Viewport: Misc comments following user feedbacks..
This commit is contained in:
		@@ -144,11 +144,14 @@ int main(int, char**)
 | 
			
		||||
        ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
 | 
			
		||||
 | 
			
		||||
        // 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)
 | 
			
		||||
        {
 | 
			
		||||
            GLFWwindow* backup_current_context = glfwGetCurrentContext();
 | 
			
		||||
            ImGui::UpdatePlatformWindows();
 | 
			
		||||
            ImGui::RenderPlatformWindowsDefault();
 | 
			
		||||
            glfwMakeContextCurrent(window);
 | 
			
		||||
            glfwMakeContextCurrent(backup_current_context);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        glfwSwapBuffers(window);
 | 
			
		||||
 
 | 
			
		||||
@@ -189,11 +189,14 @@ int main(int, char**)
 | 
			
		||||
        ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
 | 
			
		||||
    	
 | 
			
		||||
        // 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)
 | 
			
		||||
        {
 | 
			
		||||
            GLFWwindow* backup_current_context = glfwGetCurrentContext();
 | 
			
		||||
            ImGui::UpdatePlatformWindows();
 | 
			
		||||
            ImGui::RenderPlatformWindowsDefault();
 | 
			
		||||
            glfwMakeContextCurrent(window);
 | 
			
		||||
            glfwMakeContextCurrent(backup_current_context);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        glfwSwapBuffers(window);
 | 
			
		||||
 
 | 
			
		||||
@@ -147,11 +147,15 @@ int main(int, char**)
 | 
			
		||||
        ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
 | 
			
		||||
 | 
			
		||||
        // 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)
 | 
			
		||||
        {
 | 
			
		||||
            SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
 | 
			
		||||
            SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
 | 
			
		||||
            ImGui::UpdatePlatformWindows();
 | 
			
		||||
            ImGui::RenderPlatformWindowsDefault();
 | 
			
		||||
            SDL_GL_MakeCurrent(window, gl_context);
 | 
			
		||||
            SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        SDL_GL_SwapWindow(window);
 | 
			
		||||
 
 | 
			
		||||
@@ -188,11 +188,15 @@ int main(int, char**)
 | 
			
		||||
        ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
 | 
			
		||||
 | 
			
		||||
        // 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)
 | 
			
		||||
        {
 | 
			
		||||
            SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
 | 
			
		||||
            SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
 | 
			
		||||
            ImGui::UpdatePlatformWindows();
 | 
			
		||||
            ImGui::RenderPlatformWindowsDefault();
 | 
			
		||||
            SDL_GL_MakeCurrent(window, gl_context);
 | 
			
		||||
            SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        SDL_GL_SwapWindow(window);
 | 
			
		||||
 
 | 
			
		||||
@@ -3812,10 +3812,12 @@ void ImGui::EndFrame()
 | 
			
		||||
        viewport->LastPos = viewport->Pos;
 | 
			
		||||
        if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0.0f || viewport->Size.y <= 0.0f)
 | 
			
		||||
            continue;
 | 
			
		||||
        if (viewport->Window && !IsWindowActiveAndVisible(viewport->Window))
 | 
			
		||||
        if (viewport->Window && !IsWindowActiveAndVisible(viewport->Window)) // Will be destroyed in UpdatePlatformWindows()
 | 
			
		||||
            continue;
 | 
			
		||||
        if (i > 0)
 | 
			
		||||
            IM_ASSERT(viewport->Window != NULL);
 | 
			
		||||
 | 
			
		||||
        // Add to user-facing list
 | 
			
		||||
        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
 | 
			
		||||
@@ -7680,11 +7682,9 @@ void ImGui::UpdatePlatformWindows()
 | 
			
		||||
            DestroyPlatformWindow(viewport);
 | 
			
		||||
            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
 | 
			
		||||
        if (viewport->Size.x <= 0 || viewport->Size.y <= 0)
 | 
			
		||||
        if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0 || viewport->Size.y <= 0)
 | 
			
		||||
            continue;
 | 
			
		||||
 | 
			
		||||
        // Update common viewport flags for owned viewports
 | 
			
		||||
 
 | 
			
		||||
@@ -651,6 +651,7 @@ enum ImGuiViewportFlagsPrivate_
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// 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
 | 
			
		||||
{
 | 
			
		||||
    int                 Idx;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user