diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/renderer.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/renderer.js | 782 |
1 files changed, 391 insertions, 391 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index 9367c145..6ad20e57 100755 --- a/js/helper-classes/RDGE/src/core/script/renderer.js +++ b/js/helper-classes/RDGE/src/core/script/renderer.js | |||
@@ -74,7 +74,7 @@ RDGE.rdgeConstants = (function () { | |||
74 | // render constants | 74 | // render constants |
75 | MAX_MATERIAL_LIGHTS: 4, | 75 | MAX_MATERIAL_LIGHTS: 4, |
76 | 76 | ||
77 | // Material categories determine sorting materials support the following categories | 77 | // Material categories determine sorting materials support the following categories |
78 | categoryEnumeration: | 78 | categoryEnumeration: |
79 | { | 79 | { |
80 | 'BACKGROUND': 0, | 80 | 'BACKGROUND': 0, |
@@ -99,7 +99,7 @@ RDGE.rdgeConstants = (function () { | |||
99 | 99 | ||
100 | RDGE._renderer = function (canvas) { | 100 | RDGE._renderer = function (canvas) { |
101 | /* | 101 | /* |
102 | * Initialize the context associated with this canvas | 102 | * Initialize the context associated with this canvas |
103 | */ | 103 | */ |
104 | try { | 104 | try { |
105 | this.ctx = canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true }); // true, true, false, true, true); | 105 | this.ctx = canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true }); // true, true, false, true, true); |
@@ -127,36 +127,36 @@ RDGE._renderer = function (canvas) { | |||
127 | this.console = ("console" in window) ? window.console : { log: function () { } }; | 127 | this.console = ("console" in window) ? window.console : { log: function () { } }; |
128 | 128 | ||
129 | /* | 129 | /* |
130 | * Set the default clear color | 130 | * Set the default clear color |
131 | */ | 131 | */ |
132 | this.ctx.clearColor(1, 0, 0, 1); | 132 | this.ctx.clearColor(1, 0, 0, 1); |
133 | 133 | ||
134 | /* | 134 | /* |
135 | * the clear color of this renderer | 135 | * the clear color of this renderer |
136 | */ | 136 | */ |
137 | this.clearColor = [1, 0, 0, 1]; | 137 | this.clearColor = [1, 0, 0, 1]; |
138 | 138 | ||
139 | /* | 139 | /* |
140 | * The clear flags clear color and depth buffers by default | 140 | * The clear flags clear color and depth buffers by default |
141 | */ | 141 | */ |
142 | this.clearFlags = this.ctx.COLOR_BUFFER_BIT | this.ctx.DEPTH_BUFFER_BIT | 142 | this.clearFlags = this.ctx.COLOR_BUFFER_BIT | this.ctx.DEPTH_BUFFER_BIT |
143 | 143 | ||
144 | /* | 144 | /* |
145 | * clear flags | 145 | * clear flags |
146 | */ | 146 | */ |
147 | this.colorBuffer = this.ctx.COLOR_BUFFER_BIT; | 147 | this.colorBuffer = this.ctx.COLOR_BUFFER_BIT; |
148 | this.depthBuffer = this.ctx.DEPTH_BUFFER_BIT; | 148 | this.depthBuffer = this.ctx.DEPTH_BUFFER_BIT; |
149 | this.stencilBuffer = this.ctx.STENCIL_BUFFER_BIT; | 149 | this.stencilBuffer = this.ctx.STENCIL_BUFFER_BIT; |
150 | 150 | ||
151 | /* | 151 | /* |
152 | * buffer types | 152 | * buffer types |
153 | */ | 153 | */ |
154 | this.BUFFER_STATIC = 0; | 154 | this.BUFFER_STATIC = 0; |
155 | this.BUFFER_DYNAMIC = 1; | 155 | this.BUFFER_DYNAMIC = 1; |
156 | this.BUFFER_STREAM = 2; | 156 | this.BUFFER_STREAM = 2; |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * primitive types | 159 | * primitive types |
160 | */ | 160 | */ |
161 | this.POINTS = 0; | 161 | this.POINTS = 0; |
162 | this.LINES = 1; | 162 | this.LINES = 1; |
@@ -167,7 +167,7 @@ RDGE._renderer = function (canvas) { | |||
167 | this.TRIANGLE_FAN = 6; | 167 | this.TRIANGLE_FAN = 6; |
168 | 168 | ||
169 | /* | 169 | /* |
170 | * primitive data types | 170 | * primitive data types |
171 | */ | 171 | */ |
172 | this.BYTE = 0x1400; | 172 | this.BYTE = 0x1400; |
173 | this.UNSIGNED_BYTE = 0x1401; | 173 | this.UNSIGNED_BYTE = 0x1401; |
@@ -178,7 +178,7 @@ RDGE._renderer = function (canvas) { | |||
178 | this.FLOAT = 0x1406; | 178 | this.FLOAT = 0x1406; |
179 | 179 | ||
180 | /* | 180 | /* |
181 | * pre-defined vertex element type | 181 | * pre-defined vertex element type |
182 | */ | 182 | */ |
183 | this.VS_ELEMENT_FLOAT4 = 4; | 183 | this.VS_ELEMENT_FLOAT4 = 4; |
184 | this.VS_ELEMENT_POS = 3; | 184 | this.VS_ELEMENT_POS = 3; |
@@ -201,7 +201,7 @@ RDGE._renderer = function (canvas) { | |||
201 | this.usedTextureUnits = 5; | 201 | this.usedTextureUnits = 5; |
202 | 202 | ||
203 | /* | 203 | /* |
204 | * the renderers current viewport | 204 | * the renderers current viewport |
205 | */ | 205 | */ |
206 | this.vpX = 0; | 206 | this.vpX = 0; |
207 | this.vpY = 0; | 207 | this.vpY = 0; |
@@ -209,18 +209,18 @@ RDGE._renderer = function (canvas) { | |||
209 | this.vpHeight = canvas.height; | 209 | this.vpHeight = canvas.height; |
210 | 210 | ||
211 | /* | 211 | /* |
212 | * the camera manager - contains the camera stack for this render context | 212 | * the camera manager - contains the camera stack for this render context |
213 | */ | 213 | */ |
214 | this.cameraMan = new RDGE.cameraManager(); | 214 | this.cameraMan = new RDGE.cameraManager(); |
215 | 215 | ||
216 | /* | 216 | /* |
217 | * a list of device buffers that are owned by this render context | 217 | * a list of device buffers that are owned by this render context |
218 | */ | 218 | */ |
219 | this.buffers = []; | 219 | this.buffers = []; |
220 | 220 | ||
221 | 221 | ||
222 | /* | 222 | /* |
223 | * State wrappers | 223 | * State wrappers |
224 | */ | 224 | */ |
225 | this.cullBackFace = function () { | 225 | this.cullBackFace = function () { |
226 | this.ctx.cullFace(this.ctx.Back); | 226 | this.ctx.cullFace(this.ctx.Back); |
@@ -260,35 +260,35 @@ RDGE._renderer = function (canvas) { | |||
260 | }; | 260 | }; |
261 | 261 | ||
262 | /* | 262 | /* |
263 | * flags that specify how to clear the scene, can be OR'ed together | 263 | * flags that specify how to clear the scene, can be OR'ed together |
264 | */ | 264 | */ |
265 | this.setClearFlags = function (flags) { | 265 | this.setClearFlags = function (flags) { |
266 | this.clearFlags = flags; | 266 | this.clearFlags = flags; |
267 | }; | 267 | }; |
268 | 268 | ||
269 | /* | 269 | /* |
270 | * called by the system to clear the video buffer according to pre-set flags | 270 | * called by the system to clear the video buffer according to pre-set flags |
271 | */ | 271 | */ |
272 | this._clear = function () { | 272 | this._clear = function () { |
273 | this.ctx.clear(this.clearFlags); | 273 | this.ctx.clear(this.clearFlags); |
274 | }; | 274 | }; |
275 | 275 | ||
276 | /* | 276 | /* |
277 | * clears the video buffer with flags provided | 277 | * clears the video buffer with flags provided |
278 | */ | 278 | */ |
279 | this.clear = function (flags) { | 279 | this.clear = function (flags) { |
280 | this.ctx.clear(flags); | 280 | this.ctx.clear(flags); |
281 | }; | 281 | }; |
282 | 282 | ||
283 | /* | 283 | /* |
284 | * flush the video buffer | 284 | * flush the video buffer |
285 | */ | 285 | */ |
286 | this.flush = function () { | 286 | this.flush = function () { |
287 | this.ctx.flush(); | 287 | this.ctx.flush(); |
288 | }; | 288 | }; |
289 | 289 | ||
290 | /* | 290 | /* |
291 | * Sets the current viewport | 291 | * Sets the current viewport |
292 | */ | 292 | */ |
293 | this.setViewPort = function (x, y, width, height) { | 293 | this.setViewPort = function (x, y, width, height) { |
294 | this.vpX = x; | 294 | this.vpX = x; |
@@ -299,23 +299,23 @@ RDGE._renderer = function (canvas) { | |||
299 | }; | 299 | }; |
300 | 300 | ||
301 | /* | 301 | /* |
302 | * access the camera manager associated with the renderer | 302 | * access the camera manager associated with the renderer |
303 | */ | 303 | */ |
304 | this.cameraManager = function () { | 304 | this.cameraManager = function () { |
305 | return this.cameraMan; | 305 | return this.cameraMan; |
306 | }; | 306 | }; |
307 | 307 | ||
308 | /* | 308 | /* |
309 | * Sets of texture maps owned by the renderer | 309 | * Sets of texture maps owned by the renderer |
310 | */ | 310 | */ |
311 | this.textureMap = []; | 311 | this.textureMap = []; |
312 | this.rttMap = []; | 312 | this.rttMap = []; |
313 | 313 | ||
314 | /* | 314 | /* |
315 | * gets the texture by name or creates the texture requested | 315 | * gets the texture by name or creates the texture requested |
316 | * @param name - the name of the texture to try and get | 316 | * @param name - the name of the texture to try and get |
317 | * @param wrap - optional "CLAMP or "REPEAT", default is clamp | 317 | * @param wrap - optional "CLAMP or "REPEAT", default is clamp |
318 | * @param mips - optional true/false value to create mipmaps, the default is true |