Rotation combined problem

Hello, I am very newbie with openGL.
I have a simple code, but I cant get the movements.
Situation: a triangle, a quad. Both rotatin their own axis (so I translate them to the origin).
Then I need them both rotating around a point (0,0,-6). But I can’t achieve this second rotations. What’s wrong?


void drawRotations(void)
{

   glTranslatef(-1.5,0,-6);

   glPushMatrix();
   glTranslatef(0,-1/3.f,0); //
   glRotatef(alfa,0,1,0);
   glTranslatef(0,1/3.f,0);
   glBegin(GL_TRIANGLES);
    glColor3f(1.0,0.0,0.0); //red
    glVertex3f(0,1,0);

    glColor3f(0.0,1.0,0.0); // green
    glVertex3f(-1,-1,0);

    glColor3f(0.0,0.0,1.0); // blue
    glVertex3f(1,-1,0);
   glEnd();

   glPopMatrix();

   glTranslatef(3.f, 0,0);

   glPushMatrix();
   glRotatef(alfa,0,1,0);
   glBegin(GL_QUADS);
        glColor3f(0.0,1.0,1.0);
        glVertex3f(-1,1,0);
        glVertex3f(1,1,0);
        glVertex3f(1,-1,0);
        glVertex3f(-1,-1,0);
   glEnd();

   glPopMatrix();

   //glRotatef(alfa,0,1,0); here I want them to rotate around
   //glTranslatef(0,0,-6); this point. No effect at all

}


the loop, the evironment is well set.
Any idea, thanks for any suggestion.

kovi

Calling glTranslate() or glRotate() after you have created the vertices with glVertex() has no effect. You need to apply the transformation before that. This means you have to do it twice in your code, once for the triangle and once for the quad.

sorry, I don’t get your point, the glRotatef and glTranslatef transformation are before the triangle and the quad actually.

maybe I missunderstood you.

I want the triangle rotate its centre around y-axis and around a point (0,0,6-). It has two roatrion, around itself and around a point. The same for the quad.

thanks, kovi