From 9b4a4157b958843250591c68e548532f5cb8d19e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Jun 2021 22:21:27 +0200 Subject: [PATCH] - added an OnDestroy method to Shape2D so that its users can explicitly free the data it holds. In this case it is very important to care about management, because this class will hold GPU-side buffers! --- src/common/2d/v_2ddrawer.cpp | 9 +++++++-- src/common/2d/v_2ddrawer.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index 2d1387f02..44865797b 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -528,8 +528,13 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) offset = osave; } -DShape2D::~DShape2D() { - delete lastParms; +void DShape2D::OnDestroy() { + if (lastParms) delete lastParms; + lastParms = nullptr; + mIndices.Reset(); + mVertices.Reset(); + mCoords.Reset(); + buffers.Reset(); } //========================================================================== diff --git a/src/common/2d/v_2ddrawer.h b/src/common/2d/v_2ddrawer.h index feac2e4d7..8bb113905 100644 --- a/src/common/2d/v_2ddrawer.h +++ b/src/common/2d/v_2ddrawer.h @@ -269,7 +269,7 @@ public: bool uploadedOnce = false; DrawParms* lastParms; - ~DShape2D(); + void OnDestroy() override; };