OpenGL-2.8.0.0: A binding for the OpenGL graphics system

Portability | portable
Stability | stable
Maintainer | sven.panne@aedion.de
Safe Haskell | None

Graphics.Rendering.OpenGL.GL.Shaders

Contents

- Shader Objects
- Program Objects
- FragmentData
- Vertex attributes
- Uniform variables
- Implementation limits related to GLSL

Description

This module corresponds to sections 2.15 (Vertex Shaders) and section 3.11 (Fragment Shaders) of the OpenGL 2.1 specs.

Synopsis

- class (Eq s, Ord s, Show s, ObjectName s) => Shader s
- data VertexShader
- data FragmentShader
- shaderDeleteStatus :: Shader s => s -> GettableStateVar Bool
- shaderSource :: Shader s => s -> StateVar [String]
- compileShader :: Shader s => s -> IO ()
- compileStatus :: Shader s => s -> GettableStateVar Bool
- shaderInfoLog :: Shader s => s -> GettableStateVar String
- data Program
- programDeleteStatus :: Program -> GettableStateVar Bool
- attachedShaders :: Program -> StateVar ([VertexShader], [FragmentShader])
- linkProgram :: Program -> IO ()
- linkStatus :: Program -> GettableStateVar Bool
- programInfoLog :: Program -> GettableStateVar String
- validateProgram :: Program -> IO ()
- validateStatus :: Program -> GettableStateVar Bool
- currentProgram :: StateVar (Maybe Program)
- bindFragDataLocation :: Program -> String -> SettableStateVar DrawBufferIndex
- getFragDataLocation :: Program -> String -> IO (Maybe DrawBufferIndex)
- attribLocation :: Program -> String -> StateVar AttribLocation
- data VariableType
  - = Float'
  - | FloatVec2
  - | FloatVec3
  - | FloatVec4
  - | Int'
  - | IntVec2
  - | IntVec3
  - | IntVec4
  - | UnsignedInt'
  - | UnsignedIntVec2
  - | UnsignedIntVec3
  - | UnsignedIntVec4
  - | Bool
  - | BoolVec2
  - | BoolVec3
  - | BoolVec4
  - | FloatMat2
  - | FloatMat3
  - | FloatMat4
  - | FloatMat2x3
  - | FloatMat2x4
  - | FloatMat3x2
  - | FloatMat3x4
  - | FloatMat4x2
  - | FloatMat4x3
  - | Sampler1D
  - | Sampler2D
  - | Sampler3D
  - | SamplerCube
  - | Sampler1DShadow
  - | Sampler2DShadow
  - | Sampler1DArray
  - | Sampler2DArray
  - | Sampler1DArrayShadow
  - | Sampler2DArrayShadow
  - | SamplerCubeShadow
  - | Sampler2DRect
  - | Sampler2DRectShadow
  - | IntSampler1D
  - | IntSampler2D
  - | IntSampler3D
  - | IntSamplerCube
  - | IntSampler1DArray
  - | IntSampler2DArray
  - | UnsignedIntSampler1D
  - | UnsignedIntSampler2D
  - | UnsignedIntSampler3D
  - | UnsignedIntSamplerCube
  - | UnsignedIntSampler1DArray
  - | UnsignedIntSampler2DArray
- activeAttribs :: Program -> GettableStateVar [(GLint, VariableType, String)]
- data UniformLocation
- uniformLocation :: Program -> String -> GettableStateVar UniformLocation
- activeUniforms :: Program -> GettableStateVar [(GLint, VariableType, String)]
- class Uniform a where
  - uniform :: UniformLocation -> StateVar a
  - uniformv :: UniformLocation -> GLsizei -> Ptr a -> IO ()
- class Storable a => UniformComponent a
- maxVertexTextureImageUnits :: GettableStateVar GLsizei
- maxTextureImageUnits :: GettableStateVar GLsizei
- maxCombinedTextureImageUnits :: GettableStateVar GLsizei
- maxTextureCoords :: GettableStateVar GLsizei
- maxVertexUniformComponents :: GettableStateVar GLsizei
- maxFragmentUniformComponents :: GettableStateVar GLsizei
- maxVertexAttribs :: GettableStateVar GLsizei
- maxVaryingFloats :: GettableStateVar GLsizei

# Shader Objects

class (Eq s, Ord s, Show s, ObjectName s) => Shader s Source

Instances

Shader FragmentShader |
Shader VertexShader |

data VertexShader Source

Instances

Eq VertexShader |
Ord VertexShader |
Show VertexShader |
ObjectName VertexShader |
Shader VertexShader |

data FragmentShader Source

Instances

Eq FragmentShader |
Ord FragmentShader |
Show FragmentShader |
ObjectName FragmentShader |
Shader FragmentShader |

shaderDeleteStatus :: Shader s => s -> GettableStateVar Bool Source

shaderSource :: Shader s => s -> StateVar [String]Source

compileShader :: Shader s => s -> IO ()Source

compileStatus :: Shader s => s -> GettableStateVar Bool Source

shaderInfoLog :: Shader s => s -> GettableStateVar String Source

# Program Objects

data Program Source

Instances

Eq Program |
Ord Program |
Show Program |
ObjectName Program |

programDeleteStatus :: Program -> GettableStateVar Bool Source

attachedShaders :: Program -> StateVar ([VertexShader], [FragmentShader])Source

linkProgram :: Program -> IO ()Source

linkStatus :: Program -> GettableStateVar Bool Source

programInfoLog :: Program -> GettableStateVar String Source

validateProgram :: Program -> IO ()Source

validateStatus :: Program -> GettableStateVar Bool Source

currentProgram :: StateVar (Maybe Program)Source

# FragmentData

bindFragDataLocation :: Program -> String -> SettableStateVar DrawBufferIndex Source

`bindFragDataLocation` binds a varying variable, specified by program and name, to a drawbuffer. The effects only take place after succesfull linking of the program. invalid arguments and conditions are - an index larger than maxDrawBufferIndex - names starting with `gl_` linking failure will ocure when - one of the arguments was invalid - more than one varying varuable name is bound to the same index It's not an error to specify unused variables, those will be ingored.

getFragDataLocation :: Program -> String -> IO (Maybe DrawBufferIndex)Source

query the binding of a given variable, specified by program and name. The program has to be linked. The result is Nothing if an error occures or the name is not a name of a varying variable. If the program hasn't been linked an `InvalidOperation` error is generated.

# Vertex attributes

attribLocation :: Program -> String -> StateVar AttribLocation Source

data VariableType Source

Constructors

Float' |
FloatVec2 |
FloatVec3 |
FloatVec4 |
Int' |
IntVec2 |
IntVec3 |
IntVec4 |
UnsignedInt' |
UnsignedIntVec2 |
UnsignedIntVec3 |
UnsignedIntVec4 |
Bool |
BoolVec2 |
BoolVec3 |
BoolVec4 |
FloatMat2 |
FloatMat3 |
FloatMat4 |
FloatMat2x3 |
FloatMat2x4 |
FloatMat3x2 |
FloatMat3x4 |
FloatMat4x2 |
FloatMat4x3 |
Sampler1D |
Sampler2D |
Sampler3D |
SamplerCube |
Sampler1DShadow |
Sampler2DShadow |
Sampler1DArray |
Sampler2DArray |
Sampler1DArrayShadow |
Sampler2DArrayShadow |
SamplerCubeShadow |
Sampler2DRect |
Sampler2DRectShadow |
IntSampler1D |
IntSampler2D |
IntSampler3D |
IntSamplerCube |
IntSampler1DArray |
IntSampler2DArray |
UnsignedIntSampler1D |
UnsignedIntSampler2D |
UnsignedIntSampler3D |
UnsignedIntSamplerCube |
UnsignedIntSampler1DArray |
UnsignedIntSampler2DArray |

Instances

Eq VariableType |
Ord VariableType |
Show VariableType |

activeAttribs :: Program -> GettableStateVar [(GLint, VariableType, String)]Source

# Uniform variables

data UniformLocation Source

Instances

Eq UniformLocation |
Ord UniformLocation |
Show UniformLocation |

uniformLocation :: Program -> String -> GettableStateVar UniformLocation Source

activeUniforms :: Program -> GettableStateVar [(GLint, VariableType, String)]Source

class Uniform a where Source

Methods

uniform :: UniformLocation -> StateVar aSource

uniformv :: UniformLocation -> GLsizei -> Ptr a -> IO ()Source

Instances

Uniform TextureUnit |
UniformComponent a => Uniform (Index1 a) |
UniformComponent a => Uniform (Color4 a) |
UniformComponent a => Uniform (Color3 a) |
UniformComponent a => Uniform (FogCoord1 a) |
UniformComponent a => Uniform (Normal3 a) |
UniformComponent a => Uniform (TexCoord4 a) |
UniformComponent a => Uniform (TexCoord3 a) |
UniformComponent a => Uniform (TexCoord2 a) |
UniformComponent a => Uniform (TexCoord1 a) |
UniformComponent a => Uniform (Vertex4 a) |
UniformComponent a => Uniform (Vertex3 a) |
UniformComponent a => Uniform (Vertex2 a) |

class Storable a => UniformComponent a Source

Instances

UniformComponent GLfloat |
UniformComponent GLuint |
UniformComponent GLint |

# Implementation limits related to GLSL

maxVertexTextureImageUnits :: GettableStateVar GLsizei Source

Contains the number of hardware units that can be used to access texture maps from the vertex processor. The minimum legal value is 0.

maxTextureImageUnits :: GettableStateVar GLsizei Source

Contains the total number of hardware units that can be used to access texture maps from the fragment processor. The minimum legal value is 2.

maxCombinedTextureImageUnits :: GettableStateVar GLsizei Source

Contains the total number of hardware units that can be used to access texture maps from the vertex processor and the fragment processor combined. Note: If the vertex shader and the fragment processing stage access the same texture image unit, then that counts as using two texture image units. The minimum legal value is 2.

maxTextureCoords :: GettableStateVar GLsizei Source

Contains the number of texture coordinate sets that are available. The minimum legal value is 2.

maxVertexUniformComponents :: GettableStateVar GLsizei Source

Contains the number of individual components (i.e., floating-point, integer or boolean values) that are available for vertex shader uniform variables. The minimum legal value is 512.

maxFragmentUniformComponents :: GettableStateVar GLsizei Source

Contains the number of individual components (i.e., floating-point, integer or boolean values) that are available for fragment shader uniform variables. The minimum legal value is 64.

maxVertexAttribs :: GettableStateVar GLsizei Source

Contains the number of active vertex attributes that are available. The minimum legal value is 16.

maxVaryingFloats :: GettableStateVar GLsizei Source

Contains the number of individual floating-point values available for varying variables. The minimum legal value is 32.