OpenGL 2.1

I am having trouble getting my spheres to rotate in place.
It looks like a snowman. My Bottom sphere is rotating in place, but the middle and top one move around my window and I don't know why!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
void display(void)
{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    glPushMatrix();

    //bottom sphere
    glTranslated(tranX,tranY-2,tranZ);
    glRotated(rotX,1,0,0);
    glRotated(rotY,0,1,0);
    glRotated(rotZ,0,0,1);
    glScaled(scaX,scaY,scaZ);

    glColor3f(1.1,.7,.99);
    glutSolidSphere(1.5,30,30);

    //middle sphere
    glTranslated(tranX,tranY+2.3,tranZ+8);
    glRotated(rotX,1,0,0);
    glRotated(rotY,0,1,0);
    glRotated(rotZ,0,0,1);
    glScaled(scaX,scaY,scaZ);

    glColor3f(1.1,.7,.99);
    glutSolidSphere(1.3,30,30);

    //top sphere
    glTranslated(tranX,tranY+2,tranZ+10);
    glRotated(rotX,1,0,0);
    glRotated(rotY,0,1,0);
    glRotated(rotZ,0,0,1);
    glScaled(scaX,scaY,scaZ);

    glColor3f(1.1,.7,.99);
    glutSolidSphere(1,30,30);

    glFlush();
    glPopMatrix();

   glutSwapBuffers();

}
Topic archived. No new replies allowed.