gl: add texture filter selection
authorkub <derkub@gmail.com>
Tue, 20 May 2025 19:47:34 +0000 (21:47 +0200)
committerkub <derkub@gmail.com>
Tue, 20 May 2025 19:49:38 +0000 (21:49 +0200)
gl.c
gl.h
plat_sdl.c
plat_sdl.h

diff --git a/gl.c b/gl.c
index 975520e..9c1fbfc 100644 (file)
--- a/gl.c
+++ b/gl.c
@@ -144,8 +144,9 @@ int gl_init(void *display, void *window, int *quirks, int w, int h)
                goto out;
 
        // no mipmaps
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+       ret = *quirks & GL_QUIRK_SCALING_NEAREST ? GL_NEAREST : GL_LINEAR;
+       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ret);
+       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ret);
 
        //glViewport(0, 0, 512, 512);
        glLoadIdentity();
diff --git a/gl.h b/gl.h
index 760960d..86475e2 100644 (file)
--- a/gl.h
+++ b/gl.h
@@ -40,5 +40,6 @@ static __inline void gl_finish(void) {}
 #endif
 
 #define GL_QUIRK_ACTIVATE_RECREATE 1
+#define GL_QUIRK_SCALING_NEAREST 2
 
 #endif // LIBPICOFE_GL_H
index 2dd5368..c4f8fa9 100644 (file)
@@ -395,4 +395,11 @@ int plat_sdl_is_fullscreen(void)
   // consider window title bar and screen menu here
   return window_w >= fs_w && window_h >= fs_h - 2*window_b;
 }
+
+void plat_sdl_gl_scaling(int type)
+{
+  gl_quirks &= ~GL_QUIRK_SCALING_NEAREST;
+  if (type == 0)
+    gl_quirks |= GL_QUIRK_SCALING_NEAREST;
+}
 // vim:shiftwidth=2:expandtab
index e0513e3..c23cd66 100644 (file)
@@ -13,4 +13,5 @@ int plat_sdl_is_fullscreen(void);
 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_finish(void);