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:
Ethan Lee
2020-07-02 00:19:40 -04:00
parent d854c61960
commit 0f450f3e39
8 changed files with 55 additions and 50 deletions

View File

@@ -139,8 +139,6 @@ void Graphics::init()
col_tb = 0;
kludgeswnlinewidth = false;
vsync = false;
}
int Graphics::font_idx(uint32_t ch) {
@@ -3273,42 +3271,3 @@ Uint32 Graphics::crewcolourreal(int t)
}
return col_crewcyan;
}
void Graphics::processVsync()
{
SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC, vsync ? "1" : "0", SDL_HINT_OVERRIDE);
if (screenbuffer == NULL)
{
return;
}
// FIXME: Sigh... work around SDL2 bug where the VSync hint is only
// listened to at renderer creation
// Ugh, have to re-create m_screenTexture as well, otherwise the screen
// will be black...
if (screenbuffer->m_screenTexture != NULL)
{
SDL_DestroyTexture(screenbuffer->m_screenTexture);
}
if (screenbuffer->m_renderer != NULL)
{
SDL_DestroyRenderer(screenbuffer->m_renderer);
}
screenbuffer->m_renderer = SDL_CreateRenderer(screenbuffer->m_window, -1, 0);
// FIXME: This is duplicated from Screen::init()!
screenbuffer->m_screenTexture = SDL_CreateTexture(
screenbuffer->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...
screenbuffer->ResizeScreen(-1, -1);
}