From cd52bc41acd3dc5cba5e7d0c63fc53b01383cec7 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 21 Jun 2003 22:24:48 +0000 Subject: [PATCH] fix texture leak --- stepmania/src/ModelTypes.cpp | 14 ++++++++++++++ stepmania/src/ModelTypes.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/stepmania/src/ModelTypes.cpp b/stepmania/src/ModelTypes.cpp index 659baba389..1159085fd2 100644 --- a/stepmania/src/ModelTypes.cpp +++ b/stepmania/src/ModelTypes.cpp @@ -22,6 +22,11 @@ AnimatedTexture::AnimatedTexture() fSecsIntoFrame = 0; } +AnimatedTexture::~AnimatedTexture() +{ + Unload(); +} + void AnimatedTexture::Load( CString sTexOrIniPath ) { ASSERT( vFrames.empty() ); // don't load more than once @@ -107,3 +112,12 @@ int AnimatedTexture::GetNumStates() { return vFrames.size(); } + +void AnimatedTexture::Unload() +{ + for(unsigned i = 0; i < vFrames.size(); ++i) + TEXTUREMAN->UnloadTexture(vFrames[i].pTexture); + vFrames.clear(); + iCurState = 0; + fSecsIntoFrame = 0; +} diff --git a/stepmania/src/ModelTypes.h b/stepmania/src/ModelTypes.h index 6494694625..0ff0f0cc62 100644 --- a/stepmania/src/ModelTypes.h +++ b/stepmania/src/ModelTypes.h @@ -99,8 +99,10 @@ class RageTexture; struct AnimatedTexture { AnimatedTexture(); + ~AnimatedTexture(); void Load( CString sTexOrIniFile ); + void Unload(); void Update( float fDelta ); RageTexture* GetCurrentTexture();