class RenderingContext
package js.html.webgl
extended by WebGL2RenderingContext
Available on js
The WebGLRenderingContext
interface provides the OpenGL ES 2.0 rendering context for the drawing surface of an HTML canvas
element.
Documentation WebGLRenderingContext by Mozilla Contributors, licensed under CC-BY-SA 2.5.
See also:
Static variables
Variables
read onlycanvas:CanvasElement
A read-only back-reference to the HTMLCanvasElement
. Might be null
if it is not associated with a canvas
element.
read onlydrawingBufferHeight:Int
The read-only height of the current drawing buffer. Should match the height of the canvas element associated with this context.
read onlydrawingBufferWidth:Int
The read-only width of the current drawing buffer. Should match the width of the canvas element associated with this context.
Methods
bindAttribLocation(program:Program, index:Int, name:String):Void
Binds a generic vertex index to a named attribute variable.
bindFramebuffer(target:Int, framebuffer:Framebuffer):Void
Binds a WebGLFrameBuffer
object to a given target.
bindRenderbuffer(target:Int, renderbuffer:Renderbuffer):Void
Binds a WebGLRenderBuffer
object to a given target.
blendColor(red:Float, green:Float, blue:Float, alpha:Float):Void
Sets the source and destination blending factors.
blendEquation(mode:Int):Void
Sets both the RGB blend equation and alpha blend equation to a single equation.
blendEquationSeparate(modeRGB:Int, modeAlpha:Int):Void
Sets the RGB blend equation and alpha blend equation separately.
blendFunc(sfactor:Int, dfactor:Int):Void
Defines which function is used for blending pixel arithmetic.
blendFuncSeparate(srcRGB:Int, dstRGB:Int, srcAlpha:Int, dstAlpha:Int):Void
Defines which function is used for blending pixel arithmetic for RGB and alpha components separately.
bufferData(target:Int, data:ArrayBufferView, usage:Int):Void
bufferData(target:Int, size:Int, usage:Int):Void
bufferData(target:Int, data:ArrayBuffer, usage:Int):Void
Updates buffer data.
bufferSubData(target:Int, offset:Int, data:ArrayBufferView):Void
bufferSubData(target:Int, offset:Int, data:ArrayBuffer):Void
Updates buffer data starting at a passed offset.
clearColor(red:Float, green:Float, blue:Float, alpha:Float):Void
Specifies the color values used when clearing color buffers.
colorMask(red:Bool, green:Bool, blue:Bool, alpha:Bool):Void
Sets which color components to enable or to disable when drawing or rendering to a WebGLFramebuffer
.
compressedTexImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, data:ArrayBufferView):Void
Specifies a 2D texture image in a compressed format.
compressedTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, data:ArrayBufferView):Void
Specifies a 2D texture sub-image in a compressed format.
copyTexImage2D(target:Int, level:Int, internalformat:Int, x:Int, y:Int, width:Int, height:Int, border:Int):Void
Copies a 2D texture image.
copyTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, x:Int, y:Int, width:Int, height:Int):Void
Copies a 2D texture sub-image.
depthFunc(func:Int):Void
Specifies a function that compares incoming pixel depth to the current depth buffer value.
depthRange(zNear:Float, zFar:Float):Void
Specifies the depth range mapping from normalized device coordinates to window or viewport coordinates.
drawElements(mode:Int, count:Int, type:Int, offset:Int):Void
Renders primitives from element array data.
flush():Void
Empties different buffer commands, causing all commands to be executed as quickly as possible.
framebufferRenderbuffer(target:Int, attachment:Int, renderbuffertarget:Int, renderbuffer:Renderbuffer):Void
Attaches a WebGLRenderingBuffer
object to a WebGLFrameBuffer
object.
framebufferTexture2D(target:Int, attachment:Int, textarget:Int, texture:Texture, level:Int):Void
Attaches a textures image to a WebGLFrameBuffer
object.
frontFace(mode:Int):Void
Specifies whether polygons are front- or back-facing by setting a winding orientation.
getActiveAttrib(program:Program, index:Int):ActiveInfo
Returns information about an active attribute variable.
getActiveUniform(program:Program, index:Int):ActiveInfo
Returns information about an active uniform variable.
getAttachedShaders(program:Program):Array<Shader>
Returns a list of WebGLShader
objects attached to a WebGLProgram
.
getContextAttributes():ContextAttributes
Returns a WebGLContextAttributes
object that contains the actual context parameters. Might return null
, if the context is lost.
getFramebufferAttachmentParameter(target:Int, attachment:Int, pname:Int):Dynamic
Returns information about the framebuffer.
Throws:
null | DOMError |
---|
getShaderPrecisionFormat(shadertype:Int, precisiontype:Int):ShaderPrecisionFormat
Returns a WebGLShaderPrecisionFormat
object describing the precision for the numeric format of the shader.
getSupportedExtensions():Array<String>
Returns an Array
of DOMString
elements with all the supported WebGL extensions.
getUniform(program:Program, location:UniformLocation):Dynamic
Returns the value of a uniform variable at a given location.
getUniformLocation(program:Program, name:String):UniformLocation
Returns the location of a uniform variable.
getVertexAttrib(index:Int, pname:Int):Dynamic
Returns information about a vertex attribute at a given position.
Throws:
null | DOMError |
---|
hint(target:Int, mode:Int):Void
Specifies hints for certain behaviors. The interpretation of these hints depend on the implementation.
isEnabled(cap:Int):Bool
Tests whether a specific WebGL capability is enabled or not for this context.
isFramebuffer(framebuffer:Framebuffer):Bool
Returns a Boolean indicating if the passed WebGLFrameBuffer
object is valid.
isRenderbuffer(renderbuffer:Renderbuffer):Bool
Returns a Boolean indicating if the passed WebGLRenderingBuffer
is valid.
polygonOffset(factor:Float, units:Float):Void
Specifies the scale factors and units to calculate depth values.
readPixels(x:Int, y:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void
Reads a block of pixels from the WebGLFrameBuffer
.
Throws:
null | DOMError |
---|
renderbufferStorage(target:Int, internalformat:Int, width:Int, height:Int):Void
Creates a renderbuffer data store.
sampleCoverage(value:Float, invert:Bool):Void
Specifies multi-sample coverage parameters for anti-aliasing effects.
stencilFunc(func:Int, ref:Int, mask:Int):Void
Sets the both front and back function and reference value for stencil testing.
stencilFuncSeparate(face:Int, func:Int, ref:Int, mask:Int):Void
Sets the front and/or back function and reference value for stencil testing.
stencilMask(mask:Int):Void
Controls enabling and disabling of both the front and back writing of individual bits in the stencil planes.
stencilMaskSeparate(face:Int, mask:Int):Void
Controls enabling and disabling of front and/or back writing of individual bits in the stencil planes.
stencilOp(fail:Int, zfail:Int, zpass:Int):Void
Sets both the front and back-facing stencil test actions.
stencilOpSeparate(face:Int, fail:Int, zfail:Int, zpass:Int):Void
Sets the front and/or back-facing stencil test actions.
texImage2D(target:Int, level:Int, internalformat:Int, format:Int, type:Int, video:VideoElement):Void
texImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, format:Int, type:Int, pixels:ArrayBufferView):Void
texImage2D(target:Int, level:Int, internalformat:Int, format:Int, type:Int, pixels:ImageBitmap):Void
texImage2D(target:Int, level:Int, internalformat:Int, format:Int, type:Int, pixels:ImageData):Void
texImage2D(target:Int, level:Int, internalformat:Int, format:Int, type:Int, image:ImageElement):Void
texImage2D(target:Int, level:Int, internalformat:Int, format:Int, type:Int, canvas:CanvasElement):Void
Specifies a 2D texture image.
Throws:
null | DOMError |
---|
texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, format:Int, type:Int, video:VideoElement):Void
texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void
texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, format:Int, type:Int, pixels:ImageBitmap):Void
texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, format:Int, type:Int, pixels:ImageData):Void
texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, format:Int, type:Int, image:ImageElement):Void
texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, format:Int, type:Int, canvas:CanvasElement):Void
Updates a sub-rectangle of the current WebGLTexture
.
Throws:
null | DOMError |
---|
uniform1fv(location:UniformLocation, data:Float32Array):Void
uniform1fv(location:UniformLocation, data:Array<Float>):Void
uniform1iv(location:UniformLocation, data:Int32Array):Void
uniform1iv(location:UniformLocation, data:Array<Int>):Void
uniform2fv(location:UniformLocation, data:Float32Array):Void
uniform2fv(location:UniformLocation, data:Array<Float>):Void
uniform2iv(location:UniformLocation, data:Int32Array):Void
uniform2iv(location:UniformLocation, data:Array<Int>):Void
uniform3fv(location:UniformLocation, data:Float32Array):Void
uniform3fv(location:UniformLocation, data:Array<Float>):Void
uniform3iv(location:UniformLocation, data:Int32Array):Void
uniform3iv(location:UniformLocation, data:Array<Int>):Void
uniform4fv(location:UniformLocation, data:Float32Array):Void
uniform4fv(location:UniformLocation, data:Array<Float>):Void
uniform4iv(location:UniformLocation, data:Int32Array):Void
uniform4iv(location:UniformLocation, data:Array<Int>):Void
uniformMatrix2fv(location:UniformLocation, transpose:Bool, data:Float32Array):Void
uniformMatrix2fv(location:UniformLocation, transpose:Bool, data:Array<Float>):Void
uniformMatrix3fv(location:UniformLocation, transpose:Bool, data:Float32Array):Void
uniformMatrix3fv(location:UniformLocation, transpose:Bool, data:Array<Float>):Void
uniformMatrix4fv(location:UniformLocation, transpose:Bool, data:Float32Array):Void
uniformMatrix4fv(location:UniformLocation, transpose:Bool, data:Array<Float>):Void
useProgram(program:Program):Void
Uses the specified WebGLProgram
as part the current rendering state.