From 79d9f266b4ca03fa28aa2eac31143d93c3783e12 Mon Sep 17 00:00:00 2001 From: zv0n Date: Fri, 23 Jul 2021 00:05:40 +0200 Subject: [PATCH] SDLPP: add function to change texture while keeping SRC rect --- sdlpp/sdlpp_renderobject.cpp | 3 +++ sdlpp/sdlpp_renderobject.hpp | 1 + 2 files changed, 4 insertions(+) diff --git a/sdlpp/sdlpp_renderobject.cpp b/sdlpp/sdlpp_renderobject.cpp index d894c6e..63e28d2 100644 --- a/sdlpp/sdlpp_renderobject.cpp +++ b/sdlpp/sdlpp_renderobject.cpp @@ -78,6 +78,9 @@ void RenderObject::setTexture( const std::shared_ptr< Texture > &t, texture = t; src_rect = source_rect; } +void RenderObject::setTextureKeepSRC( const std::shared_ptr< Texture > &t ) { + setTexture(t, src_rect); +} void RenderObject::setTexture( const std::shared_ptr< Texture > &t, int source_x, int source_y, int source_width, int source_height ) { diff --git a/sdlpp/sdlpp_renderobject.hpp b/sdlpp/sdlpp_renderobject.hpp index d67a1a9..915daa6 100644 --- a/sdlpp/sdlpp_renderobject.hpp +++ b/sdlpp/sdlpp_renderobject.hpp @@ -63,6 +63,7 @@ public: bool hasCollisions() const; const std::vector< std::shared_ptr< CollisionPolygon > > & getCollisions() const; + virtual void setTextureKeepSRC( const std::shared_ptr< Texture > &t ); virtual void setTexture( const std::shared_ptr< Texture > &t, int source_x, int source_y, int source_width, int source_height );