Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- glsl :: QuasiQuoter
- comp :: QuasiQuoter
- frag :: QuasiQuoter
- geom :: QuasiQuoter
- tesc :: QuasiQuoter
- tese :: QuasiQuoter
- vert :: QuasiQuoter
- rgen :: QuasiQuoter
- rint :: QuasiQuoter
- rahit :: QuasiQuoter
- rchit :: QuasiQuoter
- rmiss :: QuasiQuoter
- rcall :: QuasiQuoter
- task :: QuasiQuoter
- mesh :: QuasiQuoter
- compileShaderQ :: Maybe String -> String -> String -> Q Exp
- compileShader :: MonadIO m => Maybe Loc -> Maybe String -> String -> String -> m ([ShadercWarning], Either [ShadercError] ByteString)
Documentation
glsl :: QuasiQuoter Source #
glsl
is a QuasiQuoter which produces GLSL source code with #line
directives inserted so that error locations point to the correct location in
the Haskell source file. It also permits basic string interpolation.
- Interpolated variables are prefixed with
$
- They can optionally be surrounded with braces like
${foo}
- Interpolated variables are converted to strings with
show
- To escape a
$
use\$
It is intended to be used in concert with compileShaderQ
like so
myConstant = 3.141 -- Note that this will have to be in a different module myFragmentShader = $(compileShaderQ Nothing "frag" [glsl| #version 450 const float myConstant = ${myConstant}; main (){ } |])
An explicit example (interactive
is from doctest):
>>>
let version = 450 :: Int in [glsl|#version $version|]
"#version 450\n#extension GL_GOOGLE_cpp_style_line_directive : enable\n#line 52 \"<interactive>\"\n"
Note that line number will be thrown off if any of the interpolated variables contain newlines.
comp :: QuasiQuoter Source #
QuasiQuoter for creating a compute shader.
Equivalent to calling $(compileShaderQ Nothing "comp" [glsl|...|])
without
interpolation support.
frag :: QuasiQuoter Source #
QuasiQuoter for creating a fragment shader.
Equivalent to calling $(compileShaderQ Nothing "frag" [glsl|...|])
without
interpolation support.
geom :: QuasiQuoter Source #
QuasiQuoter for creating a geometry shader.
Equivalent to calling $(compileShaderQ Nothing "geom" [glsl|...|])
without
interpolation support.
tesc :: QuasiQuoter Source #
QuasiQuoter for creating a tessellation control shader.
Equivalent to calling $(compileShaderQ Nothing "tesc" [glsl|...|])
without
interpolation support.
tese :: QuasiQuoter Source #
QuasiQuoter for creating a tessellation evaluation shader.
Equivalent to calling $(compileShaderQ Nothing "tese" [glsl|...|])
without
interpolation support.
vert :: QuasiQuoter Source #
QuasiQuoter for creating a vertex shader.
Equivalent to calling $(compileShaderQ Nothing "vert" [glsl|...|])
without
interpolation support.
rgen :: QuasiQuoter Source #
QuasiQuoter for creating a ray generation shader.
Equivalent to calling $(compileShaderQ (Just "spv1.4") "rgen" [glsl|...|])
without
interpolation support.
rint :: QuasiQuoter Source #
QuasiQuoter for creating an intersection shader.
Equivalent to calling $(compileShaderQ (Just "spv1.4") "rint" [glsl|...|])
without
interpolation support.
rahit :: QuasiQuoter Source #
QuasiQuoter for creating an any-hit shader.
Equivalent to calling $(compileShaderQ (Just "spv1.4") "rahit" [glsl|...|])
without
interpolation support.
rchit :: QuasiQuoter Source #
QuasiQuoter for creating a closest hit shader.
Equivalent to calling $(compileShaderQ (Just "spv1.4") "rchit" [glsl|...|])
without
interpolation support.
rmiss :: QuasiQuoter Source #
QuasiQuoter for creating a miss shader.
Equivalent to calling $(compileShaderQ (Just "spv1.4") "rmiss" [glsl|...|])
without
interpolation support.
rcall :: QuasiQuoter Source #
QuasiQuoter for creating a callable shader.
Equivalent to calling $(compileShaderQ (Just "spv1.4") "rcall" [glsl|...|])
without
interpolation support.
task :: QuasiQuoter Source #
QuasiQuoter for creating a task shader.
Equivalent to calling $(compileShaderQ Nothing "task" [glsl|...|])
without
interpolation support.
mesh :: QuasiQuoter Source #
QuasiQuoter for creating a mesh shader.
Equivalent to calling $(compileShaderQ Nothing "mesh" [glsl|...|])
without
interpolation support.
:: Maybe String | Argument to pass to `--target-env` |
-> String | stage |
-> String | glsl shader code |
-> Q Exp | Spir-V bytecode |
Compile a GLSL shader to spir-v using glslc.
Messages are converted to GHC warnings or errors depending on compilation success.
:: MonadIO m | |
=> Maybe Loc | Source location |
-> Maybe String | Argument to pass to `--target-env` |
-> String | stage |
-> String | glsl shader code |
-> m ([ShadercWarning], Either [ShadercError] ByteString) | Spir-V bytecode with warnings or errors |
Compile a GLSL shader to spir-v using glslc.