aboutsummaryrefslogtreecommitdiff
path: root/resource-manager/Image_asset.cpp
blob: 791e9882da8533b0cb6d2de1e551e6e8b6c2538d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "Image_asset.h"
#include <SDL2/SDL_surface.h>
#include <SDL_image.h>
#include <SDL_render.h>
#include <string>


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);
}

SDL_Surface* Texture::getSurface() const {
	return m_surface;
}

SDL_Texture* Texture::getTexture() const{
	return m_texture;
}