Hello,
I am simply trying to rotate an object by 20 degrees around the point (-.5,3.0)
glClearColor(1.0, 1.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1,0,0);
glPushMatrix();
glColor3f(1,0,0);
glTranslatef(.5 ,-3.0 ,0.0);
glRotatef(-20.0f, 0.0, 0.0, 0.0);
glTranslatef(-.5, 3.0, 0.0);
drawHead();
glPopMatrix();
here is my drawHead()
void drawHead()
{
glBegin(GL_POLYGON); // Draw A Quad
glVertex3f(-1.0f, 5.0f, 0.0f);
glVertex3f(0.0f, 5.0f, 0.0f);
glVertex3f(1.0f, 4.0f, 0.0f);
glVertex3f(0.0f, 3.0f, 0.0f);
glVertex3f(-1.0f, 3.0f, 0.0f);
glVertex3f(-2.0f, 4.0f, 0.0f);
glEnd();
}
I’ve looked on other posts and forums and this seems to be the way to do it. However, it is not coming out right when I run it. Sometimes the whole head will disappear. I’ve tried putting in different values in the glrotate to no avail. In theory this should move the whole object with the point i want to rotate about at origin. Rotate. And then go back to prior CS. Any help would be appreciated. Thanks!