Merge branch 'restore-vid-wait' into 'master'

Restore vid_wait, make it apply immediately

See merge request KartKrew/Kart!1617
This commit is contained in:
toaster 2023-11-18 13:11:03 +00:00
commit b80547edab
3 changed files with 47 additions and 3 deletions

View file

@ -460,7 +460,14 @@ consvar_t cv_usemouse = Player("use_mouse", "Off").values({{0, "Off"}, {1, "On"}
consvar_t cv_vhseffect = Player("vhspause", "On").on_off();
// synchronize page flipping with screen refresh
consvar_t cv_vidwait = GraphicsDriver("vid_wait", "Off").on_off();
extern "C++"
{
namespace srb2::cvarhandler
{
void on_set_vid_wait();
}
}
consvar_t cv_vidwait = GraphicsDriver("vid_wait", "Off").on_off().onchange(srb2::cvarhandler::on_set_vid_wait);
// if true, all sounds are loaded at game startup
consvar_t precachesound = Player("precachesound", "Off").on_off();

View file

@ -19,6 +19,8 @@ menuitem_t OPTIONS_Video[] =
{IT_STRING | IT_CVAR, "Fullscreen", "Set whether you want to use fullscreen or windowed mode.",
NULL, {.cvar = &cv_fullscreen}, 0, 0},
#endif
{IT_STRING | IT_CVAR, "Vertical Sync", "Works with your screen to reduce image tearing and judder.",
NULL, {.cvar = &cv_vidwait}, 0, 0},
{IT_NOTHING|IT_SPACE, NULL, "Kanade best waifu! I promise!",
NULL, {NULL}, 0, 0},
@ -27,13 +29,13 @@ menuitem_t OPTIONS_Video[] =
{IT_STRING | IT_CVAR | IT_CV_SLIDER, "Gamma", "Adjusts the overall brightness of the game.",
NULL, {.cvar = &cv_globalgamma}, 0, 0},
{IT_STRING | IT_CVAR, "FPS Cap", "Handles the refresh rate of the game (does not affect gamelogic).",
{IT_STRING | IT_CVAR, "FPS Cap", "Handles the frame rate of the game (35 to match game logic)",
NULL, {.cvar = &cv_fpscap}, 0, 0},
{IT_STRING | IT_CVAR, "Enable Skyboxes", "Turning this off will improve performance at the detriment of visuals for many maps.",
NULL, {.cvar = &cv_skybox}, 0, 0},
{IT_STRING | IT_CVAR, "Draw Distance", "How far objects can be drawn. Lower values may improve performance at the cost of visibility.",
{IT_STRING | IT_CVAR, "Draw Distance", "How far objects can be drawn. A tradeoff between performance & visibility.",
NULL, {.cvar = &cv_drawdist}, 0, 0},
{IT_STRING | IT_CVAR, "Weather Draw Distance", "Affects how far weather visuals can be drawn. Lower values improve performance.",

View file

@ -1810,3 +1810,38 @@ UINT32 I_GetRefreshRate(void)
// trouble querying mode over and over again.
return refresh_rate;
}
namespace srb2::cvarhandler
{
void on_set_vid_wait();
}
void srb2::cvarhandler::on_set_vid_wait()
{
int interval = 0;
if (cv_vidwait.value > 0)
{
interval = 1;
}
switch (rendermode)
{
case render_soft:
if (sdlglcontext == nullptr || SDL_GL_GetCurrentContext() != sdlglcontext)
{
return;
}
SDL_GL_SetSwapInterval(interval);
break;
#ifdef HWRENDER
case render_opengl:
if (g_legacy_gl_context == nullptr || SDL_GL_GetCurrentContext() != g_legacy_gl_context)
{
return;
}
SDL_GL_SetSwapInterval(interval);
#endif
default:
break;
}
}