From 7433f0bfbc3a7ea44320550ed2c1d90dc5e6f170 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 3 Apr 2012 16:27:01 -0700 Subject: Removed the dependence on an "assets" directory for the RDGE runtime. Now Ninja does not need to create duplicate files when it sets up the users Ninja Projects directory for RDGE support. --- js/helper-classes/RDGE/rdge-compiled.js | 12 +- js/helper-classes/RDGE/src/core/script/engine.js | 174 +++++++++++----------- js/helper-classes/RDGE/src/core/script/jshader.js | 6 +- 3 files changed, 96 insertions(+), 96 deletions(-) (limited to 'js/helper-classes/RDGE') diff --git a/js/helper-classes/RDGE/rdge-compiled.js b/js/helper-classes/RDGE/rdge-compiled.js index 66bf5a42..0bbcb05b 100755 --- a/js/helper-classes/RDGE/rdge-compiled.js +++ b/js/helper-classes/RDGE/rdge-compiled.js @@ -107,11 +107,11 @@ t);this.def[t]=null;break}for(var n in RDGE.rdgeGlobalParameters){l=new globalPa 0,o;for(o in RDGE.globals.engine.lightManager.lightUniforms[m]){loc=this.ctx.getUniformLocation(h,o);if(loc!=null){this[t].passes[g].lightParams[m]||(this[t].passes[g].lightParams[m]=[]);this[t].passes[g].lightParams[m].push({loc:loc,name:o,dataIndex:p})}p++}}for(n in d[g].params)if(typeof d[g].params[n]!="string"){l=new paramType(this.ctx,n,d[g].params,h,t);this[t].passes[g].params[n]=l;this[t][n]=l}for(n in d[g].params)typeof d[g].params[n]=="string"&&(this[t][n]=this[t].passes[g].params[n]);g++}}for(t in a){f= this[t].passes.length;for(g=0;g");var c=this.def.shaders[a.vshader],d=this.def.shaders[a.fshader];this.ctx.useProgram(null);var f=null,g=null;if(c.indexOf("{")!=-1)g=c;else{g=new XMLHttpRequest;g.open("GET",c,false);g.send(null);g=g.responseText}f=this.buildShader(this.ctx.VERTEX_SHADER,g);g=null;if(c.indexOf("{")!=-1)g=d;else{g=new XMLHttpRequest;g.open("GET",d,false);g.send(null);g=g.responseText}g=this.buildShader(this.ctx.FRAGMENT_SHADER, -g);if(!f||!g)return null;this.compiledShaders[a.vshader]=f;this.compiledShaders[a.fshader]=g;c=this.ctx.createProgram();if(!c)return null;this.ctx.attachShader(c,f);this.ctx.attachShader(c,g);d=0;a.attribPairs=[];for(var h in a.attributes){a.attribPairs.push({loc:d,name:h});this.ctx.bindAttribLocation(c,d++,h)}this.ctx.linkProgram(c);if(!this.ctx.getProgramParameter(c,this.ctx.LINK_STATUS)){a=this.ctx.getProgramInfoLog(c);window.console.log("Error in program linking:"+a);this.ctx.deleteProgram(c); -this.ctx.deleteProgram(g);this.ctx.deleteProgram(f);return null}return c};this.setLightContext=function(a){for(t in this.technique)for(var c=this.technique.passes.length,d=0;d");var c=RDGE.globals.engine.remapAssetFolder(this.def.shaders[a.vshader]),d=RDGE.globals.engine.remapAssetFolder(this.def.shaders[a.fshader]);this.ctx.useProgram(null);var f=null,g=null;if(c.indexOf("{")!=-1)g=c;else{g=new XMLHttpRequest;g.open("GET",c,false);g.send(null);g=g.responseText}f=this.buildShader(this.ctx.VERTEX_SHADER,g);g=null;if(c.indexOf("{")!=-1)g=d;else{g=new XMLHttpRequest;g.open("GET", +d,false);g.send(null);g=g.responseText}g=this.buildShader(this.ctx.FRAGMENT_SHADER,g);if(!f||!g)return null;this.compiledShaders[a.vshader]=f;this.compiledShaders[a.fshader]=g;c=this.ctx.createProgram();if(!c)return null;this.ctx.attachShader(c,f);this.ctx.attachShader(c,g);d=0;a.attribPairs=[];for(var h in a.attributes){a.attribPairs.push({loc:d,name:h});this.ctx.bindAttribLocation(c,d++,h)}this.ctx.linkProgram(c);if(!this.ctx.getProgramParameter(c,this.ctx.LINK_STATUS)){a=this.ctx.getProgramInfoLog(c); +window.console.log("Error in program linking:"+a);this.ctx.deleteProgram(c);this.ctx.deleteProgram(g);this.ctx.deleteProgram(f);return null}return c};this.setLightContext=function(a){for(t in this.technique)for(var c=this.technique.passes.length,d=0;d= 0) - { - rtnPath = url.substr( index + searchStr.length ); - rtnPath = this._assetPath + rtnPath; - } - return rtnPath; - }; + this.setAssetPath = function (path) { + this._assetPath = path.slice(); + }; + + 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/jshader.js b/js/helper-classes/RDGE/src/core/script/jshader.js index 2bccaa80..22180344 100755 --- a/js/helper-classes/RDGE/src/core/script/jshader.js +++ b/js/helper-classes/RDGE/src/core/script/jshader.js @@ -482,8 +482,8 @@ RDGE.jshader = function (addr) { this.buildProgram = function (t) { window.console.log("building shader pair: <" + t.vshader + ", " + t.fshader + ">"); - var vShaderDef = this.def.shaders[t.vshader]; - var fShaderDef = this.def.shaders[t.fshader]; + var vShaderDef = RDGE.globals.engine.remapAssetFolder(this.def.shaders[t.vshader]); + var fShaderDef = RDGE.globals.engine.remapAssetFolder(this.def.shaders[t.fshader]); this.ctx.useProgram(null); @@ -494,7 +494,7 @@ RDGE.jshader = function (addr) { source = vShaderDef; } else { var vshaderRequest = new XMLHttpRequest(); - var urlVertShader = vShaderDef; + var urlVertShader = vShaderDef; vshaderRequest.open("GET", urlVertShader, false); vshaderRequest.send(null); source = vshaderRequest.responseText; -- cgit v1.2.3