B.Render

Contains a set of primitives that provide staging graphics core architecture.

ENUMERATIONS:

Mask

Color mask.

{number} R = 1

Red component.

{number} G = 2

Green component.

{number} B = 4

Blue component.

{number} A = 8

Alpha component.

{number} RGB = 7

Red, Green, Blue components.

{number} RGBA = 15

Red, Green, Blue, Alpha components.

Attribute

Vertex attribute type.

{number} UINT = 1

Unsigned integer.

{number} FLOAT = 2

Floating-point scalar.

{number} VECTOR2 = 3

Floating-point 2D-vector.

{number} VECTOR3 = 4

Floating-point 3D-vector.

{number} VECTOR4 = 5

Floating-point 4D-vector.

{number} POSITION = 6

Position (VECTOR3 alias).

{number} NORMAL = 7

Normal (VECTOR3 alias).

{number} TANGENT = 8

Tangent (VECTOR3 alias).

{number} UV = 9

UV-coordinates (VECTOR2 alias).

{number} COLOR = 10

Color (UINT alias).

Index

Index type.

{number} USHORT = 1

16-bit index.

{number} UINT = 2

32-bit index (to check hardware support use device.caps().indexUInt flag).

Primitive

Primitive type.

{number} POINT = 1

Isolated point.

{number} LINE = 2

Isolated straight line.

{number} TRIANGLE = 3

Isolated triangle.

Usage

Specifies the usage pattern of the data store.

{number} STATIC = 1

The data store contents will be modified once.

{number} DYNAMIC = 2

The data store contents will be modified repeatedly.

Format

Surface format.

{number} A = 1

8-bit format (alpha only).

{number} RGB = 2

24-bit format using 8 bits for the each channel (red, green, blue).

{number} RGBA = 3

32-bit format using 8 bits for the each channel (red, green, blue, alpha).

{number} RGB_DXT1 = 4

DXT1 (S3TC) compression format. To check hardware support use device.caps().textureDXT flag.

{number} RGBA_DXT5 = 5

DXT5 (S3TC) compression format. To check hardware support use device.caps().textureDXT flag.

{number} A_F16 = 6

16-bit floating-point format (alpha only). To check hardware support use device.caps().textureFloat16 flag.

{number} RGB_F16 = 7

48-bit floating-point format using 16 bits for the each channel (red, green, blue). To check hardware support use device.caps().textureFloat16 flag.

{number} RGBA_F16 = 8

64-bit floating-point format using 16 bits for the each channel (red, green, blue, alpha). To check hardware support use device.caps().textureFloat16 flag.

{number} A_F32 = 9

32-bit floating-point format (alpha only). To check hardware support use device.caps().textureFloat32 flag.

{number} RGB_F32 = 10

96-bit floating-point format using 32 bits for the each channel (red, green, blue). To check hardware support use device.caps().textureFloat32 flag.

{number} RGBA_F32 = 11

128-bit floating-point format using 32 bits for the each channel (red, green, blue, alpha). To check hardware support use device.caps().textureFloat32 flag.

{number} DEPTH = 12

16-bit depth format.

{number} DEPTH_STENCIL = 13

32-bit depth-stencil format using 24 bits for the depth and 8 bits for the stencil.

CubeFace

Cubemap face.

{number} POSITIVE_X = 0

Positive X-face.

{number} NEGATIVE_X = 1

Negative X-face.

{number} POSITIVE_Y = 2

Positive Y-face.

{number} NEGATIVE_Y = 3

Negative Y-face.

{number} POSITIVE_Z = 4

Positive Z-face.

{number} NEGATIVE_Z = 5

Negative Z-face.

{number} COUNT = 6

Face count.

Uniform

Uniform type.

{number} FLOAT = 1

Floating-point scalar.

{number} VECTOR2 = 2

Floating-point 2D-vector.

{number} VECTOR3 = 3

Floating-point 3D-vector.

{number} VECTOR4 = 4

Floating-point 4D-vector.

{number} MATRIX3 = 5

Floating-point 3x3-matrix.

{number} MATRIX4 = 6

Floating-point 4x4-matrix.

{number} SAMPLER_2D = 7

2D-sampler.

{number} SAMPLER_CUBE = 8

Cube-sampler.

State

Rendering state type.

{number} POLYGON = 0

Polygon state.

{number} MULTISAMPLE = 1

Multisample state.

{number} COLOR = 2

Color state.

{number} DEPTH = 3

Depth state.

{number} STENCIL = 4

Stencil state.

{number} BLEND = 5

Blend state.

{number} COUNT = 6

State count.

Face

Polygon's face direction.

{number} FRONT = 1

Front.

{number} BACK = 2

Back.

{number} BOTH = 3

Front and back.

CmpFunc

Compare function.

{number} NEVER = 1

Never passes.

{number} ALWAYS = 2

Always passes.

{number} LESS = 3

Passes if the incoming value is less than the current value.

{number} LESS_EQUAL = 4

Passes if the incoming value is less than or equal to the current value.

{number} GREATER = 5

Passes if the incoming value is greater than the current value.

{number} GREATER_EQUAL = 6

Passes if the incoming value is greater than or equal to the current value.

{number} EQUAL = 7

Passes if the incoming value is equal to the current value.

{number} NOT_EQUAL = 8

Passes if the incoming value is not equal to the current value.

StencilOp

Stencil-buffer operation.

{number} KEEP = 1

Keeps the current value.

{number} ZERO = 2

Sets the value to 0.

{number} REPLACE = 3

Sets the value to ref, as specified by stencilState.test(func, ref, mask)

{number} INCR = 4

Increments the current value. Clamps to the maximum representable unsigned value.

{number} INCR_WRAP = 5

Increments the current value. Wraps the value to zero when incrementing the maximum representable unsigned value.

{number} DECR = 6

Decrements the current value. Clamps to zero.

{number} DECR_WRAP = 7

Decrements the current value. Wraps the value to the maximum representable unsigned value when decrementing a value of zero.

{number} INVERT = 8

Bitwise inverts the current value.

Blend

Blending factor.

{number} ZERO = 1

Factor is (0, 0, 0, 0).

{number} ONE = 2

Factor is (1, 1, 1, 1).

{number} SRC_COLOR = 3

Factor is (SrcR, SrcG, SrcB, SrcA).

{number} INV_SRC_COLOR = 4

Factor is (1 - SrcR, 1 - SrcG, 1 - SrcB, 1 - SrcA).

{number} DEST_COLOR = 5

Factor is (DestR, DestG, DestB, DestA).

{number} INV_DEST_COLOR = 6

Factor is (1 - DestR, 1 - DestG, 1 - DestB, 1 - DestA).

{number} SRC_ALPHA = 7

Factor is (SrcA, SrcA, SrcA, SrcA).

{number} INV_SRC_ALPHA = 8

Factor is (1 - SrcA, 1 - SrcA, 1 - SrcA, 1 - SrcA).

{number} DEST_ALPHA = 9

Factor is (DestA, DestA, DestA, DestA).

{number} INV_DEST_ALPHA = 10

Factor is (1 - DestA, 1 - DestA, 1 - DestA, 1 - DestA).

{number} CONST_COLOR = 11

Factor is (ConstR, ConstG, ConstB, ConstA).

{number} INV_CONST_COLOR = 12

Factor is (1 - ConstR, 1 - ConstG, 1 - ConstB, 1 - ConstA).

{number} CONST_ALPHA = 13

Factor is (ConstA, ConstA, ConstA, ConstA).

{number} INV_CONST_ALPHA = 14

Factor is (1 - ConstA, 1 - ConstA, 1 - ConstA, 1 - ConstA).

{number} SRC_ALPHA_SAT = 15

Factor is (f, f, f, 1) where f = min(SrcA, 1 - DestA).

BlendEq

Blending equation.

{number} ADD = 1

Result = Src * SrcFactor + Dst * DstFactor

{number} SUBTRACT = 2

Result = Src * SrcFactor - Dst * DstFactor

{number} REV_SUBTRACT = 3

Result = Dst * DstFactor - Src * SrcFactor

Address

Texture addressing mode.

{number} WRAP = 1

Tile the texture at every integer junction.

{number} MIRROR = 2

Similar to WRAP, except that the texture is flipped at every integer junction.

{number} CLAMP = 3

Texture coordinates outside the range [0.0, 1.0] are set to the texture color at 0.0 or 1.0 respectively.

Filter

Texture filtering mode.

To check floating-point texture filtering hardware support use device.caps().textureFloat16Filter and device.caps().textureFloat32Filter flags.

{number} NONE = 1

Filtering disabled.

{number} BILINEAR = 2

Bilinear filtering.

{number} TRILINEAR = 3

Trilinear filtering.

Shader

Shader type.

{number} VERTEX = 0

Vertex shader.

{number} FRAGMENT = 1

Fragment shader.

{number} COUNT = 2

Shader count.

TYPES:

WebglSettings

Describe a webgl-context settings.

See: http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2

{boolean} antialias = true

{boolean} premultipliedAlpha = true

{boolean} preserveDrawingBuffer = true

{boolean} preferLowPowerToHighPerformance = true

{boolean} failIfMajorPerformanceCaveat = true

FUNCTIONS:

makeDevice(canvas, colorFormat, depthFormat, settings)

Makes a rendering device.

var device = B.Render.makeDevice(canvas);

var device = B.Render.makeDevice(canvas, B.Render.Format.RGB, false);

var device = B.Render.makeDevice(canvas, B.Render.Format.RGB, B.Render.Format.DEPTH_STENCIL,
    {
        antialias: false,
        premultipliedAlpha: false
    }
);

PARAMETERS:

{HTMLCanvasElement} canvas

rendering output

{B.Render.Format} [colorFormat] = B.Render.Format.RGB

color target format (supported formats are B.Render.Format.RGB and B.Render.Format.RGBA)

{B.Render.Format | false} [depthFormat] = B.Render.Format.DEPTH

depth-stencil target format (supported formats are B.Render.Format.DEPTH and B.Render.Format.DEPTH_STENCIL) or false to disable depth

{B.Render~WebglSettings} [settings]

webgl-context settings

RETURNS:

THROWS:

{B.Render.Error}

if WebGL is not supported or target parameters are incorrect

isPowerOfTwo(value)

Returns true if numeric value is power of two, false otherwise.

PARAMETERS:

{number} value

RETURNS:

{boolean}

toPowerOfTwo(value)

Converts numeric value to closest power of two.

PARAMETERS:

{number} value

RETURNS:

{number}

genQuad(device, xSize, ySize, uScale, vScale)

Generates a quad mesh.

The mesh will have positions, normals, tangents and uv-coordinates.

PARAMETERS:

{B.Render.Device} device

{number} [xSize] = 1.0

{number} [ySize] = 1.0

{number} [uScale] = 1.0

{number} [vScale] = 1.0

RETURNS:

genBox(device, xSize, ySize, zSize, uScale, vScale)

Generates a box mesh.

The mesh will have positions, normals, tangents and uv-coordinates.

PARAMETERS:

{B.Render.Device} device

{number} [xSize] = 1.0

{number} [ySize] = 1.0

{number} [zSize] = 1.0

{number} [uScale] = 1.0

{number} [vScale] = 1.0

RETURNS:

genSphere(device, radius, segments, uScale, vScale)

Generates a sphere mesh.

The mesh will have positions, normals, tangents and uv-coordinates.

PARAMETERS:

{B.Render.Device} device

{number} [radius] = 1.0

{number} [segments] = 32

{number} [uScale] = 1.0

{number} [vScale] = 1.0

RETURNS:

attributeByteSize(type)

Returns byte size of attribute type.

PARAMETERS:

RETURNS:

{number}

checkAttributes(attributes)

Checks vertex attributes consistency.

PARAMETERS:

{Object.<string, B.Render.Attribute>} attributes

RETURNS:

{boolean}

indexByteSize(type)

Returns byte size of index type.

PARAMETERS:

RETURNS:

{number}

indicesPerPrimitive(primitive)

Returns index count per primitive.

PARAMETERS:

{B.Render.Primitive} primitive

RETURNS:

{number}

formatBitSize(format)

Returns bit size of surface format.

PARAMETERS:

{B.Render.Format} format

RETURNS:

{number}

formatBlockByteSize(format)

Returns byte size of compressed format block.

PARAMETERS:

{B.Render.Format} format

RETURNS:

{number}

formatBlockTexelSize(format)

Returns texel size (one dimension) of compressed format block.

PARAMETERS:

{B.Render.Format} format

RETURNS:

{number}

imagePitch(format, width)

Calculates pitch (in bytes) for arbitrary format and width.

PARAMETERS:

{B.Render.Format} format

{number} width

RETURNS:

{number}

imageRows(format, height)

Calculates rows count for arbitrary format and height.

PARAMETERS:

{B.Render.Format} format

{number} height

RETURNS:

{number}

imageByteSize(format, width, height)

Calculates byte size for arbitrary image.

PARAMETERS:

{B.Render.Format} format

{number} width

{number} height

RETURNS:

{number}

checkColorFormat(device, format, renderable)

Checks color format consistency.

PARAMETERS:

{B.Render.Device} device

{B.Render.Format} format

{boolean} [renderable] = false

RETURNS:

{boolean}

checkDepthFormat(device, format)

Checks depth-stencil format consistency.

PARAMETERS:

{B.Render.Device} device

{B.Render.Format} format

RETURNS:

{boolean}

uniformByteSize(type)

Returns byte size of uniform type.

PARAMETERS:

RETURNS:

{number}

CLASSES:

ENUMERATIONS:

TYPES:

FUNCTIONS: