Re: [PyOpenGL-Users] Using Vertex and index buffer objects in glDrawElements(...)
Brought to you by:
mcfletch
|
From: Mike C. F. <mcf...@vr...> - 2009-11-07 07:35:19
|
Richard Guercke wrote:
> Hi,
> I’d like to know what I am doing wrong.
> I want to transfer an array with vertices and another one with index data into buffers on the graphics card and use them in a drawElements(..) call.
> As a beginner with OpenGL (coming from Java3d), I am looking for an example that works with PyOpenGL. The C code that I have found on the Internet does not really help in this context because the problem is possibly my lack of understanding the PyOpenGL wrapping.
> Here is the code I tried:
>
There are a few convenience mechanisms in PyOpenGL, so your VBOs can be
defined like so:
from OpenGL.arrays import vbo
verts = vbo.VBO( array([[ 0,0,0 ], [ 9,0,0 ], [ 0,9,0 ], [ 0,0,9 ]],
dtype=float32) )
idxs = vbo.VBO( array([ 0,1, 0,2, 0,3],dtype=ubyte),
target=GL_ELEMENT_ARRAY_BUFFER )
verts.bind()
glEnableClientState(GL_VERTEX_ARRAY)
glVertexPointer(..., verts )
idxs.bind()
glDrawElements( ..., idxs )
the 0's in your calls are getting converted to 1-element arrays of
ints. A ctypes.c_void_p( 0 ) should work fine, if you don't want to use
a vbo object.
HTH,
Mike
--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
|