/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
</copyright> */
var RDGE = RDGE || {};
// runtime globals
RDGE.rdgeConstants = (function () {
return {
// clear flags
colorBuffer: 0x00004000,
depthBuffer: 0x00000100,
stencilBuffer: 0x00000400,
// primitive types
POINTS: 0,
LINES: 1,
LINE_LOOP: 2,
LINE_STRIP: 3,
TRIANGLES: 4,
TRIANGLE_STRIP: 5,
TRIANGLE_FAN: 6,
// primitive data types
BYTE: 0x1400,
UNSIGNED_BYTE: 0x1401,
SHORT: 0x1402,
UNSIGNED_SHORT: 0x1403,
INT: 0x1404,
UNSIGNED_INT: 0x1405,
FLOAT: 0x1406,
// pre-defined vertex element type
VS_ELEMENT_FLOAT4: 4,
VS_ELEMENT_POS: 3,
VS_ELEMENT_NORM: 3,
VS_ELEMENT_FLOAT3: 3,
VS_ELEMENT_FLOAT2: 2,
VS_ELEMENT_UV: 2,
VS_ELEMENT_FLOAT: 1,
MAX_ELEM_TYPES: 7,
// GL Definition of buffer types
BUFFER_STATIC: 0x88E0,
BUFFER_DYNAMIC: 0x88E4,
BUFFER_STREAM: 0x88E8,
// render constants
MAX_MATERIAL_LIGHTS: 4,
// Material categories determine sorting materials support the following categories
categoryEnumeration:
{
'BACKGROUND': 0,
'OPAQUE': 1,
'TRANSPARENT': 2,
'ADDITIVE': 3,
'TRANSLUCENT': 4,
'FOREGROUND': 5,
'MAX_CAT': 6
},
// Node types supported by the scene graph
nodeType:
{
'TRNODE': 0,
'MESHNODE': 1,
'MATNODE': 2,
'LIGHTNODE': 3
}
};
})();
RDGE._renderer = function (canvas) {
/*
* Initialize the context associated with this canvas
*/
try {
this.ctx = canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true }); // true, true, false, true, true);
if (!this.ctx) {
this.ctx = canvas.getContext("webgl", { preserveDrawingBuffer: true });
}
if (!this.ctx) {
this.ctx = canvas.getContext("webkit-3d", { preserveDrawingBuffer: true });
}
if (!this.ctx) {
this.ctx = canvas.getContext("moz-webgl", { preserveDrawingBuffer: true });
}
}
catch (err) { }
if (!this.ctx) {
window.console.log("Could not create GL context");
return null;
}
// set viewport for the first time
this.ctx.viewport(0, 0, canvas.width, canvas.height);
// Add a console output to the renderer
this.console = ("console" in window) ? window.console : { log: function () { } };
/*
* Set the default clear color
*/
this.ctx.clearColor(1, 0, 0, 1);
/*
* the clear color of this renderer
*/
this.clearColor = [1, 0, 0, 1];
/*
* The clear flags clear color and depth buffers by default
*/
this.clearFlags = this.ctx.COLOR_BUFFER_BIT | this.ctx.DEPTH_BUFFER_BIT
/*
* clear flags
*/
this.colorBuffer = this.ctx.COLOR_BUFFER_BIT;
this.depthBuffer = this.ctx.DEPTH_BUFFER_BIT;
this.stencilBuffer = this
|