def copy_data( self ): """Copy our data into the buffer on the GL side (if required) Ensures that the GL's version of the data in the VBO matches our internal view of the data, either by copying the entire data-set over with glBufferData or by updating the already-transferred data with glBufferSubData. """ assert self.buffers, """Should do create_buffers before copy_data""" if self.copied: if self._copy_segments: while self._copy_segments: start,size,data = self._copy_segments.pop(0) dataptr = ArrayDatatype.voidDataPointer( data ) self.implementation.glBufferSubData(self.target, start, size, dataptr) else: if self.data is not None and self.size is None: self.size = ArrayDatatype.arrayByteCount( self.data ) self.implementation.glBufferData( self.target, self.size, self.data, self.usage, ) self.copied = True
def glVertexAttribPointer( baseOperation, index, size, type, normalized, stride, pointer, ): """Set an attribute pointer for a given shader (index) index -- the index of the generic vertex to bind, see glGetAttribLocation for retrieval of the value, note that index is a global variable, not per-shader size -- number of basic elements per record, 1,2,3, or 4 type -- enum constant for data-type normalized -- whether to perform int to float normalization on integer-type values stride -- stride in machine units (bytes) between consecutive records, normally used to create "interleaved" arrays pointer -- data-pointer which provides the data-values, normally a vertex-buffer-object or offset into the same. This implementation stores a copy of the data-pointer in the contextdata structure in order to prevent null- reference errors in the renderer. """ array = ArrayDatatype.asArray( pointer, type ) key = ('vertex-attrib',index) contextdata.setValue( key, array ) return baseOperation( index, size, type, normalized, stride, ArrayDatatype.voidDataPointer( array ) )
def glVertexAttribPointerARB( baseOperation, index, size, type, normalized, stride, pointer, ): """Set an attribute pointer for a given shader (index) index -- the index of the generic vertex to bind, see glGetAttribLocation for retrieval of the value, note that index is a global variable, not per-shader size -- number of basic elements per record, 1,2,3, or 4 type -- enum constant for data-type normalized -- whether to perform int to float normalization on integer-type values stride -- stride in machine units (bytes) between consecutive records, normally used to create "interleaved" arrays pointer -- data-pointer which provides the data-values, normally a vertex-buffer-object or offset into the same. This implementation stores a copy of the data-pointer in the contextdata structure in order to prevent null- reference errors in the renderer. """ array = ArrayDatatype.asArray(pointer, type) key = ('vertex-attrib', index) contextdata.setValue(key, array) return baseOperation(index, size, type, normalized, stride, ArrayDatatype.voidDataPointer(array))
def copy_data( self ): """Copy our data into the buffer on the GL side""" assert self.buffers, """Should do create_buffers before copy_data""" if self.copied: if self._copy_segments: while self._copy_segments: start,size,data = self._copy_segments.pop(0) dataptr = ArrayDatatype.voidDataPointer( data ) self.implementation.glBufferSubData(self.target, start, size, dataptr) else: self.implementation.glBufferData( self.target, self.data, self.usage, ) self.copied = True
def copy_data(self): """Copy our data into the buffer on the GL side""" assert self.buffers, """Should do create_buffers before copy_data""" if self.copied: if self._copy_segments: while self._copy_segments: start, size, data = self._copy_segments.pop(0) dataptr = ArrayDatatype.voidDataPointer(data) self.implementation.glBufferSubData( self.target, start, size, dataptr) else: self.implementation.glBufferData( self.target, self.data, self.usage, ) self.copied = True
def setSlice(self, start, size, data): """ sets a slice of data. """ dataptr = ArrayDatatype.voidDataPointer( data ) gl.glBufferSubData( self.target, start, size, dataptr )