I have a sprite loaded as a texture and I need to animate it, allowing it to ‘face’ left or right — essentially sometimes I need to ‘flip’ it. I know that OpenGL has a gltranslate which repositions an object, and glrotate which rotates it. Is there a method that simply flips it across one axis? If not, how would you accomplish this?
Share
I haven’t messed around with point sprites, but I believe that they are textures. Textures have texture matrices, which means you can use
glTranslatef(),glScalef()andglRotatef()on them.I would try out something along the lines of
glScalef(-1,1,1);which would flip the texture coordinate by the X axis.As I said, I haven’t played with point sprites, but I didn’t mess with texture matrices either. They do seem quite useful, though.
Update: I have played with texture matrices in the meantime. In the same way that you switch between modelview and projection matrices, you can switch to texture matrix; approximately:
glMatrixMode(GL_TEXTURE);after which you can do the aforementioned operations.You could also just paint a quad/two triangles and be done with it 🙂