From 86a801c057fc3b0580d6130be5740c2ee503444f Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 27 Jan 2012 15:52:36 -0800 Subject: updated from old repo --- js/helper-classes/RDGE/src/core/script/init_state.js | 7 ++++++- js/helper-classes/RDGE/src/core/script/renderer.js | 14 +++++++++++--- js/helper-classes/RDGE/src/core/script/run_state.js | 10 +++++++++- js/helper-classes/RDGE/src/core/script/runtime.js | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) (limited to 'js/helper-classes/RDGE/src/core') diff --git a/js/helper-classes/RDGE/src/core/script/init_state.js b/js/helper-classes/RDGE/src/core/script/init_state.js index 8c69d218..4b97a4f4 100644 --- a/js/helper-classes/RDGE/src/core/script/init_state.js +++ b/js/helper-classes/RDGE/src/core/script/init_state.js @@ -42,11 +42,16 @@ LoadState.prototype.Init = function() if(this.sceneName) { this.loadScene("assets_web/mesh/" + this.sceneName + ".json", this.sceneName); - } + } + + if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) + this.userRunState.onLoadState(); } LoadState.prototype.ReInit = function() { + if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) + this.userRunState.onLoadState(); } LoadState.prototype.Resize = function() diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index 0c51d2cb..517947df 100644 --- a/js/helper-classes/RDGE/src/core/script/renderer.js +++ b/js/helper-classes/RDGE/src/core/script/renderer.js @@ -335,14 +335,19 @@ _renderer = function(canvas) { var tex = this.textureMap[name]; - if (tex === undefined) { - - + if (tex === undefined) + { // load the texture tex = this.createTexture(name + ext, wrap, mips); this.textureMap[name] = tex; tex.lookUpName = name; + tex.previouslyReferenced = false; } + else + { + //console.log( "texture already loaded: " + name ); + tex.previouslyReferenced = true; + } return tex; @@ -364,6 +369,7 @@ _renderer = function(canvas) { mips = true; if (texture) { + //console.log( "createTexture: " + url ); texture.image = new Image(); texture.image.src = url; texture.image.context = g_Engine.getContext(); @@ -371,6 +377,8 @@ _renderer = function(canvas) { texture.image.onload = function() { var stateMan = this.context.ctxStateManager; stateMan.RDGEInitState.loadTexture(texture); + //console.log( "loaded texture: " + texture.lookUpName ); + if (texture.callback) texture.callback( texture ); }; } return texture; diff --git a/js/helper-classes/RDGE/src/core/script/run_state.js b/js/helper-classes/RDGE/src/core/script/run_state.js index ad56d9ea..acdb6797 100644 --- a/js/helper-classes/RDGE/src/core/script/run_state.js +++ b/js/helper-classes/RDGE/src/core/script/run_state.js @@ -30,6 +30,9 @@ RunState.prototype.Init = function() this.userRunState.init(); } + if (this.hasUserState && this.userRunState && this.userRunState.onRunState) + this.userRunState.onRunState(); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -94,6 +97,11 @@ RunState.prototype.ReInit = function() if(!this.initialized) { this.Init(); + } + else + { + if (this.hasUserState && this.userRunState && this.userRunState.onRunState) + this.userRunState.onRunState(); } } @@ -117,7 +125,7 @@ RunState.prototype.Draw = function () var width = this.renderer.vpWidth; var height = this.renderer.vpHeight; - this.renderer._clear(); +// this.renderer._clear(); this.userRunState.draw(); diff --git a/js/helper-classes/RDGE/src/core/script/runtime.js b/js/helper-classes/RDGE/src/core/script/runtime.js index 8d8fdf38..e950fce0 100644 --- a/js/helper-classes/RDGE/src/core/script/runtime.js +++ b/js/helper-classes/RDGE/src/core/script/runtime.js @@ -121,7 +121,7 @@ function RDGEStart(canvasOrID) g_Engine.registerCanvas(canvas); - canvas.task = new RDGETask(canvas, true); + //canvas.task = new RDGETask(canvas, true); if (!g_shaderMan) g_shaderMan = new ShaderManager(); -- cgit v1.2.3 From b2ce8b819cc85a558d862c04965b7e65a6ce8640 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 1 Feb 2012 13:05:32 -0800 Subject: changes to allow minimal rendering ofnon-animated materials. --- js/helper-classes/RDGE/src/core/script/engine.js | 18 +++++++++--------- js/helper-classes/RDGE/src/core/script/jshader.js | 6 +++--- js/helper-classes/RDGE/src/core/script/runtime.js | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'js/helper-classes/RDGE/src/core') diff --git a/js/helper-classes/RDGE/src/core/script/engine.js b/js/helper-classes/RDGE/src/core/script/engine.js index 6fe964c7..5bc9305c 100644 --- a/js/helper-classes/RDGE/src/core/script/engine.js +++ b/js/helper-classes/RDGE/src/core/script/engine.js @@ -377,13 +377,13 @@ Engine.prototype.getRDGEPanel=function(panelID) return panelObjectManager.handleToObject(panelID); } -Engine.prototype.registerCanvas = function(canvas, runState) { - if (canvas && this.getContext(canvas.id)) - return; - +Engine.prototype.registerCanvas = function(canvas, runState) { + if (canvas && this.getContext(canvas.rdgeid)) + return; + canvas.renderer = new _renderer(canvas); // create the renderer for the context - this.canvasToRendererMap[canvas.id] = canvas; // store the canvas in the context map - canvas.renderer.id = canvas.id; + this.canvasToRendererMap[canvas.rdgeid] = canvas; // store the canvas in the context map + canvas.renderer.id = canvas.rdgeid; // configure the state manager for this context var stateMan = new stateManager(); @@ -391,11 +391,11 @@ Engine.prototype.registerCanvas = function(canvas, runState) { // add this context to the contextManager and attach the handle to DOM canvas for user retrieval var context = new contextDef(); - context.id = canvas.id; + context.id = canvas.rdgeid; context.renderer = canvas.renderer; context.ctxStateManager = stateMan; context.startUpState; - context.fpsTracker = new fpsTracker(canvas.id); + context.fpsTracker = new fpsTracker(canvas.rdgeid); context.renderer.mvMatrix = mat4.identity(); context.renderer.invMvMatrix = mat4.identity(); @@ -471,7 +471,7 @@ Engine.prototype.registerCanvas = function(canvas, runState) { } Engine.prototype.unregisterCanvas = function(canvas) { - stat.closePage(canvas.id + "_fps"); + stat.closePage(canvas.rdgeid + "_fps"); contextManager.removeObject(canvas.rdgeCtxHandle); } diff --git a/js/helper-classes/RDGE/src/core/script/jshader.js b/js/helper-classes/RDGE/src/core/script/jshader.js index f28219cf..36c5939e 100644 --- a/js/helper-classes/RDGE/src/core/script/jshader.js +++ b/js/helper-classes/RDGE/src/core/script/jshader.js @@ -173,7 +173,7 @@ jshader = function(addr) { // if the parameter does not exist in the shader cull it from the pass if (this.loc == null) { - window.console.log("ctx:" + ctx.canvas.id + ", technique: " + technique + ", uniform: " + name + " was not found, jshader param will have no affect"); + window.console.log("ctx:" + ctx.canvas.rdgeid + ", technique: " + technique + ", uniform: " + name + " was not found, jshader param will have no affect"); //return; } @@ -308,7 +308,7 @@ jshader = function(addr) { } } - program.ctxId = this.ctx.canvas.id; + program.ctxId = this.ctx.canvas.rdgeid; if (!program) { this.renderer.console.log("Build errors found in technique: " + t); this.def[t] = null; // remove bad technique @@ -322,7 +322,7 @@ jshader = function(addr) { var gp = new globalParam(this.ctx, p, rdgeGlobalParameters[p], program); if (gp.loc != null) { - gp.loc.ctxID = this.ctx.canvas.id; + gp.loc.ctxID = this.ctx.canvas.rdgeid; this[t].passes[i].defParams[p] = gp; this.global[p] = gp; } diff --git a/js/helper-classes/RDGE/src/core/script/runtime.js b/js/helper-classes/RDGE/src/core/script/runtime.js index e950fce0..18b9b223 100644 --- a/js/helper-classes/RDGE/src/core/script/runtime.js +++ b/js/helper-classes/RDGE/src/core/script/runtime.js @@ -121,7 +121,7 @@ function RDGEStart(canvasOrID) g_Engine.registerCanvas(canvas); - //canvas.task = new RDGETask(canvas, true); + canvas.task = new RDGETask(canvas, true); if (!g_shaderMan) g_shaderMan = new ShaderManager(); @@ -179,7 +179,7 @@ RDGERequestAnimationFrame = (function() { RDGETask = (function() { var tasks = {}; return function(canvas, startNow) { - this.id = canvas.id; + this.id = canvas.rdgeid; this.currTime = 0.0; this.lastTime = 0.0; this.running = false; -- cgit v1.2.3