Answer the question
In order to leave comments, you need to log in
How to rotate a texture by a certain degree without rotating the polygon on which the texture is applied?
How to rotate a texture by a certain degree without rotating the polygon on which the texture is applied? Graphic editors are not allowed.
glBegin(GL_QUADS);
glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(0.001f * (sin(PI*60.0f/180.0f)), 1.0f * cos(PI*60.0f/180.0f));
glVertex3f(-2.0f, 1.0f, -2.5f);
glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f * (sin(PI*60.0f/180.0f)), 1.0f * cos(PI*60.0f/180.0f)); glVertex3f(2.0f, 1.0f, -2.5f);
glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f * (sin(PI*60.0f/180.0f)), 0.001f * cos(PI*60.0f/180.0f)); glVertex3f(2.0f, 1.0f, 2.5f);
glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(0.001f * (sin(PI*60.0f/180.0f)), 0.001f * cos(PI*60.0f/180.0f)); glVertex3f(-2.0, 1.0f, 2.5f);
glEnd();
}
Answer the question
In order to leave comments, you need to log in
Actually, no way.
But if you really want to:
1. You need to make a texture that is larger than the polygon at any angle of rotation. Then rotate the texture coordinates about the center.
2. If the texture is made "to the edge" of the polygon and it is "looped" during rotation, then only rendering to textures will help here
Kerman, In general, you can rotate by changing the coordinates! but here I need a hitch at a certain angle and not from a lantern!
I'll post what is probably the best solution in a separate answer:
//Переключаемся в режим матрицы текстур
glMatrixMode(GL_TEXTURE);
//Получаем матрицу по умолчанию
glLoadIdentity();
//Смещаемся в центр, вокруг которого будет вращение
glTranslatef(0.5,0.5,0.0);
//вращаем
glRotatef(angle,0.0,0.0,1.0);
//возвращаем центр на место
glTranslatef(-0.5,-0.5,0.0);
//возвращаем режим матрицы назад
glMatrixMode(GL_MODELVIEW);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question