diff options
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;  } |