Search code examples
segmentation-faultglutpyopengl

glutInitDisplayMode causes segmentation fault


I'm trying to do my first pyopengl program but having some issues when calling the glutInitDisplayMode function. Here's what I did:

blackbear@blackbear-laptop:~/Programmazione/python$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from OpenGL.GL import *
>>> from OpenGL.GLU import *
>>> from OpenGL.GLUT import *
>>> import sys
>>> def main():
...     glClear(GL_COLOR_BUFFER_BIT)
...     glutWireTeapot(0.5)
...     glFlush()
... 
>>> glutInit(sys.argv)
['']
>>> glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
Segmentation fault
blackbear@blackbear-laptop:~/Programmazione/python$ 

It shouldn't be that difficult but still causes me troubles ;)


Solution

  • The solution is quite trivial actually, calling glutCreateWindow before glutInitDisplayMode fixed the issue.