Expand Minimize

clear method

Sets all pixels in a specific buffer to the same value.

IE11

 

Syntax

WebGLRenderingContext.clear(mask);

Parameters

mask [in]

Type: Number

Contains one or both (OR'd together) of the following values.

Mask nameDescriptionValue
gl.DEPTH_BUFFER_BITClears the depth buffer0x00000100
gl.STENCIL_BUFFER_BITClears the stencil buffer0x00000400
gl.COLOR_BUFFER_BITClears the color buffer0x00004000

 

Return value

This method does not return a value.

Remarks

WebGL errorDescription
gl.INVALID_VALUEIf any bit other than the ones listed are defined in mask.
gl.INVALID_FRAMEBUFFER_OPERATION framebuffer or renderbuffer is in valid.

 

The clear method sets the buffer to values preselected by clearColor, clearDepth, or clearStencil. If a buffer doesn't exist, this method has no effect.

The clear function can be used to clear the stencil buffer either by itself or in conjunction with other buffers (such as the color or depth buffers).

You can set a stencil write mask prior to clearing the stencil buffer, and the stencil write mask will be respected during the clear operation. This also applies to when the stencil test is disabled.

Examples

The syntax can be one of the following:


gl.clear(gl.COLOR_BUFFER_BIT);
gl.clear(gl.DEPTH_BUFFER_BIT);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

See also

WebGLRenderingContext

 

 

Show:
© 2014 Microsoft