diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-10-22 15:37:00 +0200 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-10-22 15:37:00 +0200 |
commit | f1857fc2d4ddec71b3f0395903f8446cf96b8d0c (patch) | |
tree | feb0a1b4f80cb67ca9af89545ae67a2c03e2f23b /src/crepe/api/Texture.cpp | |
parent | b151274f9009eb9f86e4df29ca2c75f5b01d4092 (diff) |
fixed everything and can now work with new compiler, example rendering and made it work with component manager
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; } |