Rotating a texture
Hi
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 :
glMatrixMode(GL_TEXTURE);
glTranslatef(0,0,0.5f);
glRotatef(angle,0,0,1.0f);
glTranslatef(0,0,-0.5f);
glMatrixMode(GL_MODELVIEW);
thanks,
Bruno
I''m not..
That was made in a moment of desesperation, and i pasted the wrong code., i''m translating in x/y to match u/v
That was made in a moment of desesperation, and i pasted the wrong code., i''m translating in x/y to match u/v
try:
gltranslate(-.5,-.5,0); // translate to middle of texture
glrotate(angle,0,0,1); // rotate
gltranslate(.5,.5,0); // translate back
You may have to swap the signs of the translates, nor sure. The point is translate to the middle of the texture, and rotate there. Havent tried it, let me know.
zin
zintel.com - 3d graphics & more or less
gltranslate(-.5,-.5,0); // translate to middle of texture
glrotate(angle,0,0,1); // rotate
gltranslate(.5,.5,0); // translate back
You may have to swap the signs of the translates, nor sure. The point is translate to the middle of the texture, and rotate there. Havent tried it, let me know.
zin
zintel.com - 3d graphics & more or less
zintel.com - 3d graphics & more or less
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement