From 96a0a8c916533eb5625816192ed38488f639326d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 22 Feb 2012 11:00:20 -0800 Subject: Integrating canvas-2d drawing and WebGL fixes, including adding back WebGL materials. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/RDGE/GLWorld.js | 45 +++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'js/helper-classes/RDGE/GLWorld.js') diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index c8327064..1edd5cff 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js @@ -163,7 +163,7 @@ function GLWorld( canvas, use3D ) this.renderer.cameraManager().setActiveCamera(cam); // change clear color - this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT); + //this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT); this.renderer.setClearColor([1.0, 1.0, 1.0, 0.0]); //this.renderer.NinjaWorld = this; @@ -206,6 +206,7 @@ function GLWorld( canvas, use3D ) { if (!dt) dt = 0.2; + dt = 0.01; // use our own internal throttle this.elapsed += dt; if (this._useWebGL) @@ -232,39 +233,35 @@ function GLWorld( canvas, use3D ) { g_Engine.setContext( this._canvas.uuid ); var ctx = g_Engine.getContext(); - var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); - if (ctx1 != ctx) - console.log( "***** different contexts (2) *****" ); - var aRenderer = ctx1.renderer; var renderer = ctx.renderer; - if (renderer != aRenderer) - { - console.log( "***** DIFFERENT RENDERERS *****" ); - renderer = aRenderer; - } - if (renderer.unloadedTextureCount <= 0) { renderer.disableCulling(); //console.log( "GLWorld.draw " + renderer._world._worldCount ); + renderer._clear(); this.myScene.render(); if (this._firstRender) { - this._firstRender = false; - - if (!this.hasAnimatedMaterials()) + if (this._canvas.task) { - //this.myScene.render(); - this._canvas.task.stop(); - //this._renderCount = 10; + this._firstRender = false; + + if (!this.hasAnimatedMaterials()) + { + this._canvas.task.stop(); + //this._renderCount = 10; + } } } else if (this._renderCount >= 0) { - this._renderCount--; - if (this._renderCount <= 0) - this._canvas.task.stop(); + if (this._canvas.task) + { + this._renderCount--; + if (this._renderCount <= 0) + this._canvas.task.stop(); + } } } } @@ -394,11 +391,9 @@ function GLWorld( canvas, use3D ) if (this._useWebGL) { rdgeStarted = true; - - this._canvas.rdgeid = this._canvas.uuid; - - g_Engine.registerCanvas(this._canvas, this); - RDGEStart( this._canvas ); + this._canvas.rdgeid = this._canvas.uuid; + g_Engine.registerCanvas(this._canvas, this); + RDGEStart( this._canvas ); //this._canvas.fpsTracker = new fpsTracker( '0' ); //this._canvas.task = new RDGETask(this._canvas, false); -- cgit v1.2.3