How to flip sprite / texture in OpenGLES?

I have a sprite loaded as a texture, and I need to animate it, letting it โ€œlookโ€ left or right - in fact, I sometimes need to โ€œflipโ€ it. I know that OpenGL has gltranslate, which repositions the object, and glrotate, which rotates it. Is there a method that just flips it along one axis? If not, how would you do it?

+6
objective-c iphone opengl
source share
2 answers

I have not confused with point sprites, but I think these are textures. Textures have texture matrices, which means you can use glTranslatef() , glScalef() and glRotatef() .

I would try something along the lines of glScalef(-1,1,1); that would flip the coordinate of the texture along the x axis.

As I said, I did not play with point sprites, but I also did not interfere with texture matrices. However, they are really useful.

Update: I played with texture matrices in the meantime. Just as you switch between model and projection matrices, you can switch to a texture matrix; approximately: glMatrixMode(GL_TEXTURE); , after which you can perform the above operations.

You can also just draw a square / two triangles and make with it :)

+6
source share

You cannot do this with OpenGL point sprites; although you can move the center of the sprite around, its shape is always oriented the same way.

What you can do is draw your sprites as ATVs that allow you to flip, rotate and tinker with them the way you want. There are tutorials on hand drawing sprites (aka billboards) on NeHe

0
source share

All Articles