ソースを参照

Hopefully fixed high DPI display mouse mapping #74

vurtun 9 年 前
コミット
bbe282a272
5 ファイル変更10 行追加10 行削除
  1. 2 2
      demo/glfw/nuklear_glfw.c
  2. 2 2
      example/calculator.c
  3. 2 2
      example/extended.c
  4. 2 2
      example/node_editor.c
  5. 2 2
      example/overview.c

+ 2 - 2
demo/glfw/nuklear_glfw.c

@@ -356,8 +356,8 @@ nk_glfw3_new_frame(void)
     }
 
     glfwGetCursorPos(win, &x, &y);
-    x *= (double)(int)((float)glfw.width/(float)glfw.display_width);
-    y *= (double)(int)((float)glfw.height/(float)glfw.display_height);
+    x *= (double)(int)((float)glfw.display_width/(float)glfw.width);
+    y *= (double)(int)((float)glfw.display_height/(float)glfw.height);
     nk_input_motion(ctx, (int)x, (int)y);
 
     nk_input_button(ctx, NK_BUTTON_LEFT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS);

+ 2 - 2
example/calculator.c

@@ -350,8 +350,8 @@ int main(int argc, char *argv[])
             nk_input_key(&ctx, NK_KEY_SHIFT, 0);
         }
         glfwGetCursorPos(win, &x, &y);
-        x *= (double)(int)((float)width/(float)display_width);
-        y *= (double)(int)((float)height/(float)display_height);
+        x *= (double)(int)((float)display_width/(float)width);
+        y *= (double)(int)((float)display_height/(float)height);
 
         nk_input_motion(&ctx, (int)x, (int)y);
         nk_input_button(&ctx, NK_BUTTON_LEFT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS);

+ 2 - 2
example/extended.c

@@ -857,8 +857,8 @@ int main(int argc, char *argv[])
             nk_input_key(&ctx, NK_KEY_SHIFT, 0);
         }
         glfwGetCursorPos(win, &x, &y);
-        x *= (double)(int)((float)width/(float)display_width);
-        y *= (double)(int)((float)height/(float)display_height);
+        x *= (double)(int)((float)display_width/(float)width);
+        y *= (double)(int)((float)display_height/(float)height);
 
         nk_input_motion(&ctx, (int)x, (int)y);
         nk_input_button(&ctx, NK_BUTTON_LEFT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS);

+ 2 - 2
example/node_editor.c

@@ -697,8 +697,8 @@ int main(int argc, char *argv[])
             nk_input_key(&ctx, NK_KEY_SHIFT, 0);
         }
         glfwGetCursorPos(win, &x, &y);
-        x *= (double)(int)((float)width/(float)display_width);
-        y *= (double)(int)((float)height/(float)display_height);
+        x *= (double)(int)((float)display_width/(float)width);
+        y *= (double)(int)((float)display_height/(float)height);
 
         nk_input_motion(&ctx, (int)x, (int)y);
         nk_input_button(&ctx, NK_BUTTON_LEFT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS);

+ 2 - 2
example/overview.c

@@ -1446,8 +1446,8 @@ int main(int argc, char *argv[])
             nk_input_key(&ctx, NK_KEY_SHIFT, 0);
         }
         glfwGetCursorPos(win, &x, &y);
-        x *= (double)(int)((float)width/(float)display_width);
-        y *= (double)(int)((float)height/(float)display_height);
+        x *= (double)(int)((float)display_width/(float)width);
+        y *= (double)(int)((float)display_height/(float)height);
 
         nk_input_motion(&ctx, (int)x, (int)y);
         nk_input_button(&ctx, NK_BUTTON_LEFT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS);