From 9e048d2cf359c305e895fe7c0bebf09016896531 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 9 Mar 2012 15:11:48 -0800 Subject: remap hard coded strings in rdge internal code. --- js/helper-classes/RDGE/src/core/script/engine.js | 15 +++++++++++++++ js/helper-classes/RDGE/src/core/script/fx/ssao.js | 2 +- js/helper-classes/RDGE/src/core/script/init_state.js | 12 ++++++------ js/helper-classes/RDGE/src/core/script/jshader.js | 8 ++++---- js/helper-classes/RDGE/src/core/script/renderer.js | 1 + js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | 2 +- js/helper-classes/RDGE/src/core/script/utilities.js | 4 ++-- 7 files changed, 30 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 5bc9305c..f5724665 100755 --- a/js/helper-classes/RDGE/src/core/script/engine.js +++ b/js/helper-classes/RDGE/src/core/script/engine.js @@ -89,6 +89,8 @@ stateManager = function() g_enableBenchmarks = true; function Engine() { + this._assetPath = "assets/"; + // map of scene graphs to names this.sceneMap = []; @@ -228,6 +230,19 @@ function Engine() contextManager.currentCtx = savedCtx; } + + this.remapAssetFolder = function( url ) + { + var searchStr = "assets/"; + var index = url.indexOf( searchStr ); + var rtnPath = url; + if (index >= 0) + { + rtnPath = url.substr( index + searchStr.length ); + rtnPath = this._assetPath + rtnPath; + } + return rtnPath; + } } diff --git a/js/helper-classes/RDGE/src/core/script/fx/ssao.js b/js/helper-classes/RDGE/src/core/script/fx/ssao.js index 05793594..9761b02d 100755 --- a/js/helper-classes/RDGE/src/core/script/fx/ssao.js +++ b/js/helper-classes/RDGE/src/core/script/fx/ssao.js @@ -32,7 +32,7 @@ function fxSSAO(enHRDepth) } // Load random normal texture - this.randTexture = createTexture(gl, "assets/images/random_normal.png"); + this.randTexture = createTexture(gl, g_Engine._assetPath+"images/random_normal.png"); gl.bindTexture(gl.TEXTURE_2D, this.randTexture); gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.REPEAT); 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 4b97a4f4..5ffbbd13 100755 --- a/js/helper-classes/RDGE/src/core/script/init_state.js +++ b/js/helper-classes/RDGE/src/core/script/init_state.js @@ -42,16 +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(); + } + + 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(); + 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/jshader.js b/js/helper-classes/RDGE/src/core/script/jshader.js index 36c5939e..ceb67536 100755 --- a/js/helper-classes/RDGE/src/core/script/jshader.js +++ b/js/helper-classes/RDGE/src/core/script/jshader.js @@ -191,8 +191,8 @@ jshader = function(addr) { case "mat2": this.data = [0, 0, 0, 0]; break; case "float": this.data = [0]; break; case "int": this.data = [0]; break; - case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; - case "texCube": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; + case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; + case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; } } else { @@ -243,8 +243,8 @@ jshader = function(addr) { case "mat2": this.data = [0, 0, 0, 0]; break; case "float": this.data = [0]; break; case "int": this.data = [0]; break; - case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; - case "texCube": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; + case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; + case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; } } else { diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index a50b8a68..c01068a4 100755 --- a/js/helper-classes/RDGE/src/core/script/renderer.js +++ b/js/helper-classes/RDGE/src/core/script/renderer.js @@ -338,6 +338,7 @@ _renderer = function(canvas) { if (tex === undefined) { // load the texture + name = g_Engine.remapAssetFolder( name ); tex = this.createTexture(name + ext, wrap, mips); this.textureMap[name] = tex; tex.lookUpName = name; diff --git a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js index e80a14fb..93ee12bf 100755 --- a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js +++ b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js @@ -336,7 +336,7 @@ materialNodeTemplate = function(matNode) matNode.setTexture = function(texType, texName) { var renderer = g_Engine.getContext().renderer; - this.textureList[texType].handle = renderer.getTextureByName("assets/images/" + texName); + this.textureList[texType].handle = renderer.getTextureByName(g_Engine._assetPath+"/images/" + texName); this.textureList[texType].unit = texType; this.textureList[texType].type = UNIFORMTYPE.TEXTURE2D; diff --git a/js/helper-classes/RDGE/src/core/script/utilities.js b/js/helper-classes/RDGE/src/core/script/utilities.js index e19c727f..e55f2b33 100755 --- a/js/helper-classes/RDGE/src/core/script/utilities.js +++ b/js/helper-classes/RDGE/src/core/script/utilities.js @@ -159,7 +159,7 @@ function createShader(ctx, strVertShaderName, strFragShaderName, attribs) } else { var vshaderRequest = new XMLHttpRequest(); - vshaderRequest.open("GET", 'assets/shaders/' + strVertShaderName + '.glsl', false); + vshaderRequest.open("GET", g_Engine._assetPath+'shaders/' + strVertShaderName + '.glsl', false); vshaderRequest.send(null); vShader = vshaderRequest.responseText; } @@ -169,7 +169,7 @@ function createShader(ctx, strVertShaderName, strFragShaderName, attribs) } else { var fshaderRequest = new XMLHttpRequest(); - fshaderRequest.open("GET", 'assets/shaders/' + strFragShaderName + '.glsl', false); + fshaderRequest.open("GET", g_Engine._assetPath+'shaders/' + strFragShaderName + '.glsl', false); fshaderRequest.send(null); fShader = fshaderRequest.responseText; } -- cgit v1.2.3 From 46defc9bd11bf077efd672c72787a3b67da1a178 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 12 Mar 2012 14:59:08 -0700 Subject: Uber material changes for IO --- js/helper-classes/RDGE/src/core/script/MeshManager.js | 2 +- js/helper-classes/RDGE/src/core/script/run_state.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'js/helper-classes/RDGE/src/core') diff --git a/js/helper-classes/RDGE/src/core/script/MeshManager.js b/js/helper-classes/RDGE/src/core/script/MeshManager.js index 43813078..7dfc79d4 100755 --- a/js/helper-classes/RDGE/src/core/script/MeshManager.js +++ b/js/helper-classes/RDGE/src/core/script/MeshManager.js @@ -69,7 +69,7 @@ MeshManager.prototype.deleteMesh = function (name) if (model) { g_Engine.ctxMan.forEach(function(context) - { + { context.renderer.deletePrimitive(model.primitive); }); 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 acdb6797..a5981caa 100755 --- a/js/helper-classes/RDGE/src/core/script/run_state.js +++ b/js/helper-classes/RDGE/src/core/script/run_state.js @@ -30,9 +30,9 @@ RunState.prototype.Init = function() this.userRunState.init(); } - if (this.hasUserState && this.userRunState && this.userRunState.onRunState) - this.userRunState.onRunState(); - + if (this.hasUserState && this.userRunState && this.userRunState.onRunState) + this.userRunState.onRunState(); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -97,11 +97,11 @@ RunState.prototype.ReInit = function() if(!this.initialized) { this.Init(); - } - else - { - if (this.hasUserState && this.userRunState && this.userRunState.onRunState) - this.userRunState.onRunState(); + } + else + { + if (this.hasUserState && this.userRunState && this.userRunState.onRunState) + this.userRunState.onRunState(); } } -- cgit v1.2.3 From fdeed8051c3af538d28ca3bc599121cea483c22c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 22 Mar 2012 15:47:56 -0700 Subject: Squashed commit of the following GL integration Signed-off-by: Valerio Virgillito --- js/helper-classes/RDGE/src/core/script/engine.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (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 f5724665..1341d032 100755 --- a/js/helper-classes/RDGE/src/core/script/engine.js +++ b/js/helper-classes/RDGE/src/core/script/engine.js @@ -214,6 +214,11 @@ function Engine() return contextManager.contextMap[optCanvasID]; } } + + this.clearContext = function( canvasID ) + { + contextManager.contextMap[canvasID] = undefined; + } /* * give the contextID (canvas id) of the context to set @@ -488,7 +493,7 @@ Engine.prototype.registerCanvas = function(canvas, runState) { Engine.prototype.unregisterCanvas = function(canvas) { stat.closePage(canvas.rdgeid + "_fps"); contextManager.removeObject(canvas.rdgeCtxHandle); - + this.clearContext( canvas.rdgeid ); } Engine.prototype.getCanvas = function( id ) -- cgit v1.2.3