summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/graphics/shader.scm14
1 files changed, 14 insertions, 0 deletions
diff --git a/chickadee/graphics/shader.scm b/chickadee/graphics/shader.scm
index 08e8672..7def1f2 100644
--- a/chickadee/graphics/shader.scm
+++ b/chickadee/graphics/shader.scm
@@ -45,6 +45,7 @@
float-vec2
float-vec3
float-vec4
+ mat3
mat4
sampler-2d
sampler-cube
@@ -214,6 +215,18 @@
#:setter gl-uniform4fv
#:null (make-null-rect))
+(define-shader-primitive-type mat3
+ #:name 'mat3
+ #:size (* 3 3 4) ; 3 rows x 3 columns x 4 byte floats
+ #:validator matrix3?
+ #:serializer
+ (let ((matrix3-bv (@@ (chickadee math matrix) matrix3-bv)))
+ (lambda (bv i m)
+ (bytevector-copy! (matrix3-bv m) 0 bv i (* 3 3 4))))
+ #:setter (lambda (location count ptr)
+ (gl-uniform-matrix3fv location count #f ptr))
+ #:null (make-identity-matrix3))
+
(define-shader-primitive-type mat4
#:name 'mat4
#:size 64 ; 4 rows x 4 columns = 16 floats x 4 bytes each = 64 bytes
@@ -588,6 +601,7 @@ them into a GPU shader program."
((= type (version-2-0 float-vec2)) float-vec2)
((= type (version-2-0 float-vec3)) float-vec3)
((= type (version-2-0 float-vec4)) float-vec4)
+ ((= type (version-2-0 float-mat3)) mat3)
((= type (version-2-0 float-mat4)) mat4)
((= type (version-2-0 sampler-2d)) sampler-2d)
((= type (version-2-0 sampler-cube)) sampler-cube)