aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2026-04-10 22:56:01 +0000
committers-ol <s+removethis@s-ol.nu>2026-04-11 21:55:39 +0000
commit749f8b50e09ced09e512fd6450f1717b321b39be (patch)
treeebdfc9c64dc3154f61110809e2248a79752c773b
parentlib/array: add history (diff)
downloadalive-749f8b50e09ced09e512fd6450f1717b321b39be.tar.gz
alive-749f8b50e09ced09e512fd6450f1717b321b39be.zip
lib/glsl-view: support array uniforms
-rw-r--r--alv-lib/glsl-view.moon19
1 files changed, 15 insertions, 4 deletions
diff --git a/alv-lib/glsl-view.moon b/alv-lib/glsl-view.moon
index 4e8fd19..6142502 100644
--- a/alv-lib/glsl-view.moon
+++ b/alv-lib/glsl-view.moon
@@ -33,8 +33,14 @@ GLSL_SAMPLER_TYPES =
Uniform = Struct type: T.str, val: T.str
get_typestr = (type) ->
- typestr = GLSL_TYPES[tostring type]
- assert typestr, Error 'type', "can't wrap #{type} in uniform"
+ if typestr = GLSL_TYPES[tostring type]
+ return typestr
+
+ if type.__class == Array
+ if typestr = GLSL_TYPES[tostring type.type]
+ return "#{typestr}[#{type.size}]"
+
+ error Error 'type', "can't wrap #{type} in uniform"
uniform = Constant.meta
meta:
@@ -166,7 +172,7 @@ buffered_stream_source = Constant.meta
meta:
name: 'buffered-stream-source'
summary: "load a stream as a 3d texture source."
- examples: { '(stream-source [socket] type depth uri [format] [args])' }
+ examples: { '(buffered-stream-source [socket] type depth uri [format] [args])' }
description: "Creates a circular buffer 3d texture from a capture source.
- `type` must be `3D` or `2D_ARRAY`.
@@ -371,7 +377,12 @@ draw = Constant.meta
with Bundle.new Timetag.new!
chunks = { '#version 330 core\n' }
for key, val in pairs shader.uniforms
- table.insert chunks, "uniform #{val.type} #{key};"
+ typ, arrsuff = val.type\match "^(%w+)(%[%d+%])$"
+ table.insert chunks, if typ and arrsuff
+ print "typ and arrsuf", typ, arrsuff
+ "uniform #{typ} #{key}#{arrsuff};"
+ else
+ "uniform #{val.type} #{key};"
table.insert chunks, shader.shader
\add content: { address: '/shader', types: 's', table.concat chunks, '\n' }