Hey Matthew,

Actually, one of the examples I was going off of does exactly this.  First hit 
on google if you search for pyopengl vertex buffer objects.
http://ltslashgt.com/2007/08/31/vertex-buffer-object-pyopengl/

Nice simple vertex buffer object wrapper actually.

I assumed I wouldn't be able to load pyopengl and use that within maya.  I just 
tried it and that doesn't seem to work either.

from OpenGL.raw import GL
...
self.vbuffer = GL.GLuint(0)
glFT.glGenBuffersARB(1, self.vbuffer)
self.vbuffer = self.vbuffer.value
glFT.glBindBufferARB(OpenMayaRender.MGL_ARRAY_BUFFER_ARB, self.buffer)

Maya is still complaining
// Error: TypeError: file /Users/Justin/Documents/workspace/lidar/ptxViewer.py 
line 288: in method 'MGLFunctionTable_glGenBuffersARB', argument 3 of type 
'MGLuint *' //

where line 288 is glFT.glGenBuffersARB(1, self.vbuffer)

I don't have a direct link, but I read in the docs somewhere today that Maya 
overrides every openGL call with an M prefix (GL -> MGL).  Seems like it really 
wants an MGLuint*.

If I were writing this in c++ I could directly import the GL libraries and do 
whatever i need.  It seems that the python side of things is somewhat limited.

Thanks for the help!  Let me know if you think of anything else!  Any help is 
greatly appreciated.

Justin



On Apr 18, 2010, at 10:57 PM, Matthew Chapman wrote:

> I dont have a great test case to fiddle with it but I think this might help.
> 
> from OpenGL.raw import GL  
> buffer = GL.GLuint(0)  
> glGenBuffers(1, buffer)
> 
> Some docs
> http://pyopengl.sourceforge.net/documentation/opengl_diffs.html
> http://www.siafoo.net/article/58/diff?to=5&from=4
> 
> 
> On Sun, Apr 18, 2010 at 1:15 PM, Justin Rosen <[email protected]> wrote:
> Has anyone done any in depth OpenGL with the python API?
> 
> My plug-in is essentially a point cloud viewer displaying +millions of 
> points.  My first implementation used display lists which is good for static 
> geometry, but not so good for wanting to dial in density or using an 
> interactive crop box.  The display lists need to be regenerated every time 
> there's a change.
> 
> My plan was to implement both vertex arrays and vertex buffer objects and 
> have a toggle between display lists, vertex arrays and vertex buffer objects 
> to see the performance of each.
> 
> I was able to create vertex arrays using numpy.  But, I'm unable to create 
> vertex buffer arrays.
> 
> I'm trying to use glFT.glGenBuffersARB within a locator node with no luck.  
> glGenBuffersARB takes 2 arguments
> 
> From the OpenGL 3.2 Spec
>       GenBuffers(sizei n, uint *buffers)
> From PyOpenGL 3.0
>       glGenBuffers(GLsizei(n), GLuintArray(buffers))
> 
> No matter what I give it Maya throws the following error
> 
> // Error: TypeError: file 
> /Users/Justin/Documents/workspace/lidar/ptxViewer.py line 285: in method 
> 'MGLFunctionTable_glGenBuffersARB', argument 3 of type 'MGLuint *' // 
> 
> Does anyone know how to create a MGLuint* in Maya's python?
> 
> I've tried passing a few things in hopes that something would give, but to no 
> avail.
> 
> buffer = numpy.zeros(0, 'uint32')
> buffer = OpenMaya.MScriptUtil().asUintPtr()
> buffer = OpenMaya.MUintArray()
> 
> glFT.glGenBuffersARB(1, buffer)
> 
> I know this is probably doable through the C++ API, but I liked the idea of 
> prototyping in python then porting it to see the performance benefits between 
> the python/c++ implementations.
> 
> Cheers,
> Justin
> 
> -- 
> http://groups.google.com/group/python_inside_maya
> 
> 
> -- 
> http://groups.google.com/group/python_inside_maya

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to