Class: App

App(gl)

new App(gl)

Primary entry point to PicoGL. An app will store all parts of the WebGL state.
Parameters:
Name Type Description
gl WebGLRenderingContext
Properties:
Name Type Description
canvas HTMLElement The canvas on which this app drawing.
gl WebGLRenderingContext The WebGL context.
width number The width of the drawing surface.
height number The height of the drawing surface.
state Object Tracked GL state.
Properties
Name Type Default Description
drawFramebufferBinding Object GL.DRAW_FRAMEBUFFER Binding point to bind framebuffers to for draw. Should be set before any binding occurs. Should only have values GL.DRAW_FRAMEBUFFER or GL.FRAMEBUFFER (the latter with state.readFramebufferBinding set to the same).
readFramebufferBinding Object GL.READ_FRAMEBUFFER Binding point to bind framebuffers to for read. Should be set before any binding occurs. Should only have values GL.READ_FRAMEBUFFER or GL.FRAMEBUFFER (the latter with state.drawFramebufferBinding set to the same).
clearBits GLenum Current clear mask to use with clear().
Source:

Methods

blendEquation(mode) → {App}

Set the blend equation. E.g. app.blendEquation(PicoGL.MIN).
Parameters:
Name Type Description
mode GLenum The operation to use in combining source and destination channels.
Source:
Returns:
The App object.
Type
App

blendFunc(src, dest) → {App}

Set the blend function. E.g. app.blendFunc(PicoGL.ONE, PicoGL.ONE_MINUS_SRC_ALPHA).
Parameters:
Name Type Description
src GLenum The source blending weight.
dest GLenum The destination blending weight.
Source:
Returns:
The App object.
Type
App

blendFuncSeparate(csrc, cdest, asrc, adest) → {App}

Set the blend function, with separate weighting for color and alpha channels. E.g. app.blendFuncSeparate(PicoGL.ONE, PicoGL.ONE_MINUS_SRC_ALPHA, PicoGL.ONE, PicoGL.ONE).
Parameters:
Name Type Description
csrc GLenum The source blending weight for the RGB channels.
cdest GLenum The destination blending weight for the RGB channels.
asrc GLenum The source blending weight for the alpha channel.
adest GLenum The destination blending weight for the alpha channel.
Source:
Returns:
The App object.
Type
App

blitFramebuffer(mask, optionsopt) → {App}

Copy data from framebuffer attached to READ_FRAMEBUFFER to framebuffer attached to DRAW_FRAMEBUFFER.
Parameters:
Name Type Attributes Description
mask GLenum Write mask (e.g. PicoGL.COLOR_BUFFER_BIT).
options Object <optional>
Blit options.
Properties
Name Type Attributes Default Description
srcStartX number <optional>
0 Source start x coordinate.
srcStartY number <optional>
0 Source start y coordinate.
srcEndX number <optional>
Width of the read framebuffer Source end x coordinate.
srcEndY number <optional>
Height of the read framebuffer Source end y coordinate.
dstStartX number <optional>
0 Destination start x coordinate.
dstStartY number <optional>
0 Destination start y coordinate.
dstEndX number <optional>
Width of the draw framebuffer Destination end x coordinate.
dstEndY number <optional>
Height of the draw framebuffer Destination end y coordinate.
filter number <optional>
NEAREST Sampling filter.
Source:
Returns:
The App object.
Type
App

clear() → {App}

Clear the canvas
Source:
Returns:
The App object.
Type
App

clearColor(r, g, b, a) → {App}

Set the clear color.
Parameters:
Name Type Description
r number Red channel.
g number Green channel.
b number Blue channel.
a number Alpha channel.
Source:
Returns:
The App object.
Type
App

clearMask(mask) → {App}

Set the clear mask bits to use when calling clear(). E.g. app.clearMask(PicoGL.COLOR_BUFFER_BIT).
Parameters:
Name Type Description
mask GLenum Bit mask of buffers to clear.
Source:
Returns:
The App object.
Type
App

colorMask(r, g, b, a) → {App}

Set the color mask to selectively enable or disable particular color channels while rendering.
Parameters:
Name Type Description
r boolean Red channel.
g boolean Green channel.
b boolean Blue channel.
a boolean Alpha channel.
Source:
Returns:
The App object.
Type
App

createCubemap(options) → {Cubemap}

Create a cubemap.
Parameters:
Name Type Description
options Object Texture options.
Properties
Name Type Attributes Default Description
negX HTMLElement | ArrayBufferView <optional>
The image data for the negative X direction. Can be any format that would be accepted by texImage2D.
posX HTMLElement | ArrayBufferView <optional>
The image data for the positive X direction. Can be any format that would be accepted by texImage2D.
negY HTMLElement | ArrayBufferView <optional>
The image data for the negative Y direction. Can be any format that would be accepted by texImage2D.
posY HTMLElement | ArrayBufferView <optional>
The image data for the positive Y direction. Can be any format that would be accepted by texImage2D.
negZ HTMLElement | ArrayBufferView <optional>
The image data for the negative Z direction. Can be any format that would be accepted by texImage2D.
posZ HTMLElement | ArrayBufferView <optional>
The image data for the positive Z direction. Can be any format that would be accepted by texImage2D.
width number <optional>
Cubemap side width. Defaults to the width of negX if negX is an image.
height number <optional>
Cubemap side height. Defaults to the height of negX if negX is an image.
internalFormat GLenum <optional>
RGBA8 Texture data internal format. Must be a sized format.
type GLenum <optional>
Type of data stored in the texture. Default based on internalFormat.
flipY boolean <optional>
false Whether the y-axis should be flipped when unpacking the image.
premultiplyAlpha boolean <optional>
false Whether the alpha channel should be pre-multiplied when unpacking the image.
minFilter GLenum <optional>
Minification filter. Defaults to LINEAR_MIPMAP_NEAREST if image data is provided, NEAREST otherwise.
magFilter GLenum <optional>
Magnification filter. Defaults to LINEAR if image data is provided, NEAREST otherwise.
wrapS GLenum <optional>
REPEAT Horizontal wrap mode.
wrapT GLenum <optional>
REPEAT Vertical wrap mode.
compareMode GLenum <optional>
NONE Comparison mode.
compareFunc GLenum <optional>
LEQUAL Comparison function.
baseLevel GLenum <optional>
Base mipmap level.
maxLevel GLenum <optional>
Maximum mipmap level.
minLOD GLenum <optional>
Mimimum level of detail.
maxLOD GLenum <optional>
Maximum level of detail.
maxAnisotropy GLenum <optional>
Maximum anisotropy in filtering.
Source:
Returns:
New Cubemap object.
Type
Cubemap

createDrawCall(program, vertexArrayopt) → {DrawCall}

Create a DrawCall. A DrawCall manages the state associated with a WebGL draw call including a program and associated vertex data, textures, uniforms and uniform blocks.
Parameters:
Name Type Attributes Default Description
program Program The program to use for this DrawCall.
vertexArray VertexArray <optional>
null Vertex data to use for drawing.
Source:
Returns:
New DrawCall object.
Type
DrawCall

createFramebuffer() → {Framebuffer}

Create a framebuffer.
Source:
Returns:
New Framebuffer object.
Type
Framebuffer

createIndexBuffer(type, data, usageopt) → {VertexBuffer}

Create an index buffer. If the `itemSize` is not specified, it defaults to 3
Parameters:
Name Type Attributes Default Description
type GLenum The data type stored in the index buffer.
data ArrayBufferView Index buffer data.
usage GLenum <optional>
STATIC_DRAW Buffer usage.
Source:
Returns:
New VertexBuffer object.
Type
VertexBuffer

createIndexBuffer(type, itemSize, data, usageopt) → {VertexBuffer}

Create an index buffer.
Parameters:
Name Type Attributes Default Description
type GLenum The data type stored in the index buffer.
itemSize number Number of elements per primitive.
data ArrayBufferView Index buffer data.
usage GLenum <optional>
STATIC_DRAW Buffer usage.
Source:
Returns:
New VertexBuffer object.
Type
VertexBuffer

createInterleavedBuffer(bytesPerVertex, data, usageopt) → {VertexBuffer}

Create an buffer without any structure information. Structure must be fully specified when binding to a VertexArray.
Parameters:
Name Type Attributes Default Description
bytesPerVertex number Number of bytes per vertex.
data ArrayBufferView | number Buffer data itself or the total number of bytes to be allocated.
usage GLenum <optional>
STATIC_DRAW Buffer usage.
Source:
Returns:
New VertexBuffer object.
Type
VertexBuffer

createMatrixBuffer(type, data, usageopt) → {VertexBuffer}

Create a per-vertex matrix buffer. Matrix buffers ensure that columns are correctly split across attribute locations.
Parameters:
Name Type Attributes Default Description
type GLenum The data type stored in the matrix buffer. Valid types are FLOAT_MAT4, FLOAT_MAT4x2, FLOAT_MAT4x3, FLOAT_MAT3, FLOAT_MAT3x2, FLOAT_MAT3x4, FLOAT_MAT2, FLOAT_MAT2x3, FLOAT_MAT2x4.
data ArrayBufferView Matrix buffer data.
usage GLenum <optional>
STATIC_DRAW Buffer usage.
Source:
Returns:
New VertexBuffer object.
Type
VertexBuffer

createProgram(vertexShader, fragmentShader, optionsopt) → {Program}

Create a program synchronously. It is highly recommended to use createPrograms instead as that method will compile shaders in parallel where possible.
Parameters:
Name Type Attributes Description
vertexShader Shader | string Vertex shader object or source code.
fragmentShader Shader | string Fragment shader object or source code.
options Object <optional>
Texture options.
Properties
Name Type Attributes Description
attributeLocations Object <optional>
Map of attribute names to locations (useful when using GLSL 1).
transformFeedbackVaryings Array <optional>
Array of varying names used for transform feedback output.
transformFeedbackMode GLenum <optional>
Capture mode of the transform feedback. (Default: PicoGL.SEPARATE_ATTRIBS).
Source:
Returns:
New Program object.
Type
Program

createPrograms(…sources) → {Promise.<Array.<Program>>}

Create several programs. Preferred method for program creation as it will compile shaders in parallel where possible.
Parameters:
Name Type Attributes Description
sources Array <repeatable>
Variable number of 2 or 3 element arrays, each containing:
  • (Shader|string) Vertex shader object or source code.
  • (Shader|string) Fragment shader object or source code.
  • (Object - optional) Optional program parameters.
    • (Object - optional) attributeLocations Map of attribute names to locations (useful when using GLSL 1).
    • (Array - optional) transformFeedbackVaryings Array of varying names used for transform feedback output.
    • (GLenum - optional) transformFeedbackMode Capture mode of the transform feedback. (Default: PicoGL.SEPARATE_ATTRIBS).
Source:
Returns:
Promise that will resolve to an array of Programs when compilation and linking are complete for all programs.
Type
Promise.<Array.<Program>>

createQuery(target) → {Query}

Create a query.
Parameters:
Name Type Description
target GLenum Information to query.
Source:
Returns:
New Query object.
Type
Query

createRenderbuffer(width, height, internalFormat, samplesopt) → {Renderbuffer}

Create a renderbuffer.
Parameters:
Name Type Attributes Default Description
width number Renderbuffer width.
height number Renderbuffer height.
internalFormat GLenum Internal arrangement of the renderbuffer data.
samples number <optional>
0 Number of MSAA samples.
Source:
Returns:
New Renderbuffer object.
Type
Renderbuffer

createShader(type, source) → {Shader}

Create a shader. Creating a shader separately from a program allows for shader reuse.
Parameters:
Name Type Description
type GLenum Shader type.
source string Shader source.
Source:
Returns:
New Shader object.
Type
Shader

createTexture2D(width, height, optionsopt) → {Texture}

Create empty 2D texture.
Parameters:
Name Type Attributes Description
width number Texture width. Required for array or empty data.
height number Texture height. Required for array or empty data.
options Object <optional>
Texture options.
Properties
Name Type Attributes Default Description
internalFormat GLenum <optional>
RGBA8 Texture data internal format. Must be a sized format.
type GLenum <optional>
Type of data stored in the texture. Default based on internalFormat.
flipY boolean <optional>
false Whether the y-axis should be flipped when unpacking the texture.
premultiplyAlpha boolean <optional>
false Whether the alpha channel should be pre-multiplied when unpacking the texture.
minFilter GLenum <optional>
Minification filter. Defaults to LINEAR_MIPMAP_NEAREST if image data is provided, NEAREST otherwise.
magFilter GLenum <optional>
Magnification filter. Defaults to LINEAR if image data is provided, NEAREST otherwise.
wrapS GLenum <optional>
REPEAT Horizontal wrap mode.
wrapT GLenum <optional>
REPEAT Vertical wrap mode.
compareMode GLenum <optional>
NONE Comparison mode.
compareFunc GLenum <optional>
LEQUAL Comparison function.
baseLevel GLenum <optional>
Base mipmap level.
maxLevel GLenum <optional>
Maximum mipmap level.
minLOD GLenum <optional>
Mimimum level of detail.
maxLOD GLenum <optional>
Maximum level of detail.
maxAnisotropy GLenum <optional>
Maximum anisotropy in filtering.
Source:
Returns:
New Texture object.
Type
Texture

createTexture2D(image, optionsopt) → {Texture}

Create a 2D texture from a DOM image element.
Parameters:
Name Type Attributes Description
image HTMLImageElement | Array.<HTMLImageElement> Image data. An array can be passed to manually set all levels of the mipmap chain. If a single level is passed and mipmap filtering is being used, generateMipmap() will be called to produce the remaining levels.
options Object <optional>
Texture options.
Properties
Name Type Attributes Default Description
internalFormat GLenum <optional>
RGBA8 Texture data internal format. Must be a sized format.
type GLenum <optional>
Type of data stored in the texture. Default based on intrnalFormat.
flipY boolean <optional>
false Whether the y-axis should be flipped when unpacking the texture.
premultiplyAlpha boolean <optional>
false Whether the alpha channel should be pre-multiplied when unpacking the texture.
minFilter GLenum <optional>
Minification filter. Defaults to LINEAR_MIPMAP_NEAREST if image data is provided, NEAREST otherwise.
magFilter GLenum <optional>
Magnification filter. Defaults to LINEAR if image data is provided, NEAREST otherwise.
wrapS GLenum <optional>
REPEAT Horizontal wrap mode.
wrapT GLenum <optional>
REPEAT Vertical wrap mode.
compareMode GLenum <optional>
NONE Comparison mode.
compareFunc GLenum <optional>
LEQUAL Comparison function.
baseLevel GLenum <optional>
Base mipmap level.
maxLevel GLenum <optional>
Maximum mipmap level.
minLOD GLenum <optional>
Mimimum level of detail.
maxLOD GLenum <optional>
Maximum level of detail.
maxAnisotropy GLenum <optional>
Maximum anisotropy in filtering.
Source:
Returns:
New Texture object.
Type
Texture

createTexture2D(image, width, height, optionsopt) → {Texture}

Create 2D texture from a typed array.
Parameters:
Name Type Attributes Description
image ArrayBufferView | Array.<ArrayBufferView> Image data. An array can be passed to manually set all levels of the mipmap chain. If a single level is passed and mipmap filtering is being used, generateMipmap() will be called to produce the remaining levels.
width number Texture width. Required for array or empty data.
height number Texture height. Required for array or empty data.
options Object <optional>
Texture options.
Properties
Name Type Attributes Default Description
internalFormat GLenum <optional>
RGBA8 Texture data internal format. Must be a sized format.
type GLenum <optional>
Type of data stored in the texture. Default based on internalFormat.
flipY boolean <optional>
false Whether the y-axis should be flipped when unpacking the texture.
premultiplyAlpha boolean <optional>
false Whether the alpha channel should be pre-multiplied when unpacking the texture.
minFilter GLenum <optional>
Minification filter. Defaults to LINEAR_MIPMAP_NEAREST if image data is provided, NEAREST otherwise.
magFilter GLenum <optional>
Magnification filter. Defaults to LINEAR if image data is provided, NEAREST otherwise.
wrapS GLenum <optional>
REPEAT Horizontal wrap mode.
wrapT GLenum <optional>
REPEAT Vertical wrap mode.
compareMode GLenum <optional>
NONE Comparison mode.
compareFunc GLenum <optional>
LEQUAL Comparison function.
baseLevel GLenum <optional>
Base mipmap level.
maxLevel GLenum <optional>
Maximum mipmap level.
minLOD GLenum <optional>
Mimimum level of detail.
maxLOD GLenum <optional>
Maximum level of detail.
maxAnisotropy GLenum <optional>
Maximum anisotropy in filtering.
Source:
Returns:
New Texture object.
Type
Texture

createTexture3D(image, width, height, depth, optionsopt) → {Texture}

Create a 3D texture.
Parameters:
Name Type Attributes Description
image ArrayBufferView | Array Pixel data. An array can be passed to manually set all levels of the mipmap chain. If a single level is passed and mipmap filtering is being used, generateMipmap() will be called to produce the remaining levels.
width number Texture width.
height number Texture height.
depth number Texture depth.
options Object <optional>
Texture options.
Properties
Name Type Attributes Default Description
internalFormat GLenum <optional>
RGBA8 Texture data internal format. Must be a sized format.
type GLenum <optional>
Type of data stored in the texture. Default based on internalFormat.
flipY boolean <optional>
false Whether the y-axis should be flipped when unpacking the texture.
minFilter GLenum <optional>
Minification filter. Defaults to LINEAR_MIPMAP_NEAREST if image data is provided, NEAREST otherwise.
magFilter GLenum <optional>
Magnification filter. Defaults to LINEAR if image data is provided, NEAREST otherwise.
wrapS GLenum <optional>
REPEAT Horizontal wrap mode.
wrapT GLenum <optional>
REPEAT Vertical wrap mode.
wrapR GLenum <optional>
REPEAT Depth wrap mode.
compareMode GLenum <optional>
NONE Comparison mode.
compareFunc GLenum <optional>
LEQUAL Comparison function.
baseLevel GLenum <optional>
Base mipmap level.
maxLevel GLenum <optional>
Maximum mipmap level.
minLOD GLenum <optional>
Mimimum level of detail.
maxLOD GLenum <optional>
Maximum level of detail.
maxAnisotropy GLenum <optional>
Maximum anisotropy in filtering.
Source:
Returns:
New Texture object.
Type
Texture

createTextureArray(image, width, height, size, optionsopt) → {Texture}

Create a 2D texture array.
Parameters:
Name Type Attributes Description
image ArrayBufferView | Array Pixel data. An array can be passed to manually set all levels of the mipmap chain. If a single level is passed and mipmap filtering is being used, generateMipmap() will be called to produce the remaining levels.
width number Texture width.
height number Texture height.
size number Number of images in the array.
options Object <optional>
Texture options.
Properties
Name Type Attributes Default Description
internalFormat GLenum <optional>
RGBA8 Texture data internal format. Must be a sized format.
type GLenum <optional>
Type of data stored in the texture. Default based on internalFormat.
flipY boolean <optional>
false Whether the y-axis should be flipped when unpacking the texture.
minFilter GLenum <optional>
Minification filter. Defaults to LINEAR_MIPMAP_NEAREST if image data is provided, NEAREST otherwise.
magFilter GLenum <optional>
Magnification filter. Defaults to LINEAR if image data is provided, NEAREST otherwise.
wrapS GLenum <optional>
REPEAT Horizontal wrap mode.
wrapT GLenum <optional>
REPEAT Vertical wrap mode.
wrapR GLenum <optional>
REPEAT Depth wrap mode.
compareMode GLenum <optional>
NONE Comparison mode.
compareFunc GLenum <optional>
LEQUAL Comparison function.
baseLevel GLenum <optional>
Base mipmap level.
maxLevel GLenum <optional>
Maximum mipmap level.
minLOD GLenum <optional>
Mimimum level of detail.
maxLOD GLenum <optional>
Maximum level of detail.
maxAnisotropy GLenum <optional>
Maximum anisotropy in filtering.
Source:
Returns:
New Texture object.
Type
Texture

createTimer() → {Timer}

Create a timer.
Source:
Returns:
New Timer object.
Type
Timer

createTransformFeedback() → {TransformFeedback}

Create a transform feedback object.
Source:
Returns:
New TransformFeedback object.
Type
TransformFeedback

createUniformBuffer(layout, usageopt) → {UniformBuffer}

Create a uniform buffer in std140 layout. NOTE: FLOAT_MAT2, FLOAT_MAT3x2, FLOAT_MAT4x2, FLOAT_MAT3, FLOAT_MAT2x3, FLOAT_MAT4x3 are supported, but must be manually padded to 4-float column alignment by the application!
Parameters:
Name Type Attributes Default Description
layout Array Array indicating the order and types of items to be stored in the buffer.
usage GLenum <optional>
DYNAMIC_DRAW Buffer usage.
Source:
Returns:
New UniformBuffer object.
Type
UniformBuffer

createVertexArray() → {VertexArray}

Create a vertex array.
Source:
Returns:
New VertexArray object.
Type
VertexArray

createVertexBuffer(type, itemSize, data, usageopt) → {VertexBuffer}

Create a vertex buffer.
Parameters:
Name Type Attributes Default Description
type GLenum The data type stored in the vertex buffer.
itemSize number Number of elements per vertex.
data ArrayBufferView | number Buffer data itself or the total number of elements to be allocated.
usage GLenum <optional>
STATIC_DRAW Buffer usage.
Source:
Returns:
New VertexBuffer object.
Type
VertexBuffer

defaultDrawFramebuffer() → {App}

Switch back to the default framebuffer for drawing (i.e. draw to the screen). Note that this method resets the viewport to match the default framebuffer.
Source:
Returns:
The App object.
Type
App

defaultReadFramebuffer() → {App}

Switch back to the default framebuffer for reading (i.e. read from the screen).
Source:
Returns:
The App object.
Type
App

defaultViewport() → {App}

Set the viewport to the full canvas.
Source:
Returns:
The App object.
Type
App

depthFunc(func) → {App}

Set the depth test function. E.g. app.depthFunc(PicoGL.LEQUAL).
Parameters:
Name Type Description
func GLenum The depth testing function to use.
Source:
Returns:
The App object.
Type
App

depthMask(mask) → {App}

Enable or disable writing to the depth buffer.
Parameters:
Name Type Description
mask Boolean The depth mask.
Source:
Returns:
The App object.
Type
App

depthRange(near, far) → {App}

Set the depth range.
Parameters:
Name Type Description
near number Minimum depth value.
far number Maximum depth value.
Source:
Returns:
The App object.
Type
App

disable(cap) → {App}

Disable WebGL capability (e.g. depth testing, blending, etc.).
Parameters:
Name Type Description
cap GLenum Capability to disable.
Source:
Returns:
The App object.
Type
App

drawFramebuffer(framebuffer) → {App}

Bind a draw framebuffer to the WebGL context.
Parameters:
Name Type Description
framebuffer Framebuffer The Framebuffer object to bind.
Source:
See:
Returns:
The App object.
Type
App

enable(cap) → {App}

Enable WebGL capability (e.g. depth testing, blending, etc.).
Parameters:
Name Type Description
cap GLenum Capability to enable.
Source:
Returns:
The App object.
Type
App

loseContext() → {App}

Simulate context loss.
Source:
Returns:
The App object.
Type
App

onContextRestored(fn) → {App}

Set function to handle context restoration after loss.
Parameters:
Name Type Description
fn function Context restored handler.
Source:
Returns:
The App object.
Type
App

polygonOffset(factor, units) → {App}

Set the scale and units used.
Parameters:
Name Type Description
factor Number Scale factor used to create a variable depth offset for each polygon.
units Number Constant depth offset.
Source:
Returns:
The App object.
Type
App

readFramebuffer(framebuffer) → {App}

Bind a read framebuffer to the WebGL context.
Parameters:
Name Type Description
framebuffer Framebuffer The Framebuffer object to bind.
Source:
See:
Returns:
The App object.
Type
App

readPixel(x, y, outColor, optionsopt) → {App}

Read a pixel's color value from the currently-bound framebuffer.
Parameters:
Name Type Attributes Description
x number The x coordinate of the pixel.
y number The y coordinate of the pixel.
outColor ArrayBufferView Typed array to store the pixel's color.
options object <optional>
Options.
Properties
Name Type Attributes Default Description
type GLenum <optional>
UNSIGNED_BYTE Type of data stored in the read framebuffer.
format GLenum <optional>
RGBA Read framebuffer data format.
Source:
Returns:
The App object.
Type
App

resize(width, height) → {App}

Resize the drawing surface.
Parameters:
Name Type Description
width number The new canvas width.
height number The new canvas height.
Source:
Returns:
The App object.
Type
App

restoreContext() → {App}

Simulate context restoration.
Source:
Returns:
The App object.
Type
App

restorePrograms(…sources) → {Promise.<void>}

Restore several programs after a context loss. Will do so in parallel where available.
Parameters:
Name Type Attributes Description
sources Program <repeatable>
Variable number of programs to restore.
Source:
Returns:
Promise that will resolve once all programs have been restored.
Type
Promise.<void>

scissor(x, y, width, height) → {App}

Define the scissor box.
Parameters:
Name Type Description
x Number Horizontal position of the scissor box.
y Number Vertical position of the scissor box.
width Number Width of the scissor box.
height Number Height of the scissor box.
Source:
Returns:
The App object.
Type
App

stencilFunc(func, ref, mask) → {App}

Set the stencil function and reference value. E.g. app.stencilFunc(PicoGL.EQUAL, 1, 0xFF). NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
Parameters:
Name Type Description
func GLenum The testing function.
ref number The reference value.
mask GLenum The bitmask to use against tested values before applying the stencil function.
Source:
Returns:
The App object.
Type
App

stencilFuncSeparate(face, func, ref, mask) → {App}

Set the stencil function and reference value for a particular face orientation. E.g. app.stencilFuncSeparate(PicoGL.FRONT, PicoGL.EQUAL, 1, 0xFF). NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
Parameters:
Name Type Description
face GLenum The face orientation to apply the function to.
func GLenum The testing function.
ref number The reference value.
mask GLenum The bitmask to use against tested values before applying the stencil function.
Source:
Returns:
The App object.
Type
App

stencilMask(mask) → {App}

Set the bitmask to use for tested stencil values. E.g. app.stencilMask(0xFF). NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
Parameters:
Name Type Description
mask number The mask value.
Source:
Returns:
The App object.
Type
App

stencilMaskSeparate(face, mask) → {App}

Set the bitmask to use for tested stencil values for a particular face orientation. E.g. app.stencilMaskSeparate(PicoGL.FRONT, 0xFF). NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
Parameters:
Name Type Description
face GLenum The face orientation to apply the mask to.
mask number The mask value.
Source:
Returns:
The App object.
Type
App

stencilOp(stencilFail, depthFail, pass) → {App}

Set the operations for updating stencil buffer values. E.g. app.stencilOp(PicoGL.KEEP, PicoGL.KEEP, PicoGL.REPLACE). NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
Parameters:
Name Type Description
stencilFail GLenum Operation to apply if the stencil test fails.
depthFail GLenum Operation to apply if the depth test fails.
pass GLenum Operation to apply if the both the depth and stencil tests pass.
Source:
Returns:
The App object.
Type
App

stencilOpSeparate(face, stencilFail, depthFail, pass) → {App}

Set the operations for updating stencil buffer values for a particular face orientation. E.g. app.stencilOpSeparate(PicoGL.FRONT, PicoGL.KEEP, PicoGL.KEEP, PicoGL.REPLACE). NOTE: Only works if { stencil: true } passed as a context attribute when creating the App!
Parameters:
Name Type Description
face GLenum The face orientation to apply the operations to.
stencilFail GLenum Operation to apply if the stencil test fails.
depthFail GLenum Operation to apply if the depth test fails.
pass GLenum Operation to apply if the both the depth and stencil tests pass.
Source:
Returns:
The App object.
Type
App

viewport(x, y, width, height) → {App}

Set the viewport.
Parameters:
Name Type Description
x number Left bound of the viewport rectangle.
y number Lower bound of the viewport rectangle.
width number Width of the viewport rectangle.
height number Height of the viewport rectangle.
Source:
Returns:
The App object.
Type
App