Problem with displaying 3 objects using OpenGL

I am trying to draw a cube, rectangular prism, and a triangular pyramid and trying to display all 3 objects (rotating) on the screen at the same time. I can display each object separately and rotate each object separately, but I cannot draw and rotate all objects on the window at the same time. I am using glEnable and glDisable. I tried using PushMatrix and PopMatrix but nothing worked. Does anyone have any suggestions?

Hi, if you can see it separately, you dont need to do nothing with glEnable to see all.

if you need to rotate this with one common axis try this:
glRotatef(angle, 0,1,0)
glPushMatrix()
<draw first object>
glPopMatrix()

glPushMatrix()
<draw second object>
glPopMatrix()

glPushMatrix()
<draw third object>
glPopMatrix()

if there are a axis for each object try with:

glPushMatrix()
glRotatef(angle1, 0,1,0)
<draw first object>
glPopMatrix()

glPushMatrix()
glRotatef(angle2, 0,1,0)
<draw second object>
glPopMatrix()

glPushMatrix()
glRotatef(angle3, 0,1,0)
<draw third object>
glPopMatrix()

Hi !

Please try this:

DrawGLScene()
{

// assume that we are looking down
// -ve z-axis.
// depending on the object size, &
// vieweing volume, please adjust
// cam coordinates.

gluLookAt(0.0f, 0.0f, 50.0f, // eye
0.0f, 0.0f, 0.0f, // look-at
0.0f, 1.0f, 0.0f); // up


glPushMatrix();
—DrawCentreObject(); // 1
glPopMatrix();


glPushMatrix();
—glTranslatef(10.f, 0.0f, 0.0f);
—DrawRightObject(); // 2
glPopMatrix();


glPushMatrix();
—glTranslatef(-10.f, 0.0f, 0.0f);
—DrawLeftObject(); // 3
glPopMatrix();


} // end of Draw()

Hope that helps…