aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/rendercontext.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/rendercontext.js
parent04343eda8c2f870b0da55cfdc8003c99fe1cc4de (diff)
downloadninja-3644cb6def4f681c99959e5729e78ea353441fad.tar.gz
Normalize to unix line terminators
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/rendercontext.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/rendercontext.js578
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>
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// render flags, handles, states 33// render flags, handles, states
34RDGE.g_whiteTex = null; 34RDGE.g_whiteTex = null;
35RDGE.g_blackTex = null; 35RDGE.g_blackTex = null;
36RDGE.g_blueTex = null; 36RDGE.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
39RDGE.RDGEWebTexture = function () { 39RDGE.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
45RDGE.RDGEWebUniformPair = function (uniform, value, type) { 45RDGE.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
53RDGE.defaultState = function () { 53RDGE.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); )
60RDGE.CreateMasterList = function () { 60RDGE.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
89RDGE.RDGEUniformInit = function () { 89RDGE.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
97RDGE.RDGEUniformInit.prototype.SetUni = function (name, _value) { 97RDGE.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
104RDGE.RDGEUniform = new RDGE.RDGEUniformInit(); 104RDGE.RDGEUniform = new RDGE.RDGEUniformInit();
105 105
106RDGE.RenderContext = function () { 106RDGE.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;
115 enableNormalMapping = true; 115 enableNormalMapping = true;