QuadCompositor

class QuadCompositor extends Compositor

A WebGL Compositor object. This class handles all of the WebGL state
Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU

Constructor


new QuadCompositor() → {}

Public Methods


addQuad quad_compositor.js:196
addQuad(texture: TextureAtlas, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number) → {}

Add a textured quad

Parameters:
Name Type Description
texture TextureAtlas

Source texture atlas

x number

Destination x-coordinate

y number

Destination y-coordinate

w number

Destination width

h number

Destination height

u0 number

Texture UV (u0) value.

v0 number

Texture UV (v0) value.

u1 number

Texture UV (u1) value.

v1 number

Texture UV (v1) value.

tint number

tint color to be applied to the texture in UINT32 (argb) format

bindTexture2D quad_compositor.js:128
bindTexture2D(texture: WebGLTexture, unit: number) → {}

assign the given WebGL texture to the current batch

Parameters:
Name Type Description
texture WebGLTexture

a WebGL texture

unit number

Texture unit to which the given texture is bound

createTexture2D quad_compositor.js:61
createTexture2D(unit: number, pixels: Image | HTMLCanvasElement | ImageData | Array<Uint8Array> | Array<Float32Array>, filter: number, repeat: string, w: number, h: number, premultipliedAlpha: boolean, mipmap: boolean) → {WebGLTexture}

Create a WebGL texture from an image

Parameters:
Name Type Attributes Default Description
unit number

Destination texture unit

pixels Image | HTMLCanvasElement | ImageData | Array<Uint8Array> | Array<Float32Array>

<optional>

null

Source image

filter number

gl.LINEAR or gl.NEAREST

repeat string

<optional>

"no-repeat"

Image repeat behavior (see ImageLayer#repeat)

w number

<optional>

pixels.width

Source image width (Only use with UInt8Array[] or Float32Array[] source image)

h number

<optional>

pixels.height

Source image height (Only use with UInt8Array[] or Float32Array[] source image)

premultipliedAlpha boolean

<optional>

true

Multiplies the alpha channel into the other color channels

mipmap boolean

<optional>

true

Whether mipmap levels should be generated for this texture

Returns:
Type Description
WebGLTexture

a WebGL texture

deleteTexture2D quad_compositor.js:110
deleteTexture2D(texture: WebGLTexture) → {}

delete the given WebGL texture

Parameters:
Name Type Attributes Description
texture WebGLTexture

<optional>

a WebGL texture to delete

getTexture2D quad_compositor.js:119
getTexture2D(unit: number) → {WebGLTexture}

returns the WebGL texture associated to the given texture unit

Parameters:
Name Type Description
unit number

Texture unit to which a texture is bound

Returns:
Type Description
WebGLTexture

texture a WebGL texture

unbindTexture2D quad_compositor.js:153
unbindTexture2D(texture: WebGLTexture, unit: number) → {number}

unbind the given WebGL texture, forcing it to be reuploaded

Parameters:
Name Type Attributes Description
texture WebGLTexture

<optional>

a WebGL texture

unit number

<optional>

a WebGL texture

Returns:
Type Description
number

unit the unit number that was associated with the given texture


Powered by webdoc!