hlsl is a QuasiQuoter which produces HLSL source code with a #line
directive 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 [hlsl|
static const float myConstant = ${myConstant};
float main (){
return myConstant;
}
|])
An explicit example (interactive is from doctest):
let foo = 450 :: Int in [hlsl|const float foo = $foo|]"#line ... \"<interactive>\"\nconst float foo = 450"
Note that line number will be thrown off if any of the interpolated variables contain newlines.