PDA

View Full Version : Texture Rotation



scrodde
12-08-2005, 10:12 AM
I was wondering howto rotate my texture around its center and not the lower left corner that it does now with this code:

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glRotatef(x, 0.0f, 0.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);

memfr0b
12-08-2005, 12:40 PM
This should make the texture rotate around (0.5, 0.5):


glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslate(0.5, 0.5, 0.5); // z is not really relevant
glRotatef(x, 0.0f, 0.0f, 1.0f);
glTranslate(-0.5, -0.5, -0.5);
glMatrixMode(GL_MODELVIEW);