[PyOpenGL-Users] Re: glDrawArrays
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2002-08-29 13:37:17
|
Here's code from the OpenGLContext glDrawArrays demo: from OpenGLContext import testingcontext BaseContext, MainFunction = testingcontext.getInteractive() from OpenGL.GL import * from Numeric import array import string from OpenGLContext.tests import flower_geometry class TestContext( BaseContext): def Render( self, mode = 0): BaseContext.Render( self, mode ) glVertexPointerd(flower_geometry.points_expanded ) glNormalPointerf(flower_geometry.normals_expanded ) glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glDrawArrays(GL_TRIANGLES, 0, len(flower_geometry.points_expanded)) (Where the points_expanded array is just an x*3 array of vertex coordinates and normals_expanded is the same for normals). That works fine on my Win2K box. See also the gldrawarrays_string demo in OpenGLContext. As for portability, glDrawArrays is (if I recall correctly) an OpenGL 1.1 feature, so potentially you might find some really old systems that only have OpenGL 1.0 that don't work with it, but basically you can rely on it in most situations. Note, that the array-drawing functionality, though generally fast enough for anything you can do in Python, does require the transfer of the array data across the AGP bus. If you're rendering _static_ geometry on modern hardware it can be faster to use a display list. If that doesn't help, please send me the exception output for the tests that aren't working for you so I can try to figure out what's going wrong. HTH, Mike Copied to the PyOpenGL list for archival purposes... Max Biagi wrote: > Hi! > I try to port this code to python: > > void Draw(){ > glColorPointer(4, GL_UNSIGNED_BYTE, 0, datColor); > glVertexPointer(3, GL_FLOAT, 0, datVertex3D); > glTexCoordPointer(2, GL_FLOAT, 0, datTexCoord); > glDrawArrays(GL_QUADS,0,datVtx); > } > > I foud 3 demos of glDrawArrays in PyOpenGl distribution but none is > working!! (win2000) > I don't know how to replace c pointers in python. > I utilize last version of Python, PyOpenGl and PyGame. > > Can you point me to a working demo? > > I'm looking to portability, do you suggest me to utilize "standard" > glbegin(GL_QUADS) / glVertex... (that works on my pc) or glDrawArrays > will work on all platform? > > Thanks! > > _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |