Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
etorth committed Dec 13, 2023
1 parent 19c946d commit 34c2c76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/src/sdldevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ SDLDeviceHelper::EnableRenderBlendMode::~EnableRenderBlendMode()

SDLDeviceHelper::EnableRenderClipRectangle::EnableRenderClipRectangle(int x, int y, int w, int h, SDLDevice *devPtr)
: m_device(devPtr ? devPtr : g_sdlDevice)
, m_clipped(SDL_RenderIsClipEnabled(m_device->getRenderer()) == SDL_TRUE)
{
SDL_RenderGetClipRect(m_device->getRenderer(), &m_rect);
if(m_clipped){
SDL_RenderGetClipRect(m_device->getRenderer(), &m_rect);
}

SDL_Rect newRect;
newRect.x = x;
Expand All @@ -80,7 +83,7 @@ SDLDeviceHelper::EnableRenderClipRectangle::EnableRenderClipRectangle(int x, int

SDLDeviceHelper::EnableRenderClipRectangle::~EnableRenderClipRectangle()
{
if(SDL_RenderSetClipRect(m_device->getRenderer(), &m_rect)){
if(SDL_RenderSetClipRect(m_device->getRenderer(), m_clipped ? &m_rect : nullptr)){
g_log->addLog(LOGTYPE_WARNING, "set renderer clip rectangle failed: %s", SDL_GetError());
}
}
Expand Down
3 changes: 3 additions & 0 deletions client/src/sdldevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ namespace SDLDeviceHelper
private:
SDLDevice *m_device;

private:
const bool m_clipped;

private:
SDL_Rect m_rect;

Expand Down

0 comments on commit 34c2c76

Please sign in to comment.