mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 18:04:09 +03:00
Work around SDL2 bug where VSync hint only applies on renderer creation
Ugh, this is terrible and stupid and I hate myself for it. Anyway, since the SDL2 VSync hint only applies when the renderer is created, we have to re-create the renderer whenever VSync is toggled. However, this also means we need to re-create m_screenTexture as well, AND call ResizeScreen() after that or else the letterbox/integer modes won't be applied. Unfortunately, this means that in main(), gameScreen.init() will create a renderer only to be destroyed later by graphics.processVsync(). There's not much we can do about this. Fixing this would require putting graphics.processVsync() before gameScreen.init(). However, in order to know whether the user has VSync set, we would have to call game.loadstats() first, but wait, we can't, because game.loadstats() mutates gameScreen! Gahhhhhh!!!! @leo60228 suggested to fix that problem ( https://github.com/TerryCavanagh/VVVVVV/pull/220#issuecomment-624217939 ) by adding NULL checks to game.loadstats() and then calling it twice, but then you're trading wastefully creating a renderer only to be destroyed, for wastefully opening and parsing unlock.vvv twice instead of once. In either case, you're doing something twice and wasting work.
This commit is contained in:
@@ -217,6 +217,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
//Moved screensetting init here from main menu V2.1
|
||||
game.loadstats();
|
||||
|
||||
// FIXME: Thanks to having to work around an SDL2 bug, this destroys the
|
||||
// renderer created by Screen::init(), which is a bit wasteful!
|
||||
// This is annoying to fix because we'd have to call gameScreen.init() after
|
||||
// game.loadstats(), but game.loadstats() assumes gameScreen.init() is already called!
|
||||
graphics.processVsync();
|
||||
|
||||
if (game.skipfakeload)
|
||||
|
||||
Reference in New Issue
Block a user