Add a way to reset render target to default (e.g. screen)

This commit is contained in:
Dmitry Marakasov 2013-12-18 04:35:49 +04:00
parent 150830b270
commit acebd488aa
2 changed files with 6 additions and 0 deletions

View File

@ -74,6 +74,11 @@ void Renderer::SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) {
throw Exception("SDL_SetRenderDrawColor failed"); throw Exception("SDL_SetRenderDrawColor failed");
} }
void Renderer::SetTarget() {
if (SDL_SetRenderTarget(renderer_, nullptr) != 0)
throw Exception("SDL_SetRenderTarget failed");
}
void Renderer::SetTarget(Texture& texture) { void Renderer::SetTarget(Texture& texture) {
if (SDL_SetRenderTarget(renderer_, texture.Get()) != 0) if (SDL_SetRenderTarget(renderer_, texture.Get()) != 0)
throw Exception("SDL_SetRenderTarget failed"); throw Exception("SDL_SetRenderTarget failed");

View File

@ -56,6 +56,7 @@ public:
void Copy(Texture& texture, const Rect& srcrect, const Rect& dstrect, double angle, const Point& center, SDL_RendererFlip flip); void Copy(Texture& texture, const Rect& srcrect, const Rect& dstrect, double angle, const Point& center, SDL_RendererFlip flip);
void SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255); void SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255);
void SetTarget();
void SetTarget(Texture& texture); void SetTarget(Texture& texture);
void SetDrawBlendMode(SDL_BlendMode blendMode); void SetDrawBlendMode(SDL_BlendMode blendMode);