Skip to content

Commit

Permalink
Adding menu item for multisampling
Browse files Browse the repository at this point in the history
  • Loading branch information
atsb committed Apr 19, 2023
1 parent 06b87e6 commit bc1defd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/engine/gl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ CVAR_EXTERNAL(v_vsync);
CVAR_EXTERNAL(r_filter);
CVAR_EXTERNAL(r_texturecombiner);
CVAR_EXTERNAL(r_anisotropic);
CVAR_EXTERNAL(r_multisample);
CVAR_EXTERNAL(st_flashoverlay);
CVAR_EXTERNAL(r_colorscale);

Expand Down
13 changes: 11 additions & 2 deletions src/engine/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ CVAR(v_height, 480);
CVAR(v_windowed, 1);
CVAR(v_windowborderless, 0);

CVAR_EXTERNAL(r_multisample);

SDL_Surface* screen;
int video_width;
int video_height;
Expand Down Expand Up @@ -128,8 +130,15 @@ void I_InitScreen(void) {
SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 0);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);

if (r_multisample.value > 0)
{
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
} else {
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
}

flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_ALLOW_HIGHDPI;

Expand Down
12 changes: 12 additions & 0 deletions src/engine/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,7 @@ void M_ChangeWindowed(int choice);
void M_ChangeRatio(int choice);
void M_ChangeResolution(int choice);
void M_ChangeAnisotropic(int choice);
void M_ChangeAntiAliasing(int choice);
void M_ChangeInterpolateFrames(int choice);
void M_ChangeVerticalSynchronisation(int choice);
void M_ChangeAccessibility(int choice);
Expand All @@ -1757,6 +1758,7 @@ CVAR_EXTERNAL(i_gamma);
CVAR_EXTERNAL(i_brightness);
CVAR_EXTERNAL(r_filter);
CVAR_EXTERNAL(r_anisotropic);
CVAR_EXTERNAL(r_multisample);
CVAR_EXTERNAL(i_interpolateframes);
CVAR_EXTERNAL(v_vsync);
CVAR_EXTERNAL(v_accessibility);
Expand All @@ -1768,6 +1770,7 @@ enum {
video_empty2,
filter,
anisotropic,
multisample,
windowed,
ratio,
resolution,
Expand All @@ -1787,6 +1790,7 @@ menuitem_t VideoMenu[] = {
{-1,"",0},
{2,"Filter:",M_ChangeFilter, 'f'},
{2,"Anisotropy:",M_ChangeAnisotropic, 'a'},
{2,"Antialiasing:",M_ChangeAntiAliasing, 't'},
{2,"Windowed:",M_ChangeWindowed, 'w'},
{2,"Aspect Ratio:",M_ChangeRatio, 'a'},
{2,"Resolution:",M_ChangeResolution, 'r'},
Expand All @@ -1804,6 +1808,7 @@ char* VideoHints[video_end] = {
"adjust screen gamma",
NULL,
"toggle texture filtering",
"toggle antialiasing",
"toggle blur reduction on textures",
"toggle windowed mode",
"select aspect ratio",
Expand All @@ -1819,6 +1824,7 @@ menudefault_t VideoDefault[] = {
{ &i_gamma, 0 },
{ &r_filter, 0 },
{ &r_anisotropic, 1 },
{ &r_multisample, 1 },
{ &v_windowed, 0 },
{ &i_interpolateframes, 1 },
{ &v_vsync, 1 },
Expand Down Expand Up @@ -2019,6 +2025,7 @@ void M_DrawVideo(void) {
static const char* ratioName[5] = { "4 : 3", "16 : 9", "16 : 10", "5 : 4", "21 : 09"};
static const char* frametype[2] = { "Off", "On" };
static const char* vsynctype[2] = { "Off", "Adaptive" };
static const char* multisampletype[2] = { "4", "Off"};
char res[16];
int y;

Expand Down Expand Up @@ -2046,6 +2053,7 @@ void M_DrawVideo(void) {

DRAWVIDEOITEM2(filter, r_filter.value, filterType);
DRAWVIDEOITEM2(anisotropic, r_anisotropic.value, msgNames);
DRAWVIDEOITEM2(multisample, r_multisample.value, multisampletype);
DRAWVIDEOITEM2(windowed, v_windowed.value, msgNames);
DRAWVIDEOITEM2(ratio, m_aspectRatio, ratioName);

Expand Down Expand Up @@ -2139,6 +2147,10 @@ void M_ChangeAnisotropic(int choice) {
M_SetOptionValue(choice, 0, 1, 1, &r_anisotropic);
}

void M_ChangeAntiAliasing(int choice) {
M_SetOptionValue(choice, 0, 1, 1, &r_multisample);
}

void M_ChangeWindowed(int choice) {
M_SetOptionValue(choice, 0, 1, 1, &v_windowed);
}
Expand Down
2 changes: 2 additions & 0 deletions src/engine/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ CVAR_CMD(r_anisotropic, 1) {
GL_SetTextureFilter();
}

CVAR(r_multisample, 1);
CVAR_EXTERNAL(r_texturecombiner);
CVAR_EXTERNAL(i_interpolateframes);
CVAR_EXTERNAL(p_usecontext);
Expand Down Expand Up @@ -796,6 +797,7 @@ void R_RegisterCvars(void) {
CON_CvarRegister(&r_fog);
CON_CvarRegister(&r_filter);
CON_CvarRegister(&r_anisotropic);
CON_CvarRegister(&r_multisample);
CON_CvarRegister(&r_wipe);
CON_CvarRegister(&r_drawmobjbox);
CON_CvarRegister(&r_rendersprites);
Expand Down

0 comments on commit bc1defd

Please sign in to comment.