ombra-0.2.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 #

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

drawInit :: GLES => Draw () Source #

Initialize the render engine.

drawLayer :: GLES => Layer -> Draw () Source #

Draw a Layer.

resizeViewport Source #

Arguments

:: GLES 
=> Int

Width.

-> Int

Height.

-> Draw () 

Viewport.

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.

preloadGeometry :: GLES => Geometry is -> Draw () Source #

Manually allocate a Geometry in the GPU.

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

Manually allocate a Texture in the GPU.

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

Manually allocate a Program in the GPU.

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

Manually delete a Geometry from the GPU. Note that if you try to draw it, it will be allocated again.

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.

gl :: GL a -> Draw a Source #

Perform a GL action in the Draw monad.