diff options
author | hwc487 | 2012-02-08 13:41:52 -0800 |
---|---|---|
committer | hwc487 | 2012-02-08 13:41:52 -0800 |
commit | 064d74fb2694318615f513c83772276cec34bb86 (patch) | |
tree | f683a9d518e827c6cac8754faf2868f2a0bfc8bf /js | |
parent | 6173fe8440152b1e4c63834a6b4dc7573d532339 (diff) | |
download | ninja-064d74fb2694318615f513c83772276cec34bb86.tar.gz |
Fixed context switching problems in rdge
Diffstat (limited to 'js')
-rw-r--r-- | js/helper-classes/RDGE/GLCircle.js | 3 | ||||
-rw-r--r-- | js/helper-classes/RDGE/GLLine.js | 3 | ||||
-rw-r--r-- | js/helper-classes/RDGE/GLRectangle.js | 6 | ||||
-rw-r--r-- | js/helper-classes/RDGE/GLWorld.js | 27 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/RadialGradientMaterial.js | 1 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/core/script/renderer.js | 13 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/tools/compile-rdge-core.bat | 4 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/tools/compile-rdge-core.sh | 3 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/tools/compiler.jar | bin | 0 -> 4927265 bytes | |||
-rw-r--r-- | js/helper-classes/RDGE/src/tools/rdge-compiled.js | 461 |
10 files changed, 507 insertions, 14 deletions
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js index 942eb528..08057778 100644 --- a/js/helper-classes/RDGE/GLCircle.js +++ b/js/helper-classes/RDGE/GLCircle.js | |||
@@ -133,6 +133,9 @@ function GLCircle() | |||
133 | if (!world) throw( "null world in buildBuffers" ); | 133 | if (!world) throw( "null world in buildBuffers" ); |
134 | 134 | ||
135 | if (!world._useWebGL) return; | 135 | if (!world._useWebGL) return; |
136 | |||
137 | // make sure RDGE has the correct context | ||
138 | g_Engine.setContext( world.getCanvas().uuid ); | ||
136 | 139 | ||
137 | // create the gl buffer | 140 | // create the gl buffer |
138 | var gl = world.getGLContext(); | 141 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index bd3cbc26..f01e1610 100644 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js | |||
@@ -109,6 +109,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro | |||
109 | var world = this.getWorld(); | 109 | var world = this.getWorld(); |
110 | if (!world) throw( "null world in buildBuffers" ); | 110 | if (!world) throw( "null world in buildBuffers" ); |
111 | if (!world._useWebGL) return; | 111 | if (!world._useWebGL) return; |
112 | |||
113 | // make sure RDGE has the correct context | ||
114 | g_Engine.setContext( world.getCanvas().uuid ); | ||
112 | 115 | ||
113 | // create the gl buffer | 116 | // create the gl buffer |
114 | var gl = world.getGLContext(); | 117 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index f6f5a899..595a5b48 100644 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js | |||
@@ -210,8 +210,11 @@ function GLRectangle() | |||
210 | // get the world | 210 | // get the world |
211 | var world = this.getWorld(); | 211 | var world = this.getWorld(); |
212 | if (!world) throw( "null world in buildBuffers" ); | 212 | if (!world) throw( "null world in buildBuffers" ); |
213 | 213 | //console.log( "GLRectangle.buildBuffers " + world._worldCount ); | |
214 | if (!world._useWebGL) return; | 214 | if (!world._useWebGL) return; |
215 | |||
216 | // make sure RDGE has the correct context | ||
217 | g_Engine.setContext( world.getCanvas().uuid ); | ||
215 | 218 | ||
216 | // create the gl buffer | 219 | // create the gl buffer |
217 | var gl = world.getGLContext(); | 220 | var gl = world.getGLContext(); |
@@ -284,6 +287,7 @@ function GLRectangle() | |||
284 | xFill -= strokeSize; | 287 | xFill -= strokeSize; |
285 | yFill -= strokeSize; | 288 | yFill -= strokeSize; |
286 | var fillMaterial = this.makeFillMaterial(); | 289 | var fillMaterial = this.makeFillMaterial(); |
290 | //console.log( "fillMaterial: " + fillMaterial.getName() ); | ||
287 | var fillPrim = this.createFill([x,y], 2*xFill, 2*yFill, tlRadius, blRadius, brRadius, trRadius, fillMaterial); | 291 | var fillPrim = this.createFill([x,y], 2*xFill, 2*yFill, tlRadius, blRadius, brRadius, trRadius, fillMaterial); |
288 | this._primArray.push( fillPrim ); | 292 | this._primArray.push( fillPrim ); |
289 | this._materialNodeArray.push( fillMaterial.getMaterialNode() ); | 293 | this._materialNodeArray.push( fillMaterial.getMaterialNode() ); |
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index afd61c8a..e6e7f466 100644 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -151,6 +151,7 @@ function GLWorld( canvas, use3D ) | |||
151 | ctx2 = g_Engine.getContext(); | 151 | ctx2 = g_Engine.getContext(); |
152 | if (ctx1 != ctx2) console.log( "***** different contexts *****" ); | 152 | if (ctx1 != ctx2) console.log( "***** different contexts *****" ); |
153 | this.renderer = ctx1.renderer; | 153 | this.renderer = ctx1.renderer; |
154 | this.renderer._world = this; | ||
154 | 155 | ||
155 | // 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 |
156 | var cam = new camera(); | 157 | var cam = new camera(); |
@@ -229,18 +230,24 @@ function GLWorld( canvas, use3D ) | |||
229 | { | 230 | { |
230 | if (this._useWebGL) | 231 | if (this._useWebGL) |
231 | { | 232 | { |
233 | g_Engine.setContext( this._canvas.uuid ); | ||
232 | var ctx = g_Engine.getContext(); | 234 | var ctx = g_Engine.getContext(); |
233 | var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); | 235 | var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); |
234 | if (ctx1 != ctx) console.log( "***** different contexts (2) *****" ); | 236 | if (ctx1 != ctx) |
237 | console.log( "***** different contexts (2) *****" ); | ||
235 | var aRenderer = ctx1.renderer; | 238 | var aRenderer = ctx1.renderer; |
236 | var renderer = ctx.renderer; | 239 | var renderer = ctx.renderer; |
237 | if (renderer != aRenderer) console.log( "***** DIFFERENT RENDERERS *****" ); | 240 | if (renderer != aRenderer) |
241 | { | ||
242 | console.log( "***** DIFFERENT RENDERERS *****" ); | ||
243 | renderer = aRenderer; | ||
244 | } | ||
238 | 245 | ||
239 | if (renderer.unloadedTextureCount <= 0) | 246 | if (renderer.unloadedTextureCount <= 0) |
240 | { | 247 | { |
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 | { |
@@ -389,7 +396,6 @@ function GLWorld( canvas, use3D ) | |||
389 | rdgeStarted = true; | 396 | rdgeStarted = true; |
390 | 397 | ||
391 | this._canvas.rdgeid = this._canvas.uuid; | 398 | this._canvas.rdgeid = this._canvas.uuid; |
392 | this._canvas.id = this._canvas.uuid; | ||
393 | 399 | ||
394 | g_Engine.registerCanvas(this._canvas, this); | 400 | g_Engine.registerCanvas(this._canvas, this); |
395 | RDGEStart( this._canvas ); | 401 | RDGEStart( this._canvas ); |
@@ -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 | ||
diff --git a/js/helper-classes/RDGE/Materials/RadialGradientMaterial.js b/js/helper-classes/RDGE/Materials/RadialGradientMaterial.js index cf91f1aa..50833f4f 100644 --- a/js/helper-classes/RDGE/Materials/RadialGradientMaterial.js +++ b/js/helper-classes/RDGE/Materials/RadialGradientMaterial.js | |||
@@ -264,7 +264,6 @@ var radialGradientMaterialDef = | |||
264 | 'u_colorStop2': { 'type' : 'float' }, | 264 | 'u_colorStop2': { 'type' : 'float' }, |
265 | 'u_colorStop3': { 'type' : 'float' }, | 265 | 'u_colorStop3': { 'type' : 'float' }, |
266 | 'u_colorStop4': { 'type' : 'float' }, | 266 | 'u_colorStop4': { 'type' : 'float' }, |
267 | 'u_cos_sin_angle' : { 'type' : 'vec2' } | ||
268 | //'u_colorCount': {'type' : 'int' } | 267 | //'u_colorCount': {'type' : 'int' } |
269 | }, | 268 | }, |
270 | 269 | ||
diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index 04cb36a7..a50b8a68 100644 --- a/js/helper-classes/RDGE/src/core/script/renderer.js +++ b/js/helper-classes/RDGE/src/core/script/renderer.js | |||
@@ -371,7 +371,6 @@ _renderer = function(canvas) { | |||
371 | mips = true; | 371 | mips = true; |
372 | 372 | ||
373 | if (texture) { | 373 | if (texture) { |
374 | //console.log( "createTexture: " + url ); | ||
375 | texture.image = new Image(); | 374 | texture.image = new Image(); |
376 | texture.image.src = url; | 375 | texture.image.src = url; |
377 | texture.image.context = g_Engine.getContext(); | 376 | texture.image.context = g_Engine.getContext(); |
@@ -379,16 +378,16 @@ _renderer = function(canvas) { | |||
379 | texture.image.onload = function() { | 378 | texture.image.onload = function() { |
380 | var stateMan = this.context.ctxStateManager; | 379 | var stateMan = this.context.ctxStateManager; |
381 | stateMan.RDGEInitState.loadTexture(texture); | 380 | stateMan.RDGEInitState.loadTexture(texture); |
382 | //console.log( "loaded texture: " + texture.lookUpName ); | ||
383 | if (texture.callback) texture.callback( texture ); | ||
384 | this.context.renderer.unloadedTextureCount--; | 381 | this.context.renderer.unloadedTextureCount--; |
382 | //console.log( "loaded texture: " + texture.lookUpName + ",to: " + this.context.renderer._world._worldCount + ", textures remaining to load: " + this.context.renderer.unloadedTextureCount ); | ||
383 | if (texture.callback) texture.callback( texture ); | ||
385 | if (this.context.renderer.unloadedTextureCount < 0) | 384 | if (this.context.renderer.unloadedTextureCount < 0) |
386 | console.log( "more textures loaded then created..." ); | 385 | console.log( "more textures loaded then created..." ); |