PDA

View Full Version : one inside another



jonn82
02-07-2004, 03:35 AM
This is a part of my C code, and my aim is to combine a Teapot and a cylinder.What I want is the cylinder to appear through the teapot.What changes should I do? Urgent...

glPushMatrix();
glTranslatef(30,-30,0);
glRotatef(-80,1,0,0);
glColor4f(1.0, 0.0, 0.0,1.0);
GLUquadricObj *p2 = gluNewQuadric();
gluQuadricDrawStyle(p2,GLU_FILL);
gluCylinder(p2, 2.0, 2.0, 40.0, 1000, 100);
//glPushMatrix();
glRotatef(90,1,0,0);
glTranslatef(0,25,0);
glColor4f(0.0,0.5,0.7,0.0);
glutSolidTeapot(4.0);
//glPopMatrix();
glPopMatrix();

JustHanging
02-09-2004, 09:18 AM
Enable depth test...?

Or do you want to cut a hole into the teapot with the cylinder? In that case you have to use a stencil buffer trick to perform csg subtraction on the objects. Just stick the keywords into Google.

-Ilkka