Gary Herron wrote: > Jamie wrote: > >> Hi, >> >> I've finally had a chance to write some code to try and do this and it >> just >> doesn't seem to display anything. I'm probably doing something >> stupid, but >> I can't see it. I've set up a minimal test case that replicates what >> i'm >> doing in my app (below), and it also fails to display anything. Is >> there a >> flag i'm missing? Gary, does this look similar to what you do in your >> code? >> >> > It's close, but there are several little problems. > > * If you are going to do depth testing, you need to clear the depth > buffer. Otherwise all draws past the first will not pass the depth > test and fail to draw anything. > > glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) > > > * Your array's type is (by default) numpy.float64 (i.e., doubles), > but you tell glVertexPointer that you are passing floats. This is > what you should tell it. (Or, since doubles are way overkill, > change your array to dtype=numpy.float32). > glVertexPointer(2,GL_DOUBLE, > > 0,self.cverts.ctypes.data_as(ctypes.POINTER(ctypes.c_double))) > > * Your call to glDrawArrays is supposed to provide the number of > vertices not the number of quads. > glDrawArrays(GL_QUADS,0,4*50) > > * Your method of building arrays is VERY inefficient -- every append > creates a new array, copies from the old, and ultimately deletes the > old. Try this instead: > self.vertarray = array([ [10+10*i,10+10*i, 10+10*i,20+10*i, > 20+10*i,20+10*i, 20+10*i,10+10*i] > for i in range(50) > ], > dtype=float64) > self.vertarray=self.vertarray.reshape(50*4,2) # Unneeded, > but nice > > (I threw the +10*i into each coordinate to calculate 50 *different* > quads rather than one quad 50 times.) > > * The call > glEnable(GL_VERTEX_ARRAY) > is not needed. In fact it's wrong, but seems to neither hurt nor > cause an error. Weird. > > * The calls to glPushClientAttrib and glPopClientAttrib do nothing > useful (in this code; Don't know about your real code). > > > Hope that helps. > > Gary Herron > > > Sorry, after all those changes, I probably should have included a final working version.
Gary Herron --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
t.py
Description: application/python
