Merge pull request #1091 from apartfromtime/Texture-filter-menu-option

Texture filtering options for OpenGL and Software video modes
This commit is contained in:
Yamagi 2024-03-19 19:24:41 +01:00 committed by GitHub
commit 9569f41c3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 73 additions and 25 deletions

View file

@ -188,6 +188,9 @@ ResetDefaults(void *unused)
static void static void
ApplyFilter(void* unused) ApplyFilter(void* unused)
{
if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0 ||
Q_stricmp(vid_renderer->string, "gl1") == 0)
{ {
if (s_filter_list.curvalue == 0) if (s_filter_list.curvalue == 0)
{ {
@ -203,6 +206,19 @@ ApplyFilter(void* unused)
} }
} }
if (Q_stricmp(vid_renderer->string, "soft") == 0)
{
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");
}
}
}
static void static void
ApplyChanges(void *unused) ApplyChanges(void *unused)
{ {
@ -404,6 +420,12 @@ VID_MenuInit(void)
0 0
}; };
static const char *onoff_names[] = {
"off",
"on",
0
};
static const char *yesno_names[] = { static const char *yesno_names[] = {
"no", "no",
"yes", "yes",
@ -702,14 +724,21 @@ VID_MenuInit(void)
s_filter_list.generic.type = MTYPE_SPINCONTROL; s_filter_list.generic.type = MTYPE_SPINCONTROL;
s_filter_list.generic.name = "texture filter"; 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.curvalue = 0;
s_filter_list.generic.callback = ApplyFilter; s_filter_list.generic.callback = ApplyFilter;
const char* filter = Cvar_VariableString("gl_texturemode"); const char* filter = NULL;
int mode = 3; 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)
{ {
@ -723,6 +752,21 @@ VID_MenuInit(void)
{ {
mode = 2; 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;
if (Q_stricmp(filter, "1") == 0)
{
mode = 1;
}
}
s_filter_list.curvalue = mode; s_filter_list.curvalue = mode;
@ -772,7 +816,11 @@ VID_MenuInit(void)
Menu_AddItem(&s_opengl_menu, (void *)&s_vsync_list); 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_af_list);
Menu_AddItem(&s_opengl_menu, (void *)&s_msaa_list); Menu_AddItem(&s_opengl_menu, (void *)&s_msaa_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_filter_list);
}
Menu_AddItem(&s_opengl_menu, (void *)&s_defaults_action); Menu_AddItem(&s_opengl_menu, (void *)&s_defaults_action);
Menu_AddItem(&s_opengl_menu, (void *)&s_apply_action); Menu_AddItem(&s_opengl_menu, (void *)&s_apply_action);

View file

@ -1332,7 +1332,7 @@ RE_RenderFrame (refdef_t *fd)
// compare current position with old // compare current position with old
if (vid_buffer_width <= 640 || if (vid_buffer_width <= 640 ||
!VectorCompareRound(fd->vieworg, lastvieworg) || !VectorCompareRound(fd->vieworg, lastvieworg) ||
!VectorCompare(fd->viewangles, lastviewangles)) !VectorCompareRound(fd->viewangles, lastviewangles))
{ {
fastmoving = true; fastmoving = true;
} }