No matching definitions.

glsl/core

src/glsl/core.tur
defn

glsl-let

(glsl-let [name :cstr type :cstr init :cstr] :cstr)

declare a typed local variable.

namevariable name
typeTurmeric type keyword, e.g. ":float"
initinitializer expression string

GLSL declaration statement, e.g. "float x = 1.0;"

(glsl-let "x" ":float" "1.0")  ; => "float x = 1.0;"

Since: v0.1.0

defn

glsl-set!

(glsl-set! [name :cstr value :cstr] :cstr)

assign to a variable.

namevariable name or field expression
valueright-hand side expression string

GLSL assignment statement, e.g. "fragColor = result;"

(glsl-set! "fragColor" "vec4(1.0)")  ; => "fragColor = vec4(1.0);"

Since: v0.1.0

defn

glsl-return

(glsl-return [expr :cstr] :cstr)

return statement.

exprexpression string to return

"return expr;"

(glsl-return "(x * x)")  ; => "return (x * x);"

Since: v0.1.0

defn

glsl-discard

(glsl-discard :cstr)

discard the current fragment.

"discard;"

(glsl-discard)  ; => "discard;"

Since: v0.1.0

defn

glsl-inc!

(glsl-inc! [name :cstr] :cstr)

post-increment statement.

namevariable name

"name++;"

(glsl-inc! "i")  ; => "i++;"

Since: v0.1.0

defn

glsl-dec!

(glsl-dec! [name :cstr] :cstr)

post-decrement statement.

namevariable name

"name--;"

(glsl-dec! "i")  ; => "i--;"

Since: v0.1.0

defn

glsl-binop

(glsl-binop [op :cstr left :cstr right :cstr] :cstr)

binary infix operation.

opoperator string, e.g. "+"
leftleft-hand expression string
rightright-hand expression string

Parenthesized expression, e.g. "(a + b)"

(glsl-binop "+" "a" "b")  ; => "(a + b)"

Since: v0.1.0

defn

glsl-if

(glsl-if [cond :cstr then-body :cstr else-body :cstr] :cstr)

if/else statement.

condcondition expression string
then-bodybody executed when cond is true
else-bodybody executed when cond is false

GLSL if/else statement string.

(glsl-if "(x > 0.0)" (glsl-return "1.0") (glsl-return "-1.0"))

Since: v0.1.0

defn

glsl-if-only

(glsl-if-only [cond :cstr body :cstr] :cstr)

if statement without else.

condcondition expression string
bodystatement body string

GLSL if statement string.

(glsl-if-only "(alpha < 0.01)" (glsl-discard))

Since: v0.1.0

defn

glsl-for

(glsl-for [init :cstr cond :cstr step :cstr body :cstr] :cstr)

for loop with a pre-built init clause.

initinit clause string, e.g. "int i = 0"
condloop condition, e.g. "i < 10"
stepstep expression, e.g. "i++"
bodyloop body string

GLSL for loop statement string.

(glsl-for "int i = 0" "i < 4" "i++" (glsl-set! "sum" "(sum + arr[i])"))

Since: v0.1.0

defn

glsl-for1

(glsl-for1 [name :cstr type :cstr init :cstr cond :cstr step :cstr body :cstr] :cstr)

for loop with a typed loop variable.

nameloop variable name
typetype keyword, e.g. ":int"
initinitial value expression, e.g. "0"
condloop condition, e.g. "i < 4"
stepstep expression, e.g. "i++"
bodyloop body string

GLSL for loop statement string.

(glsl-for1 "i" ":int" "0" "i < 4" "i++" body)

Since: v0.1.0

defn

glsl-param

(glsl-param [name :cstr type :cstr] :cstr)

build a single function parameter string.

nameparameter name
typetype keyword

GLSL parameter string, e.g. "vec3 normal"

(glsl-param "normal" ":vec3")  ; => "vec3 normal"

Since: v0.1.0

defn

glsl-defn

(glsl-defn [name :cstr params :int ret :cstr body :cstr] :cstr)

define a GLSL function.

namefunction name
paramscons list of parameter strings from glsl-param
retreturn type keyword
bodyfunction body string, typically built with glsl-stmts

Complete GLSL function definition string.

(glsl-defn "square"
    (cons (glsl-param "x" ":float") 0)
    ":float"
    (glsl-return "(x * x)"))

Since: v0.1.0