lowgl-0.4.0.1: Basic gl wrapper and reference

Safe HaskellNone
LanguageHaskell2010

Graphics.GL.Low.BufferObject

Contents

Description

Buffer Objects are objects for holding arbitrary blobs of bytes. This library exposes two types of buffer objects: VBOs and ElementArrays.

Synopsis

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 appropriately 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 rendering 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

newBufferObject :: Storable a => Vector a -> UsageHint -> IO BufferObject Source

Use this to create VBOs or element arrays from raw data. Choose the usage hint based on how often you expect to modify the VBO's contents.

deleteBufferObject :: BufferObject -> IO () Source

Delete a buffer object.

bindVBO :: BufferObject -> IO () Source

Bind a VBO to the array buffer binding target. The buffer object bound there will be replaced, if any.

updateVBO :: Storable a => Vector a -> Int -> IO () Source

Modify the data in the currently bound VBO starting from the specified index in bytes.

bindElementArray :: BufferObject -> IO () Source

Assign an element array to the element array binding target. It will replace the buffer object already bound there, if any. The binding will be remembered in the currently bound VAO.

updateElementArray :: Storable a => Vector a -> Int -> IO () Source

Modify contents in the currently bound element array starting at the specified index in bytes.

data BufferObject Source

Handle to a buffer object, such as a VBO or an element array.

Instances

data UsageHint Source

Usage hint for allocation of buffer object storage.

Constructors

StaticDraw

Data will seldomly change.

DynamicDraw

Data will change.

StreamDraw

Data will change very often.