Re: [PyOpenGL-Users] VBO help and performance
Brought to you by:
mcfletch
From: Leo H. <leo...@gm...> - 2010-05-01 08:57:33
|
I don't claim to be a PyOpenGL master so YMMV, but when I did something similar a few years ago, I had to add a call to tostring() to prepare the array for PyOpenGL. I was using Numeric at the time, so the relevant code fragments were: self.vertexPositions = Numeric.zeros((size*3,3),Numeric.Float32) self._vertexPositionStr = self.vertexPositions.tostring() glEnableClientState(GL_VERTEX_ARRAY) glVertexPointer(3,GL_FLOAT,0,self._vertexPositionStr) I haven't actually used this code much in several years though. Leo On Sat, May 1, 2010 at 4:08 PM, Wakefield, Robert <rjw...@en...>wrote: > Hello, > > I've been using PyOpenGL to try to get faster graphics in pygame, and from > what I've been able to find online VBOs are the best way to optimize in my > case (2D sprites and tiled backgrounds). However, for some reason they and > the vertex arrays they're based on won't work. In even the simplest > example, nothing appears, while the corresponding display list or > glBegin/End call works without a hitch. Am I missing something, or could > this be a technical issue? Any other ideas as to what's wrong? The code I > have in the draw test is listed below (I also tried to generate/bind > buffers, to no effect, but I think the problem is the array): > > # shows nothing; also didn't work with GL_INT and integer types or > typing in the '.0' for decimal. > vertices = numpy.array([0,0, 0,128, 128,128], dtype=numpy.float32) > glEnableClientState(GL_VERTEX_ARRAY) > glVertexPointer(2, GL_FLOAT, 0, vertices) > glDrawArrays(GL_TRIANGLES, 0, 3) > glDisableClientState(GL_VERTEX_ARRAY) > > # this, however, works fine. The data points and mode (GL_TRIANGLES) > are both identical > glBegin(GL_TRIANGLES) > glVertex2f(0.0, 0.0) > glVertex2f(0.0, 128.0) > glVertex2f(128.0, 128.0) > glEnd() > > > > ------------------------------------------------------------------------------ > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > |