diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index ed57dae4a08..612eef005bc 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -528,13 +528,15 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) offset = osave; } +static TArray> buffersToDestroy; + void DShape2D::OnDestroy() { if (lastParms) delete lastParms; lastParms = nullptr; mIndices.Reset(); mVertices.Reset(); mCoords.Reset(); - bufferInfo = nullptr; + buffersToDestroy.Push(std::move(bufferInfo)); } //========================================================================== @@ -1082,6 +1084,17 @@ void F2DDrawer::Clear() screenFade = 1.f; } +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::OnFrameDone() +{ + buffersToDestroy.Clear(); +} + F2DVertexBuffer::F2DVertexBuffer() { mVertexBuffer = screen->CreateVertexBuffer(); diff --git a/src/common/2d/v_2ddrawer.h b/src/common/2d/v_2ddrawer.h index 0e91d3b2c65..ebcef614214 100644 --- a/src/common/2d/v_2ddrawer.h +++ b/src/common/2d/v_2ddrawer.h @@ -216,6 +216,7 @@ class F2DDrawer void Begin(int w, int h) { isIn2D = true; Width = w; Height = h; } void End() { isIn2D = false; } bool HasBegun2D() { return isIn2D; } + void OnFrameDone(); void ClearClipRect() { clipleft = cliptop = 0; clipwidth = clipheight = -1; } void SetClipRect(int x, int y, int w, int h); diff --git a/src/d_main.cpp b/src/d_main.cpp index 245922beb4c..51f7fb5aa46 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -903,6 +903,7 @@ static void End2DAndUpdate() twod->End(); CheckBench(); screen->Update(); + twod->OnFrameDone(); } //==========================================================================