Safe Haskell | None |
---|---|
Language | Haskell2010 |
Vertex array objects, or VAOs as we abbreviate them.
These are used to specify how data in a Buffer
is made
available in a shader program.
https://www.opengl.org/wiki/Vertex_Array_Object
Either OpenGL 3.0 or GL_ARB_vertex_array_object
extension is required to
use operations from this module.
- newVAO :: MonadIO m => m VAO
- data VAO
- sourceVertexData :: MonadIO m => Buffer -> Sourcing -> VAO -> m ()
- data Sourcing = Sourcing {
- offset :: Int
- attributeIndex :: Int
- components :: Int
- stride :: Int
- normalize :: Bool
- integerMapping :: Bool
- instancingDivisor :: Int
- sourceType :: SourceType
- defaultSourcing :: Sourcing
- defaultSourcingType :: SourceableType a => a -> Sourcing
- class SourceableType a where
- reifyType :: a -> SourceType
- data SourceType
- sourceTypeSize :: SourceType -> Int
Creation
newVAO :: MonadIO m => m VAO Source
Creates a vertex array object.
Initially, the vertex array object makes no data available to a shader program.
The vertex array object data type.
Sourcing
:: MonadIO m | |
=> Buffer | From which buffer to source the data. |
-> Sourcing | Specifies how the sourcing is done. |
-> VAO | |
-> m () |
Specifies that some data from a buffer should be sourced for each vertex.
The vertex array object retains a reference to the buffer which means it will not be garbage collected as long as the VAO remains active.
Consequences are undefined if your Sourcing
does not make sense. There is
some error checking but it can only detect obviously invalid values in the
sourcing.
Specifies how to source data.
For forward compatibility, you might want to use defaultSourcing
or
defaultSourcingType
and then set the fields that are of interest to you.
Sourcing | |
|
defaultSourcing :: Sourcing Source
The default sourcing.
Offset and stride are set to 0.
At the very least you must set components
and attributeIndex
.
You must also set normalize
, integerMapping
and sourceType
in a
consistent way. See Sourcing
.
:: SourceableType a | |
=> a | Used to pass the type; not evaluated. |
-> Sourcing |
Same as defaultSourcing
but sets sourceType
according to a Haskell
type.
Sourceable types
class SourceableType a where Source
Class of types that are valid for sourcing data.
This is a convenience class to turn Haskell types to SourceType
.
reifyType :: a -> SourceType Source
Reify the type to a compatible SourceType
.
data SourceType Source
Types allowed for sourcing.
These are mostly Haskell types except for SHalfFloat
which has no Haskell
equivalent.
sourceTypeSize :: SourceType -> Int Source
This returns the size of a SourceType
, in bytes.