Re: [PyOpenGL-Users] glVertexAttribPointer(); loading platform-specific functions
Brought to you by:
mcfletch
From: Paulo S. <nit...@gm...> - 2009-08-13 14:38:24
|
Joshua Davis from http://www.joshuadavis.com/ :O ? awesome, be welcome! \o/ anyway, i don't know if it is your very first approach on OpenGL using PyOpenGL - i think i'm even struggling with it way much more than you - my very first approaches were trying to analyse some pyweek games like http://pyweek.org/e/GNAG/ , but it uses Pyglet instead (which also uses OpenGL as well) - in the case you can't fix what you try to do with PyOpenGL, maybe would be a good idea trying Pyglet also... cheers! On 8/13/09, Joshua Davis <joshuardavis@q.com> wrote: > 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 > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > |