summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render.scm14
1 files changed, 13 insertions, 1 deletions
diff --git a/chickadee/render.scm b/chickadee/render.scm
index 195529d..23dc6d2 100644
--- a/chickadee/render.scm
+++ b/chickadee/render.scm
@@ -35,12 +35,14 @@
current-framebuffer
current-blend-mode
current-depth-test
+ current-stencil-test
current-texture
current-projection
with-viewport
with-framebuffer
with-blend-mode
with-depth-test
+ with-stencil-test
with-texture
with-projection
clear-screen
@@ -51,12 +53,13 @@
(define-record-type <render-context>
(make-render-context viewport framebuffer blend-mode depth-test
- projection textures)
+ stencil-test projection textures)
render-context?
(viewport render-context-viewport set-render-context-viewport!)
(framebuffer render-context-framebuffer set-render-context-framebuffer!)
(blend-mode render-context-blend-mode set-render-context-blend-mode!)
(depth-test render-context-depth-test set-render-context-depth-test!)
+ (stencil-test render-context-stencil-test set-render-context-stencil-test!)
(projection render-context-projection set-render-context-projection!)
(textures render-context-textures))
@@ -65,6 +68,7 @@
null-framebuffer
'replace
#f
+ #f
(make-identity-matrix4)
(make-vector 32 null-texture)))
@@ -80,6 +84,9 @@
(define (current-depth-test)
(render-context-depth-test render-context))
+(define (current-stencil-test)
+ (render-context-stencil-test render-context))
+
(define (current-texture i)
(vector-ref (render-context-textures render-context) i))
@@ -120,6 +127,10 @@
(with (render-context-depth-test set-render-context-depth-test! depth-test)
body ...))
+(define-syntax-rule (with-stencil-test stencil-test body ...)
+ (with (render-context-stencil-test set-render-context-stencil-test! stencil-test)
+ body ...))
+
(define-syntax-rule (with-texture n texture body ...)
(let* ((textures (render-context-textures render-context))
(prev (vector-ref textures n)))
@@ -155,6 +166,7 @@
(set-gpu-viewport! gpu (current-viewport))
(set-gpu-blend-mode! gpu (current-blend-mode))
(set-gpu-depth-test! gpu (current-depth-test))
+ (set-gpu-stencil-test! gpu (current-stencil-test))
(set-gpu-shader! gpu shader)
(let loop ((i 0))
(when (< i 32)