Skip to content

Commit

Permalink
- added an OnDestroy method to Shape2D so that its users can explicit…
Browse files Browse the repository at this point in the history
…ly free the data it holds.

In this case it is very important to care about management, because this class will hold GPU-side buffers!
  • Loading branch information
coelckers committed Jul 25, 2021
1 parent 9e60613 commit d8640d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/common/2d/v_2ddrawer.cpp
Expand Up @@ -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();
}

//==========================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/common/2d/v_2ddrawer.h
Expand Up @@ -269,7 +269,7 @@ class DShape2D : public DObject
bool uploadedOnce = false;
DrawParms* lastParms;

~DShape2D();
void OnDestroy() override;
};


Expand Down

0 comments on commit d8640d0

Please sign in to comment.