aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/renderer.js
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 12:34:53 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit3644cb6def4f681c99959e5729e78ea353441fad (patch)
treef8a886f4829e507cc4956db37cff2580cae6003d /js/helper-classes/RDGE/src/core/script/renderer.js
parent04343eda8c2f870b0da55cfdc8003c99fe1cc4de (diff)
downloadninja-3644cb6def4f681c99959e5729e78ea353441fad.tar.gz
Normalize to unix line terminators
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/renderer.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/renderer.js3370
1 files changed, 1685 insertions, 1685 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js
index cac0c33f..2d0c6f1e 100755
--- a/js/helper-classes/RDGE/src/core/script/renderer.js
+++ b/js/helper-classes/RDGE/src/core/script/renderer.js
@@ -1,1685 +1,1685 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility, Inc
3All Rights Reserved. 3All Rights Reserved.
4BSD License. 4BSD License.
5 5
6Redistribution and use in source and binary forms, with or without 6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 7modification, are permitted provided that the following conditions are met:
8 8
9 - Redistributions of source code must retain the above copyright notice, 9 - Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 10 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the 12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution. 13 documentation and/or other materials provided with the distribution.
14 - Neither the name of Motorola Mobility nor the names of its contributors 14 - Neither the name of Motorola Mobility nor the names of its contributors
15 may be used to endorse or promote products derived from this software 15 may be used to endorse or promote products derived from this software
16 without specific prior written permission. 16 without specific prior written permission.
17 17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE. 28POSSIBILITY OF SUCH DAMAGE.
29</copyright> */ 29</copyright> */
30 30
31var RDGE = RDGE || {}; 31var RDGE = RDGE || {};
32 32
33// runtime globals 33// runtime globals
34RDGE.rdgeConstants = (function () { 34RDGE.rdgeConstants = (function () {
35 return { 35 return {
36 // clear flags 36 // clear flags
37 colorBuffer: 0x00004000, 37 colorBuffer: 0x00004000,
38 depthBuffer: 0x00000100, 38 depthBuffer: 0x00000100,
39 stencilBuffer: 0x00000400, 39 stencilBuffer: 0x00000400,
40 40
41 // primitive types 41 // primitive types
42 POINTS: 0, 42 POINTS: 0,
43 LINES: 1, 43 LINES: 1,
44 LINE_LOOP: 2, 44 LINE_LOOP: 2,
45 LINE_STRIP: 3, 45 LINE_STRIP: 3,
46 TRIANGLES: 4, 46 TRIANGLES: 4,
47 TRIANGLE_STRIP: 5, 47 TRIANGLE_STRIP: 5,
48 TRIANGLE_FAN: 6, 48 TRIANGLE_FAN: 6,
49 49
50 // primitive data types 50 // primitive data types
51 BYTE: 0x1400, 51 BYTE: 0x1400,
52 UNSIGNED_BYTE: 0x1401, 52 UNSIGNED_BYTE: 0x1401,
53 SHORT: 0x1402, 53 SHORT: 0x1402,
54 UNSIGNED_SHORT: 0x1403, 54 UNSIGNED_SHORT: 0x1403,
55 INT: 0x1404, 55 INT: 0x1404,
56 UNSIGNED_INT: 0x1405, 56 UNSIGNED_INT: 0x1405,
57 FLOAT: 0x1406, 57 FLOAT: 0x1406,
58 58
59 // pre-defined vertex element type 59 // pre-defined vertex element type
60 VS_ELEMENT_FLOAT4: 4, 60 VS_ELEMENT_FLOAT4: 4,
61 VS_ELEMENT_POS: 3, 61 VS_ELEMENT_POS: 3,
62 VS_ELEMENT_NORM: 3, 62 VS_ELEMENT_NORM: 3,
63 VS_ELEMENT_FLOAT3: 3, 63 VS_ELEMENT_FLOAT3: 3,
64 VS_ELEMENT_FLOAT2: 2, 64 VS_ELEMENT_FLOAT2: 2,
65 VS_ELEMENT_UV: 2, 65 VS_ELEMENT_UV: 2,
66 VS_ELEMENT_FLOAT: 1, 66 VS_ELEMENT_FLOAT: 1,
67 MAX_ELEM_TYPES: 7, 67 MAX_ELEM_TYPES: 7,
68 68
69 // GL Definition of buffer types 69 // GL Definition of buffer types
70 BUFFER_STATIC: 0x88E0, 70 BUFFER_STATIC: 0x88E0,
71 BUFFER_DYNAMIC: 0x88E4, 71 BUFFER_DYNAMIC: 0x88E4,
72 BUFFER_STREAM: 0x88E8, 72 BUFFER_STREAM: 0x88E8,
73 73
74 // render constants 74 // render constants
75 MAX_MATERIAL_LIGHTS: 4, 75 MAX_MATERIAL_LIGHTS: 4,
76 76
77 // Material categories determine sorting materials support the following categories 77 // Material categories determine sorting materials support the following categories
78 categoryEnumeration: 78 categoryEnumeration:
79 { 79 {
80 'BACKGROUND': 0, 80 'BACKGROUND': 0,
81 'OPAQUE': 1, 81 'OPAQUE': 1,
82 'TRANSPARENT': 2, 82 'TRANSPARENT': 2,
83 'ADDITIVE': 3, 83 'ADDITIVE': 3,
84 'TRANSLUCENT': 4, 84 'TRANSLUCENT': 4,
85 'FOREGROUND': 5, 85 'FOREGROUND': 5,
86 'MAX_CAT': 6 86 'MAX_CAT': 6
87 }, 87 },
88 88
89 // Node types supported by the scene graph 89 // Node types supported by the scene graph
90 nodeType: 90 nodeType:
91 { 91 {
92 'TRNODE': 0, 92 'TRNODE': 0,
93 'MESHNODE': 1, 93 'MESHNODE': 1,
94 'MATNODE': 2, 94 'MATNODE': 2,
95 'LIGHTNODE': 3 95 'LIGHTNODE': 3
96 } 96 }
97 }; 97 };
98})(); 98})();
99 99
100RDGE._renderer = function (canvas) { 100RDGE._renderer = function (canvas) {
101 /* 101 /*
102 * Initialize the context associated with this canvas 102 * Initialize the context associated with this canvas
103 */ 103 */
104 try { 104 try {
105 this.ctx = canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true }); // true, true, false, true, true); 105 this.ctx = canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true }); // true, true, false, true, true);
106 106
107 if (!this.ctx) { 107 if (!this.ctx) {
108 this.ctx = canvas.getContext("webgl", { preserveDrawingBuffer: true }); 108 this.ctx = canvas.getContext("webgl", { preserveDrawingBuffer: true });
109 } 109 }
110 if (!this.ctx) { 110 if (!this.ctx) {
111 this.ctx = canvas.getContext("webkit-3d", { preserveDrawingBuffer: true }); 111 this.ctx = canvas.getContext("webkit-3d", { preserveDrawingBuffer: true });
112 } 112 }
113 if (!this.ctx) { 113 if (!this.ctx) {
114 this.ctx = canvas.getContext("moz-webgl", { preserveDrawingBuffer: true }); 114 this.ctx = canvas.getContext("moz-webgl", { preserveDrawingBuffer: true });
115 } 115 }
116 } 116 }
117 catch (err) { } 117 catch (err) { }
118 if (!this.ctx) { 118 if (!this.ctx) {
119 window.console.log("Could not create GL context"); 119 window.console.log("Could not create GL context");
120 return null; 120 return null;
121 } 121 }
122 122
123 // set viewport for the first time 123 // set viewport for the first time
124 this.ctx.viewport(0, 0, canvas.width, canvas.height); 124 this.ctx.viewport(0, 0, canvas.width, canvas.height);
125 125
126 // Add a console output to the renderer 126 // Add a console output to the renderer
127 this.console = ("console" in window) ? window.console : { log: function () { } }; 127 this.console = ("console" in window) ? window.console : { log