From 895bec3bd5b81a7261e0f01e37ee6749bfa94180 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sun, 16 Apr 2023 18:58:45 +0200 Subject: [PATCH] increase update rate --- src/app.cpp | 7 +++++++ src/app.h | 1 + src/main.cpp | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index 27c31b6..b900cbc 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -8,6 +8,7 @@ App::App() { _tracking_origin = vr::TrackingUniverseStanding; + _frames_since_framebuffer = 999; InitOVR(); InitX11(); @@ -152,6 +153,7 @@ void App::Update() panel.Update(); } } + _frames_since_framebuffer += 1; } void App::UpdateInput() @@ -185,6 +187,11 @@ void App::UpdateInput() void App::UpdateFramebuffer() { + if (_frames_since_framebuffer < 2) + { + return; + } + _frames_since_framebuffer = 0; auto frame = XGetImage( _xdisplay, _root_window, diff --git a/src/app.h b/src/app.h index 9665051..f6bd55d 100644 --- a/src/app.h +++ b/src/app.h @@ -50,6 +50,7 @@ class App Window _root_window; GLFWwindow *_gl_window; GLuint _gl_frame; + int _frames_since_framebuffer; int _root_width; int _root_height; diff --git a/src/main.cpp b/src/main.cpp index 9644184..617bcc2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ #include "app.h" #include -#define FRAMERATE 30 +#define UPDATE_RATE 60 bool should_exit = false; @@ -19,7 +19,7 @@ int main() while (!should_exit) { app.Update(); - usleep(1000000 / FRAMERATE); + usleep(1000000 / UPDATE_RATE); } printf("\nShutting down\n"); return 0;