Skip to content
Snippets Groups Projects
Commit 9937b98c authored by Joakim Hunskaar's avatar Joakim Hunskaar
Browse files

Image now deletes its texture

parent 3bef691c
No related tags found
1 merge request!6Image now deletes its texture
......@@ -13,6 +13,7 @@ namespace TDT4102 {
public:
explicit Image();
explicit Image(std::filesystem::path pathToImageFile);
~Image();
int width = 0;
int height = 0;
......
......@@ -34,3 +34,10 @@ void TDT4102::Image::draw(SDL_Renderer *renderer, TDT4102::Point location, int i
SDL_RenderCopy(renderer, texture, nullptr, &imageBounds);
}
TDT4102::Image::~Image() {
if (texture != nullptr) {
SDL_DestroyTexture(texture);
texture = nullptr;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment