Don't leave dangling OpenGL texture IDs

This commit is contained in:
Clownacy 2020-09-14 23:43:18 +01:00
parent 9ea6caad72
commit e96ee6ed89

View file

@ -675,9 +675,17 @@ void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
return; return;
// Flush the vertex buffer if we're about to destroy its texture // Flush the vertex buffer if we're about to destroy its texture
// TODO - This leaves `last_source_texture`/`last_destination_texture` dangling if (surface->texture_id == last_source_texture)
if (surface->texture_id == last_source_texture || surface->texture_id == last_destination_texture) {
FlushVertexBuffer(); FlushVertexBuffer();
last_source_texture = 0;
}
if (surface->texture_id == last_destination_texture)
{
FlushVertexBuffer();
last_destination_texture = 0;
}
glDeleteTextures(1, &surface->texture_id); glDeleteTextures(1, &surface->texture_id);
free(surface); free(surface);