Skip to content

Commit

Permalink
Fixed raii renderer rect setters
Browse files Browse the repository at this point in the history
This fixes a problem that occurred if no previous set rect was available. In that case, both SDL_RenderGetClipRect
and SDL_RenderGetViewport returned empty rects and those were being set as the appropriate clip rects when the raii
object was destroyed.
  • Loading branch information
Vultraz committed Jun 7, 2017
1 parent 083f8fb commit a59bd9d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sdl/render_utils.hpp
Expand Up @@ -13,6 +13,7 @@

#pragma once

#include "sdl/rect.hpp"
#include "sdl/texture.hpp"
#include "video.hpp"

Expand Down Expand Up @@ -78,7 +79,11 @@ class render_raii_rect_setter_base
~render_raii_rect_setter_base()
{
if(renderer_ && operate_) {
(*S)(renderer_, &last_rect_);
if(last_rect_ != sdl::empty_rect) {
(*S)(renderer_, &last_rect_);
} else {
(*S)(renderer_, nullptr);
}
}
}

Expand Down

0 comments on commit a59bd9d

Please sign in to comment.