def __init__(self, size, *args): """ Initialize Data into default state. """ GLObject.__init__(self) self._data = {} for dtype in args: dtype = np.dtype(dtype) if not dtype.fields: raise TypeError('dtype must be structured type') array = np.empty(size, dtype) buffer = VertexBuffer(array) for name in dtype.names: self._data[name] = array, buffer
def __init__(self, size, *args): """ Initialize Data into default state. """ GLObject.__init__(self) self._data = {} for dtype in args: dtype = np.dtype(dtype) if not dtype.fields: raise TypeError('dtype must be structured type') array = np.empty(size, dtype) buffer = VertexBuffer(array) for name in dtype.names: self._data[name] = array,buffer
def __init__(self, target, data=None): """ Initialize buffer into default state. """ GLObject.__init__(self) # Store and check target if target not in (gl.GL_ARRAY_BUFFER, gl.GL_ELEMENT_ARRAY_BUFFER): raise ValueError("Invalid target for buffer object.") self._target = target # Total bytes consumed by the elements of the buffer self._nbytes = 0 # Indicate if a resize has been requested self._need_resize = False # Buffer usage (GL_STATIC_DRAW, G_STREAM_DRAW or GL_DYNAMIC_DRAW) self._usage = gl.GL_DYNAMIC_DRAW # Set data self._pending_data = [] if data is not None: self.set_data(data)