aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/RenderProcs.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/RenderProcs.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/RenderProcs.js1022
1 files changed, 511 insertions, 511 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/RenderProcs.js b/js/helper-classes/RDGE/src/core/script/RenderProcs.js
index 1583ea14..1f0d3b3c 100755
--- a/js/helper-classes/RDGE/src/core/script/RenderProcs.js
+++ b/js/helper-classes/RDGE/src/core/script/RenderProcs.js
@@ -1,511 +1,511 @@
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
31// RDGE namespaces 31// RDGE namespaces
32var RDGE = RDGE || {}; 32var RDGE = RDGE || {};
33 33
34/** 34/**
35* supported uniform types 35* supported uniform types
36*/ 36*/
37RDGE.UNIFORMTYPE = function () { 37RDGE.UNIFORMTYPE = function () {
38 this.INT = 0x3F0; 38 this.INT = 0x3F0;
39 this.FLOAT = 0x3E8; 39 this.FLOAT = 0x3E8;
40 this.FLOAT2 = 0x3E9; 40 this.FLOAT2 = 0x3E9;
41 this.FLOAT3 = 0x3EA; 41 this.FLOAT3 = 0x3EA;
42 this.FLOAT4 = 0x3EB; 42 this.FLOAT4 = 0x3EB;
43 this.MATRIX3 = 0x3EC; 43 this.MATRIX3 = 0x3EC;
44 this.MATRIX4 = 0x3ED; 44 this.MATRIX4 = 0x3ED;
45 this.TEXTURE2D = 0x3EE; 45 this.TEXTURE2D = 0x3EE;
46 this.TEXTURECUBE = 0x3EF; 46 this.TEXTURECUBE = 0x3EF;
47}; 47};
48 48
49/** 49/**
50* RDGE.RenderObject - contains references to all the data need to render, including vertex buffers, uniform handles, and matrices 50* RDGE.RenderObject - contains references to all the data need to render, including vertex buffers, uniform handles, and matrices
51* @param shaderHandle 51* @param shaderHandle
52*/ 52*/
53RDGE.RenderObject = function (shaderHandle) { 53RDGE.RenderObject = function (shaderHandle) {
54 this.shader = shaderHandle; 54 this.shader = shaderHandle;
55 this.world = null; 55 this.world = null;
56 this.bindings = new RDGE.ShaderData(); 56 this.bindings = new RDGE.ShaderData();
57 this.initRenderProc = null; 57 this.initRenderProc = null;
58 this.renderProc = null; 58 this.renderProc = null;
59 this.postRenderProc = null; 59 this.postRenderProc = null;
60}; 60};
61 61
62/** 62/**
63* Adds a uniform to the render object to bound during render 63* Adds a uniform to the render object to bound during render
64* @param name - name of the uniform 64* @param name - name of the uniform
65* @param value - reference to value that will get bound (will be referenced from now on, don't delete the ref) 65* @param value - reference to value that will get bound (will be referenced from now on, don't delete the ref)
66* @param type - type of uniform, use RDGE.UNIFORMTYPE 66* @param type - type of uniform, use RDGE.UNIFORMTYPE
67*/ 67*/
68RDGE.RenderObject.prototype.addUniform = function (name, value, type) { 68RDGE.RenderObject.prototype.addUniform = function (name, value, type) {
69 var uniform = RDGE.globals.gl.getUniformLocation(this.shader, name); 69 var uniform = RDGE.globals.gl.getUniformLocation(this.shader, name);
70 if (uniform) { 70 if (uniform) {
71 uniform.debugName = name; 71 uniform.debugName = name;
72 this.bindings.uniforms.push(new RDGE.UniformPair(uniform, value, type)); 72 this.bindings.uniforms.push(new RDGE.UniformPair(uniform, value, type));
73 } 73 }
74 /* 74 /*
75 else 75 else
76 { 76 {
77 gl.console.log("ERROR: uniform - " + name + " not found!"); 77 gl.console.log("ERROR: uniform - " + name + " not found!");
78 } 78 }
79 */ 79 */
80}; 80};
81 81
82/** 82/**
83* Adds a uniform to the render object to bound during render 83* Adds a uniform to the render object to bound during render
84* @param name - name of the uniform 84* @param name - name of the uniform
85* @param value - reference to value that will get bound (will be referenced from now on, don't delete the ref) 85* @param value - reference to value that will get bound (will be referenced from now on, don't delete the ref)
86* @param type - type of uniform, use RDGE.UNIFORMTYPE 86* @param type - type of uniform, use RDGE.UNIFORMTYPE
87*/ 87*/
88RDGE.RenderObject.prototype.addUniformArray = function (name, value, type, size) { 88RDGE.RenderObject.prototype.addUniformArray = function (name, value, type, size) {
89 var uniform = RDGE.globals.gl.getUniformLocation(this.shader, name); 89 var uniform = RDGE.globals.gl.getUniformLocation(this.shader, name);
90 if (uniform) { 90 if (uniform) {
91 for (var index = 0; index < size; index++) { 91 for (var index = 0; index < size; index++) {
92 uniform.debugName = name + index; 92 uniform.debugName = name + index;
93 this.bindings.uniforms.push(new RDGE.UniformPair(uniform, value[index], type)); 93 this.bindings.uniforms.push(new RDGE.UniformPair(uniform, value[index], type));
94 uniform += value[index].length; 94 uniform += value[index].length;
95 value++; 95 value++;
96 } 96 }
97 } 97 }
98 /* 98 /*
99 else 99 else
100 { 100 {
101 gl.console.log("ERROR: uniform - " + name + " not found!"); 101 gl.console.log("ERROR: uniform - " + name + " not found!");
102 }*/ 102 }*/
103}; 103};
104 104
105/** 105/**
106* Add texture to uniform 106* Add texture to uniform
107* @param name - handle to the texture 107* @param name - handle to the texture
108* @param unit - texture slot to use 108* @param unit - texture slot to use
109* @param type - RDGE.UNIFORMTYPE.TEXTURE2D or TEXTURE2D.TEXTURECUBE 109* @param type - RDGE.UNIFORMTYPE.TEXTURE2D or TEXTURE2D.TEXTURECUBE
110*/ 110*/
111RDGE.RenderObject.prototype.addTexture = function (name, unit, type) { 111RDGE.RenderObject.prototype.addTexture = function (name, unit, type) {
112 var uniform = RDGE.globals.gl.getUniformLocation(this.shader, name); 112 var uniform = RDGE.globals.gl.getUniformLocation(this.shader, name);
113 if (uniform) { 113 if (uniform) {
114 this.bindings.textures.push(new RDGE.TexUniform(uniform, unit, type)); 114 this.bindings.textures.push(new RDGE.TexUniform(uniform, unit, type));
115 } 115 }
116 /* 116 /*
117 else 117 else
118 { 118 {
119 gl.console.log("ERROR: texture uniform - " + name + " not found!"); 119 gl.console.log("ERROR: texture uniform - " + name + " not found!");
120 } 120 }
121 */ 121 */
122}; 122};
123 123
124/** 124/**
125* Adds a vertex buffer to the render object 125* Adds a vertex buffer to the render object
126* @param buffer - buffer to use 126* @param buffer - buffer to use
127* @param glBufferType - type of buffer i.e. gl.ARRAY_BUFFER 127* @param glBufferType - type of buffer i.e. gl.ARRAY_BUFFER
128* @param attribSize - if using attrib the size of an element (3 for vec3)