blob: c5599e9a32fac3eb1fca0a04380d70f46b5e27db (
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
33
|
#include "Image_asset.h"
#include <SDL_image.h>
#include <SDL_surface.h>
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(){
if (m_surface) {
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;
}
|