diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/RenderProcs.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/RenderProcs.js | 1022 |
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> |
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 | // RDGE namespaces | 31 | // RDGE namespaces |
32 | var RDGE = RDGE || {}; | 32 | var RDGE = RDGE || {}; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * supported uniform types | 35 | * supported uniform types |
36 | */ | 36 | */ |
37 | RDGE.UNIFORMTYPE = function () { | 37 | RDGE.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 | */ |
53 | RDGE.RenderObject = function (shaderHandle) { | 53 | RDGE.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 | */ |
68 | RDGE.RenderObject.prototype.addUniform = function (name, value, type) { | 68 | RDGE.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 | */ |
88 | RDGE.RenderObject.prototype.addUniformArray = function (name, value, type, size) { | 88 | RDGE.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 | */ |
111 | RDGE.RenderObject.prototype.addTexture = function (name, unit, type) { | 111 | RDGE.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) |