Graphics.Rendering.OpenGL.GL.BufferObjects

OpenGL-2.2.3.0: A binding for the OpenGL graphics system

Portability | portable
Stability | stable
Maintainer | sven.panne@aedion.de

Graphics.Rendering.OpenGL.GL.BufferObjects

Contents

- Object Names
- Buffer Objects
- Binding Buffer Objects
- Handling Buffer Data
- Mapping Buffer Objects

Description

This module corresponds to section 2.9 (Buffer Objects) of the OpenGL 2.1 specs.

Synopsis

- class ObjectName a where
  - genObjectNames :: Int -> IO [a]
  - deleteObjectNames :: [a] -> IO ()
  - isObjectName :: a -> IO Bool
- newtype BufferObject = BufferObject GLuint
- data BufferTarget
  - = ArrayBuffer
  - | CopyReadBuffer
  - | CopyWriteBuffer
  - | ElementArrayBuffer
  - | PixelPackBuffer
  - | PixelUnpackBuffer
- bindBuffer :: BufferTarget -> StateVar (Maybe BufferObject)
- arrayBufferBinding :: ClientArrayType -> GettableStateVar (Maybe BufferObject)
- vertexAttribArrayBufferBinding :: AttribLocation -> GettableStateVar (Maybe BufferObject)
- data BufferUsage
  - = StreamDraw
  - | StreamRead
  - | StreamCopy
  - | StaticDraw
  - | StaticRead
  - | StaticCopy
  - | DynamicDraw
  - | DynamicRead
  - | DynamicCopy
- bufferData :: BufferTarget -> StateVar (GLsizeiptr, Ptr a, BufferUsage)
- data TransferDirection
  - = ReadFromBuffer
  - | WriteToBuffer
- bufferSubData :: BufferTarget -> TransferDirection -> GLintptr -> GLsizeiptr -> Ptr a -> IO ()
- data BufferAccess
  - = ReadOnly
  - | WriteOnly
  - | ReadWrite
- data MappingFailure
  - = MappingFailed
  - | UnmappingFailed
- withMappedBuffer :: BufferTarget -> BufferAccess -> (Ptr a -> IO b) -> (MappingFailure -> IO b) -> IO b
- mapBuffer :: BufferTarget -> BufferAccess -> IO (Maybe (Ptr a))
- unmapBuffer :: BufferTarget -> IO Bool
- bufferAccess :: BufferTarget -> GettableStateVar BufferAccess
- bufferMapped :: BufferTarget -> GettableStateVar Bool

# Object Names

class ObjectName a where

An `ObjectName` corresponds to the general OpenGL notion of an explicitly handled object name, e.g. a display list name, a texture object name, a buffer object name, etc.

Methods

genObjectNames :: Int -> IO [a]

deleteObjectNames :: [a] -> IO ()

isObjectName :: a -> IO Bool

Instances

ObjectName BufferObject |
ObjectName Program |
ObjectName FragmentShader |
ObjectName VertexShader |
ObjectName DisplayList |
ObjectName QueryObject |
ObjectName TextureObject |

# Buffer Objects

newtype BufferObject

Constructors

BufferObject GLuint |

Instances

Eq BufferObject |
Ord BufferObject |
Show BufferObject |
ObjectName BufferObject |

# Binding Buffer Objects

data BufferTarget

Constructors

ArrayBuffer |
CopyReadBuffer |
CopyWriteBuffer |
ElementArrayBuffer |
PixelPackBuffer |
PixelUnpackBuffer |

Instances

Eq BufferTarget |
Ord BufferTarget |
Show BufferTarget |

bindBuffer :: BufferTarget -> StateVar (Maybe BufferObject)

arrayBufferBinding :: ClientArrayType -> GettableStateVar (Maybe BufferObject)

vertexAttribArrayBufferBinding :: AttribLocation -> GettableStateVar (Maybe BufferObject)

# Handling Buffer Data

data BufferUsage

Constructors

StreamDraw |
StreamRead |
StreamCopy |
StaticDraw |
StaticRead |
StaticCopy |
DynamicDraw |
DynamicRead |
DynamicCopy |

Instances

Eq BufferUsage |
Ord BufferUsage |
Show BufferUsage |

bufferData :: BufferTarget -> StateVar (GLsizeiptr, Ptr a, BufferUsage)

data TransferDirection

Constructors

ReadFromBuffer |
WriteToBuffer |

Instances

Eq TransferDirection |
Ord TransferDirection |
Show TransferDirection |

bufferSubData :: BufferTarget -> TransferDirection -> GLintptr -> GLsizeiptr -> Ptr a -> IO ()

# Mapping Buffer Objects

data BufferAccess

Constructors

ReadOnly |
WriteOnly |
ReadWrite |

Instances

Eq BufferAccess |
Ord BufferAccess |
Show BufferAccess |

data MappingFailure

Constructors

MappingFailed |
UnmappingFailed |

Instances

Eq MappingFailure |
Ord MappingFailure |
Show MappingFailure |

withMappedBuffer :: BufferTarget -> BufferAccess -> (Ptr a -> IO b) -> (MappingFailure -> IO b) -> IO b

Convenience function for an exception-safe combination of `mapBuffer` and `unmapBuffer`.

mapBuffer :: BufferTarget -> BufferAccess -> IO (Maybe (Ptr a))

unmapBuffer :: BufferTarget -> IO Bool

bufferAccess :: BufferTarget -> GettableStateVar BufferAccess

bufferMapped :: BufferTarget -> GettableStateVar Bool