Thread: [PyOpenGL-Users] Re: passing Numeric arrays to PyOpenGL
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2003-05-12 16:52:56
Attachments:
gldrawelements_list.py
|
(Again, switched to PyOpenGL users to avoid spamming general python people) I'm assuming you've already discovered the problem in your geometry (you are using backward-facing polygons). I've attached a working OpenGLContext module which shows both the list and array versions working properly (hit 'a' to switch between the two versions). The switch makes no difference on my machine, by the way. Both versions are drawn as nothing unless the face culling is disabled. This is running with the latest version of PyOpenGL 2.0.1, by the way. There are, obviously, two different paths through the wrapper for the list versus the array versions, but AFAIK, both versions should work, even with the 2.0.0 PyOpenGL release (I don't think I fixed any errors in this area for the 2.0.1 release). Enjoy yourself, Mike TheDustbustr wrote: >Here's the code. > >VertexArray=[[0,0,0],[1,0,0],[2,0,0], > [0,1,0],[1,1,0],[2,1,0], > [0,2,0],[1,2,0],[2,2,0]] >IndiceArray=[0,3,4,0,4,1,1,4,5,1,5,2,3,6,7,3,7,4,4,7,8,4,8,5] > >#VertexArray=array(VertexArray, 'f') #Here's the problem line >IndiceArray=array(IndiceArray, 'i') > >glVertexPointerf(VertexArray) >glDrawElementsui(GL_TRIANGLES, IndiceArray) > >With the noted line commented, a Python list is passed to glVertexPointer, and >everything is dandy. When the noted line is uncommented, nothing is drawn. No >Numeric errors. > >Whats the deal here? Why isn't IndiceArray affected by being converted to an >array, and why IS VertexArray affected? > >Thanks, Dustin > > _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |