PDA

View Full Version : newbie error (gluCylinder)



balaji
02-23-2000, 03:12 AM
Hi,
I am trying to draw a cylinder vertically oriented along the y axis, but all I see are two straight lines which could be the dges of the cylinder. I am using gluCylinder. Obviously there is a stupid mistake somewhere in my program. Could someone please point out to me, what I am doing wrong? I am posting part of the main routine along with the routines that create and draw the cylinder.

Thanks,
Balaji

main() {

glEnable (GL_DEPTH_TEST);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-100.0, 100.0, -50.0, 50.0, 1.0, 100.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();

Createit();
glLoadIdentity ();
glTranslatef (0.0, 0.0, -10.0);

while (1) {
XNextEvent (dpy, &event);
switch (event.type) {
case ButtonPress:
break;
case Expose:
Drawit(dpy, win, doubleBuffer);
break;
case ConfigureNotify:
glViewport (0, 0, event.xconfigure.width,
event.xconfigure.height);

Drawit(dpy, win, doubleBuffer);
break;
}
}

void Drawit(dpy, win, doubleBuffer)
Display *dpy;
Window win;
Bool doubleBuffer;
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f (0.8, 0.9, 0.9);
glCallList (CylList);

if (doubleBuffer)
glXSwapBuffers (dpy, win);
else
glFlush();
}


void Createit()
{
GLUquadricObj *cyl;

glNewList (CylList, GL_COMPILE);
glPushMatrix ();
glLoadIdentity ();
glRotatef (90.0, -1.0, 0.0, 0.0);
cyl = gluNewQuadric();
gluQuadricDrawStyle (cyl, GLU_FILL);
gluQuadricOrientation (cyl, GLU_OUTSIDE);
gluQuadricNormals (cyl, GLU_NONE);
gluQuadricCallback (cyl, GLU_ERROR, cylfunc);
gluCylinder (cyl, 6,6, 50, 432, 600);
glPopMatrix ();
glEndList ();
}

cOg
02-23-2000, 03:57 AM
Maybe i'm totally wrong but there is no glBegin anywhere in the code, i think u need it somewhere =)

Eric
02-23-2000, 08:43 AM
No cOg, when you use gluCylinder, you do not use glBegin/glEnd (it's included in the gluCylinder function !).

The only strange things I could notice are the lack of a gluDeleteQuadric(cyl) before the glEndList() and the lack of CylList=glGenLists(1) before using glNewList;

I do not know if it will solve the problem but it's worth a try !

Eric