summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-02-19 13:45:45 -0500
committerDavid Thompson <dthompson2@worcester.edu>2023-06-08 08:14:41 -0400
commit56394c3c904e615cedd9893f4432d3a2376a08a9 (patch)
tree522fe3a6304c1b121d81466820b91e47bfc0f049
parent3c9d8d7f5bb9d6d0edccf98d6b70b3edb19b8879 (diff)
Add REPL integration.
-rw-r--r--chickadee/graphics/seagull.scm28
1 files changed, 24 insertions, 4 deletions
diff --git a/chickadee/graphics/seagull.scm b/chickadee/graphics/seagull.scm
index cc51b37..af15f97 100644
--- a/chickadee/graphics/seagull.scm
+++ b/chickadee/graphics/seagull.scm
@@ -53,9 +53,12 @@
#:use-module (ice-9 exceptions)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
+ #:use-module (ice-9 pretty-print)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-11)
+ #:use-module (system repl command)
+ #:use-module (system repl common)
#:export (seagull-module?
seagull-module-vertex?
seagull-module-fragment?
@@ -3174,10 +3177,6 @@ vec4 texture(samplerCube tex, vec3 coord) {
(link-vertex-outputs-with-fragment-inputs vertex fragment))
(define vertex-glsl (emit-stage vertex* 'vertex version))
(define fragment-glsl (emit-stage fragment* 'fragment version))
- (display vertex-glsl)
- (newline)
- (display fragment-glsl)
- (newline)
(values vertex-glsl fragment-glsl uniform-map)))
(define* (compile-shader vertex fragment #:key
@@ -3191,3 +3190,24 @@ vec4 texture(samplerCube tex, vec3 coord) {
(make-shader vertex-port fragment-port
#:uniform-map uniform-map
#:pre-process? #f)))))))
+
+
+;;;
+;;; REPL integration
+;;;
+
+(define-meta-command ((seagull-inspect chickadee) repl module)
+ "seagull-inspect MODULE
+Show the intermediate compiled form of MODULE."
+ (pretty-print (seagull-module-compiled (repl-eval repl module))))
+
+(define-meta-command ((seagull-compile chickadee) repl vertex fragment
+ #:optional (version (graphics-engine-glsl-version)))
+ "seagull-compile VERTEX-MODULE FRAGMENT-MODULE
+Show the compiled GLSL form of VERTEX-MODULE and FRAGMENT-MODULE."
+ (define-values (vertex-glsl fragment-glsl uniform-map)
+ (link-seagull-modules (repl-eval repl vertex)
+ (repl-eval repl fragment)
+ version))
+ (format #t "Vertex GLSL:\n\n~a\n" vertex-glsl)
+ (format #t "Fragment GLSL:\n\n~a" fragment-glsl))