OpenGL glutWireCube
works but glutWireCylinder
doesn't.
glutWireCylinder
throws an 'undefined'
error. How can this be?
What am I doing wrong?
OpenGL glutWireCube
works but glutWireCylinder
doesn't.
glutWireCylinder
throws an 'undefined'
error. How can this be?
What am I doing wrong?
That function is not defined because GLUT does not have a function named glutWireCylinder()
. This is based on the official GLUT documentation here:
https://www.opengl.org/documentation/specs/glut/spec3/spec3.html
If you don't mind using legacy features, the GLU (GL Utility) library has a function for drawing cylinders (see man page for details).
// setup
GLUquadric* quadric = gluNewQuadric();
gluQuadricDrawStyle(quadric, GLU_LINE);
// drawing
gluCylinder(radius, radius, height, 32, 8);
// cleanup
gluDeleteQuadrc(quadric);
If you don't want to use deprecated libraries, writing code to draw a cylinder is easy to write yourself. My answer here shows how to draw a circle, which gets you most of the way to drawing a cylinder: How to draw a circle using VBO in ES2.0.