Существует два способа компенсировать это:
- компенсировать вращение четырехугольника, вызванное вращением вокруг ступицы
или
- повернуть текстурное координатное пространство с помощью квадрата.
Решение 1:
/* This draws a textured quad at the origin; use the modelview to position it */
void draw_textured_quad(void);
void draw_dial(float quad_angular_position)
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glRotatef(-angular_position, 0, 0, 1); /* counterrotate the quad */
glTranslatef(dial_radius, 0, 0); /* move to the dial */
glRotatef(angular_position, 0, 0, 1); /* revolve around the dial */
draw_textured_quad();
glPopMatrix();
}
Решение 2:
/* This draws a textured quad at the origin; use the modelview to position it */
void draw_textured_quad(void);
void draw_dial(float quad_angular_position)
{
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glRotatef(angular_position, 0, 0, 1); /* rotate the texture_space _with_ the quad */
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(dial_radius, 0, 0); /* move to the dial */
glRotatef(angular_position, 0, 0, 1); /* revolve around the dial */
draw_textured_quad();
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}