Skip to content

Commit

Permalink
Hopefully fixed high DPI display mouse mapping vurtun#74
Browse files Browse the repository at this point in the history
  • Loading branch information
vurtun committed Apr 27, 2016
1 parent 4d36ca4 commit bbe282a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions demo/glfw/nuklear_glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions example/calculator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions example/extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions example/node_editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions example/overview.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bbe282a

Please sign in to comment.