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

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

Graphics.Luminance.Buffer

Contents

Description

 

Synopsis

Buffer creation

data Buffer Source

A Buffer is an opaque and untyped region of abstract GPU memory. You cannot do much with it and you might even not see the type in the user interface as it’s not really needed. It’s shown for informational purposes only.

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

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

createBuffer_ :: forall a m rw. (BufferRW rw, MonadIO m, MonadResource m) => BuildRegion rw a -> m (a, Buffer) Source

Buffer access

class BufferRW rw Source

Buffer’s Regions can have reads and writes. That typeclass makes implements all possible cases.

Minimal complete definition

bufferFlagsFromRW

Buffer regions

data Region rw a Source

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

Instances

Eq (Region rw a) Source 
Show (Region rw a) Source 

data BuildRegion rw a Source

Convenient type to build Regions.

newRegion :: forall rw a. Storable a => Word32 -> BuildRegion rw (Region rw a) Source

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

Operations on buffer regions

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

Read a whole Region.

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

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

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

Fill a Region with a value.

(@?) :: (MonadIO m, Storable a, Readable r) => Region 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) => Region r a -> Word32 -> m a Source

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

writeAt :: (MonadIO m, Storable a, Writable w) => Region 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) => Region w a -> Word32 -> a -> m () Source

Index setter. Unsafe version of writeAt'.