View Full Version : Rotating a texture
04-11-2002, 12:02 PM
This should be rather simple, but i can't get it to work.
Supose i have a quad, and i want the texture wich is binded to that quad to rotate, but the rotation should be done on the center of the quad.What i'm doing is the following :
What am i doing wrong ?
04-11-2002, 10:38 PM
Switch the two glTranslatef instructions.
OpenGL matrices are left-multiplied, so the last matrix change is applied first.
And to prohibit matrix degeneration by applying the same angle over and over again, I'd suggest to call glLoadIdentity first and let the angle increase (modulo 360.0):
04-12-2002, 02:10 AM
I really have nothing to say about this. It was a simple question with a simple answer.
And yes the matrices are all left multiplied in opengl. Meaning as said, the last matrix operation gets applied first. This is actually better when concatenated matrices for complex hierarchies for animation and the like.
****** I just wanted to clarify what I meant by better. Being left multiplied as it was put is what allows you to build a MODELVIEW matrix that converted everything to eye/camera space and then apply local transforms for the object on top of that matrix. A lot of books talk about having a separate local to world transform, then the world to camera/eye and then the projection. In this case the local to world is used for animation hierarchies and then the world to camera is applied on top of this. I believe directX/3d operates in this manner. In the end it really doesn't make much difference. The end result should be the same. Opengl I believe simply believed that having one less matrix (and matrix stack) would be more efficient, and I believe they are right in that thinking.
[This message has been edited by Devulon (edited 04-12-2002).]
04-12-2002, 04:18 AM
Thanks guys, but it's still not working...
I was told by a friend that the second translate should take into account the rotation that was made, but i still can't figure it out..
I tried this too :
but.., still not working
This one will work,
glTranslatef( 0.5f, 0.5f, 0.0f );
glRotatef( AngleTime, 0.0f, 0.0f, 1.0f );
glTranslatef( -0.5f, -0.5f, 0.0f );
04-12-2002, 04:35 AM
glTranslatef( .5f, .5f, 0);
glRotatef(tx1rot, 0, 0, 1);
taken from there: http://developer.nvidia.com/view.asp?IO=Simple_Multitexturing_ogl
wich is what you want, don't you?
it will work. bug is somewhere else.. we'll take a look this evening http://www.opengl.org/discussion_boards/ubb/wink.gif
04-12-2002, 04:46 AM
I seem to remember that any changes to the texture matrix don't actually happen *unless* texturing is enabled - ie. unless you've issued this command before doing your texture matrix manipulation:-
...on the desired texture unit (if you're doing multitexturing).
Don't quote me on this, but I'm almost sure it's true.
Maybe this is your problem?
04-12-2002, 05:32 AM
Doh, sorry 'bout that, I take my first half of the answer back. Seems as if I confused deltas and coordinates. http://www.opengl.org/discussion_boards/ubb/wink.gif
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.