mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-11-04 09:44:29 +00:00 
			
		
		
		
	Examples: OpenGL: Tentative fix for miscaled call to glViewport on high-DPI screens (#441)
Fix for 980ca286fe
			
			
This commit is contained in:
		@@ -60,11 +60,12 @@ void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
 | 
					    // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
 | 
				
			||||||
    ImGuiIO& io = ImGui::GetIO();
 | 
					    ImGuiIO& io = ImGui::GetIO();
 | 
				
			||||||
    float fb_height = io.DisplaySize.y * io.DisplayFramebufferScale.y;
 | 
					    int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
 | 
				
			||||||
 | 
					    int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
 | 
				
			||||||
    draw_data->ScaleClipRects(io.DisplayFramebufferScale);
 | 
					    draw_data->ScaleClipRects(io.DisplayFramebufferScale);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Setup viewport, orthographic projection matrix
 | 
					    // Setup viewport, orthographic projection matrix
 | 
				
			||||||
    glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
 | 
					    glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
 | 
				
			||||||
    const float ortho_projection[4][4] =
 | 
					    const float ortho_projection[4][4] =
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        { 2.0f/io.DisplaySize.x, 0.0f,                   0.0f, 0.0f },
 | 
					        { 2.0f/io.DisplaySize.x, 0.0f,                   0.0f, 0.0f },
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,11 +46,12 @@ void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
 | 
					    // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
 | 
				
			||||||
    ImGuiIO& io = ImGui::GetIO();
 | 
					    ImGuiIO& io = ImGui::GetIO();
 | 
				
			||||||
    float fb_height = io.DisplaySize.y * io.DisplayFramebufferScale.y;
 | 
					    int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
 | 
				
			||||||
 | 
					    int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
 | 
				
			||||||
    draw_data->ScaleClipRects(io.DisplayFramebufferScale);
 | 
					    draw_data->ScaleClipRects(io.DisplayFramebufferScale);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Setup viewport, orthographic projection matrix
 | 
					    // Setup viewport, orthographic projection matrix
 | 
				
			||||||
    glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
 | 
					    glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
 | 
				
			||||||
    glMatrixMode(GL_PROJECTION);
 | 
					    glMatrixMode(GL_PROJECTION);
 | 
				
			||||||
    glPushMatrix();
 | 
					    glPushMatrix();
 | 
				
			||||||
    glLoadIdentity();
 | 
					    glLoadIdentity();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,11 +55,12 @@ void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
 | 
						// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
 | 
				
			||||||
	ImGuiIO& io = ImGui::GetIO();
 | 
						ImGuiIO& io = ImGui::GetIO();
 | 
				
			||||||
	float fb_height = io.DisplaySize.y * io.DisplayFramebufferScale.y;
 | 
					    int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
 | 
				
			||||||
 | 
					    int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
 | 
				
			||||||
	draw_data->ScaleClipRects(io.DisplayFramebufferScale);
 | 
						draw_data->ScaleClipRects(io.DisplayFramebufferScale);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Setup orthographic projection matrix
 | 
						// Setup orthographic projection matrix
 | 
				
			||||||
    glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
 | 
					    glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
 | 
				
			||||||
	const float ortho_projection[4][4] =
 | 
						const float ortho_projection[4][4] =
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		{ 2.0f/io.DisplaySize.x, 0.0f,                   0.0f, 0.0f },
 | 
							{ 2.0f/io.DisplaySize.x, 0.0f,                   0.0f, 0.0f },
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,11 +39,12 @@ void ImGui_ImplSdl_RenderDrawLists(ImDrawData* draw_data)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
 | 
					    // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
 | 
				
			||||||
    ImGuiIO& io = ImGui::GetIO();
 | 
					    ImGuiIO& io = ImGui::GetIO();
 | 
				
			||||||
    float fb_height = io.DisplaySize.y * io.DisplayFramebufferScale.y;
 | 
					    int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
 | 
				
			||||||
 | 
					    int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
 | 
				
			||||||
    draw_data->ScaleClipRects(io.DisplayFramebufferScale);
 | 
					    draw_data->ScaleClipRects(io.DisplayFramebufferScale);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Setup viewport, orthographic projection matrix
 | 
					    // Setup viewport, orthographic projection matrix
 | 
				
			||||||
    glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
 | 
					    glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
 | 
				
			||||||
    glMatrixMode(GL_PROJECTION);
 | 
					    glMatrixMode(GL_PROJECTION);
 | 
				
			||||||
    glPushMatrix();
 | 
					    glPushMatrix();
 | 
				
			||||||
    glLoadIdentity();
 | 
					    glLoadIdentity();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user