Copyright | (C) 2015 Dimitri Sabadie |
---|---|
License | BSD3 |
Maintainer | Dimitri Sabadie <dimitri.sabadie@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
- data Program
- programID :: Program -> GLuint
- 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)
- createProgram_ :: (HasProgramError e, MonadError e m, MonadIO m, MonadResource m) => [Stage] -> m Program
- data ProgramError
- class HasProgramError a where
- fromProgramError :: ProgramError -> a
Shader program creation
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 Stage
s 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”.
fromProgramError :: ProgramError -> a Source