aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/Texture.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-10 16:21:05 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-10 16:21:05 +0100
commit7b8de90699aea153e73b5f2cee05c69b966b81be (patch)
tree123f8b71b59a933b2bfcffb9e43e5bea66086d8f /src/crepe/facade/Texture.cpp
parent33cd5566909ac089cdf56db38a3d1daf0cb7dd10 (diff)
implemented feedback wouter, improved animator. however if spritesheet aspect_ratio is not the same as the single frame then the scaling is wrong
Diffstat (limited to 'src/crepe/facade/Texture.cpp')
-rw-r--r--src/crepe/facade/Texture.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/crepe/facade/Texture.cpp b/src/crepe/facade/Texture.cpp
new file mode 100644
index 0000000..7224cb8
--- /dev/null
+++ b/src/crepe/facade/Texture.cpp
@@ -0,0 +1,34 @@
+#include "../util/Log.h"
+#include "manager/Mediator.h"
+#include "facade/SDLContext.h"
+
+#include "Resource.h"
+#include "Texture.h"
+#include "types.h"
+
+using namespace crepe;
+using namespace std;
+
+Texture::Texture(const Asset & src, Mediator & mediator) : Resource(src, mediator){
+ dbg_trace();
+ SDLContext & ctx = mediator.sdl_context;
+ this->texture = ctx.texture_from_path(src.get_path());
+ this->size = ctx.get_size(*this);
+ this->aspect_ratio = static_cast<float>(this->size.x) / this->size.y;
+}
+
+Texture::~Texture() {
+ dbg_trace();
+ this->texture.reset();
+}
+
+const ivec2 & Texture::get_size() const noexcept{
+ return this->size;
+}
+const float & Texture::get_ratio() const noexcept{
+ return this->aspect_ratio;
+}
+
+SDL_Texture * Texture::get_img() const noexcept{
+ return this->texture.get();
+}