Question

I'm attempting to draw a solid cylinder using PyOpenGL (along with PyODE), however I am met with the following error:

OpenGL.error.NullFunctionError: Attempt to call an undefined function glutSolidCylinder, check for bool(glutSolidCylinder) before calling

I have the following three imports, and have been using other glut* calls (glutSolidSphere, glutSolidCube, etc) with no issue, but this one causes me problems.

from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
...
glutSolidCylinder(RADIUS, LENGTH, SLICES, STACKS)

I'm using Python 2.7, and when I test with print(bool(glutSolidCylinder)) I receive False.

I'd used Pip to install PyOpenGL as well.

Was it helpful?

Solution

The original GLUT implementation doesn't have cylinder functions, but freeglut does (source), (then, Python 2.7.1, PyOpenGL 3.0.1 with FreeGLUT 2.6.0 together work well on Ubuntu 12.04).

However, you can make a cylinder also with GLU functions, in Python:

quadratic = gluNewQuadric()
gluCylinder(quadratic, BASE, TOP, HEIGHT, SLICES, STACKS)      # to draw the lateral parts of the cylinder;
gluDisk(quadratic, INNER_RADIUS, OUTER_RADIUS, SLICES, LOOPS)  # call this two times in the appropriate environment to draw the top and bottom part of the cylinder with INNER_RADIUS=0.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top