aboutsummaryrefslogtreecommitdiff
path: root/js/lib/drawing
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-03-14 15:17:01 -0700
committerJose Antonio Marquez2012-03-14 15:17:01 -0700
commite7e18f02870a0cfe06e550acf8ffef6eab945231 (patch)
treec940a63fd47e60f121c42b1823194522c8c2820f /js/lib/drawing
parentef601b13a2529c207eb782942e918212e5a0805e (diff)
parent089534a80c64226bf7d124ab9147afce386fdb5c (diff)
downloadninja-e7e18f02870a0cfe06e550acf8ffef6eab945231.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/lib/drawing')
-rwxr-xr-xjs/lib/drawing/world.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index b8bceda6..049145ce 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -17,7 +17,7 @@ var worldCounter = 0;
17// Class GLWorld 17// Class GLWorld
18// Manages display in a canvas 18// Manages display in a canvas
19/////////////////////////////////////////////////////////////////////// 19///////////////////////////////////////////////////////////////////////
20var World = function GLWorld( canvas, use3D ) { 20var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
21 /////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////
22 // Instance variables 22 // Instance variables
23 /////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////
@@ -30,7 +30,11 @@ var World = function GLWorld( canvas, use3D ) {
30 30
31 this._canvas = canvas; 31 this._canvas = canvas;
32 if (this._useWebGL) { 32 if (this._useWebGL) {
33 this._glContext = canvas.getContext("experimental-webgl"); 33 if(preserveDrawingBuffer) {
34 this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});
35 } else {
36 this._glContext = canvas.getContext("experimental-webgl");
37 }
34 } else { 38 } else {
35 this._2DContext = canvas.getContext( "2d" ); 39 this._2DContext = canvas.getContext( "2d" );
36 } 40 }
@@ -347,20 +351,18 @@ var World = function GLWorld( canvas, use3D ) {
347 return false; 351 return false;
348 }; 352 };
349 353
350 this.generateUniqueNodeID = function() 354 this.generateUniqueNodeID = function() {
351 { 355 var str = "" + this._nodeCounter;
352 var str = String( this._nodeCounter );
353 this._nodeCounter++; 356 this._nodeCounter++;
354 return str; 357 return str;
355 } 358 };
356 359
357 360
358 // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state 361 // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state
359 // in the case of a procedurally built scene an init state is not needed for loading data 362 // in the case of a procedurally built scene an init state is not needed for loading data
360 if (this._useWebGL) { 363 if (this._useWebGL) {
361 rdgeStarted = true; 364 rdgeStarted = true;
362 var id = this._canvas.getAttribute( "data-RDGE-id" ); 365 this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" );
363 this._canvas.rdgeid = id;
364 g_Engine.registerCanvas(this._canvas, this); 366 g_Engine.registerCanvas(this._canvas, this);
365 RDGEStart( this._canvas ); 367 RDGEStart( this._canvas );
366 this._canvas.task.stop() 368 this._canvas.task.stop()
@@ -680,7 +682,7 @@ World.prototype.render = function() {
680 var root = this.getGeomRoot(); 682 var root = this.getGeomRoot();
681 this.hRender( root ); 683 this.hRender( root );
682 } else { 684 } else {
683 g_Engine.setContext( this._canvas.rdgeId ); 685 g_Engine.setContext( this._canvas.rdgeid );
684 //this.draw(); 686 //this.draw();
685 this.restartRenderLoop(); 687 this.restartRenderLoop();
686 } 688 }
@@ -727,7 +729,8 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) {
727 } 729 }
728}; 730};
729 731
730World.prototype.export = function( exportForPublish ) { 732World.prototype.export = function()
733{
731 var exportStr = "GLWorld 1.0\n"; 734 var exportStr = "GLWorld 1.0\n";
732 var id = this.getCanvas().getAttribute( "data-RDGE-id" ); 735 var id = this.getCanvas().getAttribute( "data-RDGE-id" );
733 exportStr += "id: " + id + "\n"; 736 exportStr += "id: " + id + "\n";
@@ -742,7 +745,8 @@ World.prototype.export = function( exportForPublish ) {
742 // we need 2 export modes: One for save/restore, one for publish. 745 // we need 2 export modes: One for save/restore, one for publish.
743 // hardcoding for now 746 // hardcoding for now
744 //var exportForPublish = false; 747 //var exportForPublish = false;
745 if (!exportForPublish) exportForPublish = false; 748 //if (!exportForPublish) exportForPublish = false;
749 var exportForPublish = true;
746 exportStr += "publish: " + exportForPublish + "\n"; 750 exportStr += "publish: " + exportForPublish + "\n";
747 751
748 if (exportForPublish && this._useWebGL) 752 if (exportForPublish && this._useWebGL)