Skip to content
Snippets Groups Projects
Commit f5523874 authored by Joakim Borge Hunskår's avatar Joakim Borge Hunskår
Browse files

Merge branch 'add-destructor-Image' into 'main'

Image now deletes its texture

Closes #2

See merge request !6
parents 3bef691c 9937b98c
No related branches found
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