From 0b3abad8f26387751620949e587eec4ae4cce2d6 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 21 May 2025 00:21:58 +0300 Subject: [PATCH] gl: allow to control vsync --- gl.c | 3 +++ gl.h | 1 + plat_sdl.c | 8 ++++++++ plat_sdl.h | 1 + 4 files changed, 13 insertions(+) diff --git a/gl.c b/gl.c index 9c1fbfc..4040b7e 100644 --- a/gl.c +++ b/gl.c @@ -123,6 +123,9 @@ int gl_init(void *display, void *window, int *quirks, int w, int h) fprintf(stderr, "eglMakeCurrent: %x\n", eglGetError()); goto out; } + + ret = *quirks & GL_QUIRK_VSYNC_ON ? 1 : 0; + eglSwapInterval(edpy, ret); // 1.x (fixed-function) only glEnable(GL_TEXTURE_2D); diff --git a/gl.h b/gl.h index 86475e2..bf8ee0d 100644 --- a/gl.h +++ b/gl.h @@ -41,5 +41,6 @@ static __inline void gl_finish(void) {} #define GL_QUIRK_ACTIVATE_RECREATE 1 #define GL_QUIRK_SCALING_NEAREST 2 +#define GL_QUIRK_VSYNC_ON 4 #endif // LIBPICOFE_GL_H diff --git a/plat_sdl.c b/plat_sdl.c index c4f8fa9..17a1f03 100644 --- a/plat_sdl.c +++ b/plat_sdl.c @@ -402,4 +402,12 @@ void plat_sdl_gl_scaling(int type) if (type == 0) gl_quirks |= GL_QUIRK_SCALING_NEAREST; } + +void plat_sdl_gl_vsync(int on) +{ + gl_quirks &= ~GL_QUIRK_VSYNC_ON; + if (on) + gl_quirks |= GL_QUIRK_VSYNC_ON; +} + // vim:shiftwidth=2:expandtab diff --git a/plat_sdl.h b/plat_sdl.h index c23cd66..3680a39 100644 --- a/plat_sdl.h +++ b/plat_sdl.h @@ -14,4 +14,5 @@ int plat_sdl_change_video_mode(int w, int h, int force); void plat_sdl_overlay_clear(void); void plat_sdl_event_handler(void *event_); void plat_sdl_gl_scaling(int type); +void plat_sdl_gl_vsync(int on); void plat_sdl_finish(void); -- 2.39.5