aboutsummaryrefslogtreecommitdiff
path: root/resource-manager/Image_asset.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'resource-manager/Image_asset.cpp')
-rw-r--r--resource-manager/Image_asset.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/resource-manager/Image_asset.cpp b/resource-manager/Image_asset.cpp
index 791e988..c5599e9 100644
--- a/resource-manager/Image_asset.cpp
+++ b/resource-manager/Image_asset.cpp
@@ -1,10 +1,9 @@
#include "Image_asset.h"
-#include <SDL2/SDL_surface.h>
#include <SDL_image.h>
-#include <SDL_render.h>
-#include <string>
+#include <SDL_surface.h>
+
Texture::Texture(const std::string& path){
@@ -15,12 +14,14 @@ void Texture::setTexture(SDL_Renderer& renderer){
m_texture = SDL_CreateTextureFromSurface(&renderer, m_surface);
}
-
Texture::~Texture(){
- SDL_FreeSurface(m_surface);
+ if (m_surface) {
+ SDL_FreeSurface(m_surface);
+ }
- if(m_texture)
+ if(m_texture){
SDL_DestroyTexture(m_texture);
+ }
}
SDL_Surface* Texture::getSurface() const {