new WebGLCompositor(renderer)
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
Parameters:
Name | Type | Description |
---|---|---|
renderer |
me.WebGLRenderer | the current WebGL renderer session |
Extends
Members
-
static activeShader :me.GLShader
-
a reference to the active WebGL shader
-
static attributes
-
an array of vertex attribute properties
-
static, readonly length :Number
-
The number of quads held in the batch
-
static mode
-
primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
- Default Value:
- gl.TRIANGLES
- See:
Methods
-
static addAttribute(name, size, type, normalized, offset)
-
add vertex attribute property definition to the compositor
Parameters:
Name Type Description name
String name of the attribute in the vertex shader
size
Number number of components per vertex attribute. Must be 1, 2, 3, or 4.
type
GLenum data type of each component in the array
normalized
Boolean whether integer data values should be normalized into a certain
offset
Number offset in bytes of the first component in the vertex attribute array
-
static addQuad(texture, key, x, y, w, h)
-
Add a textured quad
Parameters:
Name Type Description texture
me.video.renderer.Texture Source texture
key
String Source texture region name
x
Number Destination x-coordinate
y
Number Destination y-coordinate
w
Number Destination width
h
Number Destination height
-
static clear()
-
Clear the frame buffer
-
static clearColor(r, g, b, a)
-
Specify the color values used when clearing color buffers. The values are clamped between 0 and 1.
Parameters:
Name Type Description r
Number the red color value used when the color buffers are cleared
g
Number the green color value used when the color buffers are cleared
b
Number the blue color value used when the color buffers are cleared
a
Number the alpha color value used when the color buffers are cleared
-
static createTexture2D(unit, image, filter, repeatopt, wopt, hopt, bopt, bopt, premultipliedAlphaopt, mipmapopt) → {WebGLTexture}
-
Create a WebGL texture from an image
Parameters:
Name Type Attributes Default Description unit
Number Destination texture unit
image
Image | Canvas | ImageData | Array.<UInt8Array> | Array.<Float32Array> Source image
filter
Number gl.LINEAR or gl.NEAREST
repeat
String <optional>
"no-repeat" Image repeat behavior (see
me.ImageLayer#repeat
)w
Number <optional>
Source image width (Only use with UInt8Array[] or Float32Array[] source image)
h
Number <optional>
Source image height (Only use with UInt8Array[] or Float32Array[] source image)
b
Number <optional>
Source image border (Only use with UInt8Array[] or Float32Array[] source image)
b
Number <optional>
Source image border (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:
WebGLTexture -a WebGL texture
-
static drawVertices(modeopt, verts, vertexCountopt)
-
Draw an array of vertices
Parameters:
Name Type Attributes Default Description mode
GLENUM <optional>
gl.TRIANGLES primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
verts
Array.<me.Vector2d> vertices
vertexCount
Number <optional>
verts.length amount of points defined in the points array
-
static flush()
-
Flush batched texture operations to the GPU
Parameters:
Type Description -
static setTexture2D(a, unit)
-
assign the given WebGL texture to the current batch
Parameters:
Name Type Description a
WebGLTexture WebGL texture
unit
Number Texture unit to which the given texture is bound
-
static setViewport(x, y, width, height)
-
Sets the viewport
Parameters:
Name Type Description x
Number x position of viewport
y
Number y position of viewport
width
Number width of viewport
height
Number height of viewport
-
static useShader(shader)
-
Select the shader to use for compositing
Parameters:
Name Type Description shader
me.GLShader a reference to a GLShader instance
- See: