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/rendercontext.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/rendercontext.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/rendercontext.js | 578 |
1 files changed, 289 insertions, 289 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/rendercontext.js b/js/helper-classes/RDGE/src/core/script/rendercontext.js index e3cb6374..55102e49 100755 --- a/js/helper-classes/RDGE/src/core/script/rendercontext.js +++ b/js/helper-classes/RDGE/src/core/script/rendercontext.js | |||
@@ -1,289 +1,289 @@ | |||
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 | // render flags, handles, states | 33 | // render flags, handles, states |
34 | RDGE.g_whiteTex = null; | 34 | RDGE.g_whiteTex = null; |
35 | RDGE.g_blackTex = null; | 35 | RDGE.g_blackTex = null; |
36 | RDGE.g_blueTex = null; | 36 | RDGE.g_blueTex = null; |
37 | 37 | ||
38 | /* These objects appear to be unused so they are currently commented out | 38 | /* These objects appear to be unused so they are currently commented out |
39 | RDGE.RDGEWebTexture = function () { | 39 | RDGE.RDGEWebTexture = function () { |
40 | this.handle; // gl handle | 40 | this.handle; // gl handle |
41 | this.unit; // the texture slot/unit | 41 | this.unit; // the texture slot/unit |
42 | this.type = RDGE.UNIFORMTYPE.TEXTURE2D; | 42 | this.type = RDGE.UNIFORMTYPE.TEXTURE2D; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | RDGE.RDGEWebUniformPair = function (uniform, value, type) { | 45 | RDGE.RDGEWebUniformPair = function (uniform, value, type) { |
46 | this.uniform = uniform; | 46 | this.uniform = uniform; |
47 | this.value = value; | 47 | this.value = value; |
48 | this.type = type; | 48 | this.type = type; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | // pass a function that takes no parameters | 52 | // pass a function that takes no parameters |
53 | RDGE.defaultState = function () { | 53 | RDGE.defaultState = function () { |
54 | return [function () { gl.disable(gl.CULL_FACE) }, | 54 | return [function () { gl.disable(gl.CULL_FACE) }, |
55 | function () { gl.enable(gl.DEPTH_TEST) } ] | 55 | function () { gl.enable(gl.DEPTH_TEST) } ] |
56 | }; | 56 | }; |
57 | */ | 57 | */ |
58 | 58 | ||
59 | // this chunk of data contains uniform storage references set the data with RDGEUniform.set (ie RDGEUniform.set("u_name", RDGE.UNIFORMTYPE.FLOAT4, myData); ) | 59 | // this chunk of data contains uniform storage references set the data with RDGEUniform.set (ie RDGEUniform.set("u_name", RDGE.UNIFORMTYPE.FLOAT4, myData); ) |
60 | RDGE.CreateMasterList = function () { | 60 | RDGE.CreateMasterList = function () { |
61 | _MasterUniformList = | 61 | _MasterUniformList = |
62 | [ | 62 | [ |
63 | { 'uniform': projMatrixUniform = 0, 'name': "u_projMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, | 63 | { 'uniform': projMatrixUniform = 0, 'name': "u_projMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, |
64 | { 'uniform': mvMatrixUniform = 0, 'name': "u_mvMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, | 64 | { 'uniform': mvMatrixUniform = 0, 'name': "u_mvMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, |
65 | { 'uniform': normalMatrixUniform = 0, 'name': "u_normalMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, | 65 | { 'uniform': normalMatrixUniform = 0, 'name': "u_normalMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, |
66 | { 'uniform': worldMatrixUniform = 0, 'name': "u_worldMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, | 66 | { 'uniform': worldMatrixUniform = 0, 'name': "u_worldMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, |
67 | { 'uniform': lightPos = 0, 'name': "u_lightPos", 'type': RDGE.UNIFORMTYPE.FLOAT3, 'value': new Float32Array(3) }, | 67 | { 'uniform': lightPos = 0, 'name': "u_lightPos", 'type': RDGE.UNIFORMTYPE.FLOAT3, 'value': new Float32Array(3) }, |
68 | { 'uniform': lightDiff = 0, 'name': "u_lightDiff", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, | 68 | { 'uniform': lightDiff = 0, 'name': "u_lightDiff", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, |
69 | { 'uniform': lightAmb = 0, 'name': "u_lightAmb", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, | 69 | { 'uniform': lightAmb = 0, 'name': "u_lightAmb", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, |
70 | { 'uniform': colMap = 0, 'name': "colMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, | 70 | { 'uniform': colMap = 0, 'name': "colMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, |
71 | { 'uniform': envMap = 0, 'name': "envMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, | 71 | { 'uniform': envMap = 0, 'name': "envMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, |
72 | { 'uniform': normalMap = 0, 'name': "normalMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, | 72 | { 'uniform': normalMap = 0, 'name': "normalMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, |
73 | { 'uniform': glowMap = 0, 'name': "glowMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, | 73 | { 'uniform': glowMap = 0, 'name': "glowMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, |
74 | { 'uniform': matAmbient = 0, 'name': "u_matAmbient", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, | 74 | { 'uniform': matAmbient = 0, 'name': "u_matAmbient", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, |
75 | { 'uniform': matDiffuse = 0, 'name': "u_matDiffuse", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, | 75 | { 'uniform': matDiffuse = 0, 'name': "u_matDiffuse", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, |
76 | { 'uniform': matSpecular = 0, 'name': "u_matSpecular", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, | 76 | { 'uniform': matSpecular = 0, 'name': "u_matSpecular", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, |
77 | { 'uniform': matShininess = 0, 'name': "u_matShininess", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(1) }, | 77 | { 'uniform': matShininess = 0, 'name': "u_matShininess", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(1) }, |
78 | { 'uniform': matEmission = 0, 'name': "u_matEmission", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(4) }, | 78 | { 'uniform': matEmission = 0, 'name': "u_matEmission", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(4) }, |
79 | { 'uniform': frustumFarZ = 0, 'name': "u_frustumFarZ", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(1) }, | 79 | { 'uniform': frustumFarZ = 0, 'name': "u_frustumFarZ", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(1) }, |
80 | { 'uniform': shadowLightWorld = 0, 'name': "u_shadowLightWorld", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, | 80 | { 'uniform': shadowLightWorld = 0, 'name': "u_shadowLightWorld", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, |
81 | { 'uniform': shadowBiasMatrix = 0, 'name': "u_shadowBiasMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, | 81 | { 'uniform': shadowBiasMatrix = 0, 'name': "u_shadowBiasMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, |
82 | { 'uniform': vShadowLight = 0, 'name': "u_vShadowLight", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, | 82 | { 'uniform': vShadowLight = 0, 'name': "u_vShadowLight", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, |
83 | { 'uniform': depthMap = 0, 'name': "depthMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) } | 83 | { 'uniform': depthMap = 0, 'name': "depthMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) } |
84 | ]; | 84 | ]; |
85 | 85 | ||
86 | return _MasterUniformList; | 86 | return _MasterUniformList; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | RDGE.RDGEUniformInit = function () { | 89 | RDGE.RDGEUniformInit = function () { |
90 | this.uniformList = RDGE.CreateMasterList(); | 90 | this.uniformList = RDGE.CreateMasterList(); |
91 | this.uniformMap = []; | 91 | this.uniformMap = []; |
92 | for (var idx = 0; idx < this.uniformList.length; ++idx) { | 92 | for (var idx = 0; idx < this.uniformList.length; ++idx) { |
93 | this.uniformMap[this.uniformList[idx].name] = this.uniformList[idx]; | 93 | this.uniformMap[this.uniformList[idx].name] = this.uniformList[idx]; |
94 | } | 94 | } |
95 | }; | 95 | }; |
96 | 96 | ||
97 | RDGE.RDGEUniformInit.prototype.SetUni = function (name, _value) { | 97 | RDGE.RDGEUniformInit.prototype.SetUni = function (name, _value) { |
98 | //this.uniformMap[name].value.set(_value); | 98 | //this.uniformMap[name].value.set(_value); |
99 | 99 | ||
100 | this.uniformMap[name].value = _value; | 100 | this.uniformMap[name].value = _value; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | // Globally available uniform storage | 103 | // Globally available uniform storage |
104 | RDGE.RDGEUniform = new RDGE.RDGEUniformInit(); | 104 | RDGE.RDGEUniform = new RDGE.RDGEUniformInit(); |
105 | 105 | ||
106 | RDGE.RenderContext = function () { | 106 | RDGE.RenderContext = function () { |
107 | this.shaderProg = null; | 107 | this.shaderProg = null; |
108 | this.uniforms = []; | 108 | this.uniforms = []; |
109 | this.textureList = []; | 109 | this.textureList = []; |
110 | this.curRenderProc = null; | 110 | this.curRenderProc = null; |
111 | this.light0Color = [1, 1, 1, 0]; | 111 | this.light0Color = [1, 1, 1, 0]; |
112 | this.parentID = 0; | 112 | this.parentID = 0; |
113 | this.world = RDGE.mat4.identity(); | 113 | this.world = RDGE.mat4.identity(); |
114 | this.hide = false; | 114 | this.hide = false; |