PDA

View Full Version : matrix mode GL_TEXTURE usage



MickeyMouse
04-09-2002, 11:39 PM
hi!
i was trying to make spinning water by manipulating with matrix for texture projection and i faced some problems- after i do
glMatrixMode(GL_TEXTURE_MATRIX);
glLoadIdentity();
glRotatef(angle, 0, 1, 0);
the drawn texture is rotated but around some other axis - my water are y-constant polys, and i simply wanted it to rotate around y-axis..
that means i think y for texture matrix is not the same as y for modelview matrix, am i right or i don't understand anything?
anyway i tried to find some tuts on different methods of manipulating texture matrix in OpenGL but i didn't succed

thx for any help

Bob
04-10-2002, 03:12 AM
When rotating a texture, you must rotate about the proper axis in texture coordinate space, not world space as when you rotate your geometry. If you map a 2D texture onto a surface, you specify texture coordinates along the axes S and T, and you should rotate about R (the third texture coordinate). Think about 2D geometry you specify along the X and Y axis on the screen. If you want to rotate it, you should rotate about the Z-axis, the axis pointing out from/in to the screen.

So to make the texture rotate on the surface, I believe you should rotate like this.



glMatrixMode(GL_TEXTURE_MATRIX);
glLoadIdentity();
glRotatef(angle, 0, 0, 1); // rotate about (S, T, R) = (0, 0, 1)