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() → {}
Summary
Methods from QuadCompositor
|
|
|
|
WebGLTexture |
|
|
|
WebGLTexture |
|
number |
|
Properties inherited from Compositor
Array<Object> |
|
GLShader |
|
GLShader |
|
number |
|
number |
|
VertexArrayBuffer |
|
number |
|
Methods inherited from Compositor
|
|
called by the WebGL renderer when a compositor become the current one |
|
|
|
|
|
|
Public Methods
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
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(texture: WebGLTexture, unit: number) → {}
assign the given WebGL texture to the current batch
Name | Type | Description |
---|---|---|
texture | WebGLTexture |
a WebGL texture |
unit | number |
Texture unit to which the given texture is bound |
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
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 |
Type | Description |
---|---|
WebGLTexture |
a WebGL texture |
deleteTexture2D(texture: WebGLTexture) → {}
delete the given WebGL texture
Name | Type | Attributes | Description |
---|---|---|---|
texture | WebGLTexture |
<optional> |
a WebGL texture to delete |
getTexture2D(unit: number) → {WebGLTexture}
returns the WebGL texture associated to the given texture unit
Name | Type | Description |
---|---|---|
unit | number |
Texture unit to which a texture is bound |
Type | Description |
---|---|
WebGLTexture |
texture a WebGL texture |
unbindTexture2D(texture: WebGLTexture, unit: number) → {number}
unbind the given WebGL texture, forcing it to be reuploaded
Name | Type | Attributes | Description |
---|---|---|---|
texture | WebGLTexture |
<optional> |
a WebGL texture |
unit | number |
<optional> |
a WebGL texture |
Type | Description |
---|---|
number |
unit the unit number that was associated with the given texture |