diff options
author | hwc487 | 2012-07-09 16:08:02 -0700 |
---|---|---|
committer | hwc487 | 2012-07-09 16:08:02 -0700 |
commit | 5085d0f67df89a21715308956004164597a6ba79 (patch) | |
tree | 2c896163143a66331205a39b0a3b1b45d51bf12a /js/helper-classes/RDGE/src/core/script/renderer.js | |
parent | 51f1691f792dbda9b740ded8aa0457c9406db156 (diff) | |
parent | 84b3327bd92faafab7954b5eb64c7abe24a3fe13 (diff) | |
download | ninja-5085d0f67df89a21715308956004164597a6ba79.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into GridFixes
Conflicts:
js/helper-classes/3D/StageLine.js
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/renderer.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/renderer.js | 3370 |
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 9367c145..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> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility, Inc |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | BSD License. |
5 | 5 | ||
6 | Redistribution and use in source and binary forms, with or without | 6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 7 | modification, 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 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | POSSIBILITY OF SUCH DAMAGE. |
29 | </copyright> */ | 29 | </copyright> */ |
30 | 30 | ||
31 | var RDGE = RDGE || {}; | 31 | var RDGE = RDGE || {}; |
32 | 32 | ||
33 | // runtime globals | 33 | // runtime globals |
34 | RDGE.rdgeConstants = (function () { | 34 | RDGE.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 | ||
100 | RDGE._renderer = function (canvas) { | 100 | RDGE._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 |