[PyOpenGL-Users] glVertexAttribPointer(); loading platform-specific functions
Brought to you by:
mcfletch
From: Joshua D. <joshuardavis@q.com> - 2009-08-13 14:06:14
|
I have some questions that probably boil down to my inexperience with Python. My setup is PyOpenGL-3.0.0c1 on Python 2.5.x on Mac OS X. I'm trying to modernize my OpenGL to use VBOs and vertex attributes, working through the tutorials at http://bazaar.launchpad.net/ ~mcfletch/openglcontext/trunk/annotate/head:/tests/shader_4.py. When I execute code like this: vertexBufferObject = vbo.VBO(...) gl.glVertexAttribPointer(positionLocation, 3, GL_FLOAT, False, 24, vertexBufferObject) The second line generates this error: ctypes.ArgumentError: argument 6: <type 'exceptions.TypeError'>: Don't know how to convert parameter 6 The following code is what I've been doing to get platform-specific (?) PyOpenGL functions. They often seem to require some massaging of argument types; is the same thing needed for glVertexAttribPointer() above? # This is adapted from http://www.pygame.org/wiki/GLSLExample. try: from OpenGL import platform gl = platform.OpenGL except ImportError: try: gl = cdll.LoadLibrary('libGL.so') except OSError: from ctypes.util import find_library path = find_library('OpenGL') gl = cdll.LoadLibrary(path) gl.glShaderSource.argtypes = [c_int, c_int, POINTER(c_char_p), POINTER (c_int)] gl.glGetShaderiv.argtypes = [c_int, c_int, POINTER(c_int)] gl.glGetShaderInfoLog.argtypes = [c_int, c_int, POINTER(c_int), c_char_p] Is there some newer, better way to load these functions? Is there some web tutorial that explains what's going on here, so that I can debug it myself next time? Thanks -- Josh |