From 191cb96b3b4e1e5aa805211e5ab8dbd6aa075881 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 9 Feb 2012 10:09:13 -0800 Subject: Merging WebGL changes that allow users to modify different shape instances. Also, merging in changes that improve rendering performance by not updating static materials. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/RDGE/src/core/script/renderer.js | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'js/helper-classes/RDGE/src/core/script/renderer.js') diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index 0c51d2cb..a50b8a68 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; @@ -354,9 +359,11 @@ _renderer = function(canvas) { * @param wrap - optional "CLAMP or "REPEAT", default is clamp * @param mips - optional true/false value to create mipmaps, the default is true */ + this.unloadedTextureCount = 0; _texparams = function(wrap, mips) { this.wrap = wrap, this.mips = mips }; this.createTexture = function(url, wrap, mips) { var texture = this.ctx.createTexture(); + this.unloadedTextureCount++; if (wrap === undefined) wrap = "CLAMP"; @@ -371,7 +378,20 @@ _renderer = function(canvas) { texture.image.onload = function() { var stateMan = this.context.ctxStateManager; stateMan.RDGEInitState.loadTexture(texture); + this.context.renderer.unloadedTextureCount--; + //console.log( "loaded texture: " + texture.lookUpName + ",to: " + this.context.renderer._world._worldCount + ", textures remaining to load: " + this.context.renderer.unloadedTextureCount ); + if (texture.callback) texture.callback( texture ); + if (this.context.renderer.unloadedTextureCount < 0) + console.log( "more textures loaded then created..." ); }; + texture.image.onerror = function() { + this.context.renderer.unloadedTextureCount--; + if (texture.callback) texture.callback( texture ); + //console.log( "Error loading texture: " + texture.image.src ); + if (this.context.renderer.unloadedTextureCount < 0) + console.log( "more textures loaded then created..." ); + } + } return texture; } @@ -544,8 +564,10 @@ _renderer = function(canvas) { */ rdgeDefaultShaderDefintion = { 'shaders': { - 'defaultVShader':"assets/shaders/test_vshader.glsl", - 'defaultFShader':"assets/shaders/test_fshader.glsl" + //'defaultVShader':"assets/shaders/test_vshader.glsl", + //'defaultFShader':"assets/shaders/test_fshader.glsl" + 'defaultVShader':"assets/shaders/Basic.vert.glsl", + 'defaultFShader':"assets/shaders/Basic.frag.glsl" }, 'techniques': { 'defaultTechnique':[{ -- cgit v1.2.3