increase update rate

This commit is contained in:
Crispy 2023-04-16 18:58:45 +02:00
parent e73e9b12f8
commit 895bec3bd5
3 changed files with 10 additions and 2 deletions

View file

@ -8,6 +8,7 @@
App::App() App::App()
{ {
_tracking_origin = vr::TrackingUniverseStanding; _tracking_origin = vr::TrackingUniverseStanding;
_frames_since_framebuffer = 999;
InitOVR(); InitOVR();
InitX11(); InitX11();
@ -152,6 +153,7 @@ void App::Update()
panel.Update(); panel.Update();
} }
} }
_frames_since_framebuffer += 1;
} }
void App::UpdateInput() void App::UpdateInput()
@ -185,6 +187,11 @@ void App::UpdateInput()
void App::UpdateFramebuffer() void App::UpdateFramebuffer()
{ {
if (_frames_since_framebuffer < 2)
{
return;
}
_frames_since_framebuffer = 0;
auto frame = XGetImage( auto frame = XGetImage(
_xdisplay, _xdisplay,
_root_window, _root_window,

View file

@ -50,6 +50,7 @@ class App
Window _root_window; Window _root_window;
GLFWwindow *_gl_window; GLFWwindow *_gl_window;
GLuint _gl_frame; GLuint _gl_frame;
int _frames_since_framebuffer;
int _root_width; int _root_width;
int _root_height; int _root_height;

View file

@ -1,7 +1,7 @@
#include "app.h" #include "app.h"
#include <signal.h> #include <signal.h>
#define FRAMERATE 30 #define UPDATE_RATE 60
bool should_exit = false; bool should_exit = false;
@ -19,7 +19,7 @@ int main()
while (!should_exit) while (!should_exit)
{ {
app.Update(); app.Update();
usleep(1000000 / FRAMERATE); usleep(1000000 / UPDATE_RATE);
} }
printf("\nShutting down\n"); printf("\nShutting down\n");
return 0; return 0;