summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2022-07-13 12:10:00 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-06-08 08:14:41 -0400
commit3d44f870911c3cf904b5b59c94eed33255baa4a8 (patch)
tree634356ac7468eae6f2dce89c1ff78ad2f8ef08dd
parentcc06f8302c3614390a2ea4095a39a0b444e553f3 (diff)
graphics: shader: Use SGLSL.
-rw-r--r--chickadee/graphics/shader.scm16
1 files changed, 16 insertions, 0 deletions
diff --git a/chickadee/graphics/shader.scm b/chickadee/graphics/shader.scm
index 94c6bfc..73c8136 100644
--- a/chickadee/graphics/shader.scm
+++ b/chickadee/graphics/shader.scm
@@ -33,6 +33,7 @@
#:use-module (chickadee graphics color)
#:use-module (chickadee graphics engine)
#:use-module (chickadee graphics gl)
+ #:use-module (chickadee graphics sglsl)
#:use-module (chickadee graphics texture)
#:use-module (chickadee utils)
#:export (shader-data-type?
@@ -59,6 +60,7 @@
current-shader
load-shader
strings->shader
+ make-shader*
shader-uniform
shader-uniforms
shader-attributes
@@ -790,6 +792,20 @@ shader program."
(lambda (fragment-port)
(make-shader vertex-port fragment-port))))))
+(define-syntax make-shader*
+ (lambda (x)
+ (syntax-case x ()
+ ((_ vertex fragment)
+ (with-syntax ((vert-glsl (datum->syntax x
+ (with-output-to-string
+ (lambda ()
+ (sglsl->glsl (syntax->datum #'vertex))))))
+ (frag-glsl (datum->syntax x
+ (with-output-to-string
+ (lambda ()
+ (sglsl->glsl (syntax->datum #'fragment)))))))
+ #'(strings->shader (pk vert-glsl) (pk frag-glsl)))))))
+
(define (shader-uniform shader name)
"Return the metadata for the uniform NAME in SHADER."
(let ((uniform (uniform-namespace-ref (shader-uniforms shader) name)))