JavaScripture
Contribute via GitHub Feedback

JavaScript WebGLContextAttributes : Object

WebGLContexAttributes allow you to configure WebGLRenderingContext creation options when passed as an additional context attributes parameter to HTMLCanvasElement.getContext(). Any JavaScript object can be used as the WebGLContextAttributes and if the properties below are specified on it, they will be used instead of the default values. Only the options passed to the first call to getContext will apply, subsequent calls will ignore the attributes.

Instance Properties

alpha : Boolean

If set to true, the context will have an alpha (transparency) channel. Defaults to true.

antialias : Boolean

If set to true, the context will attempt to perform antialiased rendering if possible. Defaults to true.

depth : Boolean

If set to true, the context will have a 16 bit depth buffer. Defaults to true. Use gl.enable(DEPTH_TEST) to enable the depth test and gl.depthFunc(), gl.depthMask(), and gl.depthRange() to configure the depth test.

premultipliedAlpha : Boolean

If set to true, the color channels in the framebuffer will be stored premultipled by the alpha channel to improve performance. Defaults to true.

preserveDrawingBuffer : Boolean

If set to false, the buffer will be cleared after rendering. If you wish to use canvas.toDataURL(), you will either need to draw to the canvas immediately before calling toDataURL(), or set preserveDrawingBuffer to true to keep the buffer available after the browser has displayed the buffer (at the cost of increased memory use). Defaults to false.

stencil : Boolean

If set to true, the context will have an 8 bit stencil buffer. Defaults to false. Use gl.enable(STENCIL_TEST) to enable depth test and gl.stencilFunc(), gl.stencilFuncSeparate(), gl.stencilMask(), gl.stencilMaskSeparate(), gl.stencilOp(), and gl.stencilOpSeparate() to configure the stencil test.