From 35224c07549448e919a18a463e5dec81bbabf7c6 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 25 Sep 2024 13:07:13 +0200 Subject: spritesheet and image changed --- resource-manager/Image_asset.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'resource-manager/Image_asset.cpp') diff --git a/resource-manager/Image_asset.cpp b/resource-manager/Image_asset.cpp index 10b35f8..791e988 100644 --- a/resource-manager/Image_asset.cpp +++ b/resource-manager/Image_asset.cpp @@ -1,21 +1,32 @@ #include "Image_asset.h" -#include "spritesheet.h" #include #include +#include #include -Image::Image(const std::string& path){ - surface = IMG_Load(path.c_str()); +Texture::Texture(const std::string& path){ + m_surface = IMG_Load(path.c_str()); } +void Texture::setTexture(SDL_Renderer& renderer){ + m_texture = SDL_CreateTextureFromSurface(&renderer, m_surface); +} + + +Texture::~Texture(){ + SDL_FreeSurface(m_surface); + + if(m_texture) + SDL_DestroyTexture(m_texture); +} -Image::~Image(){ - SDL_FreeSurface(surface); +SDL_Surface* Texture::getSurface() const { + return m_surface; } -SDL_Surface* Image::getSurface() const { - return surface; +SDL_Texture* Texture::getTexture() const{ + return m_texture; } -- cgit v1.2.3