GPipe-2.1.2: Typesafe functional GPU graphics programming

Safe HaskellNone



Uniform values are constants that you can combine with all vertices or fragments of a PrimitiveStream or FragmentStream. They are loaded from a Buffer and OpenGl uniform blocks are used under the hood.



class BufferFormat a => UniformInput a where Source

This class constraints which buffer types can be loaded as uniforms, and what type those values have.

Associated Types

type UniformFormat a x Source

The type the buffer value will be turned into once it becomes a vertex or fragment value (the x parameter is either V or F).


toUniform :: ToUniform x a (UniformFormat a x) Source

An arrow action that turns a value from it's buffer representation to it's vertex or fragment representation. Use toUniform from the GPipe provided instances to operate in this arrow. Also note that this arrow needs to be able to return a value lazily, so ensure you use

proc ~pattern -> do ....

data ToUniform x a b Source

The arrow type for toUniform.


getUniform :: forall os f s b x. UniformInput b => (s -> (Buffer os (Uniform b), Int)) -> Shader os f s (UniformFormat b x) Source

Load a uniform value from a Buffer into a Shader. The argument function is used to retrieve the buffer and the index into this buffer from the shader environment.

newtype Uniform a Source

Any buffer value that is going to be used as a uniform needs to be wrapped in this newtype. This will cause is to be aligned properly for uniform usage. It can still be used as input for vertex arrays, but due to the uniform alignment it will probably be padded quite heavily and thus wasteful.


Uniform a