def _loaddata(self): a = array.array(self.elementType, self.indices) self.datastring = a.tostring() glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, self.id) glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, len(self.datastring), self.datastring, self.usage) glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0)
def __init__(self, id, points): self.id = id self.datastring = array.array('f', points).tostring() glEnableClientState(GL_VERTEX_ARRAY) glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.id) glBufferDataARB(GL_ARRAY_BUFFER_ARB, len(self.datastring), self.datastring, GL_STATIC_DRAW_ARB)
def _upload(self): """Copies all the vertex data to the graphics card""" #determine the offsets for each block and the total size offset = 0 for block in self.dataBlocks: block.offset = offset offset += block.sizeInBytes self.totalSize = offset #create one monolithic data string and give it to opengl self.datastring = ''.join([x.datastring for x in self.dataBlocks]) glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.id) glBufferDataARB(GL_ARRAY_BUFFER_ARB, len(self.datastring), self.datastring, self.usage) glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)
def __init__(self, id, points): self.id = id self.datastring = array.array( 'f', points).tostring() glEnableClientState( GL_VERTEX_ARRAY ) glBindBufferARB( GL_ARRAY_BUFFER_ARB, self.id ) glBufferDataARB( GL_ARRAY_BUFFER_ARB, len( self.datastring ), self.datastring, GL_STATIC_DRAW_ARB );