diff options
author | dec05eba <dec05eba@protonmail.com> | 2023-08-25 11:03:02 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2023-08-25 11:03:02 +0200 |
commit | 5e50a5249f089f44b568e7dd4ba0782521e67e0b (patch) | |
tree | 90ccbe16b5df0d72d14a3fc82d9eb3940d0eaf39 /src/window | |
parent | a6c350cd014fc57cefc4beb6698ac80781ca028c (diff) |
Dont enable low latency mode by default since it increases cpu usage
Diffstat (limited to 'src/window')
-rw-r--r-- | src/window/window.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/window/window.c b/src/window/window.c index d0c9cc0..00bcf57 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -487,6 +487,7 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window self->monitors = NULL; self->num_monitors = 0; self->pos = (mgl_vec2i){ 0, 0 }; + self->low_latency = false; mgl_vec2i window_size = params ? params->size : (mgl_vec2i){ 0, 0 }; if(window_size.x <= 0 || window_size.y <= 0) { @@ -1190,8 +1191,10 @@ bool mgl_window_poll_event(mgl_window *self, mgl_event *event) { void mgl_window_display(mgl_window *self) { mgl_context *context = mgl_get_context(); context->gl.glXSwapBuffers(context->connection, self->window); - context->gl.glFlush(); - context->gl.glFinish(); + if(self->low_latency) { + context->gl.glFlush(); + context->gl.glFinish(); + } if(self->frame_time_limit > 0.000001) { double time_left_to_sleep = self->frame_time_limit - mgl_clock_get_elapsed_time_seconds(&self->frame_timer); @@ -1368,6 +1371,14 @@ bool mgl_window_is_fullscreen(const mgl_window *self) { return is_fullscreen; } +void mgl_window_set_low_latency(mgl_window *self, bool low_latency) { + self->low_latency = low_latency; +} + +bool mgl_window_is_low_latency_enabled(const mgl_window *self) { + return self->low_latency; +} + void mgl_window_set_position(mgl_window *self, mgl_vec2i position) { XMoveWindow(mgl_get_context()->connection, self->window, position.x, position.y); } |