mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Move the VSync work to Screen.
The problem we're running into is entirely contained in the Screen - we need to either decouple graphics context init from Screen::init or we need to take out the screenbuffer interaction from loadstats (which I'm more in favor of since we can just pull the config values and pass them to Screen::init later).
This commit is contained in:
@@ -26,6 +26,7 @@ void Screen::init()
|
||||
isWindowed = true;
|
||||
stretchMode = 0;
|
||||
isFiltered = false;
|
||||
vsync = false;
|
||||
filterSubrect.x = 1;
|
||||
filterSubrect.y = 1;
|
||||
filterSubrect.w = 318;
|
||||
@@ -287,3 +288,49 @@ void Screen::toggleLinearFilter()
|
||||
240
|
||||
);
|
||||
}
|
||||
|
||||
void Screen::resetRendererWorkaround()
|
||||
{
|
||||
SDL_SetHintWithPriority(
|
||||
SDL_HINT_RENDER_VSYNC,
|
||||
vsync ? "1" : "0",
|
||||
SDL_HINT_OVERRIDE
|
||||
);
|
||||
|
||||
/* FIXME: This exists because SDL_HINT_RENDER_VSYNC is not dynamic!
|
||||
* As a result, our only workaround is to tear down the renderer
|
||||
* and recreate everything so that it can process the variable.
|
||||
* -flibit
|
||||
*/
|
||||
|
||||
if (m_renderer == NULL)
|
||||
{
|
||||
/* We haven't made it to init yet, don't worry about it */
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_RendererInfo renderInfo;
|
||||
SDL_GetRendererInfo(m_renderer, &renderInfo);
|
||||
bool curVsync = (renderInfo.flags & SDL_RENDERER_PRESENTVSYNC) != 0;
|
||||
if (vsync == curVsync)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_DestroyTexture(m_screenTexture);
|
||||
SDL_DestroyRenderer(m_renderer);
|
||||
|
||||
m_renderer = SDL_CreateRenderer(m_window, -1, 0);
|
||||
m_screenTexture = SDL_CreateTexture(
|
||||
m_renderer,
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
320,
|
||||
240
|
||||
);
|
||||
|
||||
/* Ugh, have to make sure to re-apply graphics options after doing the
|
||||
* above, otherwise letterbox/integer won't be applied...
|
||||
*/
|
||||
ResizeScreen(-1, -1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user