PDA

View Full Version : rotate the texture



hwj_just
07-07-2005, 04:45 PM
hello i want to rotate the texture and my code is like this:
glMatrixMode[GL_PROJECTION];
glLoadIdentity[];
glOrtho[ m_dOrthoD, m_dOrthoD,
m_dOrthoD, m_dOrthoD,
-50, m_dOrthoD + m_dOrthoD ];
glTranslatef[0.0, 0.0, m_dOrthoD]];
glMatrixMode[GL_TEXTURE];
glPushMatrix[];
glLoadIdentity[];
glTranslatef[0.5,0.5,0.5];
glRotatef[float[m_nAngleAroundY], 0.0, 1.0, 0.0];
glRotatef[float[-m_nAngleAroundX], 1.0, 0.0, 0.0];
glRotatef[float[m_nAngleAroundZ], 0.0, 0.0, 1.0];
glTranslatef[-0.5,-0.5,-0.5];

then i could not rotate the texture .but if i put the
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho( m_dOrthoD, m_dOrthoD,
m_dOrthoD, m_dOrthoD,
-50, m_dOrthoD + m_dOrthoD );
glTranslatef(0.0, 0.0, m_dOrthoD));
after glMatrixMode(GL_TEXTURE);i can get the right rotation.why is it like this? am i do it right?any one who could give me some suggestion?thank you very much!

tamlin
07-07-2005, 05:09 PM
Do the actual drawing code modify the current matrix? Hint: what matrix is current when leaving the posted code in the working vs. the non-working case?

hwj_just
07-07-2005, 06:00 PM
i think that my actual drawing code doesnot modify the current matrix,just do the texture mapping from back to frount.i cannot understand your hint,could you please expatiate it ?thank you very much!

tamlin
07-07-2005, 11:39 PM
My idea was that perhaps some code, after what you displayed, modified the current matrix. Then your changes to the texture matrix would be changed/overwritten.

To verify if this is the problem or not, just make the projection matrix current again, after you set up the texture matrix, in the non-workin scenario.

jide
07-08-2005, 01:38 AM
I'm really not sure, but it might be because you're under a projection matrix. Maybe gl is expecting a modelview matrix before. That sounds strange thought so forget me if I'm completly wrong.