Created
February 10, 2013 22:31
-
-
Save Shaptic/4751336 to your computer and use it in GitHub Desktop.
Swap out sprite sheets on the fly.
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
void CAnimation::SwapSpriteSheet(const AnimationHeader& Header) | |
{ | |
// New texture for the renderer and new dimensions for the shader. | |
m_Mesh.GetSurfaces()[0]->pMaterial->pTexture = Header.pTexture; | |
m_TexcDim = math::vector2_t(1.f / Header.columns, 1.f / Header.rows); | |
m_SheetDetails = Header; | |
m_loops_done = 0; | |
// Adjust shader for new texture dimensions. | |
gfx::CShaderPair* pShader = m_Mesh.GetSurfaces()[0]->pMaterial->pShader; | |
pShader->Bind(); | |
glUniform2f(m_tc_loc, m_TexcDim.x, m_TexcDim.y); | |
pShader->Unbind(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment