luminance-0.10: Type-safe, type-level and stateless graphics framework

Copyright(C) 2015, 2016 Dimitri Sabadie
LicenseBSD3
MaintainerDimitri Sabadie <dimitri.sabadie@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Graphics.Luminance.Buffer

Contents

Description

 

Synopsis

Buffer creation

createBuffer :: forall a m rw. (BufferRW rw, MonadIO m, MonadResource m) => BuildBuffer rw a -> m a Source

Create a new Buffer. Through the 'BuildBuild type, you can yield new regions and embed them in the type of your choice. The function returns that type.

Buffer access

class BufferRW rw Source

Buffers can have reads and writes. That typeclass makes implements all possible cases.

Minimal complete definition

bufferFlagsFromRW

Buffer regions

data Buffer rw a Source

A Buffer is a GPU typed memory area. It can be pictured as a GPU array.

Instances

Eq (Buffer rw a) Source 
Show (Buffer rw a) Source 

data BuildBuffer rw a Source

Convenient type to build Buffers.

newRegion :: forall rw a. Storable a => Word32 -> BuildBuffer rw (Buffer rw a) Source

Create a new Buffer by providing the number of wished elements.

Operations on buffer regions

readWhole :: (MonadIO m, Readable r, Storable a) => Buffer r a -> m [a] Source

Read a whole Buffer.

writeWhole :: (Foldable f, MonadIO m, Storable a, Writable w) => Buffer w a -> f a -> m () Source

Write the whole Buffer. If values are missing, only the provided values will replace the existing ones. If there are more values than the size of the Buffer, they are ignored.

fill :: (MonadIO m, Storable a, Writable w) => Buffer w a -> a -> m () Source

Fill a Buffer with a value.

(@?) :: (MonadIO m, Storable a, Readable r) => Buffer r a -> Word32 -> m (Maybe a) Source

Index getter. Bounds checking is performed and returns Nothing if out of bounds.

(@!) :: (MonadIO m, Storable a, Readable r) => Buffer r a -> Word32 -> m a Source

Index getter. Unsafe version of '(@?)'.

writeAt :: (MonadIO m, Storable a, Writable w) => Buffer w a -> Word32 -> a -> m () Source

Index setter. Bounds checking is performed and nothing is done if out of bounds.

writeAt' :: (MonadIO m, Storable a, Writable w) => Buffer w a -> Word32 -> a -> m () Source

Index setter. Unsafe version of writeAt.