diff options
| author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-09-10 17:33:32 +0700 |
|---|---|---|
| committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-09-10 17:33:32 +0700 |
| commit | 92c1abc665e3a77301d3e38a9785e70b7ce3efe4 (patch) | |
| tree | 0091034a51fc13f2d18d8ebf6b2219f21809a8d2 /src/Support.cpp | |
| parent | 5247e298e05a623e001f0be01238a03b61d715b8 (diff) | |
| download | blackshades-92c1abc665e3a77301d3e38a9785e70b7ce3efe4.tar.gz | |
Fix camera look
Diffstat (limited to 'src/Support.cpp')
| -rw-r--r-- | src/Support.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Support.cpp b/src/Support.cpp index 4703b14..a233dd7 100644 --- a/src/Support.cpp +++ b/src/Support.cpp @@ -25,30 +25,33 @@ void GetMouse(Point *p) { double xpos, ypos; glfwGetCursorPos(glfwGetCurrentContext(), &xpos, &ypos); - p->h = xpos; - p->v = ypos; + p->h = floor(xpos); + p->v = floor(ypos); } void GetMouseRel(Point *p) { - return GetMouse(p); + const auto window = glfwGetCurrentContext(); + glfwGetWindowSize(window, &p->h, &p->v); + p->h /= 2; + p->v /= 2; + + double xpos, ypos; + glfwGetCursorPos(window, &xpos, &ypos); + glfwSetCursorPos(window, p->h, p->v); // we shouldn't need this + p->h = floor(xpos) - p->h; + p->v = floor(ypos) - p->v; } int Button(void) { - auto window = glfwGetCurrentContext(); + const auto window = glfwGetCurrentContext(); return glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS; } -void MoveMouse(int xcoord, int ycoord, Point *mouseloc) -{ - /* TODO: mouse warp is annoying when we can just grab the mouse */ - GetMouse(mouseloc); -} - bool IsKeyDown(int key) { - auto window = glfwGetCurrentContext(); + const auto window = glfwGetCurrentContext(); return glfwGetKey(window, key) == GLFW_PRESS; } |
