GLUtil-0.7.5: Miscellaneous OpenGL utilities.

Safe HaskellNone
LanguageHaskell98

Graphics.GLUtil.ShaderProgram

Contents

Description

Convenience interface for working with GLSL shader programs. Provides an interface for setting attributes and uniforms.

Synopsis

The ShaderProgram type

data ShaderProgram Source

Representation of a GLSL shader program that has been compiled and linked.

Simple shader programs utilizing a vertex shader and a fragment shader

simpleShaderProgram :: FilePath -> FilePath -> IO ShaderProgram Source

Load a ShaderProgram from a vertex shader source file and a fragment shader source file. The active attributes and uniforms in the linked program are recorded in the ShaderProgram.

simpleShaderProgramWith :: FilePath -> FilePath -> (Program -> IO ()) -> IO ShaderProgram Source

Load a ShaderProgram from a vertex shader source file and a fragment shader source file. The active attributes and uniforms in the linked program are recorded in the ShaderProgram. The supplied IO function is applied to the new program after shader objects are attached to the program, but before linking. This supports the use of bindFragDataLocation to map fragment shader outputs.

simpleShaderExplicit :: FilePath -> FilePath -> ([String], [String]) -> IO ShaderProgram Source

Load a ShaderProgram from a vertex and fragment shader source files. the third argument is a tuple of the attribute names and uniform names that will be set in this program. If all attributes and uniforms are desired, consider using loadShaderProgram.

simpleShaderProgramBS :: ByteString -> ByteString -> IO ShaderProgram Source

Load a ShaderProgram from vertex and fragment shader source strings. The active attributes and uniforms in the linked program are recorded in the ShaderProgram.

simpleShaderProgramWithBS :: ByteString -> ByteString -> (Program -> IO ()) -> IO ShaderProgram Source

Load a ShaderProgram from vertex and fragment shader source strings. See simpleShaderProgramWith for more information.

Explicit shader loading

loadShaderProgram :: [(ShaderType, FilePath)] -> IO ShaderProgram Source

Load a ShaderProgram from a list of individual shader program files. The active attributes and uniforms in the linked program are recorded in the ShaderProgram

loadShaderProgramBS :: [(ShaderType, ByteString)] -> IO ShaderProgram Source

Load a ShaderProgram from a list of individual shader program source strings. The active attributes and uniforms in the linked program are recorded in the ShaderProgram

Working with ShaderProgram parameters

getAttrib :: ShaderProgram -> String -> AttribLocation Source

Get the AttribLocation associated with a named vertex attribute.

enableAttrib :: ShaderProgram -> String -> IO () Source

Enable a named vertex attribute.

setUniform :: Uniform a => ShaderProgram -> String -> a -> IO () Source

Set a named uniform parameter associated with a particular shader program.

getUniform :: ShaderProgram -> String -> UniformLocation Source

Get the UniformLocation associated with a named uniform parameter.