From 72de1d45f8d6ca0f86379be65e59892402d9c71f Mon Sep 17 00:00:00 2001 From: apartfromtime <42292382+apartfromtime@users.noreply.github.com> Date: Mon, 18 Mar 2024 11:11:47 +1100 Subject: [PATCH 1/2] Texture filtering options for OpenGL and Software video modes Add renderer specific menu options. --- src/client/menu/videomenu.c | 96 +++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 24 deletions(-) diff --git a/src/client/menu/videomenu.c b/src/client/menu/videomenu.c index ca76eddb..bbb3f652 100644 --- a/src/client/menu/videomenu.c +++ b/src/client/menu/videomenu.c @@ -182,17 +182,33 @@ ResetDefaults(void *unused) static void ApplyFilter(void* unused) { - if (s_filter_list.curvalue == 0) + if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0 || + Q_stricmp(vid_renderer->string, "gl1") == 0) { - Cvar_Set("gl_texturemode", "GL_NEAREST"); + if (s_filter_list.curvalue == 0) + { + Cvar_Set("gl_texturemode", "GL_NEAREST"); + } + else if (s_filter_list.curvalue == 1) + { + Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST"); + } + else if (s_filter_list.curvalue == 2) + { + Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_LINEAR"); + } } - else if (s_filter_list.curvalue == 1) + + if (Q_stricmp(vid_renderer->string, "soft") == 0) { - Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST"); - } - else if (s_filter_list.curvalue == 2) - { - Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_LINEAR"); + if (s_filter_list.curvalue == 0) + { + Cvar_Set("sw_texture_filtering", "0"); + } + else if (s_filter_list.curvalue == 1) + { + Cvar_Set("sw_texture_filtering", "1"); + } } } @@ -397,6 +413,12 @@ VID_MenuInit(void) 0 }; + static const char *onoff_names[] = { + "off", + "on", + 0 + }; + static const char *yesno_names[] = { "no", "yes", @@ -692,29 +714,51 @@ VID_MenuInit(void) pow(2, s_msaa_list.curvalue) <= gl_msaa_samples->value); s_msaa_list.curvalue--; } - + s_filter_list.generic.type = MTYPE_SPINCONTROL; s_filter_list.generic.name = "texture filter"; - s_filter_list.generic.x = 0; - s_filter_list.generic.y = (y += 10); - s_filter_list.itemnames = filter_names; s_filter_list.curvalue = 0; s_filter_list.generic.callback = ApplyFilter; - const char* filter = Cvar_VariableString("gl_texturemode"); - int mode = 3; + const char* filter = NULL; + int mode = 0; + + if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0 || + Q_stricmp(vid_renderer->string, "gl1") == 0) + { + s_filter_list.generic.x = 0; + s_filter_list.generic.y = (y += 10); + s_filter_list.itemnames = filter_names; + + filter = Cvar_VariableString("gl_texturemode"); + mode = 3; - if (Q_stricmp(filter, "GL_NEAREST") == 0) + if (Q_stricmp(filter, "GL_NEAREST") == 0) + { + mode = 0; + } + else if (Q_stricmp(filter, "GL_LINEAR_MIPMAP_NEAREST") == 0) + { + mode = 1; + } + else if (Q_stricmp(filter, "GL_LINEAR_MIPMAP_LINEAR") == 0) + { + mode = 2; + } + } + else if (Q_stricmp(vid_renderer->string, "soft") == 0) { + s_filter_list.generic.x = 0; + s_filter_list.generic.y = (y += 10); + s_filter_list.itemnames = onoff_names; + + filter = Cvar_VariableString("sw_texture_filtering"); mode = 0; - } - else if (Q_stricmp(filter, "GL_LINEAR_MIPMAP_NEAREST") == 0) - { - mode = 1; - } - else if (Q_stricmp(filter, "GL_LINEAR_MIPMAP_LINEAR") == 0) - { - mode = 2; + + if (Q_stricmp(filter, "1") == 0) + { + mode = 1; + } } s_filter_list.curvalue = mode; @@ -765,7 +809,11 @@ VID_MenuInit(void) Menu_AddItem(&s_opengl_menu, (void *)&s_vsync_list); Menu_AddItem(&s_opengl_menu, (void *)&s_af_list); Menu_AddItem(&s_opengl_menu, (void *)&s_msaa_list); - Menu_AddItem(&s_opengl_menu, (void *)&s_filter_list); + if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0 || + Q_stricmp(vid_renderer->string, "gl1") == 0 || Q_stricmp(vid_renderer->string, "soft") == 0) + { + Menu_AddItem(&s_opengl_menu, (void *)&s_filter_list); + } Menu_AddItem(&s_opengl_menu, (void *)&s_defaults_action); Menu_AddItem(&s_opengl_menu, (void *)&s_apply_action); From 26194c76cfe7aa596bcddb9fa2d88519e125595b Mon Sep 17 00:00:00 2001 From: apartfromtime <42292382+apartfromtime@users.noreply.github.com> Date: Mon, 18 Mar 2024 12:19:35 +1100 Subject: [PATCH 2/2] Fix software dithering Rounding view angles to degrees fixes undefined software texture filter behaviour. --- src/client/refresh/soft/sw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index 641e1cc9..47b738ce 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -1332,7 +1332,7 @@ RE_RenderFrame (refdef_t *fd) // compare current position with old if (vid_buffer_width <= 640 || !VectorCompareRound(fd->vieworg, lastvieworg) || - !VectorCompare(fd->viewangles, lastviewangles)) + !VectorCompareRound(fd->viewangles, lastviewangles)) { fastmoving = true; }