glsl/codegen
glsl-cat2
(glsl-cat2 [a :cstr b :cstr] :cstr)
concatenate two strings.
| a | first string | |
| b | second string |
Concatenated string.
(glsl-cat2 "vec3 " "pos") ; => "vec3 pos"
Since: v0.1.0
glsl-cat3
(glsl-cat3 [a :cstr b :cstr c :cstr] :cstr)
concatenate three strings.
| a | first string | |
| b | second string | |
| c | third string |
Concatenated string.
(glsl-cat3 "if (" cond ") {")
Since: v0.1.0
glsl-cat4
(glsl-cat4 [a :cstr b :cstr c :cstr d :cstr] :cstr)
concatenate four strings.
| a b c d -- strings to concatenate |
Concatenated string.
Since: v0.1.0
glsl-sprintf1
(glsl-sprintf1 [fmt :cstr a :cstr] :cstr)
format a string with one substitution.
| fmt | format string with one %s | |
| a | substitution value |
Formatted string.
(glsl-sprintf1 "return %s;" "x") ; => "return x;"
Since: v0.1.0
glsl-sprintf2
(glsl-sprintf2 [fmt :cstr a :cstr b :cstr] :cstr)
format a string with two substitutions.
| fmt | format string with two %s placeholders | |
| a b -- substitution values |
Formatted string.
(glsl-sprintf2 "%s = %s;" name value)
Since: v0.1.0
glsl-sprintf3
(glsl-sprintf3 [fmt :cstr a :cstr b :cstr c :cstr] :cstr)
format a string with three substitutions.
| fmt | format string with three %s placeholders | |
| a b c -- substitution values |
Formatted string.
(glsl-sprintf3 "%s %s = %s;" type name init)
Since: v0.1.0
glsl-sprintf4
(glsl-sprintf4 [fmt :cstr a :cstr b :cstr c :cstr d :cstr] :cstr)
format a string with four substitutions.
| fmt | format string with four %s placeholders | |
| a b c d -- substitution values |
Formatted string.
Since: v0.1.0
glsl-int->str
(glsl-int->str [n :int] :cstr)
convert an integer to a decimal string.
| n | integer value |
Decimal string representation.
(glsl-int->str 42) ; => "42"
Since: v0.1.0
glsl-join-vec
(glsl-join-vec [sep :cstr items :int] :cstr)
join a cons list of strings with a separator.
| sep | separator string | |
| items | cons list of :cstr values (opaque :int handle) | |
| sep | separator inserted between elements | |
| items | Vec[cstr] of strings to concatenate |
The joined string.
(glsl-join-vec ", " (vec-of "float x" "vec3 n")) ; => "float x, vec3 n"
Since: v0.2.0
glsl-join
(glsl-join [sep :cstr items :int] :cstr)
glsl-indent
(glsl-indent [src :cstr] :cstr)
indent every line of src by 4 spaces.
| src | GLSL source fragment (may be multi-line) |
Source with 4 spaces prepended to every line.
(glsl-indent "return x;") ; => " return x;"
Since: v0.1.0
glsl-raw
(glsl-raw [src :cstr] :cstr)
return src unchanged.
| src | any string |
src unchanged. Useful as a pass-through in higher-order contexts.
Since: v0.1.0
glsl-stmts
(glsl-stmts [stmts :int] :cstr)
join a cons list of statement strings with newlines.
| stmts | cons list of statement strings |
Statements joined with "\n".
(glsl-stmts (cons "float x = 1.0;" (cons "float y = 2.0;" 0))) ; => "float x = 1.0;\nfloat y = 2.0;"
Since: v0.1.0
compile-glsl
(compile-glsl [src :cstr] :cstr)
return the assembled GLSL source string.
| src | complete GLSL source string |
src unchanged.
(compile-glsl (glsl-vertex-shader "330 core" decls body))
Since: v0.1.0