4

I have an issue with PyOpenGL 3.0.2 on a Windows 8 64 bits laptop with an Intel HD 3000 graphics chipset. Any call to glGenBuffers(1) (after proper GL initialization) crashes:

  File ".\sample.py", line 7, in init
    buffer = glGenBuffers(1)
  File "latebind.pyx", line 32, in OpenGL_accelerate.latebind.LateBind.__call__ (src\latebind.c:768)
  File "wrapper.pyx", line 308, in OpenGL_accelerate.wrapper.Wrapper.__call__ (src\wrapper.c:5811)
  File "C:\Python27\lib\site-packages\OpenGL\platform\baseplatform.py", line 379, in __call__
    return self( *args, **named )
WindowsError: exception: access violation writing 0x00000000720CF630

The exact same script works on other machines.

I have the latest version of the GPU driver (15.28.12.64.2932) which supports OpenGL 3.1.

Any ideas?

Here is the sample script:

import sys
from OpenGL.GLUT import *
from OpenGL.GL import *
from OpenGL.GLU import *

def init():
    buffer = glGenBuffers(1)

glutInit(sys.argv)
glutInitWindowSize(600, 600)
glutCreateWindow("Sample")
init()
glutMainLoop()
Cyrille Rossant
  • 488
  • 1
  • 6
  • 19
  • possible duplicate of [Calling OpenGL Extensions from Python](http://stackoverflow.com/questions/6423994/calling-opengl-extensions-from-python) – genpfault Mar 07 '13 at 19:05
  • I don't think it is, `glGenBuffers` is in `OpenGL.GL.*` and not in `OpenGL.GL.ARB.*`. In addition, there is no `OpenGL.GL.ARB.vertex_buffer_object` on my system. – Cyrille Rossant Mar 08 '13 at 10:32

2 Answers2

1

Even though your drivers support OpenGl 3.1, Glut is going to give you an OpenGL 2.0 context by default. You are going to have to ask for a 3.1 cpntext, probably like this:

glutInitContextVersion(3, 1) 
glutInitContextFlags(GLUT_FORWARD_COMPATIBLE) 
glutInitContextProfile(GLUT_CORE_PROFILE)

Without a proper 3.1 context, any 3.1 specific calls will lead you to a crash.

  • 1
    I just tried and I have the exact same issue. Also, I have the same problem with PyQt4 (using QGLWidget), so I don't think it's Glut-specific. – Cyrille Rossant Mar 07 '13 at 23:47
  • It isn't Glut specific. On most platforms when you start up OpenGL you will have at best a 2.x context. If you try to use 3.x functionality without the proper context, you will crash. – Stephan van den Heuvel Mar 08 '13 at 00:13
  • OK. I have two questions though: * When I do `glGetString(GL_VERSION)` I get OpenGL 3.1: does that guarantee that OpenGL 3.1 is really loaded? If not, how do I know the exact version? * I think `glGenBuffers` is core OpenGL 1.5, so it should work whether I have OpenGL 2 or OpenGL 3.1, right? – Cyrille Rossant Mar 08 '13 at 09:54
1

I finally resolved the problem by uninstalling my whole Python 64 bits distribution and installing Python 32 bits and all the libraries in 32 bits. In addition I had to use PyOpenGL 3.1.a. I have no idea what caused the problem with the 64 bits installation in the first place.

Cyrille Rossant
  • 488
  • 1
  • 6
  • 19