Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Code = Code {}
- glsl :: QuasiQuoter
- trimming :: QuasiQuoter
- compileVert :: Code -> Q Exp
- compileFrag :: Code -> Q Exp
- compileComp :: Code -> Q Exp
Documentation
A wrapper to show
code into compileShaderQ
vars.
glsl :: QuasiQuoter #
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" Nothing [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 32 \"<interactive>\"\n"
Note that line number will be thrown off if any of the interpolated variables contain newlines.
trimming :: QuasiQuoter #
Trimmed quasiquoter variation.
Same as untrimming
, but also
removes the leading and trailing whitespace.