Created
February 10, 2013 22:23
-
-
Save Shaptic/4751306 to your computer and use it in GitHub Desktop.
Iterating over the current sprite sheet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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