Browse Source

Fix division type error for highdpi calculation (#2386)

The way the highdpi value was calculated could lead to it being set to 0 or inf for certain types of window managers.
(Tiling window managers). This was caused by it trying to resize the window to a width and height of 0x0, or by having
the logical width/height of the window be smaller than the pyhsical one. This would cause the `highdpi` variable to be
set to 0, which would later cause a glfw call to be made with `inf` as an argument.
DJAntivenom 10 months ago
parent
commit
ba69acc509
1 changed files with 2 additions and 2 deletions
  1. 2 2
      include/igl/opengl/glfw/Viewer.cpp

+ 2 - 2
include/igl/opengl/glfw/Viewer.cpp

@@ -212,8 +212,8 @@ namespace glfw
     glfwGetFramebufferSize(window, &width, &height);
     int width_window, height_window;
     glfwGetWindowSize(window, &width_window, &height_window);
-    highdpiw = windowWidth/width_window;
-    highdpih = windowHeight/height_window;
+    highdpiw = (windowWidth <= 0 || width_window <= 0) ? 1 : ((double)windowWidth/width_window);
+    highdpih = (windowHeight <= 0 || height_window <= 0) ? 1 : ((double)windowHeight/height_window);
     glfw_window_size(window,width_window,height_window);
     // Initialize IGL viewer
     init();