PDA

View Full Version : glucylinder in cube



omegafox
12-10-2003, 09:15 AM
I am trying to get see through the hole on the cube by glucylinder. The problem is GL_QUADS cover the hole by glucylinder(you see circle, but you cant see through it). it works with GL_LINE_LOOP, but I really want to use with GL_QUADS bec it looks better. Any suggestions? Thanks in advance!!


public override void glDraw()
{

glClearColor(1.0f, 1.0f, 1.0f, 1.0f);//background color
glColor3f(0.0f,0.0f,0.0f);//black


glBegin(GL.GL_QUADS);//top
glVertex3f(1, 1, -1);
glVertex3f(-1, 1, -1);
glVertex3f(-1, 1, 1);
glVertex3f(1, 1, 1);
glEnd();

glBegin(GL.GL_QUADS);
glVertex3f(-1, -1, 1);//bottom
glVertex3f(1, -1, 1);
glVertex3f(1, -1, -1);
glVertex3f(-1, -1, -1);
glEnd();

glBegin(GL.GL_QUADS);
glVertex3f(1, 1, 1);//front
glVertex3f(-1, 1, 1);
glVertex3f(-1, -1, 1);
glVertex3f(1, -1, 1);
glEnd();

glBegin(GL.GL_QUADS);
glVertex3f(-1, 1, -1);//back
glVertex3f(1, 1,-1);
glVertex3f(1, -1, -1);
glVertex3f(-1, -1, -1);
glEnd();

glBegin(GL.GL_QUADS);
glVertex3f(-1,1,1); //left
glVertex3f(-1,1,-1);
glVertex3f(-1,-1,-1);
glVertex3f(-1,-1,1);
glEnd();

glBegin(GL.GL_QUADS);
glVertex3f(1,1,-1);//right
glVertex3f(1,1,1);
glVertex3f(1,-1, 1);
glVertex3f(1,-1,-1);
glEnd();

glPushMatrix();
glColor3f(1.0f,0.0f,1.0f);//pink

gluQuadricDrawStyle(cyl,GL.GL_FILL);
gluQuadricNormals(cyl, GL.GL_SMOOTH);
gluCylinder(cyl, rad, rad2, height, 20, 100);
glPopMatrix();


}

ZbuffeR
12-10-2003, 11:16 AM
What you want to do is not clear to me.
Can you be more precise / have better english / put some handrawn pictures ?

Moreover, it looks more like a beginner problem (gluCylinder and the like). Try to draw your own cylinder, it will be more flexible. Believe me, it is not very difficult.

Coconut
12-10-2003, 11:23 AM
Search the keyword "CSG" in this forum, and you should read a trick using stencil buffer.