GPipe-Core-0.2.3.0: Typesafe functional GPU graphics programming
Safe HaskellNone
LanguageHaskell2010

Graphics.GPipe.Internal.Shader

Synopsis

Documentation

newtype Shader os s a Source #

The monad in which all GPU computations are done. 'Shader os s a' lives in an object space os and a context with format f, closing over an environent of type s.

Constructors

Shader (ShaderM s a) 

Instances

Instances details
Monad (Shader os s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

(>>=) :: Shader os s a -> (a -> Shader os s b) -> Shader os s b #

(>>) :: Shader os s a -> Shader os s b -> Shader os s b #

return :: a -> Shader os s a #

Functor (Shader os s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

fmap :: (a -> b) -> Shader os s a -> Shader os s b #

(<$) :: a -> Shader os s b -> Shader os s a #

Applicative (Shader os s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

pure :: a -> Shader os s a #

(<*>) :: Shader os s (a -> b) -> Shader os s a -> Shader os s b #

liftA2 :: (a -> b -> c) -> Shader os s a -> Shader os s b -> Shader os s c #

(*>) :: Shader os s a -> Shader os s b -> Shader os s b #

(<*) :: Shader os s a -> Shader os s b -> Shader os s a #

Alternative (Shader os s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

empty :: Shader os s a #

(<|>) :: Shader os s a -> Shader os s a -> Shader os s a #

some :: Shader os s a -> Shader os s [a] #

many :: Shader os s a -> Shader os s [a] #

MonadPlus (Shader os s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

mzero :: Shader os s a #

mplus :: Shader os s a -> Shader os s a -> Shader os s a #

newtype ShaderM s a Source #

Constructors

ShaderM (ReaderT UniformAlignment (WriterT ([IO (Drawcall s)], s -> All) (ListT (State (ShaderState s)))) a) 

Instances

Instances details
Monad (ShaderM s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

(>>=) :: ShaderM s a -> (a -> ShaderM s b) -> ShaderM s b #

(>>) :: ShaderM s a -> ShaderM s b -> ShaderM s b #

return :: a -> ShaderM s a #

Functor (ShaderM s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

fmap :: (a -> b) -> ShaderM s a -> ShaderM s b #

(<$) :: a -> ShaderM s b -> ShaderM s a #

Applicative (ShaderM s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

pure :: a -> ShaderM s a #

(<*>) :: ShaderM s (a -> b) -> ShaderM s a -> ShaderM s b #

liftA2 :: (a -> b -> c) -> ShaderM s a -> ShaderM s b -> ShaderM s c #

(*>) :: ShaderM s a -> ShaderM s b -> ShaderM s b #

(<*) :: ShaderM s a -> ShaderM s b -> ShaderM s a #

Alternative (ShaderM s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

empty :: ShaderM s a #

(<|>) :: ShaderM s a -> ShaderM s a -> ShaderM s a #

some :: ShaderM s a -> ShaderM s [a] #

many :: ShaderM s a -> ShaderM s [a] #

MonadPlus (ShaderM s) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Shader

Methods

mzero :: ShaderM s a #

mplus :: ShaderM s a -> ShaderM s a -> ShaderM s a #

type CompiledShader os s = s -> Render os () Source #

A compiled shader is just a function that takes an environment and returns a Render action It could have been called CompiledDrawcall or Renderer because it is the same thing.

newtype Render os a Source #

A monad in which shaders are run.

Constructors

Render 

Fields

Instances

Instances details
Monad (Render os) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Context

Methods

(>>=) :: Render os a -> (a -> Render os b) -> Render os b #

(>>) :: Render os a -> Render os b -> Render os b #

return :: a -> Render os a #

Functor (Render os) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Context

Methods

fmap :: (a -> b) -> Render os a -> Render os b #

(<$) :: a -> Render os b -> Render os a #

Applicative (Render os) Source # 
Instance details

Defined in Graphics.GPipe.Internal.Context

Methods

pure :: a -> Render os a #

(<*>) :: Render os (a -> b) -> Render os a -> Render os b #

liftA2 :: (a -> b -> c) -> Render os a -> Render os b -> Render os c #

(*>) :: Render os a -> Render os b -> Render os b #

(<*) :: Render os a -> Render os b -> Render os a #

compileShader :: (ContextHandler ctx, MonadIO m, MonadException m) => Shader os s () -> ContextT ctx os m (CompiledShader os s) Source #

Compiles a shader into a CompiledShader. This action will usually take a second or more, so put it during a loading sequence or something.

May throw a GPipeException if the graphics driver doesn't support something in this shader (e.g. too many interpolated floats sent between a vertex and a fragment shader)

mapShader :: (s -> s') -> Shader os s' a -> Shader os s a Source #

Map the environment to a different environment and run a Shader in that sub environment, returning it's result.

guard' :: (s -> Bool) -> Shader os s () Source #

Like guard, but dependent on the Shaders environment value. Since this will be evaluated at shader run time, as opposed to shader compile time for guard, using this to do recursion will make compileShader diverge. You can break that divergence by combining it with a normal guard and a maximum loop count.

maybeShader :: (s -> Maybe s') -> Shader os s' () -> Shader os s () Source #

Conditionally run the effects of a shader when a Maybe value is Just something.

chooseShader :: (s -> Either s' s'') -> Shader os s' a -> Shader os s'' a -> Shader os s a Source #

Select one of two Shader actions based on whether an Either value is Left or Right.

silenceShader :: Shader os s a -> Shader os s a Source #

Discard all effects of a Shader action (i.e., dont draw anything) and just return the resulting value.