diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-11-22 20:39:43 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-11-22 20:39:43 -0500 |
commit | 14fe147c19c0f4d83726d0710184a2c9fcb82a79 (patch) | |
tree | e4aa2efedd74840deec2b2a5b796c464eb5ffd6e /sly/render | |
parent | 1dd0f32459f335b9303de15f77cfa8a966689720 (diff) |
render: Enable render context reuse when rendering scene graphs.
* sly/render/renderer.scm (%make-renderer): Delete.
(make-renderer): Expose record type constructor.
* sly/render/scene.scm (scene->renderer): Add 'context' parameter.
(draw-scene): Likewise.
Diffstat (limited to 'sly/render')
-rw-r--r-- | sly/render/renderer.scm | 5 | ||||
-rw-r--r-- | sly/render/scene.scm | 10 |
2 files changed, 7 insertions, 8 deletions
diff --git a/sly/render/renderer.scm b/sly/render/renderer.scm index fc9e5e6..498e00c 100644 --- a/sly/render/renderer.scm +++ b/sly/render/renderer.scm @@ -104,15 +104,12 @@ CONTEXT." %null-pointer)))) (define-record-type <renderer> - (%make-renderer context cameras ops) + (make-renderer context cameras ops) renderer? (context renderer-context) (cameras renderer-cameras) (ops renderer-ops)) -(define (make-renderer cameras ops) - (%make-renderer (make-render-context) cameras ops)) - (define (render renderer) "Apply all of the render operations in RENDERER. The render operations are applied once for each camera." diff --git a/sly/render/scene.scm b/sly/render/scene.scm index e2961a0..3249cc2 100644 --- a/sly/render/scene.scm +++ b/sly/render/scene.scm @@ -93,7 +93,7 @@ whether to draw the node and all of its children or not." (set-identity! t) -(define (scene->renderer node camera) +(define (scene->renderer node context camera) "Traverse the scene graph defined by NODE and its children, as seen by CAMERA, and return a list of the render operations needed to display the scene." @@ -111,9 +111,11 @@ display the scene." (map (cut iter <> transform) (scene-node-children node)))) '()))) - (make-renderer (list camera) (flatten (iter node identity-transform)))) + (make-renderer context + (list camera) + (flatten (iter node identity-transform)))) -(define (draw-scene node camera) +(define (draw-scene node context camera) "Draw the scene defined by NODE, as seen by CAMERA." (apply-viewport (camera-viewport camera)) - (render (scene->renderer node camera))) + (render (scene->renderer node context camera))) |