diff --git a/src/video.cpp b/src/video.cpp index 1dcd0238bfe..fd9763fabfd 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -345,11 +345,37 @@ void CVideo::render_screen() } } -void CVideo::render_copy(const texture& txt, SDL_Rect* src_rect, SDL_Rect* dst_rect) +void CVideo::render_copy( + const texture& txt, SDL_Rect* src_rect, SDL_Rect* dst_rect, const bool flip_h, const bool flip_v) { - if(window) { - SDL_RenderCopy(*window, txt, src_rect, dst_rect);; + if(!window) { + return; } + + // If no additional data was provided, render immediately. + if(!flip_h && !flip_v) { + SDL_RenderCopy(*window, txt, src_rect, dst_rect); + return; + } + + // Calculate flipping mode. + int fmode = SDL_FLIP_NONE; + + if(flip_h && flip_v) { + fmode = SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL; + } else if(flip_h) { + fmode = SDL_FLIP_HORIZONTAL; + } else if(flip_v) { + fmode = SDL_FLIP_VERTICAL; + } + + SDL_RendererFlip flip_mode = static_cast(fmode); + + // TODO: add handling of rotations. + static const double rotate_angle = 0; + static const SDL_Point* center = nullptr; + + SDL_RenderCopyEx(*window, txt, src_rect, dst_rect, rotate_angle, center, flip_mode); } void CVideo::lock_updates(bool value) diff --git a/src/video.hpp b/src/video.hpp index d011b999e59..edbf59c9758 100644 --- a/src/video.hpp +++ b/src/video.hpp @@ -173,7 +173,11 @@ public: /** Renders the screen. Should normally not be called directly! */ void render_screen(); - void render_copy(const texture& txt, SDL_Rect* src_rect = nullptr, SDL_Rect* dst_rect = nullptr); + void render_copy(const texture& txt, + SDL_Rect* src_rect = nullptr, + SDL_Rect* dst_rect = nullptr, + const bool flip_h = false, + const bool flip_v = false); /** * Updates and ensures the framebuffer surface is valid.