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.Shader.Program

Contents

Description

 

Synopsis

Shader program creation

data Program Source

Shader program.

createProgram :: (HasProgramError e, MonadError e m, MonadIO m, MonadResource m) => [Stage] -> ((forall a. Uniform a => Either String Natural -> UniformInterface m (U a)) -> (forall a. UniformBlock a => String -> UniformInterface m (U (Region rw (UB a)))) -> UniformInterface m i) -> m (Program, i) Source

Create a new shader Program.

That function takes a list of Stages and a uniform interface builder function and yields a Program and the interface.

The builder function takes a function you can use to retrieve uniforms. You can pass 'Left name' to map a String to a uniform or you can pass 'Right sem' to map a semantic Natural to a uniform. If the uniform can’t be retrieved, throws InactiveUniform.

In the end, you get the new Program and a polymorphic value you can choose the type of in the function you pass as argument. You can use that value to gather uniforms for instance.

createProgram_ :: (HasProgramError e, MonadError e m, MonadIO m, MonadResource m) => [Stage] -> m Program Source

A simpler version of createProgram. That function assumes you don’t need a uniform interface and then just returns the Program.

Error handling

data ProgramError Source

Shader program error.

'LinkFailed reason' happens when a program fails to link. reason contains the error message.

'InactiveUniform uni' happens at linking when a uniform is inactive in the program; that is, unused or semantically set to a negative value.

class HasProgramError a where Source

Types that can handle ProgramError – read as, “have”.