gl: allow to control vsync
authornotaz <notasas@gmail.com>
Tue, 20 May 2025 21:21:58 +0000 (00:21 +0300)
committerkub <derkub@gmail.com>
Thu, 22 May 2025 20:04:50 +0000 (22:04 +0200)
gl.c
gl.h
plat_sdl.c
plat_sdl.h

diff --git a/gl.c b/gl.c
index 9c1fbfc..4040b7e 100644 (file)
--- 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 (file)
--- 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
index c4f8fa9..17a1f03 100644 (file)
@@ -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
index c23cd66..3680a39 100644 (file)
@@ -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);