diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 17:21:43 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-11 17:21:43 +0100 |
commit | c585731ab4557e2a03be9630a54295a3700103fc (patch) | |
tree | 1baff648eb415fbc81612077dce5c2551abf12a2 /src/crepe/facade/Texture.cpp | |
parent | 4bb6e89d93596c9c53798b1b9a01c588cabfe881 (diff) | |
parent | 30c17c98e54c1534664de08ca3838c40c859d166 (diff) |
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/text-component
Diffstat (limited to 'src/crepe/facade/Texture.cpp')
-rw-r--r-- | src/crepe/facade/Texture.cpp | 28 |
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(); } |