diff options
Diffstat (limited to 'src/crepe/api/Texture.cpp')
-rw-r--r-- | src/crepe/api/Texture.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp index b4e3aa8..2d170c3 100644 --- a/src/crepe/api/Texture.cpp +++ b/src/crepe/api/Texture.cpp @@ -1,39 +1,34 @@ +#include "Asset.h" +#include "SdlContext.h" #include "util/log.h" #include "Texture.h" -#include "SdlContext.h" #include <SDL2/SDL_render.h> +#include <iostream> +#include <string> -using namespace crepe; +using namespace crepe::api; -Texture::Texture(std::unique_ptr<api::Resource> res) { +Texture::Texture(std::unique_ptr<Asset> res) { dbg_trace(); this->load(std::move(res)); } Texture::Texture(const char * src) { dbg_trace(); - this->load(std::make_unique<api::Resource>(src)); + this->load(std::make_unique<Asset>(src)); } -Texture::~Texture(){ +Texture::~Texture() { dbg_trace(); - if(this->m_texture){ + if (this->m_texture != nullptr) { SDL_DestroyTexture(m_texture); } } -void Texture::load(std::unique_ptr<api::Resource> res) { - dbg_trace(); - SdlContext& ctx = SdlContext::get_instance(); - m_texture = ctx.setTextureFromPath(res->canonical(), srcrect, 1, 1); -} - -SDL_Texture* Texture::get_texture() const{ - return m_texture; -} +void Texture::load(std::unique_ptr<Asset> res) { + SdlContext & ctx = SdlContext::get_instance(); + m_texture = ctx.texture_from_path(res->canonical()); -SDL_Rect& Texture::get_rect() { - return srcrect; } |