summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-08-29 17:38:59 -0400
committerDavid Thompson <dthompson2@worcester.edu>2018-08-29 17:38:59 -0400
commitf2414b6904e9bd8b31ba296df3f9c998c36c6f46 (patch)
treee5bae0e93b10a45a3cec1eae21179df79b1afe10
parente39cf322b25a8ffd9f0fc3f3d85370802740528f (diff)
render: shapes: Allow matrix to be passed to draw-line.
* chickadee/render/shapes.scm (draw-line): Add matrix argument.
-rw-r--r--chickadee/render/shapes.scm17
1 files changed, 12 insertions, 5 deletions
diff --git a/chickadee/render/shapes.scm b/chickadee/render/shapes.scm
index 70efef1..9c89928 100644
--- a/chickadee/render/shapes.scm
+++ b/chickadee/render/shapes.scm
@@ -106,7 +106,8 @@ void main (void) {
#:color color))))))
(define draw-line
- (let* ((vertex-buffer
+ (let* ((mvp (make-null-matrix4))
+ (vertex-buffer
(delay
(make-streaming-typed-buffer 'vec2 'float 4
#:name "line-typed-buffer")))
@@ -134,11 +135,11 @@ void main (void) {
in vec2 position;
in vec2 tex;
out vec2 frag_tex;
-uniform mat4 projection;
+uniform mat4 mvp;
void main(void) {
frag_tex = tex;
- gl_Position = projection * vec4(position.xy, 0.0, 1.0);
+ gl_Position = mvp * vec4(position.xy, 0.0, 1.0);
}
"
"
@@ -211,7 +212,8 @@ void main (void) {
(feather 1.0)
(cap 'round)
(color white)
- (shader (force default-shader)))
+ (shader (force default-shader))
+ matrix)
"Draw a line segment from START to END. The line will be
THICKNESS pixels thick with an antialiased border FEATHER pixels wide.
The line will be colored COLOR. CAP specifies the type of end cap that
@@ -272,7 +274,12 @@ may use SHADER to override the built-in line segment shader."
(f32vector-set! bv 7 t4)))
(with-blend-mode 'alpha
(gpu-apply shader (force vertex-array)
- #:projection (current-projection)
+ #:mvp (if matrix
+ (begin
+ (matrix4-mult! mvp matrix
+ (current-projection))
+ mvp)
+ (current-projection))
#:color color
#:w thickness
#:r feather