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