diff options
Diffstat (limited to 'js/helper-classes/RDGE/GLWorld.js')
-rw-r--r-- | js/helper-classes/RDGE/GLWorld.js | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index b86d9715..e6e7f466 100644 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -14,6 +14,7 @@ var fragmentShaderSource = ""; | |||
14 | var rdgeStarted = false; | 14 | var rdgeStarted = false; |
15 | 15 | ||
16 | var nodeCounter = 0; | 16 | var nodeCounter = 0; |
17 | var worldCounter = 0; | ||
17 | 18 | ||
18 | 19 | ||
19 | /////////////////////////////////////////////////////////////////////// | 20 | /////////////////////////////////////////////////////////////////////// |
@@ -70,6 +71,9 @@ function GLWorld( canvas, use3D ) | |||
70 | // no animated materials | 71 | // no animated materials |
71 | this._firstRender = true; | 72 | this._firstRender = true; |
72 | 73 | ||
74 | this._worldCount = worldCounter; | ||
75 | worldCounter++; | ||
76 | |||
73 | /////////////////////////////////////////////////////////////////////// | 77 | /////////////////////////////////////////////////////////////////////// |
74 | // Property accessors | 78 | // Property accessors |
75 | /////////////////////////////////////////////////////////////////////// | 79 | /////////////////////////////////////////////////////////////////////// |
@@ -147,6 +151,7 @@ function GLWorld( canvas, use3D ) | |||
147 | ctx2 = g_Engine.getContext(); | 151 | ctx2 = g_Engine.getContext(); |
148 | if (ctx1 != ctx2) console.log( "***** different contexts *****" ); | 152 | if (ctx1 != ctx2) console.log( "***** different contexts *****" ); |
149 | this.renderer = ctx1.renderer; | 153 | this.renderer = ctx1.renderer; |
154 | this.renderer._world = this; | ||
150 | 155 | ||
151 | // create a camera, set its perspective, and then point it at the origin | 156 | // create a camera, set its perspective, and then point it at the origin |
152 | var cam = new camera(); | 157 | var cam = new camera(); |
@@ -225,22 +230,24 @@ function GLWorld( canvas, use3D ) | |||
225 | { | 230 | { |
226 | if (this._useWebGL) | 231 | if (this._useWebGL) |
227 | { | 232 | { |
228 | if (this._allMapsLoaded) | 233 | g_Engine.setContext( this._canvas.uuid ); |
234 | var ctx = g_Engine.getContext(); | ||
235 | var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); | ||
236 | if (ctx1 != ctx) | ||
237 | console.log( "***** different contexts (2) *****" ); | ||
238 | var aRenderer = ctx1.renderer; | ||
239 | var renderer = ctx.renderer; | ||
240 | if (renderer != aRenderer) | ||
241 | { | ||
242 | console.log( "***** DIFFERENT RENDERERS *****" ); | ||
243 | renderer = aRenderer; | ||
244 | } | ||
245 | |||
246 | if (renderer.unloadedTextureCount <= 0) | ||
229 | { | 247 | { |
230 | var ctx = g_Engine.getContext(); | ||
231 | //console.log( "RDGE state: " + ctx.ctxStateManager.currentState().name); | ||
232 | |||
233 | ///////////////////////////// | ||
234 | var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); | ||
235 | if (ctx1 != ctx) console.log( "***** different contexts (2) *****" ); | ||
236 | var aRenderer = ctx1.renderer; | ||
237 | ////////////////////////////////////////// | ||
238 | |||
239 | var renderer = ctx.renderer; | ||
240 | if (renderer != aRenderer) console.log( "***** DIFFERENT RENDERERS *****" ); | ||
241 | renderer.disableCulling(); | 248 | renderer.disableCulling(); |
249 | //console.log( "GLWorld.draw " + renderer._world._worldCount ); | ||
242 | this.myScene.render(); | 250 | this.myScene.render(); |
243 | //console.log( "render" ); | ||
244 | 251 | ||
245 | if (this._firstRender) | 252 | if (this._firstRender) |
246 | { | 253 | { |
@@ -249,8 +256,8 @@ function GLWorld( canvas, use3D ) | |||
249 | if (!this.hasAnimatedMaterials()) | 256 | if (!this.hasAnimatedMaterials()) |
250 | { | 257 | { |
251 | //this.myScene.render(); | 258 | //this.myScene.render(); |
252 | //this._canvas.task.stop(); | 259 | this._canvas.task.stop(); |
253 | this._renderCount = 10; | 260 | //this._renderCount = 10; |
254 | } | 261 | } |
255 | } | 262 | } |
256 | else if (this._renderCount >= 0) | 263 | else if (this._renderCount >= 0) |
@@ -259,7 +266,6 @@ function GLWorld( canvas, use3D ) | |||
259 | if (this._renderCount <= 0) | 266 | if (this._renderCount <= 0) |
260 | this._canvas.task.stop(); | 267 | this._canvas.task.stop(); |
261 | } | 268 | } |
262 | |||
263 | } | 269 | } |
264 | } | 270 | } |
265 | else | 271 | else |
@@ -389,10 +395,10 @@ function GLWorld( canvas, use3D ) | |||
389 | { | 395 | { |
390 | rdgeStarted = true; | 396 | rdgeStarted = true; |
391 | 397 | ||
392 | // TODO - temporary fix for RDGE id's | 398 | this._canvas.rdgeid = this._canvas.uuid; |
393 | this._canvas.id = "rdge_" + this._canvas.uuid; | 399 | |
394 | g_Engine.registerCanvas(this._canvas, this); | 400 | g_Engine.registerCanvas(this._canvas, this); |
395 | RDGEStart( this._canvas ); | 401 | RDGEStart( this._canvas ); |
396 | 402 | ||
397 | //this._canvas.fpsTracker = new fpsTracker( '0' ); | 403 | //this._canvas.fpsTracker = new fpsTracker( '0' ); |
398 | //this._canvas.task = new RDGETask(this._canvas, false); | 404 | //this._canvas.task = new RDGETask(this._canvas, false); |
@@ -508,16 +514,22 @@ GLWorld.prototype.addObject = function( obj ) | |||
508 | 514 | ||
509 | GLWorld.prototype.restartRenderLoop = function() | 515 | GLWorld.prototype.restartRenderLoop = function() |
510 | { | 516 | { |
511 | console.log( "restartRenderLoop" ); | 517 | //console.log( "restartRenderLoop" ); |
512 | 518 | ||
513 | this._firstRender = true; | 519 | this._firstRender = true; |
514 | this._renderCount = -1; | 520 | this._renderCount = -1; |
515 | if (this._canvas.task) | 521 | if (this._canvas.task) |
516 | { | 522 | { |
517 | if (this._allMapsLoaded) | 523 | if (this._allMapsLoaded) |
524 | { | ||
525 | //console.log( "starting task" ); | ||
518 | this._canvas.task.start(); | 526 | this._canvas.task.start(); |
527 | } | ||
519 | else | 528 | else |
529 | { | ||
530 | //console.log( "stopping task" ); | ||
520 | this._canvas.task.stop(); | 531 | this._canvas.task.stop(); |
532 | } | ||
521 | } | 533 | } |
522 | } | 534 | } |
523 | 535 | ||
@@ -757,7 +769,10 @@ GLWorld.prototype.render = function() | |||
757 | } | 769 | } |
758 | else | 770 | else |
759 | { | 771 | { |
760 | this.draw(); | 772 | console.log( "GLWorld.render, " + this._worldCount ); |
773 | g_Engine.setContext( this._canvas.uuid ); | ||
774 | //this.draw(); | ||
775 | this.restartRenderLoop(); | ||
761 | } | 776 | } |
762 | } | 777 | } |
763 | 778 | ||