From e96ee6ed897090223f897a344d090b3f172c4af6 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 14 Sep 2020 23:43:18 +0100 Subject: [PATCH] Don't leave dangling OpenGL texture IDs --- src/Backends/Rendering/OpenGL3.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Backends/Rendering/OpenGL3.cpp b/src/Backends/Rendering/OpenGL3.cpp index 4368f7de..b9526670 100644 --- a/src/Backends/Rendering/OpenGL3.cpp +++ b/src/Backends/Rendering/OpenGL3.cpp @@ -675,9 +675,17 @@ void RenderBackend_FreeSurface(RenderBackend_Surface *surface) return; // 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 || surface->texture_id == last_destination_texture) + if (surface->texture_id == last_source_texture) + { FlushVertexBuffer(); + last_source_texture = 0; + } + + if (surface->texture_id == last_destination_texture) + { + FlushVertexBuffer(); + last_destination_texture = 0; + } glDeleteTextures(1, &surface->texture_id); free(surface);