1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-24 13:38:29 +02:00

Add VSync graphics option, off by default

This is if you want delta-timesteps to go as quickly as possible. Also
it seems like on Windows this only has an effect in exclusive fullscreen
mode.
This commit is contained in:
Misa 2020-05-04 13:19:47 -07:00 committed by Ethan Lee
parent 179315c889
commit 694e8f42ab
6 changed files with 43 additions and 4 deletions

View File

@ -4753,6 +4753,11 @@ void Game::loadstats()
over30mode = atoi(pText);
}
if (pKey == "vsync")
{
graphics.vsync = atoi(pText);
}
if (pKey == "notextoutline")
{
graphics.notextoutline = atoi(pText);
@ -5002,6 +5007,10 @@ void Game::savestats()
msg->LinkEndChild(doc.NewText(help.String((int) over30mode).c_str()));
dataNode->LinkEndChild(msg);
msg = doc.NewElement("vsync");
msg->LinkEndChild(doc.NewText(help.String((int) graphics.vsync).c_str()));
dataNode->LinkEndChild(msg);
for (size_t i = 0; i < controllerButton_flip.size(); i += 1)
{
msg = doc.NewElement("flipButton");
@ -7075,9 +7084,10 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
option("toggle analogue");
option("toggle mouse");
option("toggle fps");
option("toggle vsync");
option("return");
menuxoff = -50;
menuyoff = 8;
menuxoff = -85;
menuyoff = 0;
break;
case Menu::ed_settings:
option("change description");

View File

@ -139,6 +139,8 @@ void Graphics::init()
col_tb = 0;
kludgeswnlinewidth = false;
vsync = false;
}
int Graphics::font_idx(uint32_t ch) {
@ -3100,3 +3102,8 @@ Uint32 Graphics::crewcolourreal(int t)
}
return col_crewcyan;
}
void Graphics::processVsync()
{
SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC, vsync ? "1" : "0", SDL_HINT_OVERRIDE);
}

View File

@ -324,6 +324,9 @@ public:
bool kludgeswnlinewidth;
Uint32 crewcolourreal(int t);
bool vsync;
void processVsync();
};
extern Graphics graphics;

View File

@ -364,6 +364,13 @@ void menuactionpress()
game.over30mode = !game.over30mode;
game.savestats();
break;
case 6:
//toggle vsync
music.playef(11);
graphics.vsync = !graphics.vsync;
graphics.processVsync();
game.savestats();
break;
default:
//back
music.playef(11);

View File

@ -176,6 +176,18 @@ void menurender()
graphics.Print(-1, 95, "Current mode: Over 30 FPS", tr, tg, tb, true);
}
break;
case 6:
graphics.bigprint(-1, 30, "Toggle VSync", tr, tg, tb, true);
graphics.Print(-1, 65, "Turn VSync on or off.", tr, tg, tb, true);
if (!graphics.vsync)
{
graphics.Print(-1, 95, "Current mode: VSYNC OFF", tr/2, tg/2, tb/2, true);
}
else
{
graphics.Print(-1, 95, "Current mode: VSYNC ON", tr, tg, tb, true);
}
}
break;
case Menu::credits:

View File

@ -105,8 +105,6 @@ int main(int argc, char *argv[])
}
}
SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC, "1", SDL_HINT_OVERRIDE);
if(!FILESYSTEM_init(argv[0], baseDir, assetsPath))
{
return 1;
@ -208,6 +206,8 @@ int main(int argc, char *argv[])
//Moved screensetting init here from main menu V2.1
game.loadstats();
graphics.processVsync();
if (game.skipfakeload)
game.gamestate = TITLEMODE;
if(game.usingmmmmmm==0) music.usingmmmmmm=false;