PyOpenGL glVertexPointer trouble
Mike C. Fletcher
mcfletch at rogers.com
Wed May 7 21:24:07 EDT 2003
TheDustbustr wrote:
...
>I want to port this to glVertexPointer code. Here is what I have so far:
>
>
...
> glVertexPointer(3, GL_FLOAT, 0, VertexArray)
>
>
...
>This doesn't work... What am I doing wrong? I have tried variations to this
>code, end results have been PyGame "parachuting", PyGame segfaulting, or
>nothing being displayed at all. The glVertex3f code works exactly as expected.
>
>
Looks like there's something weird going on with the glVertexPointer
code. I can imagine that almost no-one has used the raw glVertexPointer
function, given the alternate spellings being so much easier to use from
Python. The segfaulting etceteras is possible because the undecorated
method is basically letting you specify directly to the OpenGL engine a
set of array-traversal specs. If you get them slightly off (e.g. length
> array) you'll potentially get a memory-access failure. That, and the
ease of using the decorated functions is probably why no-one has
stumbled across the error before.
I've added a bug report to the PyOpenGL project assigned to me, will try
to get to it fairly soon.
Here's a working version of your code that uses the "decorated"
function, in case you want it:
points = array([[0,0,0],[1,0,0],[1,1,0],[0,1,0]], 'f')
indices = array( range(len(points)), 'i')
class TestContext( BaseContext ):
def OnInit( self ):
"""Initialisation"""
print """Should see square over black background"""
def Render( self, mode = 0):
BaseContext.Render( self, mode )
## glVertexPointer( len(points),GL_FLOAT, 0, points)
glVertexPointerf( points )
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElementsui(
GL_QUADS,
indices
)
Enjoy,
Mike
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
More information about the Python-list
mailing list