Reputation: 23
With OpenGL, I am trying to draw an arrow with cylinders(one cylinder and one cone). I used the gluCylinder()
to draw a cylinder or cone. But the base and top of the cylinder is not visible. Can anyone tell me why?
Below is the code I used.
const double AXES_LEN = 300.0;
const double ARROW_LEN = 100.0;
const double ARROW_RADIUS = 30.0;
GLUquadricObj *objCylinder = gluNewQuadric();
glPushMatrix();
glColor3f(1.0f, 1.0f, 1.0f);
gluSphere(objCylinder, 15, 20, 20);
glPopMatrix();
glPushMatrix();
glColor3f(0.0f, 0.0f, 1.0f);
gluSphere(objCylinder, 0.25, 6, 6);
gluCylinder(objCylinder, 10, 10, AXES_LEN, 10, 5); //z
//glTranslatef(0.0f, 0.0f, (GLfloat)AXES_LEN);
//gluCylinder(objCylinder, ARROW_RADIUS, 0, ARROW_LEN, 10, 5); //blue arrow
glPopMatrix();
glPushMatrix();
glColor3f(0.0f, 1.0f, 0.0f);
glRotatef(-90, 1.0, 0.0, 0.0);
gluCylinder(objCylinder, 15, 15, AXES_LEN, 10, 5); //Y North arrow
glTranslatef(0.0f, 0.0f, (GLfloat)AXES_LEN);
gluSphere(objCylinder, ARROW_RADIUS, 20, 20);
gluCylinder(objCylinder, ARROW_RADIUS*2, 2 , ARROW_LEN*2, 10, 5); //green arrow
glPopMatrix();
glPushMatrix();
glColor3f(1.0f, 0.0f, 0.0f);
glRotatef(-90, 0.0, 1.0, 0.0);
gluCylinder(objCylinder, 10, 10, AXES_LEN, 10, 5); //X
//glTranslatef(0.0f, 0.0f, (GLfloat)AXES_LEN);
//gluCylinder(objCylinder, ARROW_RADIUS, 0, ARROW_LEN, 10, 5); //red arrow
glPopMatrix();
// RESTORE VIEW STATES
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
Upvotes: 0
Views: 424
Reputation: 1870
It seems that, because the gluCylinder
is a function that draws only the side curved face.
If you want draw top and bottom faces, you may be able to use gludisk
.
Upvotes: 3