aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/rendercontext.js
diff options
context:
space:
mode:
authorJohn Mayhew2012-07-09 17:28:24 -0700
committerJohn Mayhew2012-07-09 17:28:24 -0700
commit770bcb52422742ff741a88a75ecefbeb90bc9247 (patch)
tree64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/helper-classes/RDGE/src/core/script/rendercontext.js
parent8c5ecaf90062f9e030386f338bdc19fd62b826c8 (diff)
parent2b2b5fbb4b6a786daa4e9d4ee9eba9ac78924842 (diff)
downloadninja-770bcb52422742ff741a88a75ecefbeb90bc9247.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Conflicts: manifest.json
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/rendercontext.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/rendercontext.js579
1 files changed, 290 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..17d3f8cb 100755
--- a/js/helper-classes/RDGE/src/core/script/rendercontext.js
+++ b/js/helper-classes/RDGE/src/core/script/rendercontext.js
@@ -1,289 +1,290 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License. 4
5 5Redistribution and use in source and binary forms, with or without
6Redistribution and use in source and binary forms, with or without 6modification, are permitted provided that the following conditions are met:
7modification, 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.
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28POSSIBILITY OF SUCH DAMAGE. 28ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29</copyright> */ 29POSSIBILITY OF SUCH DAMAGE.
30 30</copyright> */
31var RDGE = RDGE || {}; 31
32 32var RDGE = RDGE || {};
33// render flags, handles, states 33
34RDGE.g_whiteTex = null; 34// render flags, handles, states
35RDGE.g_blackTex = null; 35RDGE.g_whiteTex = null;
36RDGE.g_blueTex = null; 36RDGE.g_blackTex = null;
37 37RDGE.g_blueTex = null;
38/* These objects appear to be unused so they are currently commented out 38
39RDGE.RDGEWebTexture = function () { 39/* These objects appear to be unused so they are currently commented out
40 this.handle; // gl handle 40RDGE.RDGEWebTexture = function () {
41 this.unit; // the texture slot/unit 41 this.handle; // gl handle
42 this.type = RDGE.UNIFORMTYPE.TEXTURE2D; 42 this.unit; // the texture slot/unit
43}; 43 this.type = RDGE.UNIFORMTYPE.TEXTURE2D;
44 44};
45RDGE.RDGEWebUniformPair = function (uniform, value, type) { 45
46 this.uniform = uniform; 46RDGE.RDGEWebUniformPair = function (uniform, value, type) {
47 this.value = value; 47 this.uniform = uniform;
48 this.type = type; 48 this.value = value;
49}; 49 this.type = type;
50 50};
51 51
52// pass a function that takes no parameters 52
53RDGE.defaultState = function () { 53// pass a function that takes no parameters
54 return [function () { gl.disable(gl.CULL_FACE) }, 54RDGE.defaultState = function () {
55 function () { gl.enable(gl.DEPTH_TEST) } ] 55 return [function () { gl.disable(gl.CULL_FACE) },
56}; 56 function () { gl.enable(gl.DEPTH_TEST) } ]
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
60RDGE.CreateMasterList = function () { 60// this chunk of data contains uniform storage references set the data with RDGEUniform.set (ie RDGEUniform.set("u_name", RDGE.UNIFORMTYPE.FLOAT4, myData); )
61 _MasterUniformList = 61RDGE.CreateMasterList = function () {
62 [ 62 _MasterUniformList =
63 { 'uniform': projMatrixUniform = 0, 'name': "u_projMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, 63 [
64 { 'uniform': mvMatrixUniform = 0, 'name': "u_mvMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, 64 { 'uniform': projMatrixUniform = 0, 'name': "u_projMatrix", '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': mvMatrixUniform = 0, 'name': "u_mvMatrix", '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': normalMatrixUniform = 0, 'name': "u_normalMatrix", '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': worldMatrixUniform = 0, 'name': "u_worldMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) },
68 { 'uniform': lightDiff = 0, 'name': "u_lightDiff", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, 68 { 'uniform': lightPos = 0, 'name': "u_lightPos", 'type': RDGE.UNIFORMTYPE.FLOAT3, 'value': new Float32Array(3) },
69 { 'uniform': lightAmb = 0, 'name': "u_lightAmb", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, 69 { 'uniform': lightDiff = 0, 'name': "u_lightDiff", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) },
70 { 'uniform': colMap = 0, 'name': "colMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, 70 { 'uniform': lightAmb = 0, 'name': "u_lightAmb", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) },
71 { 'uniform': envMap = 0, 'name': "envMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, 71 { 'uniform': colMap = 0, 'name': "colMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) },
72 { 'uniform': normalMap = 0, 'name': "normalMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, 72 { 'uniform': envMap = 0, 'name': "envMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) },
73 { 'uniform': glowMap = 0, 'name': "glowMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }, 73 { 'uniform': normalMap = 0, 'name': "normalMap", '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': glowMap = 0, 'name': "glowMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) },
75 { 'uniform': matDiffuse = 0, 'name': "u_matDiffuse", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) }, 75 { 'uniform': matAmbient = 0, 'name': "u_matAmbient", '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': matDiffuse = 0, 'name': "u_matDiffuse", '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': matSpecular = 0, 'name': "u_matSpecular", 'type': RDGE.UNIFORMTYPE.FLOAT4, 'value': new Float32Array(4) },
78 { 'uniform': matEmission = 0, 'name': "u_matEmission", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(4) }, 78 { 'uniform': matShininess = 0, 'name': "u_matShininess", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(1) },
79 { 'uniform': frustumFarZ = 0, 'name': "u_frustumFarZ", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(1) }, 79 { 'uniform': matEmission = 0, 'name': "u_matEmission", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(4) },
80 { 'uniform': shadowLightWorld = 0, 'name': "u_shadowLightWorld", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, 80 { 'uniform': frustumFarZ = 0, 'name': "u_frustumFarZ", 'type': RDGE.UNIFORMTYPE.FLOAT, 'value': new Float32Array(1) },
81 { 'uniform': shadowBiasMatrix = 0, 'name': "u_shadowBiasMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) }, 81 { 'uniform': shadowLightWorld = 0, 'name': "u_shadowLightWorld", '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': shadowBiasMatrix = 0, 'name': "u_shadowBiasMatrix", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) },
83 { 'uniform': depthMap = 0, 'name': "depthMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) } 83 { 'uniform': vShadowLight = 0, 'name': "u_vShadowLight", 'type': RDGE.UNIFORMTYPE.MATRIX4, 'value': new Float32Array(16) },
84 ]; 84 { 'uniform': depthMap = 0, 'name': "depthMap", 'type': RDGE.UNIFORMTYPE.TEXTURE2D, 'value': new Int32Array(1) }
85 85 ];
86 return _MasterUniformList; 86
87}; 87 return _MasterUniformList;
88 88};
89RDGE.RDGEUniformInit = function () { 89
90 this.uniformList = RDGE.CreateMasterList(); 90RDGE.RDGEUniformInit = function () {
91 this.uniformMap = []; 91 this.uniformList = RDGE.CreateMasterList();
92 for (var idx = 0; idx < this.uniformList.length; ++idx) { 92 this.uniformMap = [];
93 this.uniformMap[this.uniformList[idx].name] = this.uniformList[idx]; 93 for (var idx = 0; idx < this.uniformList.length; ++idx) {
94 } 94 this.uniformMap[this.uniformList[idx].name] = this.uniformList[idx];
95}; 95 }
96 96};
97RDGE.RDGEUniformInit.prototype.SetUni = function (name, _value) { 97
98 //this.uniformMap[name].value.set(_value); 98RDGE.RDGEUniformInit.prototype.SetUni = function (name, _value) {
99 99 //this.uniformMap[name].value.set(_value);
100 this.uniformMap[name].value = _value; 100
101}; 101 this.uniformMap[name].value = _value;
102 102};
103// Globally available uniform storage 103
104RDGE.RDGEUniform = new RDGE.RDGEUniformInit(); 104// Globally available uniform storage
105 105RDGE.RDGEUniform = new RDGE.RDGEUniformInit();
106RDGE.RenderContext = function () { 106
107 this.shaderProg = null; 107RDGE.RenderContext = function () {
108 this.uniforms = []; 108 this.shaderProg = null;
109 this.textureList = []; 109 this.uniforms = [];
110 this.curRenderProc = null; 110 this.textureList = [];
111 this.light0Color = [1, 1, 1, 0]; 111 this.curRenderProc = null;
112 this.parentID = 0; 112 this.light0Color = [1, 1, 1, 0];
113 this.world = RDGE.mat4.identity(); 113 this.parentID = 0;
114 this.hide = false; 114 this.world = RDGE.mat4.identity();
115 enableNormalMapping = true; 115 this.hide = false;
116 this.lights = [null, null, null, null]; 116 enableNormalMapping = true;
117 117 this.lights = [null, null, null, null];
118 // state settings - set functions in the array that set states or 'other' so long as it makes since 118
119 this.stateSettings = []; 119 // state settings - set functions in the array that set states or 'other' so long as it makes since
120}; 120 this.stateSettings = [];