mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Refactored obtaining the renderer used
...in videomenu code. Now it allows to use switch statements, to avoid the execution of paths not meant for certain renderers.
This commit is contained in:
parent
13deb72b16
commit
b00e925d47
1 changed files with 223 additions and 175 deletions
|
@ -79,6 +79,16 @@ static menuaction_s s_apply_action;
|
||||||
// gl1, gl3, gles1, gles3, gl4, vk, soft
|
// gl1, gl3, gles1, gles3, gl4, vk, soft
|
||||||
#define MAXRENDERERS 7
|
#define MAXRENDERERS 7
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ref_custom,
|
||||||
|
ref_gl1, // encompasses gl1 and gles1
|
||||||
|
ref_gl3, // encompasses gl3 and gles3
|
||||||
|
ref_gl4,
|
||||||
|
ref_vk,
|
||||||
|
ref_soft
|
||||||
|
} renderer_type;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *boxstr;
|
const char *boxstr;
|
||||||
|
@ -195,12 +205,39 @@ ResetDefaults(void *unused)
|
||||||
#define CUSTOM_MODE_NAME "[Custom ]"
|
#define CUSTOM_MODE_NAME "[Custom ]"
|
||||||
#define AUTO_MODE_NAME "[Auto ]"
|
#define AUTO_MODE_NAME "[Auto ]"
|
||||||
|
|
||||||
|
static renderer_type
|
||||||
|
CurrentRendererByCvar(void)
|
||||||
|
{
|
||||||
|
if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0)
|
||||||
|
{
|
||||||
|
return ref_gl3;
|
||||||
|
}
|
||||||
|
if (Q_stricmp(vid_renderer->string, "gl1") == 0 || Q_stricmp(vid_renderer->string, "gles1") == 0)
|
||||||
|
{
|
||||||
|
return ref_gl1;
|
||||||
|
}
|
||||||
|
if (Q_stricmp(vid_renderer->string, "soft") == 0)
|
||||||
|
{
|
||||||
|
return ref_soft;
|
||||||
|
}
|
||||||
|
if (Q_stricmp(vid_renderer->string, "gl4") == 0)
|
||||||
|
{
|
||||||
|
return ref_gl4;
|
||||||
|
}
|
||||||
|
if (Q_stricmp(vid_renderer->string, "vk") == 0)
|
||||||
|
{
|
||||||
|
return ref_vk;
|
||||||
|
}
|
||||||
|
return ref_custom;
|
||||||
|
}
|
||||||
|
|
||||||
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 ||
|
switch (CurrentRendererByCvar())
|
||||||
Q_stricmp(vid_renderer->string, "gl1") == 0 || Q_stricmp(vid_renderer->string, "gles1") == 0)
|
|
||||||
{
|
{
|
||||||
|
case ref_gl3:
|
||||||
|
case ref_gl1:
|
||||||
if (s_filter_list.curvalue == 0)
|
if (s_filter_list.curvalue == 0)
|
||||||
{
|
{
|
||||||
Cvar_Set("gl_texturemode", "GL_NEAREST");
|
Cvar_Set("gl_texturemode", "GL_NEAREST");
|
||||||
|
@ -213,10 +250,8 @@ ApplyFilter(void* unused)
|
||||||
{
|
{
|
||||||
Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_LINEAR");
|
Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_LINEAR");
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
case ref_soft:
|
||||||
if (Q_stricmp(vid_renderer->string, "soft") == 0)
|
|
||||||
{
|
|
||||||
if (s_filter_list.curvalue == 0)
|
if (s_filter_list.curvalue == 0)
|
||||||
{
|
{
|
||||||
Cvar_Set("sw_texture_filtering", "0");
|
Cvar_Set("sw_texture_filtering", "0");
|
||||||
|
@ -225,6 +260,9 @@ ApplyFilter(void* unused)
|
||||||
{
|
{
|
||||||
Cvar_Set("sw_texture_filtering", "1");
|
Cvar_Set("sw_texture_filtering", "1");
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break; // avoid compiler warning
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,6 +450,8 @@ VID_MenuInit(void)
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderer_type current_renderer = CurrentRendererByCvar();
|
||||||
|
|
||||||
static const char *uiscale_names[] = {
|
static const char *uiscale_names[] = {
|
||||||
"auto",
|
"auto",
|
||||||
"1x",
|
"1x",
|
||||||
|
@ -569,8 +609,9 @@ VID_MenuInit(void)
|
||||||
s_fov_slider.slidestep = 1;
|
s_fov_slider.slidestep = 1;
|
||||||
s_fov_slider.printformat = "%.0f";
|
s_fov_slider.printformat = "%.0f";
|
||||||
|
|
||||||
if (strcmp(vid_renderer->string, "gl3") == 0 || strcmp(vid_renderer->string, "gles3") == 0)
|
switch (current_renderer)
|
||||||
{
|
{
|
||||||
|
case ref_gl3:
|
||||||
s_gl3_intensity_slider.generic.type = MTYPE_SLIDER;
|
s_gl3_intensity_slider.generic.type = MTYPE_SLIDER;
|
||||||
s_gl3_intensity_slider.generic.name = "color intensity";
|
s_gl3_intensity_slider.generic.name = "color intensity";
|
||||||
s_gl3_intensity_slider.generic.x = 0;
|
s_gl3_intensity_slider.generic.x = 0;
|
||||||
|
@ -594,9 +635,9 @@ VID_MenuInit(void)
|
||||||
s_gl3_colorlight_list.generic.y = (y += 10);
|
s_gl3_colorlight_list.generic.y = (y += 10);
|
||||||
s_gl3_colorlight_list.itemnames = yesno_names;
|
s_gl3_colorlight_list.itemnames = yesno_names;
|
||||||
s_gl3_colorlight_list.curvalue = (gl3_colorlight->value != 0);
|
s_gl3_colorlight_list.curvalue = (gl3_colorlight->value != 0);
|
||||||
}
|
break;
|
||||||
if (strcmp(vid_renderer->string, "gl4") == 0)
|
|
||||||
{
|
case ref_gl4:
|
||||||
s_gl4_intensity_slider.generic.type = MTYPE_SLIDER;
|
s_gl4_intensity_slider.generic.type = MTYPE_SLIDER;
|
||||||
s_gl4_intensity_slider.generic.name = "color intensity";
|
s_gl4_intensity_slider.generic.name = "color intensity";
|
||||||
s_gl4_intensity_slider.generic.x = 0;
|
s_gl4_intensity_slider.generic.x = 0;
|
||||||
|
@ -620,9 +661,9 @@ VID_MenuInit(void)
|
||||||
s_gl4_colorlight_list.generic.y = (y += 10);
|
s_gl4_colorlight_list.generic.y = (y += 10);
|
||||||
s_gl4_colorlight_list.itemnames = yesno_names;
|
s_gl4_colorlight_list.itemnames = yesno_names;
|
||||||
s_gl4_colorlight_list.curvalue = (gl4_colorlight->value != 0);
|
s_gl4_colorlight_list.curvalue = (gl4_colorlight->value != 0);
|
||||||
}
|
break;
|
||||||
else if (strcmp(vid_renderer->string, "vk") == 0)
|
|
||||||
{
|
case ref_vk:
|
||||||
s_vk_intensity_slider.generic.type = MTYPE_SLIDER;
|
s_vk_intensity_slider.generic.type = MTYPE_SLIDER;
|
||||||
s_vk_intensity_slider.generic.name = "color intensity";
|
s_vk_intensity_slider.generic.name = "color intensity";
|
||||||
s_vk_intensity_slider.generic.x = 0;
|
s_vk_intensity_slider.generic.x = 0;
|
||||||
|
@ -648,9 +689,9 @@ VID_MenuInit(void)
|
||||||
s_vk_dynamic_list.generic.y = (y += 10);
|
s_vk_dynamic_list.generic.y = (y += 10);
|
||||||
s_vk_dynamic_list.itemnames = yesno_names;
|
s_vk_dynamic_list.itemnames = yesno_names;
|
||||||
s_vk_dynamic_list.curvalue = (vk_dynamic->value != 0);
|
s_vk_dynamic_list.curvalue = (vk_dynamic->value != 0);
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
case ref_gl1:
|
||||||
gl3_colorlight = NULL;
|
gl3_colorlight = NULL;
|
||||||
s_gl1_intensity_slider.generic.type = MTYPE_SLIDER;
|
s_gl1_intensity_slider.generic.type = MTYPE_SLIDER;
|
||||||
s_gl1_intensity_slider.generic.name = "color intensity";
|
s_gl1_intensity_slider.generic.name = "color intensity";
|
||||||
|
@ -669,6 +710,10 @@ VID_MenuInit(void)
|
||||||
s_gl1_overbrightbits_slider.maxvalue = 2;
|
s_gl1_overbrightbits_slider.maxvalue = 2;
|
||||||
s_gl1_overbrightbits_slider.slidestep = 1;
|
s_gl1_overbrightbits_slider.slidestep = 1;
|
||||||
s_gl1_overbrightbits_slider.printformat = "%.0f";
|
s_gl1_overbrightbits_slider.printformat = "%.0f";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_uiscale_list.generic.type = MTYPE_SPINCONTROL;
|
s_uiscale_list.generic.type = MTYPE_SPINCONTROL;
|
||||||
|
@ -747,14 +792,15 @@ VID_MenuInit(void)
|
||||||
s_filter_list.generic.name = "texture filter";
|
s_filter_list.generic.name = "texture filter";
|
||||||
s_filter_list.curvalue = 0;
|
s_filter_list.curvalue = 0;
|
||||||
s_filter_list.generic.callback = ApplyFilter;
|
s_filter_list.generic.callback = ApplyFilter;
|
||||||
|
s_filter_list.generic.x = 0;
|
||||||
|
|
||||||
const char* filter = NULL;
|
const char* filter = NULL;
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
|
|
||||||
if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0 ||
|
switch (current_renderer)
|
||||||
Q_stricmp(vid_renderer->string, "gl1") == 0 || Q_stricmp(vid_renderer->string, "gles1") == 0)
|
|
||||||
{
|
{
|
||||||
s_filter_list.generic.x = 0;
|
case ref_gl3:
|
||||||
|
case ref_gl1:
|
||||||
s_filter_list.generic.y = (y += 10);
|
s_filter_list.generic.y = (y += 10);
|
||||||
s_filter_list.itemnames = filter_names;
|
s_filter_list.itemnames = filter_names;
|
||||||
|
|
||||||
|
@ -773,10 +819,9 @@ VID_MenuInit(void)
|
||||||
{
|
{
|
||||||
mode = 2;
|
mode = 2;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (Q_stricmp(vid_renderer->string, "soft") == 0)
|
|
||||||
{
|
case ref_soft:
|
||||||
s_filter_list.generic.x = 0;
|
|
||||||
s_filter_list.generic.y = (y += 10);
|
s_filter_list.generic.y = (y += 10);
|
||||||
s_filter_list.itemnames = onoff_names;
|
s_filter_list.itemnames = onoff_names;
|
||||||
|
|
||||||
|
@ -787,6 +832,10 @@ VID_MenuInit(void)
|
||||||
{
|
{
|
||||||
mode = 1;
|
mode = 1;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_filter_list.curvalue = mode;
|
s_filter_list.curvalue = mode;
|
||||||
|
@ -814,37 +863,36 @@ VID_MenuInit(void)
|
||||||
|
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_brightness_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_brightness_slider);
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_fov_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_fov_slider);
|
||||||
if (strcmp(vid_renderer->string, "gl3") == 0 || strcmp(vid_renderer->string, "gles3") == 0)
|
switch (current_renderer)
|
||||||
{
|
{
|
||||||
|
case ref_gl3:
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_intensity_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_intensity_slider);
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_overbrightbits_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_overbrightbits_slider);
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_colorlight_list);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_colorlight_list);
|
||||||
}
|
break;
|
||||||
else if (strcmp(vid_renderer->string, "gl4") == 0)
|
case ref_gl4:
|
||||||
{
|
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_intensity_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_intensity_slider);
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_overbrightbits_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_overbrightbits_slider);
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_colorlight_list);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_colorlight_list);
|
||||||
}
|
break;
|
||||||
else if (strcmp(vid_renderer->string, "vk") == 0)
|
case ref_vk:
|
||||||
{
|
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_vk_intensity_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_vk_intensity_slider);
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_vk_overbrightbits_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_vk_overbrightbits_slider);
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_vk_dynamic_list);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_vk_dynamic_list);
|
||||||
}
|
break;
|
||||||
else if (strcmp(vid_renderer->string, "gl1") == 0 || strcmp(vid_renderer->string, "gles1") == 0)
|
case ref_gl1:
|
||||||
{
|
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_gl1_intensity_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_gl1_intensity_slider);
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_gl1_overbrightbits_slider);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_gl1_overbrightbits_slider);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_uiscale_list);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_uiscale_list);
|
||||||
Menu_AddItem(&s_opengl_menu, (void *)&s_fs_box);
|
Menu_AddItem(&s_opengl_menu, (void *)&s_fs_box);
|
||||||
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 ||
|
if (current_renderer == ref_gl3 || current_renderer == ref_gl1 || current_renderer == ref_soft)
|
||||||
Q_stricmp(vid_renderer->string, "gl1") == 0 || Q_stricmp(vid_renderer->string, "gles1") == 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue