Skip to content

Commit d92cd4f

Browse files
authored
Merge pull request #921 from DavidHGillen/master
Minor fixes to benchmark demo
2 parents 1849362 + f45a47e commit d92cd4f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

VERSIONS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ OTHER:
3636
- added a shared createjs.deprecate() method, which wraps old methods and property getter/setters to display
3737
a console warning when used.
3838
- added a DeprecatedMethods unit test
39+
- fixed minor issues with webgl/benchmark demo
3940

4041

4142
Version 0.8.2 [November 26, 2015]

examples/WebGL/Benchmark.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
examples.hideDistractor();
169169
}
170170

171+
// because of the significance of some variables that might change, restart anew when major properties change
171172
function init() {
172173
if(!isReady) { return; }
173174

@@ -176,23 +177,25 @@
176177
canvas.parentNode.removeChild(canvas);
177178
}
178179
if(stage && stage.releaseTexture) {
179-
stage.releaseTexture(cjsSprites.spriteSheet._images[0]); // CJS cleanup for multi stage-use
180+
// As we're removing the old canvas, we have to clean up, this allows us to use the images on a new canvas.
181+
// Each canvas has a new WebGL context (by necessity) and images can't be shared between contexts.
182+
stage.releaseTexture(stage);
180183
}
181184

182185
// make new stages and canvases
183186
canvas = document.createElement("canvas");
184187
canvas.width = CANVAS_WIDTH;
185188
canvas.height = CANVAS_HEIGHT;
186189
if(guiProps.allowWebGL) {
187-
stage = new createjs.StageGL(canvas, {transparent: false, autoPurge: -1});
190+
// we know we wont be unloading textures, so turn off the cleanup routine to get maximum speed
191+
stage = new createjs.StageGL(canvas, {autoPurge: -1});
188192
stage.setClearColor(0x000000);
189193
} else {
190194
stage = new createjs.Stage(canvas);
191195
}
192196
container = new createjs.Container();
193197
stage.addChild(container);
194198

195-
196199
// insert to DOM
197200
outDOM.insertBefore(canvas, document.getElementById("stats"));
198201
}

0 commit comments

Comments
 (0)