ombra-0.3.1.0: Render engine.

Safe HaskellNone
LanguageHaskell2010

Graphics.Rendering.Ombra.Draw

Contents

Synopsis

Documentation

data Draw a Source #

A state monad on top of GL.

Instances

Monad Draw Source # 

Methods

(>>=) :: Draw a -> (a -> Draw b) -> Draw b #

(>>) :: Draw a -> Draw b -> Draw b #

return :: a -> Draw a #

fail :: String -> Draw a #

Functor Draw Source # 

Methods

fmap :: (a -> b) -> Draw a -> Draw b #

(<$) :: a -> Draw b -> Draw a #

Applicative Draw Source # 

Methods

pure :: a -> Draw a #

(<*>) :: Draw (a -> b) -> Draw a -> Draw b #

(*>) :: Draw a -> Draw b -> Draw b #

(<*) :: Draw a -> Draw b -> Draw a #

MonadIO Draw Source # 

Methods

liftIO :: IO a -> Draw a #

MonadGL Draw Source # 

Methods

gl :: GL a -> Draw a Source #

GLES => MonadScreen Draw Source # 

data DrawState Source #

The state of the Draw monad.

Running the Draw monad

refDrawCtx :: GLES => Ctx -> Draw a -> IORef DrawState -> IO a Source #

Run a Draw action using an IORef and a context.

runDrawCtx Source #

Arguments

:: Ctx

Context (use the appropriate backend functions)

-> Draw a

Draw action

-> DrawState

State (create it with drawState)

-> IO (a, DrawState) 

drawState Source #

Arguments

:: GLES 
=> Int

Viewport width

-> Int

Viewport height

-> IO DrawState 

Create a DrawState.

Draw actions

class MonadIO m => MonadGL m where Source #

Minimal complete definition

gl

Methods

gl :: GL a -> m a Source #

Instances

MonadGL GL Source # 

Methods

gl :: GL a -> GL a Source #

MonadGL Draw Source # 

Methods

gl :: GL a -> Draw a Source #

class GLES => MonadScreen m where Source #

Minimal complete definition

currentViewport, resizeViewport

Methods

resizeViewport :: Int -> Int -> m () Source #

type MonadObject m = (MonadProgram m, MonadTexture m, MonadScreen m, MonadGeometry m, MonadDrawingMode m) Source #

drawInit :: GLES => Draw () Source #

Initialize the render engine.

clearBuffers :: (GLES, MonadGL m) => [Buffer] -> m () Source #

drawLayer :: MonadObject m => Layer' Drawable t a -> m a Source #

Draw a Layer.

Resources

In Ombra, GPU resources are allocated when they're needed, and they're kept alive by their corresponding CPU resources. Specifically, these resources are Geometries, Textures and Programs. This means that, when a CPU resource is garbage collected, the GPU resource is also removed. The functions below let you manage allocation and deallocation manually. Note that if you try to use a resource that was deallocated with the remove* functions it will be allocated again.

data ResStatus r Source #

Constructors

Loaded r 
Unloaded 
Error String 

Instances

Functor ResStatus Source # 

Methods

fmap :: (a -> b) -> ResStatus a -> ResStatus b #

(<$) :: a -> ResStatus b -> ResStatus a #

preloadGeometry :: GLES => Geometry (i ': is) -> Draw (Maybe String) Source #

Manually allocate a Geometry in the GPU. Eventually returns an error string.

preloadTexture :: GLES => Texture -> Draw (Maybe String) Source #

Manually allocate a Texture in the GPU.

preloadProgram :: GLES => Program gs is -> Draw (Maybe String) Source #

Manually allocate a Program in the GPU.

removeGeometry :: GLES => Geometry (i ': is) -> Draw () Source #

Manually delete a Geometry from the GPU.

removeTexture :: GLES => Texture -> Draw () Source #

Manually delete a Texture from the GPU.

removeProgram :: GLES => Program gs is -> Draw () Source #

Manually delete a Program from the GPU.

checkGeometry :: GLES => Geometry (i ': is) -> Draw (ResStatus ()) Source #

Check if a Geometry failed to load.

checkTexture :: (GLES, Num a) => Texture -> Draw (ResStatus (a, a)) Source #

Check if a Texture failed to load. Eventually returns the texture width and height.

checkProgram :: GLES => Program gs is -> Draw (ResStatus ()) Source #

Check if a Program failed to load.

Extensions

hasVertexArrayObjects :: GLES => Ctx -> IO Bool Source #

This extension is fundamental and Ombra won't work without it.

hasFloatTextures :: GLES => Ctx -> IO Bool Source #

Required for the buffers* layer functions. May not be supported on older hardware.

hasDrawBuffers :: GLES => Ctx -> IO Bool Source #

Required for the buffers* layer functions. May not be supported on older hardware.

hasStandardDerivatives :: GLES => Ctx -> IO Bool Source #

Required for the dFdx, dFdy and fwidth shader functions.