From b4ba63045158e108356e065c1237fb72b56473a5 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 3 Apr 2012 09:39:38 -0700 Subject: fixed remaining namespace bugs ensuring the use of the RDGE namespace everywhere it is required --- js/helper-classes/RDGE/src/core/script/engine.js | 3 +- js/helper-classes/RDGE/src/core/script/fx/blur.js | 6 +- js/helper-classes/RDGE/src/core/script/fx/ssao.js | 90 +++++++++++----------- js/helper-classes/RDGE/src/core/script/jshader.js | 8 +- .../RDGE/src/core/script/math/mat4.js | 44 +++++------ js/helper-classes/RDGE/src/core/script/renderer.js | 2 +- .../RDGE/src/core/script/utilities.js | 4 +- 7 files changed, 78 insertions(+), 79 deletions(-) (limited to 'js/helper-classes/RDGE/src') diff --git a/js/helper-classes/RDGE/src/core/script/engine.js b/js/helper-classes/RDGE/src/core/script/engine.js index 1777fc22..cf576702 100755 --- a/js/helper-classes/RDGE/src/core/script/engine.js +++ b/js/helper-classes/RDGE/src/core/script/engine.js @@ -426,13 +426,12 @@ RDGE.Engine.prototype.registerCanvas = function (canvas, runState) { }; RDGE.Engine.prototype.unregisterCanvas = function (canvas) { - stat.closePage(canvas.rdgeid + "_fps"); contextManager.removeObject(canvas.rdgeCtxHandle); this.clearContext( canvas.rdgeid ); }; -Engine.prototype.getCanvas = function( id ) +RDGE.Engine.prototype.getCanvas = function (id) { return this.canvasToRendererMap[id]; }; diff --git a/js/helper-classes/RDGE/src/core/script/fx/blur.js b/js/helper-classes/RDGE/src/core/script/fx/blur.js index 110ea8e3..2a8c2ff1 100755 --- a/js/helper-classes/RDGE/src/core/script/fx/blur.js +++ b/js/helper-classes/RDGE/src/core/script/fx/blur.js @@ -56,7 +56,7 @@ RDGE.fx.fxBlur = function (mipSizes, enAuxTexture) { quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); - } + }; function renderInitCombine(quad) { quad.shader = RDGE.createShader(gl, 'separableBlur_vshader', separableBlurCombine_fshader, ["vert", "texcoord"]); @@ -73,7 +73,7 @@ RDGE.fx.fxBlur = function (mipSizes, enAuxTexture) { quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); - } + }; // Screen aligned quad geometry var quadBuf = getScreenAlignedQuad(); @@ -87,7 +87,7 @@ RDGE.fx.fxBlur = function (mipSizes, enAuxTexture) { for (var i in mipSizes) { this.fboSet1.push(createRenderTargetTexture(mipSizes[i], mipSizes[i])); this.fboSet2.push(createRenderTargetTexture(mipSizes[i], mipSizes[i])); - } + }; // Blitter for downsampling this.blitQuad = new RDGE.ScreenQuad(null); 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 5af2859d..2f96aa5b 100755 --- a/js/helper-classes/RDGE/src/core/script/fx/ssao.js +++ b/js/helper-classes/RDGE/src/core/script/fx/ssao.js @@ -8,91 +8,91 @@ var RDGE = RDGE || {}; RDGE.fx = RDGE.fx || {}; /** - * Implements SSAO. - * See http://www.gamedev.net/page/resources/_/reference/programming/140/lighting-and-shading/a-simple-and-practical-approach-to-ssao-r2753 - * @param v2ScreenSize - size of the viewport in window coordinates - */ +* Implements SSAO. +* See http://www.gamedev.net/page/resources/_/reference/programming/140/lighting-and-shading/a-simple-and-practical-approach-to-ssao-r2753 +* @param v2ScreenSize - size of the viewport in window coordinates +*/ RDGE.fx.fxSSAO = function (enHRDepth) { function renderInitSSAO(quad) { quad.shader = RDGE.createShader(RDGE.globals.gl, 'ssao_vshader', enHRDepth ? 'ssaohr_fshader' : 'ssao_fshader', ["vert", "texcoord"]); quad.renderObj = new RDGE.RenderObject(quad.shader); - var quadBuf = getScreenAlignedQuad(); - quad.vertBuffer = quadBuf.vertexObject; - quad.uvBuffer = quadBuf.texCoordObject; + var quadBuf = getScreenAlignedQuad(); + quad.vertBuffer = quadBuf.vertexObject; + quad.uvBuffer = quadBuf.texCoordObject; quad.renderObj.addTexture("sColMap", 0, RDGE.UNIFORMTYPE.TEXTURE2D); quad.renderObj.addTexture("sNormDepthMap", 1, RDGE.UNIFORMTYPE.TEXTURE2D); quad.renderObj.addTexture("sRandMap", 2, RDGE.UNIFORMTYPE.TEXTURE2D); - if (enHRDepth) + if (enHRDepth) quad.renderObj.addTexture("sHRDepthMap", 3, RDGE.UNIFORMTYPE.TEXTURE2D); quad.renderObj.addBuffers(quad.vertBuffer, RDGE.globals.gl.ARRAY_BUFFER, 3, 0, RDGE.globals.gl.FLOAT); quad.renderObj.addBuffers(quad.uvBuffer, RDGE.globals.gl.ARRAY_BUFFER, 2, 2, RDGE.globals.gl.FLOAT); - }; - - // Load random normal texture - this.randTexture = createTexture(RDGE.globals.gl, RDGE.globals.engine._assetPath+"images/random_normal.png"); + }; + + // Load random normal texture + this.randTexture = createTexture(RDGE.globals.gl, RDGE.globals.engine._assetPath + "images/random_normal.png"); RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, this.randTexture); RDGE.globals.gl.texParameteri(RDGE.globals.gl.TEXTURE_2D, RDGE.globals.gl.TEXTURE_MIN_FILTER, RDGE.globals.gl.LINEAR); RDGE.globals.gl.texParameteri(RDGE.globals.gl.TEXTURE_2D, RDGE.globals.gl.TEXTURE_WRAP_S, RDGE.globals.gl.REPEAT); RDGE.globals.gl.texParameteri(RDGE.globals.gl.TEXTURE_2D, RDGE.globals.gl.TEXTURE_WRAP_T, RDGE.globals.gl.REPEAT); - // Whether or not to use a high res depth texture - this.enHRDepth = enHRDepth; + // Whether or not to use a high res depth texture + this.enHRDepth = enHRDepth; - // Quad for full screen pass + // Quad for full screen pass this.ssaoQuad = new RDGE.ScreenQuad(null); - this.ssaoQuad.initialize(renderInitSSAO); + this.ssaoQuad.initialize(renderInitSSAO); - // Set up uniforms - var activeCam = g_cameraManager.getActiveCamera(); - this.v3FrustumFLT = activeCam.getFTR(); + // Set up uniforms + var activeCam = g_cameraManager.getActiveCamera(); + this.v3FrustumFLT = activeCam.getFTR(); this.ssaoQuad.renderObj.addUniform("u_frustumFLT", this.v3FrustumFLT, RDGE.UNIFORMTYPE.FLOAT3); - this.v4ArtVals = [1.0, 1.0, 1.0, 1.0]; + this.v4ArtVals = [1.0, 1.0, 1.0, 1.0]; this.ssaoQuad.renderObj.addUniform("u_artVals", this.v4ArtVals, RDGE.UNIFORMTYPE.FLOAT4); - this.fRandMapSize = 64.0; + this.fRandMapSize = 64.0; this.ssaoQuad.renderObj.addUniform("u_randMapSize", this.fRandMapSize, RDGE.UNIFORMTYPE.FLOAT); - this.v2ScreenSize = [1024, 1024]; + this.v2ScreenSize = [1024, 1024]; this.ssaoQuad.renderObj.addUniform("u_screenSize", this.v2ScreenSize, RDGE.UNIFORMTYPE.FLOAT2); }; /** - * Contributes SSAO to the passed offscreen surface, rendering to another surface. - * See http://www.gamedev.net/page/resources/_/reference/programming/140/lighting-and-shading/a-simple-and-practical-approach-to-ssao-r2753 - * @param srcTexColor - color surface of rendered scene - * @param srcTexNormDepth - screenspace normal+depth surface for scene; {nx, ny, nz, depth} - * @param dstRenderTarget - where to put the result of SSAO - * @param sampleRadius - - * @param intensity - - * @param distScale - - * @param bias - - */ +* Contributes SSAO to the passed offscreen surface, rendering to another surface. +* See http://www.gamedev.net/page/resources/_/reference/programming/140/lighting-and-shading/a-simple-and-practical-approach-to-ssao-r2753 +* @param srcTexColor - color surface of rendered scene +* @param srcTexNormDepth - screenspace normal+depth surface for scene; {nx, ny, nz, depth} +* @param dstRenderTarget - where to put the result of SSAO +* @param sampleRadius - +* @param intensity - +* @param distScale - +* @param bias - +*/ RDGE.fx.fxSSAO.prototype.doSSAO = function (srcTexColor, srcTexNormDepth, srcTexHRDepth, dstRenderTarget, sampleRadius, intensity, distScale, bias) { - // Set art params and other uniforms - this.v4ArtVals[0] = sampleRadius; - this.v4ArtVals[1] = intensity; - this.v4ArtVals[2] = distScale; - this.v4ArtVals[3] = bias; + // Set art params and other uniforms + this.v4ArtVals[0] = sampleRadius; + this.v4ArtVals[1] = intensity; + this.v4ArtVals[2] = distScale; + this.v4ArtVals[3] = bias; this.v2ScreenSize[0] = dstRenderTarget ? dstRenderTarget.frameBuffer.width : RDGE.globals.width; this.v2ScreenSize[1] = dstRenderTarget ? dstRenderTarget.frameBuffer.height : RDGE.globals.height; - // Do ssao + // Do ssao RDGE.globals.gl.bindFramebuffer(RDGE.globals.gl.FRAMEBUFFER, dstRenderTarget ? dstRenderTarget.frameBuffer : null); - // gl.viewport(0, 0, 99999, 99999); + // gl.viewport(0, 0, 99999, 99999); RDGE.globals.gl.clear(RDGE.globals.gl.COLOR_BUFFER_BIT); RDGE.globals.gl.disable(RDGE.globals.gl.DEPTH_TEST); RDGE.globals.gl.useProgram(this.ssaoQuad.shader); - this.ssaoQuad.renderObj.bindBuffers(); - this.ssaoQuad.renderObj.bindTextures(); - this.ssaoQuad.renderObj.bindUniforms(); + this.ssaoQuad.renderObj.bindBuffers(); + this.ssaoQuad.renderObj.bindTextures(); + this.ssaoQuad.renderObj.bindUniforms(); RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE0); RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, srcTexColor); @@ -100,10 +100,10 @@ RDGE.fx.fxSSAO.prototype.doSSAO = function (srcTexColor, srcTexNormDepth, srcTex RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, srcTexNormDepth); RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE2); RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, this.randTexture); - if (this.enHRDepth) { + if (this.enHRDepth) { RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE3); RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, srcTexHRDepth); - } + } RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE0); RDGE.globals.gl.drawArrays(RDGE.globals.gl.TRIANGLES, 0, 6); @@ -111,5 +111,5 @@ RDGE.fx.fxSSAO.prototype.doSSAO = function (srcTexColor, srcTexNormDepth, srcTex RDGE.globals.gl.enable(RDGE.globals.gl.DEPTH_TEST); RDGE.globals.gl.useProgram(null); - return dstRenderTarget; + return dstRenderTarget; }; diff --git a/js/helper-classes/RDGE/src/core/script/jshader.js b/js/helper-classes/RDGE/src/core/script/jshader.js index cad66b2a..2bccaa80 100755 --- a/js/helper-classes/RDGE/src/core/script/jshader.js +++ b/js/helper-classes/RDGE/src/core/script/jshader.js @@ -193,8 +193,8 @@ RDGE.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(g_Engine._assetPath+"images/white.png")]; break; - case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; + case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName(RDGE.globals.engine._assetPath+"images/white.png")]; break; + case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(RDGE.globals.engine._assetPath+"images/white.png")]; break; } } else { @@ -245,8 +245,8 @@ RDGE.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(g_Engine._assetPath+"images/white.png")]; break; - case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; + case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName(RDGE.globals.engine._assetPath+"images/white.png")]; break; + case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(RDGE.globals.engine._assetPath+"images/white.png")]; break; } } else { diff --git a/js/helper-classes/RDGE/src/core/script/math/mat4.js b/js/helper-classes/RDGE/src/core/script/math/mat4.js index 226b771a..239c646a 100755 --- a/js/helper-classes/RDGE/src/core/script/math/mat4.js +++ b/js/helper-classes/RDGE/src/core/script/math/mat4.js @@ -408,15 +408,15 @@ RDGE.mat4.mul4x3 = function (a, b) { /** * RDGE.mat4._det2x2 */ -RDGE.mat4._det2x2 = function(a, b, c, d) { - return a * d - b * c; +RDGE.mat4._det2x2 = function (a, b, c, d) { + return a * d - b * c; }; /** * RDGE.mat4._det3x3 */ -RDGE.mat4._det3x3 = function(a1, a2, a3, b1, b2, b3, c1, c2, c3) { - return a1 * RDGE.mat4._det2x2(b2, b3, c2, c3) +RDGE.mat4._det3x3 = function (a1, a2, a3, b1, b2, b3, c1, c2, c3) { + return a1 * RDGE.mat4._det2x2(b2, b3, c2, c3) - b1 * RDGE.mat4._det2x2(a2, a3, c2, c3) + c1 * RDGE.mat4._det2x2(a2, a3, b2, b3); }; @@ -424,28 +424,28 @@ RDGE.mat4._det3x3 = function(a1, a2, a3, b1, b2, b3, c1, c2, c3) { /** * RDGE.mat4._det4x4 */ -RDGE.mat4._det4x4 = function(m) { - var a1 = m[0]; - var b1 = m[1]; - var c1 = m[2]; - var d1 = m[3]; +RDGE.mat4._det4x4 = function (m) { + var a1 = m[0]; + var b1 = m[1]; + var c1 = m[2]; + var d1 = m[3]; - var a2 = m[4]; - var b2 = m[5]; - var c2 = m[6]; - var d2 = m[7]; + var a2 = m[4]; + var b2 = m[5]; + var c2 = m[6]; + var d2 = m[7]; - var a3 = m[8]; - var b3 = m[9]; - var c3 = m[10]; - var d3 = m[11]; + var a3 = m[8]; + var b3 = m[9]; + var c3 = m[10]; + var d3 = m[11]; - var a4 = m[12]; - var b4 = m[13]; - var c4 = m[14]; - var d4 = m[15]; + var a4 = m[12]; + var b4 = m[13]; + var c4 = m[14]; + var d4 = m[15]; - return a1 * RDGE.mat4._det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) + return a1 * RDGE.mat4._det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) - b1 * RDGE.mat4._det3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4) + c1 * RDGE.mat4._det3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4) - d1 * RDGE.mat4._det3x3(a2, a3, a4, b2, b3, b4, c2, c3, c4); diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index 6b968d5f..0b9185d0 100755 --- a/js/helper-classes/RDGE/src/core/script/renderer.js +++ b/js/helper-classes/RDGE/src/core/script/renderer.js @@ -305,7 +305,7 @@ RDGE._renderer = function (canvas) { if (tex === undefined) { // load the texture - name = g_Engine.remapAssetFolder( name ); + name = RDGE.globals.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/utilities.js b/js/helper-classes/RDGE/src/core/script/utilities.js index 85190097..d3e49398 100755 --- a/js/helper-classes/RDGE/src/core/script/utilities.js +++ b/js/helper-classes/RDGE/src/core/script/utilities.js @@ -158,7 +158,7 @@ RDGE.createShader = function (ctx, strVertShaderName, strFragShaderName, attribs vShader = strVertShaderName; } else { var vshaderRequest = new XMLHttpRequest(); - vshaderRequest.open("GET", g_Engine._assetPath+'shaders/' + strVertShaderName + '.glsl', false); + vshaderRequest.open("GET", RDGE.globals.engine._assetPath+'shaders/' + strVertShaderName + '.glsl', false); vshaderRequest.send(null); vShader = vshaderRequest.responseText; } @@ -167,7 +167,7 @@ RDGE.createShader = function (ctx, strVertShaderName, strFragShaderName, attribs fShader = strFragShaderName; } else { var fshaderRequest = new XMLHttpRequest(); - fshaderRequest.open("GET", g_Engine._assetPath+'shaders/' + strFragShaderName + '.glsl', false); + fshaderRequest.open("GET", RDGE.globals.engine._assetPath+'shaders/' + strFragShaderName + '.glsl', false); fshaderRequest.send(null); fShader = fshaderRequest.responseText; } -- cgit v1.2.3