diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-09-25 13:07:13 +0200 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-09-25 13:07:13 +0200 |
commit | 35224c07549448e919a18a463e5dec81bbabf7c6 (patch) | |
tree | 6c9dea5b449625b057511f7f052842ab3cd1d7e8 /resource-manager/Image_asset.cpp | |
parent | 765485ced528ca2f4cf644a1503b9446c5826731 (diff) |
spritesheet and image changed
Diffstat (limited to 'resource-manager/Image_asset.cpp')
-rw-r--r-- | resource-manager/Image_asset.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
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 <SDL2/SDL_surface.h> #include <SDL_image.h> +#include <SDL_render.h> #include <string> -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; } |