Skip to content

Instantly share code, notes, and snippets.

@Shaptic
Created February 10, 2013 22:23
Show Gist options
  • Save Shaptic/4751306 to your computer and use it in GitHub Desktop.
Save Shaptic/4751306 to your computer and use it in GitHub Desktop.
Iterating over the current sprite sheet.
bool CAnimation::NextSprite()
{
// Stay within bounds!
if(++m_active >= this->GetAnimationCount())
{
++m_loops_done;
m_active = 0;
}
// Adjust for current texture
gfx::CShaderPair* pShader = m_Mesh.GetSurfaces()[0]->pMaterial->pShader;
pShader->Bind();
glUniform2f(m_tc_str, m_active * m_TexcDim.x, m_active * m_TexcDim.y);
pShader->Unbind();
// If m_active == 0, return FALSE since that means we started looping again.
return (m_active > 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment