From 3d5b5f7c5efb25b5e605d5d120b57f2dde33fd23 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 3 Feb 2012 15:18:45 -0800 Subject: Added a counter to the renderer that tracks the number of unloaded texture maps. Started vertex deformations. --- js/helper-classes/RDGE/src/core/script/renderer.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'js/helper-classes/RDGE/src') diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index 517947df..04cb36a7 100644 --- a/js/helper-classes/RDGE/src/core/script/renderer.js +++ b/js/helper-classes/RDGE/src/core/script/renderer.js @@ -359,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"; @@ -379,7 +381,18 @@ _renderer = function(canvas) { stateMan.RDGEInitState.loadTexture(texture); //console.log( "loaded texture: " + texture.lookUpName ); if (texture.callback) texture.callback( texture ); + this.context.renderer.unloadedTextureCount--; + 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; } -- cgit v1.2.3