luminance-0.8.2: 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

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.

Instances

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

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)

Buffer access

class BufferRW rw

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

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

Instances

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

data BuildRegion rw a

Convenient type to build Regions.

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

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]

Read a whole Region.

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

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 ()

Fill a Region with a value.

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

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

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

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

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 ()

Index setter. Unsafe version of writeAt'.