diff --git a/src/video.cpp b/src/video.cpp index befc3214534..3ed4053fb4c 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -267,6 +267,19 @@ void CVideo::blit_texture(const texture& tex, const SDL_Rect* dst_rect, const SD SDL_RenderCopy(*window.get(), tex, src_rect, dst_rect); } +void CVideo::blit_texture_flipped( + const texture& tex, + bool flip_horizontal, + bool flip_vertical, + const SDL_Rect* dst_rect, + const SDL_Rect* src_rect) +{ + SDL_RendererFlip flip = + flip_horizontal ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE + | flip_vertical ? SDL_FLIP_VERTICAL : SDL_FLIP_NONE; + SDL_RenderCopyEx(*window, tex, src_rect, dst_rect, 0.0, nullptr, flip); +} + void CVideo::make_fake() { fake_screen_ = true; diff --git a/src/video.hpp b/src/video.hpp index f30c1b1e166..ab1c8e0a461 100644 --- a/src/video.hpp +++ b/src/video.hpp @@ -356,6 +356,29 @@ public: */ void blit_texture(const texture& tex, const SDL_Rect* dstrect = nullptr, const SDL_Rect* srcrect = nullptr); + /** + * Draws a texture, or part of a texture, at the given location, + * also mirroring/flipping the texture horizontally and/or vertically. + * + * Calling this function with no explicit parameters will flip the + * texture horizontally. + * + * @param tex The texture to be copied / drawn. + * @param flip_horizontal Whether to flip/mirror the texture horizontally. + * @param flip_vertical Whether to flip/mirror the texture vertically. + * @param dstrect The target location to copy the texture to, + * in low-resolution game-native drawing coordinates. + * If null, this fills the entire render target. + * @param srcrect The portion of the texture to copy. + * If null, this copies the entire texture. + */ + void blit_texture_flipped( + const texture& tex, + bool flip_horizontal = true, + bool flip_vertical = false, + const SDL_Rect* dst_rect = nullptr, + const SDL_Rect* src_rect = nullptr); + /** * Render a portion of the low-resolution drawing surface. *