Chris Herborth wrote:
Tobias Langner wrote:
- rotate the texture during drawing (can I do that by changing the
texture coordinates?)
I’m not an expert, but IIRC the texture co-ordinates are used to specify
which parts of the texture are drawn, and they can be used to mirror the
texture, but not rotate it.
Yes, you can rotate it too. If you were going to do this to draw your
normal quad:
glTexCoord2f(0.0, 0.0); glVertex2f(-0.5, -0.5);
glTexCoord2f(1.0, 0.0); glVertex2f(0.5, -0.5);
glTexCoord2f(1.0, 1.0); glVertex2f(0.5, 0.5);
glTexCoord2f(0.0, 1.0); glVertex2f(-0.5, 0.5);
you could rotate if 90 degrees to the left by doing instead:
glTexCoord2f(0.0, 1.0); glVertex2f(-0.5, -0.5);
glTexCoord2f(0.0, 0.0); glVertex2f(0.5, -0.5);
glTexCoord2f(1.0, 0.0); glVertex2f(0.5, 0.5);
glTexCoord2f(1.0, 1.0); glVertex2f(-0.5, 0.5);
You can even have OpenGL transform the texture coordinates for you by
using the GL_TEXTURE matrix:
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glRotatef(42.0f, 0.0f, 0.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
I’m not sure, but there may be a (slight?) performance hit for using the
GL_TEXTURE matrix.–
Jon