Video: expand render_copy to take flip arguments
Still needs to handle rotation.
This commit is contained in:
parent
6fdf1bcc88
commit
6fbc2491ea
2 changed files with 34 additions and 4 deletions
|
@ -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<SDL_RendererFlip>(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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue