aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-10 16:19:54 -0800
committerValerio Virgillito2012-02-10 16:19:54 -0800
commit344933fd505afb9f5dfa3be8cc959112df04da0a (patch)
treee0fd4bbc44b96909d7619593b29d9b063209a7ce /js/helper-classes/RDGE/src
parent48977780443d97b9e97b047066639c9056788041 (diff)
parentde65f73c0f129a26aa9007b69e8fce31d0e92d00 (diff)
downloadninja-344933fd505afb9f5dfa3be8cc959112df04da0a.tar.gz
Merge pull request #31 from mqg734/WebGLFixes
Merging WebGL fixes
Diffstat (limited to 'js/helper-classes/RDGE/src')
-rw-r--r--js/helper-classes/RDGE/src/core/script/renderer.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js
index 517947df..a50b8a68 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) {
359 * @param wrap - optional "CLAMP or "REPEAT", default is clamp 359 * @param wrap - optional "CLAMP or "REPEAT", default is clamp
360 * @param mips - optional true/false value to create mipmaps, the default is true 360 * @param mips - optional true/false value to create mipmaps, the default is true
361 */ 361 */
362 this.unloadedTextureCount = 0;
362 _texparams = function(wrap, mips) { this.wrap = wrap, this.mips = mips }; 363 _texparams = function(wrap, mips) { this.wrap = wrap, this.mips = mips };
363 this.createTexture = function(url, wrap, mips) { 364 this.createTexture = function(url, wrap, mips) {
364 var texture = this.ctx.createTexture(); 365 var texture = this.ctx.createTexture();
366 this.unloadedTextureCount++;
365 367
366 if (wrap === undefined) 368 if (wrap === undefined)
367 wrap = "CLAMP"; 369 wrap = "CLAMP";
@@ -369,7 +371,6 @@ _renderer = function(canvas) {
369 mips = true; 371 mips = true;
370 372
371 if (texture) { 373 if (texture) {
372 //console.log( "createTexture: " + url );
373 texture.image = new Image(); 374 texture.image = new Image();
374 texture.image.src = url; 375 texture.image.src = url;
375 texture.image.context = g_Engine.getContext(); 376 texture.image.context = g_Engine.getContext();
@@ -377,9 +378,20 @@ _renderer = function(canvas) {
377 texture.image.onload = function() { 378 texture.image.onload = function() {
378 var stateMan = this.context.ctxStateManager; 379 var stateMan = this.context.ctxStateManager;
379 stateMan.RDGEInitState.loadTexture(texture); 380 stateMan.RDGEInitState.loadTexture(texture);
380 //console.log( "loaded texture: " + texture.lookUpName ); 381 this.context.renderer.unloadedTextureCount--;
382 //console.log( "loaded texture: " + texture.lookUpName + ",to: " + this.context.renderer._world._worldCount + ", textures remaining to load: " + this.context.renderer.unloadedTextureCount );
381 if (texture.callback) texture.callback( texture ); 383 if (texture.callback) texture.callback( texture );
384 if (this.context.renderer.unloadedTextureCount < 0)
385 console.log( "more textures loaded then created..." );
382 }; 386 };
387 texture.image.onerror = function() {
388 this.context.renderer.unloadedTextureCount--;
389 if (texture.callback) texture.callback( texture );
390 //console.log( "Error loading texture: " + texture.image.src );
391 if (this.context.renderer.unloadedTextureCount < 0)
392 console.log( "more textures loaded then created..." );
393 }
394
383 } 395 }
384 return texture; 396 return texture;
385 } 397 }
@@ -552,8 +564,10 @@ _renderer = function(canvas) {
552 */ 564 */
553rdgeDefaultShaderDefintion = { 565rdgeDefaultShaderDefintion = {
554 'shaders': { 566 'shaders': {
555 'defaultVShader':"assets/shaders/test_vshader.glsl", 567 //'defaultVShader':"assets/shaders/test_vshader.glsl",
556 'defaultFShader':"assets/shaders/test_fshader.glsl" 568 //'defaultFShader':"assets/shaders/test_fshader.glsl"
569 'defaultVShader':"assets/shaders/Basic.vert.glsl",
570 'defaultFShader':"assets/shaders/Basic.frag.glsl"
557 }, 571 },
558 'techniques': { 572 'techniques': {
559 'defaultTechnique':[{ 573 'defaultTechnique':[{