Permalink
Browse files

Disable debug draw by default

  • Loading branch information...
1 parent 1956f67 commit e82ec6177dca6257e51d0e31fe60b035ee1d509e Dominic Hamon committed Jan 23, 2012
Showing with 1,472 additions and 1,008 deletions.
  1. +13 −7 dart/Bench2d.dart
  2. +1,459 −1,001 dart/Bench2d.dart.js
View
@@ -39,7 +39,9 @@ class Bench2d {
World world;
- Bench2d() {
+ bool _doDebugDraw;
+
+ Bench2d([_doDebugDraw = false]) {
final gravity = new Vector(0, GRAVITY);
bool doSleep = true;
world = new World(gravity, doSleep, new DefaultWorldPool());
@@ -62,11 +64,13 @@ class Bench2d {
viewport = new CanvasViewportTransform(extents, extents);
viewport.scale = _VIEWPORT_SCALE;
- // Create our canvas drawing tool to give to the world.
- debugDraw = new CanvasDraw(viewport, ctx);
+ if (_doDebugDraw) {
+ // Create our canvas drawing tool to give to the world.
+ debugDraw = new CanvasDraw(viewport, ctx);
- // Have the world draw itself for debugging purposes.
- world.debugDraw = debugDraw;
+ // Have the world draw itself for debugging purposes.
+ world.debugDraw = debugDraw;
+ }
}
void initialize() {
@@ -122,8 +126,10 @@ class Bench2d {
void render() {
step();
- ctx.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
- world.drawDebugData();
+ if (_doDebugDraw) {
+ ctx.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+ world.drawDebugData();
+ }
window.webkitRequestAnimationFrame((num time) {
render();
}, canvas);
Oops, something went wrong.

0 comments on commit e82ec61

Please sign in to comment.