Safe Haskell | None |
---|---|
Language | Haskell2010 |
- setVertexLayout :: [LayoutElement] -> IO ()
- data LayoutElement
- data DataType
Documentation
To feed vertices into the vertex shader, the layout of a vertex must be
specified in the current VAO for the current shader program. Make a list of
LayoutElements and use setVertexLayout
on it as seen below.
setVertexLayout [ Attrib "position" 3 GLFloat -- first 12 bytes maps to: in vec3 position; , Attrib "shininess" 1 GLFloat -- next 4 bytes maps to: in float shininess; , Attrib "texcoord" 2 GLFloat -- next 8 bytes maps to: in vec2 texcoord; , Unused 2 -- next 2 bytes ignored , Attrib "seed" 1 GLShort ] -- next 2 bytes maps to: in float seed; bytes are treated as 16-bit signed int
In this example four mappings are established between the current shader and the current VBO. The information is stored in the current VAO.
setVertexLayout :: [LayoutElement] -> IO () Source
This configures the currently bound VAO. It calls glVertexAttribPointer and glEnableVertexAttribArray.
data LayoutElement Source
The name of a vertex input to a program combined with the component format and number of components for that attribute in the vertex data. Alternatively the size of an unused section of the data in bytes.
Attrib String Int DataType | Name, component count and component format of a vertex attribute. |
Unused Int | Size in bytes of an unused section of the vertex data. |
Show LayoutElement Source |
The size and interpretation of a vertex attribute component.
GLFloat | 4-byte float |
GLByte | signed byte |
GLUnsignedByte | unsigned byte |
GLShort | 2-byte signed integer |
GLUnsignedShort | 2-byte unsigned integer |
GLInt | 4-byte signed integer |
GLUnsignedInt | 4-byte unsigned integer |