Using FreeGLUT calls with PyOpenGL

PyOpenGL exposes OpenGL GL, GLU and GLUT calls to Python programs. The FreeGLUT library was developed as an extension to GLUT and adds some important functionality to GLUT. The one which I like the most is the support for the scroll wheel of the mouse.

To use GLUT calls in a Python program, we do:

from OpenGL.GLUT import *

However, it is not obvious how to use the FreeGLUT functionality from PyOpenGL. If I include a FreeGLUT call like glutMouseWheelFunc() in a Python program, it crashes with an error:

OpenGL.error.NullFunctionError: Undefined GLUT callback function MouseWheel, check for bool(glutMouseWheelFunc) before calling

On further investigation, it turns out that PyOpenGL chooses the first available DLL between glut and freeglut. This can be seen in Python32\Lib\site-packages\OpenGL\platform\win32.py. So, to get FreeGLUT functionality, we need to make PyOpenGL to pick the freeglut DLL file instead of glut. We can do this by deleting the glut DLL file(s) in Python32\Lib\site-packages\OpenGL\DLLS. Once this is done, PyOpenGL should pick the freeglut DLL and the FreeGLUT calls should be routed to it without any problem.

Tried with: PyOpenGL 3.0.2a6 and Python 3.2 64-bit

Advertisements

One thought on “Using FreeGLUT calls with PyOpenGL

  1. just tried it…
    Still get the error…

    Tbh, this is the 3rd place that`s stated this…
    The other 2 even told me to check the windows system files.

    Another reason might be that I placed GL in my app directory,
    But tbh I REALLY doubt that.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s