Allow changing MSAA at runtime

This commit is contained in:
Matthew Coppola committed 2024-12-06 17:20:23 -05:00
1 parent 1d14877bec
commit d43c4c0cba
3 files changed
+60

No files matched your search

+2
View File
@@ -45,6 +45,7 @@ s32 videoGetDisplayMode(displaymode *out, const s32 index);
s32 videoGetNumDisplayModes(void);
s32 videoGetVsync(void);
s32 videoGetFramerateLimit(void);
s32 videoGetMSAA(void);
void videoSetWindowOffset(s32 x, s32 y);
void videoSetFullscreen(s32 fs);
@@ -55,6 +56,7 @@ void videoSetDetailTextures(s32 detail);
void videoSetDisplayMode(const s32 index);
void videoSetVsync(const s32 vsync);
void videoSetFramerateLimit(const s32 limit);
void videoSetMSAA(const s32 msaa);
s32 videoCreateFramebuffer(u32 w, u32 h, s32 upscale, s32 autoresize);
void videoSetFramebuffer(s32 target);
+46
View File
@@ -790,6 +790,44 @@ static MenuItemHandlerResult menuhandlerFramerateLimit(s32 operation, struct men
return 0;
}
static MenuItemHandlerResult menuhandlerMSAA(s32 operation, struct menuitem *item, union handlerdata *data)
{
s32 msaa;
static const char *opts[] = {
"Off",
"2x",
"4x",
"8x",
"16x"
};
switch (operation) {
case MENUOP_GETOPTIONCOUNT:
data->dropdown.value = ARRAYCOUNT(opts);
break;
case MENUOP_GETOPTIONTEXT:
return (intptr_t)opts[data->dropdown.value];
case MENUOP_SET:
videoSetMSAA(1 << data->dropdown.value);
break;
case MENUOP_GETSELECTEDINDEX:
msaa = videoGetMSAA();
if (msaa < 2) {
data->dropdown.value = 0;
} else if (msaa < 4) {
data->dropdown.value = 1;
} else if (msaa < 8) {
data->dropdown.value = 2;
} else if (msaa < 16) {
data->dropdown.value = 3;
} else {
data->dropdown.value = 4;
}
}
return 0;
}
static MenuItemHandlerResult menuhandlerResolution(s32 operation, struct menuitem *item, union handlerdata *data)
{
static char resstring[32];
@@ -999,6 +1037,14 @@ struct menuitem g_ExtendedVideoMenuItems[] = {
VIDEO_MAX_FPS,
menuhandlerFramerateLimit,
},
{
MENUITEMTYPE_DROPDOWN,
0,
MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Anti-aliasing (MSAA)",
0,
menuhandlerMSAA,
},
{
MENUITEMTYPE_CHECKBOX,
0,
+12
View File
@@ -217,6 +217,12 @@ s32 videoGetDisplayModeIndex(void)
return 0;
}
s32 videoGetMSAA(void)
{
vidMSAA = (s32)gfx_msaa_level;
return vidMSAA;
}
s32 videoGetVsync(void)
{
vidVsync = wmAPI->get_swap_interval();
@@ -414,6 +420,12 @@ s32 videoCreateFramebuffer(u32 w, u32 h, s32 upscale, s32 autoresize)
return gfx_create_framebuffer(w, h, upscale, autoresize);
}
void videoSetMSAA(const s32 msaa)
{
vidMSAA = msaa;
gfx_msaa_level = (u32)vidMSAA;
}
void videoSetVsync(const s32 vsync)
{
vidVsync = wmAPI->set_swap_interval(vsync) ? vsync : 0;