Browse Source

Fix mouse coordinates

rexim 3 years ago
parent
commit
25c2ffe455
1 changed files with 3 additions and 5 deletions
  1. 3 5
      main.c

+ 3 - 5
main.c

@@ -552,14 +552,12 @@ int main(void)
         glfwGetWindowSize(window, &width, &height);
         glfwGetWindowSize(window, &width, &height);
         double xpos, ypos;
         double xpos, ypos;
         glfwGetCursorPos(window, &xpos, &ypos);
         glfwGetCursorPos(window, &xpos, &ypos);
+        xpos = xpos - width * 0.5f;
+        ypos = (height - ypos) - height * 0.5f;
 
 
         if (!global_renderer.reload_failed) {
         if (!global_renderer.reload_failed) {
-            r_sync_uniforms(r,
-                            width, height,
-                            time,
-                            xpos, height - ypos);
-
             r_clear(r);
             r_clear(r);
+            r_sync_uniforms(r, width, height, time, xpos, ypos);
             r_quad_cr(
             r_quad_cr(
                 r,
                 r,
                 v2ff(0.0f),
                 v2ff(0.0f),