summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/graphics/path.scm25
1 files changed, 17 insertions, 8 deletions
diff --git a/chickadee/graphics/path.scm b/chickadee/graphics/path.scm
index 6eca4ab..3500c15 100644
--- a/chickadee/graphics/path.scm
+++ b/chickadee/graphics/path.scm
@@ -76,6 +76,7 @@
canvas?
set-canvas-painter!
set-canvas-matrix!
+ draw-canvas*
draw-canvas))
@@ -1229,12 +1230,14 @@
#:function 'not-equal))
(define *debug?* #f)
+(define *mvp* (make-null-matrix4))
;; TODO: gradients
-(define* (draw-filled-path filled-path)
+(define* (draw-filled-path filled-path matrix)
(let ((counts (filled-path-counts filled-path))
(offsets (filled-path-offsets filled-path))
(n (filled-path-count filled-path)))
+ (matrix4-mult! *mvp* matrix (current-projection))
;; Wireframe debug mode.
(when *debug?*
(begin
@@ -1270,7 +1273,7 @@
(filled-path-stencil-vertex-array filled-path)
(u32vector-ref offsets i)
(u32vector-ref counts i)
- #:mvp (current-projection)
+ #:mvp *mvp*
#:mode 0)
(loop (+ i 1))))))
;; Render a quad with the stencil applied. The quad is the size
@@ -1280,19 +1283,20 @@
(with-blend-mode (filled-path-blend-mode filled-path)
(gpu-apply (force path-shader)
(filled-path-quad-vertex-array filled-path)
- #:mvp (current-projection)
+ #:mvp *mvp*
#:mode 0
#:color (filled-path-color filled-path)))))))
;; TODO: dashed stroke
;; TODO: miter styles and miter limit
-(define* (draw-stroked-path stroked-path)
+(define* (draw-stroked-path stroked-path matrix)
+ (matrix4-mult! *mvp* matrix (current-projection))
(with-blend-mode (stroked-path-blend-mode stroked-path)
(gpu-apply* (force path-shader)
(stroked-path-vertex-array stroked-path)
0
(stroked-path-index-count stroked-path)
- #:mvp (current-projection)
+ #:mvp *mvp*
#:color (stroked-path-color stroked-path)
#:mode 1
#:feather (stroked-path-feather stroked-path)
@@ -1547,9 +1551,14 @@
(set-canvas-painter! canvas painter)
canvas))
-(define (draw-canvas canvas)
+(define (draw-canvas* canvas matrix)
(array-list-for-each (lambda (i tesselation)
(if (filled-path? tesselation)
- (draw-filled-path tesselation)
- (draw-stroked-path tesselation)))
+ (draw-filled-path tesselation matrix)
+ (draw-stroked-path tesselation matrix)))
(canvas-tesselated-paths canvas)))
+
+(define %identity-matrix (make-identity-matrix4))
+
+(define (draw-canvas canvas)
+ (draw-canvas* canvas %identity-matrix))