cube-sphere

Hello Again,

I have tha above question.I want to draw a sphere an bahind the sphere a cube.The problem
is that i want when i rotate my draw 90…the sphere to ba half inside the cube.I don’t want
to see two seperate schemes but one.The part of the sphere which will be inside the cube
i don’t want to be visible.Can you give me the part of the code which gives me solution to this?

please modify the code below

void Render()
{

glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_DEPTH_BUFFER_BIT);
glFrontFace(GL_CCW);

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0, 0.0,-100.0 );

glRotatef(0.0,0.0,1.0,0.0);
glPushMatrix();
glTranslatef( -3.0, 17.0, 0.0);
glScalef(0.73,1.12,0.8);
glColor4f(0.15,0.15,0.15,1.0);
glutSolidCube(14.0);
glPopMatrix();

glPushMatrix();//
glTranslatef( -3.8, 21.5, 0.0 );
glScalef(0.36,0.36,0.36);
glColor4f(0.3,0.3,0.3,1.0);
glutSolidSphere(8,35,22);
glPopMatrix();

glutSwapBuffers();

}
Pavlov123

Try this:

void Render()
{
glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_DEPTH_BUFFER_BIT);
glFrontFace(GL_CCW);

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0, -2.65, -30.0 );
glRotatef(0.0,0.0,1.0f,0.0);

glPushMatrix();
glTranslatef( -9.0, 0.8, -9.0 );
glScalef(0.73,1.12,0.8);
glColor4f(0.15,0.15,0.15,1.0);
glutSolidCube(14.0);
glPopMatrix();

glPushMatrix();//
glTranslatef( 9.0, 0.8, -9.0 );
glScalef(0.36,0.36,0.36);
glColor4f(0.3,0.3,0.3,1.0);
glutSolidSphere(8,35,22);
glPopMatrix();

glutSwapBuffers();
}

Hope this Helps!!!

  • VC6-OGL