Browse Source

prevent too early mouse position storing

Kajetan Johannes Hammerle 2 years ago
parent
commit
7d540db7f2
2 changed files with 6 additions and 1 deletions
  1. 4 1
      rendering/Window.cpp
  2. 2 0
      rendering/Window.h

+ 4 - 1
rendering/Window.cpp

@@ -293,12 +293,15 @@ void Window::endFrame() {
 
 void Window::tick() {
     tps.update();
-    lastMousePosition = mousePosition;
     for(Button& b : buttons) {
         b.tick();
     }
 }
 
+void Window::postTick() {
+    lastMousePosition = mousePosition;
+}
+
 void Window::Input::setLimit(int l) {
     inputLimit = l;
     while(input.getLength() > inputLimit) {

+ 2 - 0
rendering/Window.h

@@ -43,6 +43,7 @@ namespace Window {
     Clock::Nanos startFrame();
     void endFrame();
     void tick();
+    void postTick();
 
     template<ShouldRun SR, Tick T, Render R>
     void run(Clock::Nanos nanosPerTick) {
@@ -53,6 +54,7 @@ namespace Window {
                 lag -= nanosPerTick;
                 tick();
                 T();
+                postTick();
             }
             R(static_cast<float>(lag) / nanosPerTick);
             endFrame();