PDA

View Full Version : texture matrix manipulation



dodgyposse
08-23-2002, 03:04 AM
Hi,
I am drawing some billboarded quads on screen, and wanted them to rotate.

It then occurred to me, that I could manipulate the texture matrix, and get the same effect.( correct? ).

So, I used the following:

glMatrixMode(GL_TEXTURE);
glLoadIdentity();

glRotatef(_rotationAngle,0,0,1);
glMatrixMode(GL_MODELVIEW);

and it does rotate, but not about the centre of the texture.

I tried using

glTranslatef( -0.5,-0.5,0);

to do this, but it doesnt appear to work...

Anyone got any ideas how to get this working?

Thanks in advance
Derrick

PH
08-23-2002, 03:12 AM
The following will rotate a texture about it's center,




glTranslatef( 0.5f, 0.5f, 0.0f );
glRotatef( Angle, 0.0f, 0.0f, 1.0f );
glTranslatef( -0.5f, -0.5f, 0.0f );

dodgyposse
08-23-2002, 03:41 AM
I tried something similar to that...for some strange reason I put the 2 translations in the opposite order...

And it now works!! It's been a long day...

Thanks

dd