Browse Source

only do DPI scale if we are in high DPI mode.

Jeff Myers 1 year ago
parent
commit
99e52088ec
1 changed files with 17 additions and 5 deletions
  1. 17 5
      rlImGui.cpp

+ 17 - 5
rlImGui.cpp

@@ -110,8 +110,11 @@ static void ImGuiNewFrame(float deltaTime)
         io.DisplaySize.y = float(GetScreenHeight());
     }
     
-    const Vector2 resolutionScale = GetWindowScaleDPI();
+    Vector2 resolutionScale = GetWindowScaleDPI();
     
+    if (!IsWindowState(FLAG_WINDOW_HIGHDPI))
+        resolutionScale = Vector2{ 1,1 };
+
     io.DisplayFramebufferScale = ImVec2(resolutionScale.x, resolutionScale.y);
 
     io.DeltaTime = deltaTime;
@@ -215,10 +218,19 @@ static void EnableScissor(float x, float y, float width, float height)
 {
     rlEnableScissorTest();
     ImGuiIO& io = ImGui::GetIO();
-    rlScissor((int)(x * io.DisplayFramebufferScale.x),
-        int((io.DisplaySize.y - (int)(y + height)) * io.DisplayFramebufferScale.y),
-        (int)(width * io.DisplayFramebufferScale.x),
-        (int)(height * io.DisplayFramebufferScale.y));
+
+    ImVec2 scale = io.DisplayFramebufferScale;
+
+    if (!IsWindowState(FLAG_WINDOW_HIGHDPI))
+    {
+        scale.x = 1;
+        scale.y = 1;
+    }
+
+    rlScissor((int)(x * scale.x),
+        int((io.DisplaySize.y - (int)(y + height)) * scale.y),
+        (int)(width * scale.x),
+        (int)(height * scale.y));
 }
 
 static void SetupMouseCursors()