aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/Texture.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-14 11:40:33 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-14 11:40:33 +0100
commit061b2b8ab9aba67c1467cdd163fb7a04de95f4f1 (patch)
treee1960a83461e0d83a7027a88404af1a7c70f6dcd /src/crepe/facade/Texture.cpp
parentfd2ebb54d0c2b269c15fc84a4ac77993efc917d7 (diff)
parentb9fc66f6922b1f40f2dbe14e8dfc4caa469654bc (diff)
Merge branch 'master' of github.com:lonkaars/crepe into jaro/collision-system
Diffstat (limited to 'src/crepe/facade/Texture.cpp')
-rw-r--r--src/crepe/facade/Texture.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/crepe/facade/Texture.cpp b/src/crepe/facade/Texture.cpp
new file mode 100644
index 0000000..b63403d
--- /dev/null
+++ b/src/crepe/facade/Texture.cpp
@@ -0,0 +1,28 @@
+#include "../util/Log.h"
+#include "facade/SDLContext.h"
+#include "manager/Mediator.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(); }