I’m trying to rotate one of two objects on the screen. How should I do this? I can only get it to rotate all the objects on the screen.
Code:
glColor3f(1, 0, 0);
glBegin(GL_QUADS);
glVertex3f(0f, 0f, 0f);
glVertex3f(0f, .5f, 0f);
glVertex3f(.5f, .5f, 0f);
glVertex3f(.5f, 0f, 0f);
glEnd();
glRotated(.1, 0f, 1f, 0f);
glRotated(.1, 1f, 0f, 0f);
glRotated(.1, 0f, 0f, 1f);
glBegin(GL_QUADS);
glVertex3f(2f, 0f, 0f);
glVertex3f(2f, .5f, 0f);
glVertex3f(2.5f, .5f, 0f);
glVertex3f(2.5f, 0f, 0f);
glEnd();
code I have so far.
Calling
glRotatedendlessly without resetting the matrices is a bad idea. Rounding errors will accumulate. You currently don’t callglIdentityeach frame. Render each frame the following way:glIdentityThe way you render things the rotation difference of the two quads is only 1/10th of a degree on the three axis – which is not noticeable.
Be sure to read up on OpenGL, to learn the current way of OpenGL programming and try to improve your code. It looks as if you don’t quite understand what you’re doing, no offence.