Safe Haskell | None |
---|---|
Language | Haskell2010 |
Buffer Objects are objects for holding arbitrary blobs of bytes. This library exposes two types of buffer objects: VBOs and ElementArrays.
- newVBO :: (MonadIO m, Storable a) => Vector a -> UsageHint -> m VBO
- updateVBO :: (MonadIO m, Storable a) => Vector a -> Int -> m ()
- bindVBO :: MonadIO m => VBO -> m ()
- newElementArray :: (MonadIO m, Storable a) => Vector a -> UsageHint -> m ElementArray
- updateElementArray :: (MonadIO m, Storable a) => Vector a -> Int -> m ()
- bindElementArray :: MonadIO m => ElementArray -> m ()
- deleteBufferObject :: (MonadIO m, BufferObject a) => a -> m ()
- data VBO
- data ElementArray
- data UsageHint
VBO
Vertex Buffer Objects (VBO) contain data for a sequence of vertices. A vertex shader interprets the data for each vertex by mapping the attributes of the vertex (position, normal vector, etc) to input variables using the VAO. VBOs have the data which is used as input to the vertex shader according to the configuration of the VAO/.
Example VBO contents:
The shader will interpret those parts of the VBO as illustrated only after appropiately configuring a VAO. See Graphics.GL.Low.VAO.
ElementArray
Element arrays are buffer objects that contain a sequence of indices. When using indexed rendering, the bound element array determines the order that the vertices in the VBOs are visited to construct primitives. This allows sharing vertices in cases that many vertices overlap with each other. OpenGL accepts element array objects whose indices are encoded as unsigned bytes, unsigned 16-bit ints, and unsigned 32-bit ints.
Example ElementArray contents appropriate for render triangles and lines respectively:
See drawIndexedTriangles
and friends to see which
primitives are possible to construct with element arrays. It is not
necessary to use element arrays to render. The non-indexed versions of
the primitive render commands will simply traverse the vertices in order
specified in the VBOs.
Documentation
newVBO :: (MonadIO m, Storable a) => Vector a -> UsageHint -> m VBO Source
Create a buffer object from a blob of bytes. The usage argument hints at how often you will modify the data.
updateVBO :: (MonadIO m, Storable a) => Vector a -> Int -> m () Source
Modify the data in the currently bound VBO starting from the specified index in bytes.
bindVBO :: MonadIO m => VBO -> m () Source
Bind a VBO to the array buffer binding target. The buffer object bound there will be replaced, if any.
newElementArray :: (MonadIO m, Storable a) => Vector a -> UsageHint -> m ElementArray Source
Create a new ElementArray buffer object from the blob of packed indices. The usage argument hints at how often you plan to modify the data.
updateElementArray :: (MonadIO m, Storable a) => Vector a -> Int -> m () Source
Modify contents in the currently bound ElementArray starting at the specified index in bytes.
bindElementArray :: MonadIO m => ElementArray -> m () Source
Assign an ElementArray to the element array binding target. It will replace the ElementArray already bound there, if any. Note that the state of the element array binding target is a function of the current VAO.
deleteBufferObject :: (MonadIO m, BufferObject a) => a -> m () Source
Delete a VBO or ElementArray.
Handle to a VBO.
data ElementArray Source
Handle to an element array buffer object.
Usage hint for allocation of buffer object storage.
StaticDraw | Data will seldomly change. |
DynamicDraw | Data will change. |
StreamDraw | Data will change very often. |