Simplify Flip Mode rendering code with SDL_RenderCopyEx

Previously, Flip Mode rendering had to be complicated and allocate
another buffer to call FlipSurfaceVerticle, and it was just a mess.

Instead, why not just do SDL_RenderCopyEx, and let SDL flip the screen
for us? This ends up pretty massively simplifying the rendering code.
This commit is contained in:
Misa
2021-08-29 13:31:42 -07:00
parent 23a2f57a70
commit c58c357a81
4 changed files with 29 additions and 70 deletions

View File

@@ -306,19 +306,32 @@ const SDL_PixelFormat* Screen::GetFormat(void)
return m_screen->format;
}
void Screen::FlipScreen(void)
void Screen::FlipScreen(const bool flipmode)
{
SDL_RendererFlip flip_flags;
if (flipmode)
{
flip_flags = SDL_FLIP_VERTICAL;
}
else
{
flip_flags = SDL_FLIP_NONE;
}
SDL_UpdateTexture(
m_screenTexture,
NULL,
m_screen->pixels,
m_screen->pitch
);
SDL_RenderCopy(
SDL_RenderCopyEx(
m_renderer,
m_screenTexture,
isFiltered ? &filterSubrect : NULL,
NULL
NULL,
0.0,
NULL,
flip_flags
);
SDL_RenderPresent(m_renderer);
SDL_RenderClear(m_renderer);