From 2f54ceb96e3df96df74edef983debf6c23f1c074 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 19 Aug 2023 13:56:15 +0200 Subject: [PATCH] port: add texture filter setting --- port/fast3d/gfx_opengl.cpp | 2 +- port/fast3d/gfx_rendering_api.h | 2 +- port/src/config.c | 1 + port/src/video.c | 4 ++++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/port/fast3d/gfx_opengl.cpp b/port/fast3d/gfx_opengl.cpp index be7634553..9cb4eb08f 100644 --- a/port/fast3d/gfx_opengl.cpp +++ b/port/fast3d/gfx_opengl.cpp @@ -744,7 +744,7 @@ static uint32_t gfx_cm_to_opengl(uint32_t val) { } static void gfx_opengl_set_sampler_parameters(int tile, bool linear_filter, uint32_t cms, uint32_t cmt) { - const GLint filter = linear_filter && current_filter_mode == FILTER_LINEAR ? GL_LINEAR : GL_NEAREST; + const GLint filter = linear_filter && (current_filter_mode != FILTER_NONE) ? GL_LINEAR : GL_NEAREST; glActiveTexture(GL_TEXTURE0 + tile); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); diff --git a/port/fast3d/gfx_rendering_api.h b/port/fast3d/gfx_rendering_api.h index 0831d3e1e..b600749c2 100644 --- a/port/fast3d/gfx_rendering_api.h +++ b/port/fast3d/gfx_rendering_api.h @@ -12,7 +12,7 @@ struct GfxClipParameters { bool invert_y; }; -enum FilteringMode { FILTER_THREE_POINT, FILTER_LINEAR, FILTER_NONE }; +enum FilteringMode { FILTER_NONE, FILTER_LINEAR, FILTER_THREE_POINT }; struct GfxRenderingAPI { const char* (*get_name)(void); diff --git a/port/src/config.c b/port/src/config.c index 5d91c08b1..dd9720fa8 100644 --- a/port/src/config.c +++ b/port/src/config.c @@ -33,6 +33,7 @@ struct configentry { { "Video.VSync", CONFIG_S32, { .s32val = 1 } }, { "Video.FramerateLimit", CONFIG_S32, { .s32val = 0 } }, { "Video.FovY", CONFIG_F32, { .f32val = 60.f } }, + { "Video.TextureFilter", CONFIG_S32, { .s32val = 1 } }, /* Audio */ { "Audio.BufferSize", CONFIG_S32, { .s32val = 512 } }, { "Audio.QueueLimit", CONFIG_S32, { .s32val = 8192 } }, diff --git a/port/src/video.c b/port/src/video.c index 87a5e4aa7..a8a790433 100644 --- a/port/src/video.c +++ b/port/src/video.c @@ -41,6 +41,10 @@ s32 videoInit(void) wmAPI->set_swap_interval(configGetInt("Video.VSync", 1)); wmAPI->set_target_fps(configGetInt("Video.FramerateLimit", 0)); // disabled because vsync is on + u32 filter = configGetInt("Video.TextureFilter", FILTER_LINEAR); + if (filter > FILTER_THREE_POINT) filter = FILTER_THREE_POINT; + renderingAPI->set_texture_filter((enum FilteringMode)filter); + initDone = true; return 0; }