No matching definitions.

glsl/shaders

src/glsl/shaders.tur
defn

glsl-input

(glsl-input [name :cstr type :cstr location :int] :cstr)

build a vertex input declaration with a layout location.

nameattribute name
typetype keyword, e.g. ":vec3"
locationlayout location index

GLSL input declaration string, e.g. "layout(location = 0) in vec3 aPos;"

(glsl-input "aPos" ":vec3" 0)
  ; => "layout(location = 0) in vec3 aPos;"

Since: v0.1.0

defn

glsl-output

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

build an output variable declaration.

namevariable name
typetype keyword, e.g. ":vec4"

GLSL output declaration string, e.g. "out vec4 FragColor;"

(glsl-output "FragColor" ":vec4")  ; => "out vec4 FragColor;"

Since: v0.1.0

defn

glsl-uniform

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

build a uniform variable declaration.

nameuniform name
typetype keyword, e.g. ":mat4"

GLSL uniform declaration string, e.g. "uniform mat4 model;"

(glsl-uniform "model" ":mat4")  ; => "uniform mat4 model;"

Since: v0.1.0

defn

glsl-vertex-shader

(glsl-vertex-shader [version :cstr decls :int main-body :cstr] :cstr)

build a complete vertex shader source string.

versionGLSL version string, e.g. "330 core"
declsVec[cstr] of declaration strings (inputs, outputs, uniforms),
built with (vec-of ...). Pass (vec-of) for none.
main-bodybody of void main(), built with glsl-stmts

Complete vertex shader GLSL source string.

(glsl-vertex-shader "330 core"
    (vec-of (glsl-input "aPos" ":vec3" 0)
            (glsl-uniform "model" ":mat4"))
    (glsl-set! "gl_Position" "model * vec4(aPos, 1.0)"))

Since: v0.1.0

defn

glsl-fragment-shader

(glsl-fragment-shader [version :cstr decls :int main-body :cstr] :cstr)

build a complete fragment shader source string.

versionGLSL version string, e.g. "330 core"
declsVec[cstr] of declaration strings (inputs, outputs, uniforms),
built with (vec-of ...). Pass (vec-of) for none.
main-bodybody of void main(), built with glsl-stmts

Complete fragment shader GLSL source string.

(glsl-fragment-shader "330 core"
    (vec-of (glsl-input "ourColor" ":vec3" 0)
            (glsl-output "FragColor" ":vec4"))
    (glsl-set! "FragColor" "vec4(ourColor, 1.0)"))

Since: v0.1.0

defn

glsl-compute-shader

(glsl-compute-shader [version :cstr wg-x :int wg-y :int wg-z :int decls :int main-body :cstr] :cstr)

build a compute shader source with a work-group layout.

versionGLSL version string, e.g. "450 core"
wg-xlocal_size_x
wg-ylocal_size_y
wg-zlocal_size_z
declscons list of declaration strings
main-bodybody of void main()

Complete compute shader GLSL source string.

(glsl-compute-shader "450 core" 16 16 1 (vec-of) body)

Since: v0.1.0

defn

glsl-geometry-shader

(glsl-geometry-shader [version :cstr input-layout :cstr output-layout :cstr max-vertices :int decls :int main-body :cstr] :cstr)

Returns:

(glsl-geometry-shader "330 core" ":points" ":triangle-strip" 4 (vec-of) body)

Since: v0.1.0

Internal definitions
__build-shader-- internal helper: assemble a complete shader source.
__prim-keyword-- build a geometry shader source string.