diff options
-rw-r--r-- | sly/mesh.scm | 5 | ||||
-rw-r--r-- | sly/render/renderer.scm | 10 | ||||
-rw-r--r-- | sly/scene.scm | 3 |
3 files changed, 14 insertions, 4 deletions
diff --git a/sly/mesh.scm b/sly/mesh.scm index e662547..2a0c8ec 100644 --- a/sly/mesh.scm +++ b/sly/mesh.scm @@ -58,9 +58,8 @@ (%make-mesh (make-vertex-array indices positions textures) shader texture)) -(define-method (draw (mesh <<mesh>>) transform) +(define-method (draw (mesh <<mesh>>)) (make-render-op #:vertex-array (mesh-vao mesh) #:texture (mesh-texture mesh) #:shader (mesh-shader mesh) - #:uniforms `(("color" ,white)) - #:transform transform)) + #:uniforms `(("color" ,white)))) diff --git a/sly/render/renderer.scm b/sly/render/renderer.scm index d71b89a..3584023 100644 --- a/sly/render/renderer.scm +++ b/sly/render/renderer.scm @@ -38,6 +38,7 @@ render-op-transform render-op-vertex-array render-op-texture render-op-shader render-op-blend-mode render-op-uniforms + transform-render-op make-renderer renderer? renderer-ops render)) @@ -68,6 +69,15 @@ activated or not." (%make-render-op transform vertex-array texture shader uniforms blend-mode depth-test?)) +(define* (transform-render-op op transform) + "Return a new render operation object that is the same as OP, but +with its transformation matrix multiplied by TRANSFORM." + (match op + (($ <render-op> local-transform vertex-array texture shader uniforms + blend-mode depth-test?) + (%make-render-op (transform* transform local-transform) vertex-array + texture shader uniforms blend-mode depth-test?)))) + (define-syntax-rule (with-texture-maybe texture body ...) (if texture (with-texture texture body ...) diff --git a/sly/scene.scm b/sly/scene.scm index e068e60..6cd3a5d 100644 --- a/sly/scene.scm +++ b/sly/scene.scm @@ -78,7 +78,8 @@ display the scene." (scene-node-transform node))) (object (scene-node-object node))) (cons (if object - (draw (scene-node-object node) transform) + (transform-render-op (draw (scene-node-object node)) + transform) '()) (map (cut iter <> transform) (scene-node-children node)))) |