Safe Haskell | None |
---|---|
Language | Haskell98 |
Graphics.GLUtil.ShaderProgram
Contents
Description
Convenience interface for working with GLSL shader programs. Provides an interface for setting attributes and uniforms.
- data ShaderProgram = ShaderProgram {}
- simpleShaderProgram :: FilePath -> FilePath -> IO ShaderProgram
- simpleShaderProgramWith :: FilePath -> FilePath -> (Program -> IO ()) -> IO ShaderProgram
- simpleShaderExplicit :: FilePath -> FilePath -> ([String], [String]) -> IO ShaderProgram
- simpleShaderProgramBS :: ByteString -> ByteString -> IO ShaderProgram
- simpleShaderProgramWithBS :: ByteString -> ByteString -> (Program -> IO ()) -> IO ShaderProgram
- simpleShaderExplicitBS :: ByteString -> ByteString -> ([String], [String]) -> IO ShaderProgram
- loadShaderFamily :: FilePath -> IO ShaderProgram
- loadShaderProgram :: [(ShaderType, FilePath)] -> IO ShaderProgram
- loadShaderProgramWith :: [(ShaderType, FilePath)] -> (Program -> IO ()) -> IO ShaderProgram
- loadShaderProgramBS :: [(ShaderType, ByteString)] -> IO ShaderProgram
- loadShaderProgramWithBS :: [(ShaderType, ByteString)] -> (Program -> IO ()) -> IO ShaderProgram
- getAttrib :: ShaderProgram -> String -> AttribLocation
- enableAttrib :: ShaderProgram -> String -> IO ()
- setAttrib :: ShaderProgram -> String -> IntegerHandling -> VertexArrayDescriptor a -> IO ()
- setUniform :: AsUniform a => ShaderProgram -> String -> a -> IO ()
- getUniform :: ShaderProgram -> String -> UniformLocation
The ShaderProgram type
data ShaderProgram Source
Representation of a GLSL shader program that has been compiled and linked.
Constructors
ShaderProgram | |
Fields
|
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.
simpleShaderExplicitBS :: ByteString -> ByteString -> ([String], [String]) -> IO ShaderProgram Source
loadShaderFamily :: FilePath -> IO ShaderProgram Source
Load a shader program from vertex, geometry, and fragment shaders
that all share the same root file name and the various conventional
extensions: ".vert", ".geom", and ".frag". If a specific file
doesn't exist, such as a geometry shader, it is skipped. For
instance, loadShaderFamily "simple"
will load and compile,
"simple.vert" and "simple.frag" if those files exist.
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
loadShaderProgramWith :: [(ShaderType, FilePath)] -> (Program -> IO ()) -> IO ShaderProgram Source
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
loadShaderProgramWithBS :: [(ShaderType, ByteString)] -> (Program -> IO ()) -> IO ShaderProgram Source
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.
setAttrib :: ShaderProgram -> String -> IntegerHandling -> VertexArrayDescriptor a -> IO () Source
Set a named vertex attribute's IntegerHandling
and
VertexArrayDescriptor
.
setUniform :: AsUniform 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.