JavaScript WebGLRenderingContext : Object
The WebGLRenderingContext
is an object that is used to issue WebGL
rendering commands to a canvas. The WebGLRenderingContext is obtained by passing
'webgl'
to
the HTMLCanvasElement.getContext()
method.
See WebGLContextAttributes
for configuration
options you can specify when calling getContext()
.
For detailed information on the shader language used by WebGL, see the GLSL Specification.
While developing with WebGL, you can use the debug context to easily find errors in your code. The samples below use the debug context to help catch errors but you should remove it in production code. See http://www.khronos.org/webgl/wiki/Debugging for more details.
Instance Properties
Instance Methods
Set the texture unit subsequent texture operations apply to.
-
unit
-
must be
one of
TEXTURE0
,TEXTURE1
, togetParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS) - 1
.
TEXTURE0
. A texture must be bound to the active texture unit using bindTexture()
.
Attaches shader
to program
. A program must have both a VERTEX_SHADER
and FRAGMENT_SHADER
before it can be used. shader
can
be attached before its souce has been set. See also detachShader()
.
Example:
RunResults:
Associates a number (location
) with an attribute (a shader input such as vertex position) in
program
. Other webgl functions (such as enableVertexAttribArray()
or vertexAttribPointer()
) deal with an attribute location
number instead of the name used in the program and bindAttribLocation
is used to choose the
number used for that attribute. Locations are automatically assigned if you do not call
bindAttribLocation
so this method is only necessary if you wish to assign a specific location
for an attribute. Use getAttribLocation()
to retrieve the
automatically assigned location. bindAttribLocation()
must be called before calling linkProgram(program)
and location
must be an integer
in the range 0
to
getParameter(gl.MAX_VERTEX_ATTRIBS) - 1
.
Example:
RunResults:
Sets the current buffer for target
to buffer
. target
must be either
ARRAY_BUFFER
or ELEMENT_ARRAY_BUFFER
. Use bufferData()
to fill the bound buffer with data.
Sets the current framebuffer to framebuffer
. target
must be FRAMEBUFFER
or null
. If null
, the
rendering will go to the canvas. See createFramebuffer()
for
an example of using bindFramebuffer()
.
Sets the specified target
and texture
(created with createTexture
) for the bound texture in the active texture unit
(set through activeTexture()
and bindTexture()
). target
must be one of TEXTURE_2D
or TEXTURE_CUBE_MAP
Sets how the newly rendered pixel color and alpha (src) is combined with the existing framebuffer color and alpha (dst) before storing in the framebuffer.
-
modeRGB
andmodeAlpha
-
must be one of
FUNC_ADD
,FUNC_SUBTRACT
, orFUNC_REVERSE_SUBTRACT
.
FUNC_ADD
, the destination color will be src + dst. If the mode is
FUNC_SUBTRACT
, the destination color will be src - dst. If the mode is
FUNC_REVERSE_SUBTRACT
, the destination color will be dst - src. Both modeRGB
and
modeAlpha
default to FUNC_ADD
. Use
getParameter(gl.BLEND_EQUATION_RGB)
and
getParameter(gl.BLEND_EQUATION_ALPHA)
to get the current values. See blendFuncSeparate()
for how src
and dst are computed. Blending must be enabled with
enable(BLEND)
.
Adjusts the newly rendered pixel color and alpha (src) and existing framebuffer color and alpha in the
framebuffer (dst) before being combined using blendEquationSeparate()
.
-
srcRGB
,dstRGB
,srcAlpha
, anddstAlpha
-
must be one of
ZERO
,ONE
,SRC_COLOR
,ONE_MINUS_SRC_COLOR
,DST_COLOR
,ONE_MINUS_DST_COLOR
,SRC_ALPHA
,ONE_MINUS_SRC_ALPHA
,DST_ALPHA
,ONE_MINUS_DST_ALPHA
,CONSTANT_COLOR
,ONE_MINUS_CONSTANT_COLOR
,CONSTANT_ALPHA
,ONE_MINUS_CONSTANT_ALPHA
, orSRC_ALPHA_SATURATE
srcRGB
and srcAlpha
default to ONE
.
dstRGB
and dstAlpha
default to NONE
.
For traditional alpha blending, use:
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ZERO)
.
For premultiplied alpha blending, use:
gl.blendFuncSeparate(gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ZERO)
.
Use
getParameter(gl.BLEND_SRC_RGB)
,
getParameter(gl.BLEND_DST_RGB)
,
getParameter(gl.BLEND_SRC_ALPHA)
,
and
getParameter(gl.BLEND_DST_ALPHA)
to get the current values.
Creates the storage for the currently bound buffer.
-
target
-
must be one of
ARRAY_BUFFER
orELEMENT_ARRAY_BUFFER
. -
size
- the size in bytes of the buffer to allocate.
-
usage
-
must be one of
STREAM_DRAW
,STATIC_DRAW
, orDYNAMIC_DRAW
.
Returns one of the following to indicate the current status of the framebuffer: FRAMEBUFFER_COMPLETE
, FRAMEBUFFER_INCOMPLETE_ATTACHMENT
, FRAMEBUFFER_INCOMPLETE_DIMENSIONS
, FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
,
or FRAMEBUFFER_UNSUPPORTED
. target
must
be set to gl.FRAMEBUFFER
.
Clears the buffers specified by mask
where mask
is the bitwise OR
(|
) of one or more of the following values: COLOR_BUFFER_BIT
, STENCIL_BUFFER_BIT
, and DEPTH_BUFFER_BIT
.
Example:
RunResults:
Specifies the color to fill the color buffer when clear()
is called with
the COLOR_BUFFER_BIT
. The parameters are clamped to the range
0
to 1
.
Example:
RunResults:
Specifies the value to fill the depth buffer when clear()
is called with
the DEPTH_BUFFER_BIT
. depth
is clamped to the
range 0
(near) to 1
(far). Defaults to 1
if not specified.
Example:
RunResults:
Specifies the value (integer) to fill the depth buffer when clear()
is
called with the STENCIL_BUFFER_BIT
.
Example:
RunResults:
Turns on or off writing to the specified channels of the frame buffer. Defaults to true
for
all channels. Use
getParameter(gl.COLOR_WRITEMASK)
to get the current value.
Compiles the specified shader. Must be called after setting the source with shaderSource()
. If the shader had errors during compilation,
gl.getShaderParameter(shader, gl.COMPILE_STATUS)
will return false
and you can use getShaderInfoLog()
to get details about the error.
Copies pixels from the framebuffer to the bound texture in the active texture unit (set through activeTexture()
and bindTexture()
).
-
target
-
must be one of
TEXTURE_2D
,TEXTURE_CUBE_MAP_POSITIVE_X
,TEXTURE_CUBE_MAP_NEGATIVE_X
,TEXTURE_CUBE_MAP_POSITIVE_Y
,TEXTURE_CUBE_MAP_NEGATIVE_Y
,TEXTURE_CUBE_MAP_POSITIVE_Z
, orTEXTURE_CUBE_MAP_NEGATIVE_Z
. -
level
- specifies the mipmap level to copy into.
-
internalformat
-
ALPHA
,LUMINANCE
,LUMINANCE_ALPHA
,RGB
, orRGBA
. -
x
,y
,width
,height
- the rectangle in framebuffer to copy.
-
border
-
must be
0
.
Copies pixels from the framebuffer to a subregion of the bound texture in the active texture unit (set
through activeTexture()
and bindTexture()
).
-
target
-
must be one of
TEXTURE_2D
,TEXTURE_CUBE_MAP_POSITIVE_X
,TEXTURE_CUBE_MAP_NEGATIVE_X
,TEXTURE_CUBE_MAP_POSITIVE_Y
,TEXTURE_CUBE_MAP_NEGATIVE_Y
,TEXTURE_CUBE_MAP_POSITIVE_Z
, orTEXTURE_CUBE_MAP_NEGATIVE_Z
. -
level
- specifies the mipmap level to copy into.
-
textureX
,textureY
- the position in the texture to store the copied pixels.
-
framebufferX
,framebufferY
- the position in the framebuffer to read the pixels to copy.
-
width
,height
- the size of the region to copy.
Creates a buffer. A buffer is memory used to store data passed to the shader program through attributes.
See also bindBuffer()
, bufferData()
, bufferSubData()
, deleteBuffer()
, isBuffer()
,
vertexAttribPointer()
and enableVertexAttribArray()
.
Example:
RunResults:
Creates a framebuffer that can be used for offscreen rendering. The actual content of the surface is
stored in a either a WebGLRenderbuffer
or WebGLTexture
. See also bindFramebuffer()
, checkFramebufferStatus()
, deleteFramebuffer()
, framebufferRenderbuffer()
, framebufferTexture2D()
, getFramebufferAttachmentParameter()
, and isFramebuffer()
.
Example:
RunResults:
Creates a shader program. A shader program consists of a vertex shader and fragment shader. Use attachShader()
to associate shaders with the program and linkProgram()
to
finalize the program. After linking, use useProgram()
to select the
program to use.
Creates a renderbuffer. A renderbuffer is an offscreen section of memory used to store the result of
rendering, such as the color buffer, depth buffer, or stencil buffer. See also framebufferRenderbuffer()
, renderbufferStorage()
.
Example:
RunResults:
Creates a vertex or fragment shader. type
must be either VERTEX_SHADER
or FRAGMENT_SHADER
. Shaders must be compiled using compileShader()
and then attached to a WebGLProgram
using attachShader()
before they can be used.
Creates a texture. Use activeTexture()
to select a texture unit
and then bindTexture()
to bind a texture to that unit. See also copyTexImage2D()
, copyTexSubImage2D()
, deleteTexture()
, framebufferTexture2D()
, getTexParameter()
, isTexture()
, texImage2D()
, texParameterf()
, texParameteri()
, and texSubImage2D()
.
Example:
RunResults:
Sets which side of the triangle is culled (not drawn). mode
must be one of BACK
, FRONT
, or FRONT_AND_BACK
. Defaults to BACK
. To turn on culling, you must call
enable(CULL_FACE)
. To select which face is the
front or back, use frontFace()
.
Specifies what function used to compare the rendered depth with the existing depth in the framebuffer to
determine if the pixel will be written to the framebuffer. func
must be one of NEVER
, LESS
, EQUAL
, LEQUAL
, GREATER
, NOTEQUAL
, GEQUAL
, or ALWAYS
. Defaults to LESS
. Depth test will only be used if enabled with
enable(DEPTH_TEST)
.
Turns on or off writing to the depth buffer. Defaults to true
. Use
getParameter(gl.DEPTH_WRITEMASK)
to get the current value. Depth test will only be used if enabled with
enable(DEPTH_TEST)
.
Sets how z values returned from the vertex shader are mapped to values to store in the depth buffer. This
mapping is necessary because the vertex shader output z values will be clipped to the range
-1
to 1
but the depth buffer stores depth values in the range 0
to
1
.
-
zNear
-
specifies what the vertex shader's
-1
maps to in the depth buffer. -
zFar
-
specifies what the vertex shader's
1
maps to in the depth buffer.
zNear
is 0
and zFar
is 1
.
Draws primitives using the vertex buffer data (stored in the ARRAY_BUFFER
buffer).
-
mode
-
must be one of
POINTS
,LINE_STRIP
,LINE_LOOP
,LINES
,TRIANGLE_STRIP
,TRIANGLE_FAN
, orTRIANGLES
. -
vertexOffset
- specifies the index of the first vertex to draw.
-
vertexCount
- specifies the number of vertices to draw.
enableVertexAttribArray()
for each
attribute in the vertex shader that uses the vertex data. See also drawElements()
. Example:
RunResults:
Draws primitives using the vertex buffer data (stored in the ARRAY_BUFFER
buffer) and the index buffer data (stored in the ELEMENT_ARRAY_BUFFER
buffer).
-
mode
-
must be one of
POINTS
,LINE_STRIP
,LINE_LOOP
,LINES
,TRIANGLE_STRIP
,TRIANGLE_FAN
, orTRIANGLES
. -
indicesCount
- specifies the number of number of indices to use.
-
indicesNumberType
-
must be one of
UNSIGNED_BYTE
orUNSIGNED_SHORT
. -
indicesOffset
- specifies the index into the indices array of the first element to draw.
enableVertexAttribArray()
for each
attribute in the vertex shader that uses the vertex data. See also drawArrays()
. Example:
RunResults:
Turns on a capability. capability
must be one of the following:
-
BLEND
-
if enabled, will combine the color generated by the fragment shader with the
existing color in the framebuffer using the method specified by
blendFunc()
. Most commonly used to enable alpha blending. Defaults to disabled. -
CULL_FACE
-
if enabled, will cull (not draw) triangles based on which face is
visible. See
cullFace()
andfrontFace()
to configure culling. Defaults to disabled. -
DEPTH_TEST
-
if enabled, fragments will only be written to the framebuffer if they pass
the depth function (set with
gl.depthFunc()
). See alsodepthMask()
, anddepthRange()
. Most commonly used to draw closer objects on top of further away objects. Defaults to disabled. -
DITHER
- if enabled, the colors will be dithered when written to the color buffer. Defaults to enabled.
-
POLYGON_OFFSET_FILL
-
if enabled, the offset specified by
polygonOffset
will be added to the depth for the fragment when writing to the depth buffer. Most commonly used to draw decals on top of already drawn surfaces. Defaults to disabled. -
SAMPLE_COVERAGE
- Defaults to disabled.
-
SAMPLE_ALPHA_TO_COVERAGE
- Defaults to disabled.
-
SCISSOR_TEST
-
if enabled, fragments outside the scissor rectangle (set with
scissor()
will not be drawn. Defaults to disabled. -
STENCIL_TEST
-
if enabled, perform a stencil test on each fragment and
update the stencil buffer.
See also
stencilFunc
andstencilOp
. Defaults to disabled.
disable()
to turn off the capability.
Turns on passing data to the vertex shader from the vertex buffer for the specified attribute. Use getAttribLocation()
to retrieve the location of an attribute
by name.
Specifies the renderbuffer
to use as destination of rendering for the current framebuffer
(set with the most recent bindFramebuffer()
call).
-
target
-
must be
FRAMEBUFFER
. -
attachment
-
determines what is rendered into
renderbuffer
. PassCOLOR_ATTACHMENT0
for color data,DEPTH_ATTACHMENT
for depth data, orSTENCIL_ATTACHMENT
for stencil data. -
renderbuffertarget
-
must be
RENDERBUFFER
. -
renderbuffer
- the buffer to store the rendered output.
Example:
RunResults:
Specifies the texture
to use as destination of rendering for the current framebuffer (set
with the most recent bindFramebuffer()
call).
-
target
-
must be
FRAMEBUFFER
. -
attachment
-
determines what is rendered into
renderbuffer
. PassCOLOR_ATTACHMENT0
for color data,DEPTH_ATTACHMENT
for depth data, orSTENCIL_ATTACHMENT
for stencil data. -
target
- must be one of
TEXTURE_2D
,TEXTURE_CUBE_MAP_POSITIVE_X
,TEXTURE_CUBE_MAP_NEGATIVE_X
,TEXTURE_CUBE_MAP_POSITIVE_Y
,TEXTURE_CUBE_MAP_NEGATIVE_Y
,TEXTURE_CUBE_MAP_POSITIVE_Z
, orTEXTURE_CUBE_MAP_NEGATIVE_Z
. -
texture
- the texture to store the rendered output.
-
level
-
must be
0
.
Determines which side of triangles is the front face. mode
must be one of CW
or CCW
. To turn on culling, you must call
enable(CULL_FACE)
. To select which face is
culled, use cullFace()
.
Generate the mipmap for the bound texture in the active texture unit (set through activeTexture()
and bindTexture()
). A mipmap is a set of textures that are 1/2, 1/4,
1/8, etc of the original image. The mipmap allows higher quality rendering when drawing the texture at
smaller sizes. target
must be one of TEXTURE_2D
or TEXTURE_CUBE_MAP
. Note, you can only generate mipmaps for
textures where the width and height are both powers of 2
(such as 128
,
256
, 512
, etc).
Returns information about an attribute in program
. program
must be linked before calling getActiveAttrib()
. index
must be
between 0
and
gl.getProgramParameter(program, ACTIVE_ATTRIBUTES) - 1
.
Example:
RunResults:
Returns information about a uniform in program
. program
must be linked before calling getActiveUniform()
. index
must
be between 0
and
gl.getProgramParameter(program, ACTIVE_UNIFORMS) - 1
.
Example:
RunResults:
-
target
-
must be one of
ARRAY_BUFFER
orELEMENT_ARRAY_BUFFER
. -
parameter
-
must be one of
BUFFER_SIZE
orBUFFER_USAGE
.
Returns the attributes used to construct this context. To modify these attributes, pass in the desired
attributes to the first call to HTMLCanvasElement.getContext('webgl', attributes)
.
Example:
RunResults:
Returns the first error hit since the last time getError()
was called. The returned value
will be one of NO_ERROR
, INVALID_ENUM
, INVALID_VALUE
, INVALID_OPERATION
, INVALID_FRAMEBUFFER_OPERATION
, or OUT_OF_MEMORY
.
Enables the specified extension and returns an object that contains any constants or functions provided by
the extension. Call getSupportedExtensions()
to get an
array of valid extension names. If name
is not in the Array
returned by getSupportedExtensions()
,
getExtension()
will return null.
Example:
RunResults:
-
target
-
must be
FRAMEBUFFER
. -
attachment
-
the render target to query.
Must be one of
COLOR_ATTACHMENT0
for color data,DEPTH_ATTACHMENT
for depth data, orSTENCIL_ATTACHMENT
for stencil data. -
parameter
-
the parameter to query. Must be one of
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
, orFRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE
.
parameter
must be one of ACTIVE_TEXTURE
, ALIASED_LINE_WIDTH_RANGE
, ALIASED_POINT_SIZE_RANGE
, ALPHA_BITS
, ARRAY_BUFFER_BINDING
, BLEND
, BLEND_DST_ALPHA
, BLEND_DST_RGB
, BLEND_EQUATION_ALPHA
, BLEND_EQUATION_RGB
, BLEND_SRC_ALPHA
, BLEND_SRC_RGB
, BLUE_BITS
,
COLOR_CLEAR_VALUE
, COLOR_WRITEMASK
, COMPRESSED_TEXTURE_FORMATS
, CULL_FACE
, CULL_FACE_MODE
,
CURRENT_PROGRAM
, DEPTH_BITS
, DEPTH_CLEAR_VALUE
, DEPTH_FUNC
, DEPTH_RANGE
, DEPTH_TEST
, DEPTH_WRITEMASK
, DITHER
, ELEMENT_ARRAY_BUFFER_BINDING
, FRAMEBUFFER_BINDING
, FRONT_FACE
, GENERATE_MIPMAP_HINT
, GREEN_BITS
, LINE_WIDTH
, MAX_COMBINED_TEXTURE_IMAGE_UNITS
, MAX_CUBE_MAP_TEXTURE_SIZE
, MAX_FRAGMENT_UNIFORM_VECTORS
, MAX_RENDERBUFFER_SIZE
, MAX_TEXTURE_IMAGE_UNITS
, MAX_TEXTURE_SIZE
, MAX_VARYING_VECTORS
, MAX_VERTEX_ATTRIBS
, MAX_VERTEX_TEXTURE_IMAGE_UNITS
, MAX_VERTEX_UNIFORM_VECTORS
, MAX_VIEWPORT_DIMS
, NUM_COMPRESSED_TEXTURE_FORMATS
, PACK_ALIGNMENT
, POLYGON_OFFSET_FACTOR
, POLYGON_OFFSET_FILL
, POLYGON_OFFSET_UNITS
, RED_BITS
, RENDERBUFFER_BINDING
, RENDERER
, SAMPLE_ALPHA_TO_COVERAGE
, SAMPLE_BUFFERS
, SAMPLE_COVERAGE
, SAMPLE_COVERAGE_INVERT
, SAMPLE_COVERAGE_VALUE
, SAMPLES
, SCISSOR_BOX
, SCISSOR_TEST
, SHADING_LANGUAGE_VERSION
, STENCIL_BACK_FAIL
, STENCIL_BACK_FUNC
, STENCIL_BACK_PASS_DEPTH_FAIL
, STENCIL_BACK_PASS_DEPTH_PASS
, STENCIL_BACK_REF
, STENCIL_BACK_VALUE_MASK
, STENCIL_BACK_WRITEMASK
, STENCIL_BITS
, STENCIL_CLEAR_VALUE
, STENCIL_FAIL
, STENCIL_FUNC
, STENCIL_PASS_DEPTH_FAIL
, STENCIL_PASS_DEPTH_PASS
, STENCIL_REF
, STENCIL_TEST
,
STENCIL_VALUE_MASK
, STENCIL_WRITEMASK
, SUBPIXEL_BITS
, TEXTURE_BINDING_2D
, TEXTURE_BINDING_CUBE_MAP
, UNPACK_ALIGNMENT
, VIEWPORT
, VENDOR
, or VERSION
.
Example:
RunResults:
parameter
must be one of DELETE_STATUS
, LINK_STATUS
, VALIDATE_STATUS
, ATTACHED_SHADERS
, ACTIVE_ATTRIBUTES
, or ACTIVE_UNIFORMS
.
-
target
-
must be
RENDERBUFFER
. -
parameter
-
must be one of
RENDERBUFFER_WIDTH
,RENDERBUFFER_HEIGHT
,RENDERBUFFER_INTERNAL
,RENDERBUFFER_RED_SIZE
,RENDERBUFFER_GREEN_SIZE
,RENDERBUFFER_BLUE_SIZE
,RENDERBUFFER_ALPHA_SIZE
,RENDERBUFFER_DEPTH_SIZE
, orRENDERBUFFER_STENCIL_SIZE
.
Returns information about the numerical precision limits of shader data types. target
must be
one of FRAGMENT_SHADER
or VERTEX_SHADER
. precisiontype
must be one of LOW_FLOAT
, MEDIUM_FLOAT
, HIGH_FLOAT
, LOW_INT
, MEDIUM_INT
, or HIGH_INT
.
Example:
RunResults:
Returns an Array
of String
s that indicate which extensions
this canvas supports. See getExtension()
.
Example:
RunResults:
Returns the value of the specified parameter
for the the bound texture in the active texture
unit (set through activeTexture()
and bindTexture()
). Use texParameterf()
and texParameteri()
to set texture parameters.
-
must be one of
TEXTURE_2D
orTEXTURE_CUBE_MAP
. -
parameter
-
must be one of
TEXTURE_MAG_FILTER
,TEXTURE_MIN_FILTER
,TEXTURE_WRAP_S
, orTEXTURE_WRAP_T
.
target
Sets options that affect readPixels
, texImage2D
, texSubImage2D
.
parameter | Valid Values | Initial Value |
---|---|---|
PACK_ALIGNMENT |
1 , 2 , 4 , or 8 |
4 |
UNPACK_ALIGNMENT |
1 , 2 , 4 , or 8 |
4 |
UNPACK_FLIP_Y_WEBGL |
true or false |
false |
UNPACK_PREMULTIPLY_ALPHA_WEBGL |
true or false |
false |
UNPACK_COLORSPACE_CONVERSION_WEBGL
|
BROWSER_DEFAULT_WEBGL or NONE |
BROWSER_DEFAULT_WEBGL |
Reads pixels from the framebuffer and copies them to data
.
-
x
,y
,width
,height
- the region of the framebuffer to read.
-
format
-
must be one of
ALPHA
,RGB
, orRGBA
. -
type
-
must be one of
UNSIGNED_BYTE
,UNSIGNED_SHORT_5_6_5
,UNSIGNED_SHORT_4_4_4_4
, orUNSIGNED_SHORT_5_5_5_1
. -
data
- stores the read pixels
pixelStorei()
options.
Creates and initializes the backing storage for a renderbuffer.
-
target
-
must be
RENDERBUFFER
. -
internalformat
-
must be one of
RGBA4
,RGB565
,RGB5_A1
,DEPTH_COMPONENT16
, orSTENCIL_INDEX8
. -
width
,height
- the size of the renderbuffer.
createRenderbuffer()
.
Sets the stencil function. To use stencil tests, you must set the WebGLContextAttributes.stencil
parameter to
true
when calling getContext('webgl', contextAttributes)
and enable
with enable(STENCIL_TEST)
.
-
face
- must be one of FRONT, BACK, or FRONT_AND_BACK
-
function
- must be one of NEVER, LESS, LEQUAL, GREATER, GEQUAL, EQUAL, NOTEQUAL, or ALWAYS. Defaults to ALWAYS.
-
reference
-
The value to compare with the value in the stencil buffer. It is also the value
that be written to the stencil buffer if
stencilOp
is set toREPLACE
. -
mask
-
A value bitwise ANDed with
reference
and the value in the stencil buffer before performing the stencil function.
Specifies the data for the bound texture in the active texture unit (set through activeTexture()
and bindTexture()
).
-
target
- must be one of
TEXTURE_2D
,TEXTURE_CUBE_MAP_POSITIVE_X
,TEXTURE_CUBE_MAP_NEGATIVE_X
,TEXTURE_CUBE_MAP_POSITIVE_Y
,TEXTURE_CUBE_MAP_NEGATIVE_Y
,TEXTURE_CUBE_MAP_POSITIVE_Z
, orTEXTURE_CUBE_MAP_NEGATIVE_Z
. -
level
-
is the mipmap level (
0
is base level). -
internalformat
- must be one of
ALPHA
,LUMINANCE
,LUMINANCE_ALPHA
,RGB
, orRGBA
. -
format
- must match
internalformat
. -
type
-
must be one of
UNSIGNED_BYTE
,UNSIGNED_SHORT_5_6_5
,UNSIGNED_SHORT_4_4_4_4
, orUNSIGNED_5_5_5_1
; -
data
- is the data to load into the texture.
pixelStorei()
options. You
can also use copyTexSubImage2D
or texSubImage2D
to initialize the texture. Example:
RunResults:
Example:
RunResults:
Specifies the size and data of the bound texture in the active texture unit (set through activeTexture()
and bindTexture()
).
-
target
- must be one of
TEXTURE_2D
,TEXTURE_CUBE_MAP_POSITIVE_X
,TEXTURE_CUBE_MAP_NEGATIVE_X
,TEXTURE_CUBE_MAP_POSITIVE_Y
,TEXTURE_CUBE_MAP_NEGATIVE_Y
,TEXTURE_CUBE_MAP_POSITIVE_Z
, orTEXTURE_CUBE_MAP_NEGATIVE_Z
. -
level
- is the mipmap level (
0
is base level). -
internalformat
- must be one of
ALPHA
,LUMINANCE
,LUMINANCE_ALPHA
,RGB
, orRGBA
. -
width
andheight
- are the size of the texture.
-
border
-
must be
0
. -
format
- must match
internalformat
. -
type
- must be one of
UNSIGNED_BYTE
,UNSIGNED_SHORT_5_6_5
,UNSIGNED_SHORT_4_4_4_4
, orUNSIGNED_5_5_5_1
; -
data
-
is the data to load into the texture. May be
null
to allocate the texture without data.
pixelStorei()
options. You
can also use copyTexSubImage2D
or texSubImage2D
to initialize the texture. Example:
RunResults:
Sets the value of the specified parameter
for the bound texture in the active texture unit
(set through activeTexture()
and bindTexture()
). Use getTexParameter()
to get texture parameters.
parameter | Valid Values | Initial Value |
---|---|---|
TEXTURE_MIN_FILTER |
NEAREST ,
LINEAR ,
NEAREST_MIPMAP_NEAREST ,
LINEAR_MIPMAP_NEAREST ,
NEAREST_MIPMAP_LINEAR ,
or
LINEAR_MIPMAP_LINEAR
|
NEAREST_MIPMAP_LINEAR |
TEXTURE_MAG_FILTER |
NEAREST
or
LINEAR
|
LINEAR |
TEXTURE_WRAP_S |
CLAMP_TO_EDGE ,
MIRRORED_REPEAT ,
or
REPEAT
|
REPEAT |
TEXTURE_WRAP_T |
CLAMP_TO_EDGE ,
MIRRORED_REPEAT ,
or
REPEAT
|
REPEAT |