|
|
|
@ -28,7 +28,6 @@ AnimatedTexture::AnimatedTexture(int width, int height, int channels, int numFra
|
|
|
|
|
|
|
|
|
|
AnimatedTexture::~AnimatedTexture()
|
|
|
|
|
{
|
|
|
|
|
assert(!g_graphics.isDrawing());
|
|
|
|
|
glDeleteTextures(m_numFrames, &m_framesTextureId[0]);
|
|
|
|
|
m_textureId = 0;
|
|
|
|
|
}
|
|
|
|
@ -48,7 +47,10 @@ void AnimatedTexture::processAnimation()
|
|
|
|
|
if(m_currentFrame >= m_numFrames)
|
|
|
|
|
m_currentFrame = 0;
|
|
|
|
|
m_textureId = m_framesTextureId[m_currentFrame];
|
|
|
|
|
AnimatedTexturePtr me = std::static_pointer_cast<AnimatedTexture>(shared_from_this());
|
|
|
|
|
if(me.use_count() > 1)
|
|
|
|
|
g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, me), m_framesDelay[m_currentFrame]);
|
|
|
|
|
|
|
|
|
|
AnimatedTexturePtr self = asAnimatedTexture();
|
|
|
|
|
|
|
|
|
|
// continue to animate only if something still referencing this texture
|
|
|
|
|
if(self.use_count() > 1)
|
|
|
|
|
g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, self), m_framesDelay[m_currentFrame]);
|
|
|
|
|
}
|
|
|
|
|