This is Version 2.0 of the WebGL Specification.
This specification describes an additional rendering context and support objects for the HTML 5 canvas element [CANVAS]. This context allows rendering using an API that conforms closely to the OpenGL ES 3.0 API.
This document should be read as an extension to the WebGL 1.0 specification. It will only describe the differences from 1.0.
This document is an editor's draft. Do not cite this document as other than work in progress. Public discussion of this specification is welcome on the (archived) WebGL mailing list public_webgl@khronos.org (see instructions).
WebGL™ is an immediate mode 3D rendering API designed for the web. This is Version 2 of the WebGL specification. It is derived from OpenGL® ES 3.0, and provides similar rendering functionality, but in an HTML context.
WebGL 2 is not entirely backwards compatible with WebGL 1. Existing content written against the core WebGL 1 specification without extensions will often run in WebGL 2 without modification, but this is not always the case. All exceptions to backwards compatibility are recorded in the Backwards Incompatibility section. To access the new behavior provided in this specification, the content explicitly requests a new context (details below).
Many functions described in this document contain links to OpenGL ES man pages. While every effort is made to make these pages match the OpenGL ES 3.0 specification [GLES30], they may contain errors. In the case of a contradiction, the OpenGL ES 3.0 specification is the final authority.
The remaining sections of this document are intended to be read in conjunction with the OpenGL ES 3.0 specification (3.0.3 at the time of this writing, available from the Khronos OpenGL ES API Registry). Unless otherwise specified, the behavior of each method is defined by the OpenGL ES 3.0 specification. This specification may diverge from OpenGL ES 3.0 in order to ensure interoperability or security, often defining areas that OpenGL ES 3.0 leaves implementation-defined. These differences are summarized in the Differences Between WebGL and OpenGL ES 3.0 section.
Before using the WebGL API, the author must obtain a WebGLRenderingContext
object for a given HTMLCanvasElement [CANVAS] as described
below. This object is used to manage OpenGL state and render to the drawing buffer, which
must be created at the time of context creation.
Each WebGLRenderingContext
and WebGL2RenderingContext
has an
associated canvas, set upon creation, which is
a canvas [CANVAS].
Each WebGLRenderingContext
and WebGL2RenderingContext
has context
creation parameters, set upon creation, in
a WebGLContextAttributes
object.
Each WebGLRenderingContext
and WebGL2RenderingContext
has actual
context parameters, set each time the drawing buffer is created, in
a WebGLContextAttributes
object.
Each WebGLRenderingContext
and WebGL2RenderingContext
has a webgl
context lost flag, which is initially unset.
When the getContext()
method of a canvas
element is to return a
new object for
the contextId webgl2
[CANVASCONTEXTS],
the user agent must perform the following steps:
WebGL2RenderingContext
object, context.
getContext()
method is associated with.
WebGLContextAttributes
object, contextAttributes.
getContext()
was invoked with a second argument, options, set
the attributes of contextAttributes from those specified in options.
This section describes the interfaces and functionality added to the DOM to support runtime access to the functionality described above.
The following types are introduced in WebGL 2.0.
typedef long long GLint64; typedef unsigned long long GLuint64;
The WebGLQuery
interface represents an OpenGL Query Object.
The underlying object is created as if by calling glGenQueries
(OpenGL ES 3.0.3 §2.13,
man page)
,
made active as if by calling glBeginQuery
(OpenGL ES 3.0.3 §2.13,
man page)
,
concluded as if by calling glEndQuery
(OpenGL ES 3.0.3 §2.13,
man page)
and destroyed as if by calling glDeleteQueries
(OpenGL ES 3.0.3 §2.13,
man page)
.
interface WebGLQuery : WebGLObject { };
The WebGLSampler
interface represents an OpenGL Sampler Object.
The underlying object is created as if by calling glGenSamplers
(OpenGL ES 3.0.3 §3.8.2,
man page)
,
bound as if by calling glBindSampler
(OpenGL ES 3.0.3 §3.8.2,
man page)
and destroyed as if by calling glDeleteSamplers
(OpenGL ES 3.0.3 §3.8.2,
man page)
.
interface WebGLSampler : WebGLObject { };
The WebGLSync
interface represents an OpenGL Sync Object.
The underlying object is created as if by calling glFenceSync
(OpenGL ES 3.0.3 §5.2,
man page)
,
blocked on as if by calling glClientWaitSync
(OpenGL ES 3.0.3 §5.2.1,
man page)
,
waited on internal to GL as if by calling glWaitSync
(OpenGL ES 3.0.3 §5.2.1,
man page)
,
queried as if by calling glGetSynciv
(OpenGL ES 3.0.3 §6.2.8,
man page)
,
and destroyed as if by calling glDeleteSync
(OpenGL ES 3.0.3 §5.2,
man page)
.
interface WebGLSync : WebGLObject { };
The WebGLTransformFeedback
interface represents an OpenGL Transform Feedback Object.
The underlying object is created as if by calling glGenTransformFeedbacks
(OpenGL ES 3.0.3 §2.14.1,
man page)
,
bound as if by calling glBindTransformFeedback
(OpenGL ES 3.0.3 §2.14.1,
man page)
and destroyed as if by calling glDeleteTransformFeedbacks
(OpenGL ES 3.0.3 §2.14.1,
man page)
.
interface WebGLTransformFeedback : WebGLObject { };
The WebGLVertexArrayObject
interface represents an OpenGL Vertex Array Object.
The underlying object is created as if by calling glGenVertexArrays
(OpenGL ES 3.0.3 §2.10,
man page)
,
bound as if by calling glBindVertexArray
(OpenGL ES 3.0.3 §2.10,
man page)
and destroyed as if by calling glDeleteVertexArrays
(OpenGL ES 3.0.3 §2.10,
man page)
.
interface WebGLVertexArrayObject : WebGLObject { };
The WebGL2RenderingContext
represents the API allowing
OpenGL ES 3.0 style rendering into the canvas element.
[NoInterfaceObject] interface WebGL2RenderingContextBase { const GLenum READ_BUFFER = 0x0C02; const GLenum UNPACK_ROW_LENGTH = 0x0CF2; const GLenum UNPACK_SKIP_ROWS = 0x0CF3; const GLenum UNPACK_SKIP_PIXELS = 0x0CF4; const GLenum PACK_ROW_LENGTH = 0x0D02; const GLenum PACK_SKIP_ROWS = 0x0D03; const GLenum PACK_SKIP_PIXELS = 0x0D04; const GLenum COLOR = 0x1800; const GLenum DEPTH = 0x1801; const GLenum STENCIL = 0x1802; const GLenum RED = 0x1903; const GLenum RGB8 = 0x8051; const GLenum RGBA8 = 0x8058; const GLenum RGB10_A2 = 0x8059; const GLenum TEXTURE_BINDING_3D = 0x806A; const GLenum UNPACK_SKIP_IMAGES = 0x806D; const GLenum UNPACK_IMAGE_HEIGHT = 0x806E; const GLenum TEXTURE_3D = 0x806F; const GLenum TEXTURE_WRAP_R = 0x8072; const GLenum MAX_3D_TEXTURE_SIZE = 0x8073; const GLenum UNSIGNED_INT_2_10_10_10_REV = 0x8368; const GLenum MAX_ELEMENTS_VERTICES = 0x80E8; const GLenum MAX_ELEMENTS_INDICES = 0x80E9; const GLenum TEXTURE_MIN_LOD = 0x813A; const GLenum TEXTURE_MAX_LOD = 0x813B; const GLenum TEXTURE_BASE_LEVEL = 0x813C; const GLenum TEXTURE_MAX_LEVEL = 0x813D; const GLenum MIN = 0x8007; const GLenum MAX = 0x8008; const GLenum DEPTH_COMPONENT24 = 0x81A6; const GLenum MAX_TEXTURE_LOD_BIAS = 0x84FD; const GLenum TEXTURE_COMPARE_MODE = 0x884C; const GLenum TEXTURE_COMPARE_FUNC = 0x884D; const GLenum CURRENT_QUERY = 0x8865; const GLenum QUERY_RESULT = 0x8866; const GLenum QUERY_RESULT_AVAILABLE = 0x8867; const GLenum STREAM_READ = 0x88E1; const GLenum STREAM_COPY = 0x88E2; const GLenum STATIC_READ = 0x88E5; const GLenum STATIC_COPY = 0x88E6; const GLenum DYNAMIC_READ = 0x88E9; const GLenum DYNAMIC_COPY = 0x88EA; const GLenum MAX_DRAW_BUFFERS = 0x8824; const GLenum DRAW_BUFFER0 = 0x8825; const GLenum DRAW_BUFFER1 = 0x8826; const GLenum DRAW_BUFFER2 = 0x8827; const GLenum DRAW_BUFFER3 = 0x8828; const GLenum DRAW_BUFFER4 = 0x8829; const GLenum DRAW_BUFFER5 = 0x882A; const GLenum DRAW_BUFFER6 = 0x882B; const GLenum DRAW_BUFFER7 = 0x882C; const GLenum DRAW_BUFFER8 = 0x882D; const GLenum DRAW_BUFFER9 = 0x882E; const GLenum DRAW_BUFFER10 = 0x882F; const GLenum DRAW_BUFFER11 = 0x8830; const GLenum DRAW_BUFFER12 = 0x8831; const GLenum DRAW_BUFFER13 = 0x8832; const GLenum DRAW_BUFFER14 = 0x8833; const GLenum DRAW_BUFFER15 = 0x8834; const GLenum MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49; const GLenum MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A; const GLenum SAMPLER_3D = 0x8B5F; const GLenum SAMPLER_2D_SHADOW = 0x8B62; const GLenum FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B; const GLenum PIXEL_PACK_BUFFER = 0x88EB; const GLenum PIXEL_UNPACK_BUFFER = 0x88EC; const GLenum PIXEL_PACK_BUFFER_BINDING = 0x88ED; const GLenum PIXEL_UNPACK_BUFFER_BINDING = 0x88EF; const GLenum FLOAT_MAT2x3 = 0x8B65; const GLenum FLOAT_MAT2x4 = 0x8B66; const GLenum FLOAT_MAT3x2 = 0x8B67; const GLenum FLOAT_MAT3x4 = 0x8B68; const GLenum FLOAT_MAT4x2 = 0x8B69; const GLenum FLOAT_MAT4x3 = 0x8B6A; const GLenum SRGB = 0x8C40; const GLenum SRGB8 = 0x8C41; const GLenum SRGB8_ALPHA8 = 0x8C43; const GLenum COMPARE_REF_TO_TEXTURE = 0x884E; const GLenum RGBA32F = 0x8814; const GLenum RGB32F = 0x8815; const GLenum RGBA16F = 0x881A; const GLenum RGB16F = 0x881B; const GLenum VERTEX_ATTRIB_ARRAY_INTEGER = 0x88FD; const GLenum MAX_ARRAY_TEXTURE_LAYERS = 0x88FF; const GLenum MIN_PROGRAM_TEXEL_OFFSET = 0x8904; const GLenum MAX_PROGRAM_TEXEL_OFFSET = 0x8905; const GLenum MAX_VARYING_COMPONENTS = 0x8B4B; const GLenum TEXTURE_2D_ARRAY = 0x8C1A; const GLenum TEXTURE_BINDING_2D_ARRAY = 0x8C1D; const GLenum R11F_G11F_B10F = 0x8C3A; const GLenum UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B; const GLenum RGB9_E5 = 0x8C3D; const GLenum UNSIGNED_INT_5_9_9_9_REV = 0x8C3E; const GLenum TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8C7F; const GLenum MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8C80; const GLenum TRANSFORM_FEEDBACK_VARYINGS = 0x8C83; const GLenum TRANSFORM_FEEDBACK_BUFFER_START = 0x8C84; const GLenum TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8C85; const GLenum TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88; const GLenum RASTERIZER_DISCARD = 0x8C89; const GLenum MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A; const GLenum MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8C8B; const GLenum INTERLEAVED_ATTRIBS = 0x8C8C; const GLenum SEPARATE_ATTRIBS = 0x8C8D; const GLenum TRANSFORM_FEEDBACK_BUFFER = 0x8C8E; const GLenum TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8C8F; const GLenum RGBA32UI = 0x8D70; const GLenum RGB32UI = 0x8D71; const GLenum RGBA16UI = 0x8D76; const GLenum RGB16UI = 0x8D77; const GLenum RGBA8UI = 0x8D7C; const GLenum RGB8UI = 0x8D7D; const GLenum RGBA32I = 0x8D82; const GLenum RGB32I = 0x8D83; const GLenum RGBA16I = 0x8D88; const GLenum RGB16I = 0x8D89; const GLenum RGBA8I = 0x8D8E; const GLenum RGB8I = 0x8D8F; const GLenum RED_INTEGER = 0x8D94; const GLenum RGB_INTEGER = 0x8D98; const GLenum RGBA_INTEGER = 0x8D99; const GLenum SAMPLER_2D_ARRAY = 0x8DC1; const GLenum SAMPLER_2D_ARRAY_SHADOW = 0x8DC4; const GLenum SAMPLER_CUBE_SHADOW = 0x8DC5; const GLenum UNSIGNED_INT_VEC2 = 0x8DC6; const GLenum UNSIGNED_INT_VEC3 = 0x8DC7; const GLenum UNSIGNED_INT_VEC4 = 0x8DC8; const GLenum INT_SAMPLER_2D = 0x8DCA; const GLenum INT_SAMPLER_3D = 0x8DCB; const GLenum INT_SAMPLER_CUBE = 0x8DCC; const GLenum INT_SAMPLER_2D_ARRAY = 0x8DCF; const GLenum UNSIGNED_INT_SAMPLER_2D = 0x8DD2; const GLenum UNSIGNED_INT_SAMPLER_3D = 0x8DD3; const GLenum UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4; const GLenum UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7; const GLenum DEPTH_COMPONENT32F = 0x8CAC; const GLenum DEPTH32F_STENCIL8 = 0x8CAD; const GLenum FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD; const GLenum FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210; const GLenum FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211; const GLenum FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212; const GLenum FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213; const GLenum FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214; const GLenum FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215; const GLenum FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216; const GLenum FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217; const GLenum FRAMEBUFFER_DEFAULT = 0x8218; const GLenum DEPTH_STENCIL_ATTACHMENT = 0x821A; const GLenum DEPTH_STENCIL = 0x84F9; const GLenum UNSIGNED_INT_24_8 = 0x84FA; const GLenum DEPTH24_STENCIL8 = 0x88F0; const GLenum UNSIGNED_NORMALIZED = 0x8C17; const GLenum DRAW_FRAMEBUFFER_BINDING = 0x8CA6; /* Same as FRAMEBUFFER_BINDING */ const GLenum READ_FRAMEBUFFER = 0x8CA8; const GLenum DRAW_FRAMEBUFFER = 0x8CA9; const GLenum READ_FRAMEBUFFER_BINDING = 0x8CAA; const GLenum RENDERBUFFER_SAMPLES = 0x8CAB; const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4; const GLenum MAX_COLOR_ATTACHMENTS = 0x8CDF; const GLenum COLOR_ATTACHMENT1 = 0x8CE1; const GLenum COLOR_ATTACHMENT2 = 0x8CE2; const GLenum COLOR_ATTACHMENT3 = 0x8CE3; const GLenum COLOR_ATTACHMENT4 = 0x8CE4; const GLenum COLOR_ATTACHMENT5 = 0x8CE5; const GLenum COLOR_ATTACHMENT6 = 0x8CE6; const GLenum COLOR_ATTACHMENT7 = 0x8CE7; const GLenum COLOR_ATTACHMENT8 = 0x8CE8; const GLenum COLOR_ATTACHMENT9 = 0x8CE9; const GLenum COLOR_ATTACHMENT10 = 0x8CEA; const GLenum COLOR_ATTACHMENT11 = 0x8CEB; const GLenum COLOR_ATTACHMENT12 = 0x8CEC; const GLenum COLOR_ATTACHMENT13 = 0x8CED; const GLenum COLOR_ATTACHMENT14 = 0x8CEE; const GLenum COLOR_ATTACHMENT15 = 0x8CEF; const GLenum FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56; const GLenum MAX_SAMPLES = 0x8D57; const GLenum HALF_FLOAT = 0x140B; const GLenum RG = 0x8227; const GLenum RG_INTEGER = 0x8228; const GLenum R8 = 0x8229; const GLenum RG8 = 0x822B; const GLenum R16F = 0x822D; const GLenum R32F = 0x822E; const GLenum RG16F = 0x822F; const GLenum RG32F = 0x8230; const GLenum R8I = 0x8231; const GLenum R8UI = 0x8232; const GLenum R16I = 0x8233; const GLenum R16UI = 0x8234; const GLenum R32I = 0x8235; const GLenum R32UI = 0x8236; const GLenum RG8I = 0x8237; const GLenum RG8UI = 0x8238; const GLenum RG16I = 0x8239; const GLenum RG16UI = 0x823A; const GLenum RG32I = 0x823B; const GLenum RG32UI = 0x823C; const GLenum VERTEX_ARRAY_BINDING = 0x85B5; const GLenum R8_SNORM = 0x8F94; const GLenum RG8_SNORM = 0x8F95; const GLenum RGB8_SNORM = 0x8F96; const GLenum RGBA8_SNORM = 0x8F97; const GLenum SIGNED_NORMALIZED = 0x8F9C; const GLenum PRIMITIVE_RESTART_FIXED_INDEX = 0x8D69; const GLenum COPY_READ_BUFFER = 0x8F36; const GLenum COPY_WRITE_BUFFER = 0x8F37; const GLenum COPY_READ_BUFFER_BINDING = 0x8F36; /* Same as COPY_READ_BUFFER */ const GLenum COPY_WRITE_BUFFER_BINDING = 0x8F37; /* Same as COPY_WRITE_BUFFER */ const GLenum UNIFORM_BUFFER = 0x8A11; const GLenum UNIFORM_BUFFER_BINDING = 0x8A28; const GLenum UNIFORM_BUFFER_START = 0x8A29; const GLenum UNIFORM_BUFFER_SIZE = 0x8A2A; const GLenum MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B; const GLenum MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D; const GLenum MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E; const GLenum MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F; const GLenum MAX_UNIFORM_BLOCK_SIZE = 0x8A30; const GLenum MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31; const GLenum MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33; const GLenum UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34; const GLenum ACTIVE_UNIFORM_BLOCKS = 0x8A36; const GLenum UNIFORM_TYPE = 0x8A37; const GLenum UNIFORM_SIZE = 0x8A38; const GLenum UNIFORM_BLOCK_INDEX = 0x8A3A; const GLenum UNIFORM_OFFSET = 0x8A3B; const GLenum UNIFORM_ARRAY_STRIDE = 0x8A3C; const GLenum UNIFORM_MATRIX_STRIDE = 0x8A3D; const GLenum UNIFORM_IS_ROW_MAJOR = 0x8A3E; const GLenum UNIFORM_BLOCK_BINDING = 0x8A3F; const GLenum UNIFORM_BLOCK_DATA_SIZE = 0x8A40; const GLenum UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42; const GLenum UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43; const GLenum UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44; const GLenum UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46; const GLenum INVALID_INDEX = 0xFFFFFFFF; const GLenum MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122; const GLenum MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125; const GLenum MAX_SERVER_WAIT_TIMEOUT = 0x9111; const GLenum OBJECT_TYPE = 0x9112; const GLenum SYNC_CONDITION = 0x9113; const GLenum SYNC_STATUS = 0x9114; const GLenum SYNC_FLAGS = 0x9115; const GLenum SYNC_FENCE = 0x9116; const GLenum SYNC_GPU_COMMANDS_COMPLETE = 0x9117; const GLenum UNSIGNALED = 0x9118; const GLenum SIGNALED = 0x9119; const GLenum ALREADY_SIGNALED = 0x911A; const GLenum TIMEOUT_EXPIRED = 0x911B; const GLenum CONDITION_SATISFIED = 0x911C; const GLenum WAIT_FAILED = 0x911D; const GLenum SYNC_FLUSH_COMMANDS_BIT = 0x00000001; const GLenum VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE; const GLenum ANY_SAMPLES_PASSED = 0x8C2F; const GLenum ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A; const GLenum SAMPLER_BINDING = 0x8919; const GLenum RGB10_A2UI = 0x906F; const GLenum TEXTURE_SWIZZLE_R = 0x8E42; const GLenum TEXTURE_SWIZZLE_G = 0x8E43; const GLenum TEXTURE_SWIZZLE_B = 0x8E44; const GLenum TEXTURE_SWIZZLE_A = 0x8E45; const GLenum GREEN = 0x1904; const GLenum BLUE = 0x1905; const GLenum INT_2_10_10_10_REV = 0x8D9F; const GLenum TRANSFORM_FEEDBACK = 0x8E22; const GLenum TRANSFORM_FEEDBACK_PAUSED = 0x8E23; const GLenum TRANSFORM_FEEDBACK_ACTIVE = 0x8E24; const GLenum TRANSFORM_FEEDBACK_BINDING = 0x8E25; const GLenum COMPRESSED_R11_EAC = 0x9270; const GLenum COMPRESSED_SIGNED_R11_EAC = 0x9271; const GLenum COMPRESSED_RG11_EAC = 0x9272; const GLenum COMPRESSED_SIGNED_RG11_EAC = 0x9273; const GLenum COMPRESSED_RGB8_ETC2 = 0x9274; const GLenum COMPRESSED_SRGB8_ETC2 = 0x9275; const GLenum COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276; const GLenum COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277; const GLenum COMPRESSED_RGBA8_ETC2_EAC = 0x9278; const GLenum COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279; const GLenum TEXTURE_IMMUTABLE_FORMAT = 0x912F; const GLenum MAX_ELEMENT_INDEX = 0x8D6B; const GLenum NUM_SAMPLE_COUNTS = 0x9380; const GLenum TEXTURE_IMMUTABLE_LEVELS = 0x82DF; const GLuint64 TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFF; /* Buffer objects */ void copyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); // MapBufferRange, in particular its read-only and write-only modes, // can not be exposed safely to JavaScript. GetBufferSubData // replaces it for the purpose of fetching data back from the GPU. typedef (ArrayBuffer or ArrayBufferView) GetBufferDataDest; void getBufferSubData(GLenum target, GLintptr offset, GetBufferDataDest returnedData); /* Framebuffer objects */ void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); void framebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); any getInternalformatParameter(GLenum target, GLenum internalformat, GLenum pname); void invalidateFramebuffer(GLenum target, sequence<GLenum> attachments); void invalidateSubFramebuffer(GLenum target, sequence<GLenum> attachments, GLint x, GLint y, GLsizei width, GLsizei height); void readBuffer(GLenum src); /* Renderbuffer objects */ void renderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); /* Texture objects */ void texStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); void texStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, ArrayBufferView? pixels); void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLenum format, GLenum type, TexImageSource? source); void copyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); void compressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, ArrayBufferView data); void compressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, ArrayBufferView data); /* Programs and shaders */ [WebGLHandlesContextLoss] GLint getFragDataLocation(WebGLProgram? program, DOMString name); /* Uniforms and attributes */ void uniform1ui(WebGLUniformLocation? location, GLuint v0); void uniform2ui(WebGLUniformLocation? location, GLuint v0, GLuint v1); void uniform3ui(WebGLUniformLocation? location, GLuint v0, GLuint v1, GLuint v2); void uniform4ui(WebGLUniformLocation? location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); void uniform1uiv(WebGLUniformLocation? location, sequence<GLuint> value); void uniform2uiv(WebGLUniformLocation? location, sequence<GLuint> value); void uniform3uiv(WebGLUniformLocation? location, sequence<GLuint> value); void uniform4uiv(WebGLUniformLocation? location, sequence<GLuint> value); typedef (Float32Array or sequence<GLfloat>) UniformMatrixFVSource; void uniformMatrix2x3fv(WebGLUniformLocation? location, GLboolean transpose, UniformMatrixFVSource value); void uniformMatrix3x2fv(WebGLUniformLocation? location, GLboolean transpose, UniformMatrixFVSource value); void uniformMatrix2x4fv(WebGLUniformLocation? location, GLboolean transpose, UniformMatrixFVSource value); void uniformMatrix4x2fv(WebGLUniformLocation? location, GLboolean transpose, UniformMatrixFVSource value); void uniformMatrix3x4fv(WebGLUniformLocation? location, GLboolean transpose, UniformMatrixFVSource value); void uniformMatrix4x3fv(WebGLUniformLocation? location, GLboolean transpose, UniformMatrixFVSource value); void vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w); void vertexAttribI4iv(GLuint index, sequence<GLint> v); void vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); void vertexAttribI4uiv(GLuint index, sequence<GLuint> v); void vertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); /* Writing to the drawing buffer */ void vertexAttribDivisor(GLuint index, GLuint divisor); void drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount); void drawElementsInstanced(GLenum mode, GLsizei count, GLenum type, GLintptr offset, GLsizei instanceCount); /* TODO(kbr): argue against exposing this because it can't safely offer better performance than drawElements */ void drawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, GLintptr offset); /* Multiple Render Targets */ void drawBuffers(sequence<GLenum> buffers); typedef (Int32Array or sequence<GLint>) ClearBufferIVSource; typedef (Uint32Array or sequence<GLuint>) ClearBufferUIVSource; typedef (Float32Array or sequence<GLfloat>) ClearBufferFVSource; void clearBufferiv(GLenum buffer, GLint drawbuffer, ClearBufferIVSource value); void clearBufferuiv(GLenum buffer, GLint drawbuffer, ClearBufferUIVSource value); void clearBufferfv(GLenum buffer, GLint drawbuffer, ClearBufferFVSource value); void clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); /* Query Objects */ WebGLQuery? createQuery(); void deleteQuery(WebGLQuery? query); [WebGLHandlesContextLoss] GLboolean isQuery(WebGLQuery? query); void beginQuery(GLenum target, WebGLQuery? query); void endQuery(GLenum target); WebGLQuery? getQuery(GLenum target, GLenum pname); any getQueryParameter(WebGLQuery? query, GLenum pname); /* Sampler Objects */ WebGLSampler? createSampler(); void deleteSampler(WebGLSampler? sampler); [WebGLHandlesContextLoss] GLboolean isSampler(WebGLSampler? sampler); void bindSampler(GLuint unit, WebGLSampler? sampler); void samplerParameteri(WebGLSampler? sampler, GLenum pname, GLint param); void samplerParameterf(WebGLSampler? sampler, GLenum pname, GLfloat param); any getSamplerParameter(WebGLSampler? sampler, GLenum pname); /* Sync objects */ WebGLSync? fenceSync(GLenum condition, GLbitfield flags); [WebGLHandlesContextLoss] GLboolean isSync(WebGLSync? sync); void deleteSync(WebGLSync? sync); GLenum clientWaitSync(WebGLSync? sync, GLbitfield flags, GLuint64 timeout); void waitSync(WebGLSync? sync, GLbitfield flags, GLuint64 timeout); any getSyncParameter(WebGLSync? sync, GLenum pname); /* Transform Feedback */ WebGLTransformFeedback? createTransformFeedback(); void deleteTransformFeedback(WebGLTransformFeedback?); [WebGLHandlesContextLoss] GLboolean isTransformFeedback(WebGLTransformFeedback?); void bindTransformFeedback (GLenum target, WebGLTransformFeedback? id); void beginTransformFeedback(GLenum primitiveMode); void endTransformFeedback(); void transformFeedbackVaryings(WebGLProgram? program, sequence<DOMString> varyings, GLenum bufferMode); WebGLActiveInfo? getTransformFeedbackVarying(WebGLProgram? program, GLuint index); void pauseTransformFeedback(); void resumeTransformFeedback(); /* Uniform Buffer Objects and Transform Feedback Buffers */ void bindBufferBase(GLenum target, GLuint index, WebGLBuffer? buffer); void bindBufferRange(GLenum target, GLuint index, WebGLBuffer? buffer, GLintptr offset, GLsizeiptr size); any getIndexedParameter(GLenum target, GLuint index); sequence<GLuint>? getUniformIndices(WebGLProgram? program, sequence<DOMString> uniformNames); sequence<GLint>? getActiveUniforms(WebGLProgram? program, sequence<GLuint> uniformIndices, GLenum pname); GLuint getUniformBlockIndex(WebGLProgram? program, DOMString uniformBlockName); any getActiveUniformBlockParameter(WebGLProgram? program, GLuint uniformBlockIndex, GLenum pname); /* TODO: if there were a fake enum for GL_UNIFORM_BLOCK_NAME, then this could be folded into getActiveUniformBlockParameter */ DOMString? getActiveUniformBlockName(WebGLProgram? program, GLuint uniformBlockIndex); void uniformBlockBinding(WebGLProgram? program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); /* Vertex Array Objects */ WebGLVertexArrayObject? createVertexArray(); void deleteVertexArray(WebGLVertexArrayObject? vertexArray); [WebGLHandlesContextLoss] GLboolean isVertexArray(WebGLVertexArrayObject? vertexArray); void bindVertexArray(WebGLVertexArrayObject? array); }; WebGL2RenderingContextBase implements WebGLRenderingContextBase; interface WebGL2RenderingContext { }; WebGL2RenderingContext implements WebGL2RenderingContextBase;
pname | returned type |
---|---|
COPY_READ_BUFFER_BINDING | WebGLBuffer |
COPY_WRITE_BUFFER_BINDING | WebGLBuffer |
DRAW_BINDING | GLenum |
DRAW_FRAMEBUFFER_BINDING | WebGLFramebuffer |
FRAGMENT_SHADER_DERIVATIVE_HINT | GLenum |
IMPLEMENTATION_COLOR_READ_FORMAT | GLenum |
IMPLEMENTATION_COLOR_READ_TYPE | GLenum |
MAX_3D_TEXTURE_SIZE | GLint |
MAX_ARRAY_TEXTURE_LAYERS | GLint |
MAX_COLOR_ATTACHMENTS | GLint |
MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS | GLint64 |
MAX_COMBINED_UNIFORM_BLOCKS | GLint |
MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS | GLint64 |
MAX_DRAW_BUFFERS | GLint |
MAX_ELEMENT_INDEX | GLint64 |
MAX_ELEMENTS_INDICES | GLint |
MAX_ELEMENTS_VERTICES | GLint |
MAX_FRAGMENT_INPUT_COMPONENTS | GLint |
MAX_FRAGMENT_UNIFORM_BLOCKS | GLint |
MAX_FRAGMENT_UNIFORM_COMPONENTS | GLint |
MAX_PROGRAM_TEXEL_OFFSET | GLint |
MAX_SAMPLES | GLint |
MAX_SERVER_WAIT_TIMEOUT | GLint64 |
MAX_TEXTURE_LOD_BIAS | GLint |
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS | GLint |
MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS | GLint |
MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS | GLint |
MAX_UNIFORM_BLOCK_SIZE | GLint64 |
MAX_UNIFORM_BUFFER_BINDINGS | GLint |
MAX_VARYING_COMPONENTS | GLint |
MAX_VERTEX_OUTPUT_COMPONENTS | GLint |
MAX_VERTEX_UNIFORM_BLOCKS | GLint |
MAX_VERTEX_UNIFORM_COMPONENTS | GLint |
MIN_PROGRAM_TEXEL_OFFSET | GLint |
PACK_IMAGE_HEIGHT | GLint |
PACK_ROW_LENGTH | GLint |
PACK_SKIP_IMAGES | GLint |
PACK_SKIP_PIXELS | GLint |
PACK_SKIP_ROWS | GLint |
PIXEL_PACK_BUFFER_BINDING | WebGLBuffer |
PIXEL_UNPACK_BUFFER_BINDING | WebGLBuffer |
PRIMITIVE_RESTART_FIXED_INDEX | GLboolean |
RASTERIZER_DISCARD | GLboolean |
READ_BUFFER | GLenum |
READ_FRAMEBUFFER_BINDING | WebGLFramebuffer |
SAMPLE_ALPHA_TO_COVERAGE | GLboolean |
SAMPLE_COVERAGE | GLboolean |
SAMPLER_BINDING | WebGLSampler |
TEXTURE_BINDING_2D_ARRAY | WebGLTexture |
TEXTURE_BINDING_3D | WebGLTexture |
TRANSFORM_FEEDBACK_ACTIVE | GLboolean |
TRANSFORM_FEEDBACK_BUFFER_BINDING | WebGLBuffer |
TRANSFORM_FEEDBACK_PAUSED | GLboolean |
UNIFORM_BUFFER_BINDING | WebGLBuffer |
UNIFORM_BUFFER_OFFSET_ALIGNMENT | GLint |
UNPACK_IMAGE_HEIGHT | GLint |
UNPACK_ROW_LENGTH | GLint |
UNPACK_SKIP_IMAGES | GLboolean |
UNPACK_SKIP_PIXELS | GLboolean |
UNPACK_SKIP_ROWS | GLboolean |
VERTEX_ARRAY_BINDING | WebGLVertexArrayObject |
target
. The type returned is the natural type for the requested pname
,
as given in the following table:
target | returned type |
---|---|
TRANSFORM_FEEDBACK_BUFFER_BINDING | WebGLBuffer |
TRANSFORM_FEEDBACK_BUFFER_SIZE | GLsizeiptr |
TRANSFORM_FEEDBACK_BUFFER_START | GLintptr |
UNIFORM_BUFFER_BINDING | WebGLBuffer |
UNIFORM_BUFFER_SIZE | GLsizeiptr |
UNIFORM_BUFFER_START | GLintptr |
If target
is not in the table above, generates an INVALID_ENUM
error.
If index
is outside of the valid range for the indexed state target
, generates an INVALID_VALUE
error.
If an OpenGL error is generated, returns null.
cap
values from WebGL 1.0, PRIMITIVE_RESTART_FIXED_INDEX and RASTERIZER_DISCARD are supported.
void copyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) (OpenGL ES 3.0.3 §2.9.5, man page)
void getBufferSubData(GLenum target, GLintptr offset, GetBufferDataDest returnedData)
returnedData.byteLength
bytes from the buffer starting at byte offset offset
and write them
to returnedData
. If offset + returnedData.byteLength
would extend
beyond the end of the buffer an INVALID_VALUE
error is generated.
If returnedData
is null then an INVALID_VALUE
error is generated.
If offset
is less than zero, an INVALID_VALUE
error is generated.
If zero is bound to target
, an INVALID_OPERATION
error is generated.
If target
is TRANSFORM_FEEDBACK_BUFFER
, and any transform feedback object
is currently active, an INVALID_OPERATION
error is generated.
If any error is generated, no data is written to returnedData
.
getBufferSubData
,
it is the responsibility of the WebGL API to ensure that data are accessed consistently. This applies
even if the buffer is currently bound to a transform feedback binding point.
pname | returned type |
---|---|
FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE | GLint |
FRAMEBUFFER_ATTACHMENT_BLUE_SIZE | GLint |
FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING | Genum |
FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE | Genum |
FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE | GLint |
FRAMEBUFFER_ATTACHMENT_GREEN_SIZE | GLint |
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME | WebGLRenderbuffer or WebGLTexture |
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE | GLenum |
FRAMEBUFFER_ATTACHMENT_RED_SIZE | GLint |
FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE | GLint |
FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE | GLint |
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER | Gint |
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL | GLint |
If pname is not in the table above, generates an INVALID_ENUM
error.
If an OpenGL error is generated, returns null.
void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) (OpenGL ES 3.0.3 §4.3.3, man page)
void framebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) (OpenGL ES 3.0.3 §4.4.2, man page)
any getInternalformatParameter(GLenum target, GLenum internalformat, GLenum pname) (OpenGL ES 3.0.3 §6.1.15, man page)
pname | returned type |
---|---|
NUM_SAMPLE_COUNTS | GLint |
SAMPLES | Int32Array |
If pname is not in the table above, generates an INVALID_ENUM
error.
If an OpenGL error is generated, returns null.
Each query for SAMPLES returns a new typed array object instance.
void invalidateFramebuffer(GLenum target, sequence<GLenum> attachments) (OpenGL ES 3.0.3 §4.5, man page)
invalidateSubFramebuffer
with x
and y
set to 0 and width
and height
set to the largest framebuffer object's
attachments' width and height.
void invalidateSubFramebuffer (GLenum target, sequence<GLenum> attachments, GLint x, GLint y, GLsizei width, GLsizei height) (OpenGL ES 3.0.3 §4.5, man page)
void readBuffer(GLenum src) (OpenGL ES 3.0.3 §4.3.1, man page)
pname | returned type |
---|---|
RENDERBUFFER_WIDTH | GLint |
RENDERBUFFER_HEIGHT | GLint |
RENDERBUFFER_INTERNAL_FORMAT | GLenum |
RENDERBUFFER_RED_SIZE | GLint |
RENDERBUFFER_GREEN_SIZE | GLint |
RENDERBUFFER_BLUE_SIZE | GLint |
RENDERBUFFER_ALPHA_SIZE | GLint |
RENDERBUFFER_DEPTH_SIZE | GLint |
RENDERBUFFER_SAMPLES | GLint |
RENDERBUFFER_STENCIL_SIZE | GLint |
If pname is not in the table above, generates an INVALID_ENUM
error.
If an OpenGL error is generated, returns null.
void renderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) (OpenGL ES 3.0.3 §4.4.2, man page)
Texture objects provide storage and state for texturing operations. If no WebGLTexture is bound
(e.g., passing null or 0 to bindTexture) then attempts to modify or query the texture object shall
generate an INVALID_OPERATION
error. This is indicated in the functions below in cases
where The OpenGL ES 3.0 specification allows the function to change the default texture.
pname | returned type |
---|---|
TEXTURE_BASE_LEVEL | GLint |
TEXTURE_COMPARE_FUNC | GLenum |
TEXTURE_COMPARE_MODE | GLenum |
TEXTURE_IMMUTABLE_FORMAT | GLboolean |
TEXTURE_IMMUTABLE_LEVELS | GLuint |
TEXTURE_MAG_FILTER | GLenum |
TEXTURE_MAX_LEVEL | GLint |
TEXTURE_MAX_LOD | GLfloat |
TEXTURE_MIN_FILTER | GLenum |
TEXTURE_MIN_LOD | GLfloat |
TEXTURE_SWIZZLE_A | GLenum |
TEXTURE_SWIZZLE_B | GLenum |
TEXTURE_SWIZZLE_G | GLenum |
TEXTURE_SWIZZLE_R | GLenum |
TEXTURE_WRAP_R | GLenum |
TEXTURE_WRAP_S | GLenum |
TEXTURE_WRAP_T | GLenum |
If pname is not in the table above, generates an INVALID_ENUM
error.
If an attempt is made to call this function with no WebGLTexture bound (see above), generates an
INVALID_OPERATION
error.
If an OpenGL error is generated, returns null.
void texStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) (OpenGL ES 3.0.3 §3.8.4, man page)
void texStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) (OpenGL ES 3.0.3 §3.8.4, man page)
void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, ArrayBufferView? pixels) (OpenGL ES 3.0.3 §3.8.5, man page)
INVALID_OPERATION
error is generated. pixels
is null then an INVALID_VALUE error is generated. void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLenum format, GLenum type, TexImageSource? source) /* May throw DOMException */ (OpenGL ES 3.0.3 §3.8.5, man page)
UNPACK_PREMULTIPLY_ALPHA_WEBGL
pixel storage parameter. UNPACK_FLIP_Y_WEBGL
pixel storage
parameter. INVALID_OPERATION
error is generated. HTMLImageElement
or HTMLVideoElement
whose origin differs from the origin of the containing
Document, or with an HTMLCanvasElement
whose origin-clean flag is
set to false, a SECURITY_ERR
exception must be
thrown. See Origin Restrictions.source
is null then an INVALID_VALUE
error is
generated. void copyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) (OpenGL ES 3.0.3 §3.8.5, man page)
INVALID_OPERATION
error is generated. void compressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, ArrayBufferView data) (OpenGL ES 3.0.3 §3.8.6, man page)
void compressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, ArrayBufferView data) (OpenGL ES 3.0.3 §3.8.6, man page)
INVALID_OPERATION
error is generated. [WebGLHandlesContextLoss] GLint getFragDataLocation(WebGLProgram? program, DOMString name) (OpenGL ES 3.0.3 §3.9.2, man page)
pname | returned type |
---|---|
DELETE_STATUS | GLboolean |
LINK_STATUS | GLboolean |
VALIDATE_STATUS | GLboolean |
ATTACHED_SHADERS | GLint |
ACTIVE_ATTRIBUTES | GLint |
ACTIVE_UNIFORMS | GLint |
TRANSFORM_FEEDBACK_BUFFER_MODE | GLenum |
TRANSFORM_FEEDBACK_VARYINGS | GLint |
ACTIVE_UNIFORM_BLOCKS | GLint |
If pname is not in the table above, generates an INVALID_ENUM
error and returns null.
Returns null if any OpenGL errors are generated during the execution of this function.
uniform type | returned type |
---|---|
uint | GLuint |
uvec2 | Uint32Array (with 2 elements) |
uvec3 | Uint32Array (with 3 elements) |
uvec4 | Uint32Array (with 4 elements) |
mat2x3 | Float32Array (with 6 elements) |
mat2x4 | Float32Array (with 8 elements) |
mat3x2 | Float32Array (with 6 elements) |
mat3x4 | Float32Array (with 12 elements) |
mat4x2 | Float32Array (with 8 elements) |
mat4x3 | Float32Array (with 12 elements) |
any sampler type | GLint |
The types returned for the uniform types shared with WebGL 1 are the same as in WebGL 1.
void uniform[1234]ui(WebGLUniformLocation? location, ...)
void uniform[1234]uiv(WebGLUniformLocation? location, ...)
void uniformMatrix[234]x[234]fv(WebGLUniformLocation? location, ...) (OpenGL ES 3.0.3 §2.11.6, man page)
location
is not null and was not obtained from the
currently used program via an earlier call to getUniformLocation
,
an INVALID_OPERATION
error will be generated. If the passed
location
is null, the data passed in will be silently ignored and no uniform
variables will be changed.
v
) has an
invalid length, an INVALID_VALUE
error will be generated. The length is invalid
if it is too short for or is not an integer multiple of the assigned type.
void vertexAttribI4[u]i(GLuint indx, ...)
void vertexAttribI4[u]iv(GLuint indx, ...) (OpenGL ES 3.0.3 §2.7, man page)
vertexAttrib
are guaranteed to be returned from the getVertexAttrib
function
with the CURRENT_VERTEX_ATTRIB
param, even if there have been intervening calls to
drawArrays
or drawElements
.
void vertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset) (OpenGL ES 3.0.3 §2.8, man page)
INVALID_OPERATION
error
will be generated; see Buffer Offset and Stride
Requirements. If offset is negative, an INVALID_VALUE
error will be
generated. If no WebGLBuffer is bound to the ARRAY_BUFFER target,
an INVALID_OPERATION
error will be generated. In WebGL, the maximum supported
stride is 255; see Vertex Attribute Data Stride.
pname | returned type |
---|---|
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING | WebGLBuffer |
VERTEX_ATTRIB_ARRAY_ENABLED | GLboolean |
VERTEX_ATTRIB_ARRAY_SIZE | GLint |
VERTEX_ATTRIB_ARRAY_STRIDE | GLint |
VERTEX_ATTRIB_ARRAY_TYPE | GLenum |
VERTEX_ATTRIB_ARRAY_NORMALIZED | GLboolean |
CURRENT_VERTEX_ATTRIB | One of Float32Array, Int32Array or Uint32Array (each with 4 elements) |
VERTEX_ATTRIB_ARRAY_INTEGER | GLboolean |
VERTEX_ATTRIB_ARRAY_DIVISOR | GLint |
For CURRENT_VERTEX_ATTRIB, the return type is dictated by the most recent call to the vertexAttrib family of functions for the given index. That is, if vertexAttribI4i* was used, the return type will be Int32Array; If vertexAttribI4ui* was used, the return type will be Uint32Array; Otherwise, Float32Array.
All queries returning sequences or typed arrays return a new object each time.
If pname is not in the table above, generates an INVALID_ENUM
error.
If an OpenGL error is generated, returns null.
void clear(GLbitfield mask) (OpenGL ES 3.0.3 §4.2.3, man page)
INVALID_OPERATION
error is generated and nothing is cleared.
void vertexAttribDivisor(GLuint index, GLuint divisor) (OpenGL ES 3.0.3 §2.8, man page)
index
advances when drawing.
void drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) (OpenGL ES 3.0.3 §2.8.3, man page)
instanceCount
instances of geometry using the currently enabled vertex attributes.
Vertex attributes which have a non-zero divisor advance once every divisor instances.
void drawElementsInstanced(GLenum mode, GLsizei count, GLenum type, GLintptr offset, GLsizei instanceCount) (OpenGL ES 3.0.3 §2.8.3, man page)
instanceCount
instances of geometry using the currently bound element array buffer.
Vertex attributes which have a non-zero divisor advance once every divisor instances.
void drawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, GLintptr offset) (OpenGL ES 3.0.3 §2.8.3, man page)
drawElements
in the section Writing
to the drawing buffer of the WebGL 1.0 specification apply. In addition, indices used to draw
must lie between start
and end
inclusive. If the draw call references
indices that are not within this range, an INVALID_OPERATION
error is generated and
nothing is drawn.drawElements
, drawArrays
, drawRangeElements
and their
instanced variants. See Range Checking,
Enabled Attribute, and Active
Uniform Block Backing.
void drawBuffers(sequence<GLenum> buffers) (OpenGL ES 3.0.3 §4.2.1, man page)
void clearBufferiv(GLenum buffer, GLint drawbuffer, ClearBufferISource value)
void clearBufferuiv(GLenum buffer, GLint drawbuffer, ClearBufferUISource value)
void clearBufferfv(GLenum buffer, GLint drawbuffer, ClearBufferFSource value)
void clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) (OpenGL ES 3.0.3 §4.2.3, man page)
Type of buffer | clearBuffer function |
---|---|
floating point | clearBufferfv |
fixed point | clearBufferfv |
signed integer | clearBufferiv |
unsigned integer | clearBufferuiv |
buffer
is COLOR_BUFFER
and the function is not chosen according to the
above table, an INVALID_OPERATION
error is generated and nothing is cleared.
WebGLQuery? createQuery() (OpenGL ES 3.0.3 §2.13, man page)
void deleteQuery(WebGLQuery? query) (OpenGL ES 3.0.3 §2.13, man page)
WebGLQuery
as if by calling
glDeleteQueries. If the query has already been deleted the call has no effect.
Note that the query object will be deleted when the WebGLQuery
object is destroyed.
This method merely gives the author greater control over when the query object is destroyed.
[WebGLHandlesContextLoss] GLboolean isQuery(WebGLQuery? query) (OpenGL ES 3.0.3 §6.1.7, man page)
WebGLQuery
is valid and false otherwise.void beginQuery(GLenum target, WebGLQuery? query) (OpenGL ES 3.0.3 §2.13, man page)
void endQuery(GLenum target) (OpenGL ES 3.0.3 §2.13, man page)
getQueryParameter
.
WebGLQuery? getQuery(GLenum target, GLenum pname) (OpenGL ES 3.0.3 §6.1.7, man page)
Returns information about a query target target, which must be one
of ANY_SAMPLES_PASSED
or ANY_SAMPLES_PASSED_CONSERVATIVE
for
occlusion queries, or TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
for primitive
queries. pname specifies the symbolic name of a query object target
parameter. Currently it must be CURRENT_QUERY
, and returns either the
currently active query for the target, or null.
If target or pname are not in the list above, generates
an INVALID_ENUM
error and returns null.
Returns null if any OpenGL errors are generated during the execution of this function.
any getQueryParameter(WebGLQuery? query, GLenum pname) (OpenGL ES 3.0.3 §6.1.7, man page)
Returns a parameter pname of a query object. QUERY_RESULT
returns
the value of the query object's passed samples counter.
QUERY_RESULT_AVAILABLE
returns whether the samples counter is immediately
available. The type returned is the natural type for the requested pname, as given in the
following table:
pname | returned type |
---|---|
QUERY_RESULT | GLuint |
QUERY_RESULT_AVAILABLE | GLboolean |
If pname is not in the table above, generates an INVALID_ENUM
error and returns null.
If query is not a valid query object, or is a currently active query object,
generates an INVALID_OPERATION
error and returns null.
Returns null if any OpenGL errors are generated during the execution of this function.
WebGLSampler? createSampler() (OpenGL ES 3.0.3 §3.8.2, man page)
WebGLSampler
object and initialize it with a sampler object name as if by
calling glGenSamplers.
void deleteSampler(WebGLSampler? sampler) (OpenGL ES 3.0.3 §3.8.2, man page)
WebGLSampler
as if by calling
glDeleteSamplers. If the sampler has already been deleted the call has no effect.
Note that the sampler object will be deleted when the WebGLSampler
object is destroyed.
This method merely gives the author greater control over when the sampler object is destroyed.
[WebGLHandlesContextLoss] GLboolean isSampler(WebGLSampler? sampler) (OpenGL ES 3.0.3 §3.8.2, man page)
WebGLSampler
is valid and false otherwise. void bindSampler(GLuint unit, WebGLSampler? sampler) (OpenGL ES 3.0.3 §3.8.2, man page)
WebGLSampler
to the texture unit at the
passed index. If a sampler is bound to a texture unit, the sampler's state supersedes the sampling
state of the texture bound to that texture unit.
void samplerParameteri(WebGLSampler? sampler, GLenum pname, GLint param);
void samplerParameterf(WebGLSampler? sampler, GLenum pname, GLfloat param);
(OpenGL ES 3.0.3 §3.8.2, man page)pname | returned type |
---|---|
TEXTURE_COMPARE_FUNC | GLenum |
TEXTURE_COMPARE_MODE | GLenum |
TEXTURE_MAG_FILTER | GLenum |
TEXTURE_MAX_LOD | GLfloat |
TEXTURE_MIN_FILTER | GLenum |
TEXTURE_MIN_LOD | GLfloat |
TEXTURE_WRAP_R | GLenum |
TEXTURE_WRAP_S | GLenum |
TEXTURE_WRAP_T | GLenum |
If pname is not in the table above, generates an INVALID_ENUM
error.
If an OpenGL error is generated, returns null.
Sync objects can be used to synchronize execution between the GL server and the client.
WebGLSync? fenceSync(GLenum condition, GLbitfield flags) (OpenGL ES 3.0.3 §5.2, man page)
[WebGLHandlesContextLoss] GLboolean isSync(WebGLSync? sync) (OpenGL ES 3.0.3 §6.1.8, man page)
WebGLSync
is valid and false otherwise. void deleteSync(WebGLSync? sync) (OpenGL ES 3.0.3 §5.2, man page)
WebGLSync
as if by calling
glDeleteSync. If the sync has already been deleted the call has no effect.
Note that the sync object will be deleted when the WebGLSync
object is destroyed.
This method merely gives the author greater control over when the sync object is destroyed.
GLenum clientWaitSync(WebGLSync? sync, GLbitfield flags, GLuint64 timeout) (OpenGL ES 3.0.3 §5.2.1, man page)
ALREADY_SIGNALED
, TIMEOUT_EXPIRED
, or CONDITION_SATISFIED
.
void waitSync(WebGLSync? sync, GLbitfield flags, GLuint64 timeout) (OpenGL ES 3.0.3 §5.2.1, man page)
TIMEOUT_IGNORED
.
pname | returned type |
---|---|
OBJECT_TYPE | GLenum |
SYNC_STATUS | GLenum |
SYNC_CONDITION | GLenum |
SYNC_FLAGS | GLbitfield |
If pname is not in the table above, generates an INVALID_ENUM
error and returns null.
Returns null if any OpenGL errors are generated during the execution of this function.
Transform feedback mode captures the values of output variables written by the vertex shader. The vertices are captured before flatshading and clipping. The transformed vertices may be optionally discarded after being stored into one or more buffer objects, or they can be passed on down to the clipping stage for further processing. The set of output variables captured is determined when a program is linked.
WebGLTransformFeedback
object and initialize it with a transform feedback object name as if by
calling glGenTransformFeedbacks.
WebGLTransformFeedback
as if by calling
glDeleteTransformFeedbacks. If the transform feedback has already been deleted the call has no effect.
Note that the transform feedback object will be deleted when the WebGLTransformFeedback
object is destroyed.
This method merely gives the author greater control over when the transform feedback object is destroyed.
WebGLTransformFeedback
is valid and false otherwise. WebGLTransformFeedback
object.
If transformFeedback
is null, the default transform feedback object provided by the context
is bound.
Uniform buffer objects provide the storage for named uniform blocks, so the values of active uniforms in named uniform blocks may be changed by modifying the contents of the buffer object.
WebGLBuffer
object to the binding point at index
of the array of targets
specified by target
.
WebGLBuffer
object buffer represented by offset
and size
to the binding point at index
of the array of targets specified by target
program
.
pname
for each of the uniforms within program
whose indices
are specified in the array of uniformIndices
.
program
.
program
. The type returned is the natural type for the requested
pname
, as given in the following table:
pname | returned type |
---|---|
UNIFORM_BLOCK_BINDING | GLuint |
UNIFORM_BLOCK_DATA_SIZE | GLuint |
UNIFORM_BLOCK_ACTIVE_UNIFORMS | GLuint |
UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES | Uint32Array |
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER | GLboolean |
UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER | GLboolean |
If pname
is not in the table above, generates an INVALID_ENUM
error.
If uniformBlockIndex
is not an active block uniform for program
or greater than or equal to the
value of ACTIVE_UNIFORM_BLOCKS
, generates an INVALID_VALUE
error.
If an OpenGL error is generated, returns null.
uniformBlockIndex
within program
.
Vertex Array objects (sometimes referred to as VAOs) encapsulate all state related to the definition of data used by the vertex processor.
WebGLVertexArrayObject
object.
If vertexArray
is null, the default vertex array provided by the context
is bound.
WebGLVertexArrayObject
object and initialize it with a vertex array object name as if by
calling glGenVertexArrays.
WebGLVertexArrayObject
as if by calling
glDeleteVertexArrays. If the vertex array has already been deleted the call has no effect.
Note that the vertex array object will be deleted when the WebGLVertexArrayObject
object is destroyed.
This method merely gives the author greater control over when the vertex array object is
destroyed.
WebGLVertexArrayObject
is valid and false otherwise. Some extensions that may have been supported in the WebGL 1 API are removed from the WebGL 2 API. For more details, see the WebGL Extension Registry.
In addition to supporting The OpenGL ES Shading Language, Version 1.00, the WebGL 2 API also accepts shaders written in The OpenGL ES Shading Language, Version 3.00 [GLES30GLSL], with some restrictions.
As in the WebGL 1.0 API, identifiers starting with "webgl_" and "_webgl_" are reserved for use by WebGL. A shader which declares a function, variable, structure name, or structure field starting with these prefixes must not be allowed to load.
In the WebGL 2 API, vertex attributes which have a non-zero divisor do not advance during calls to
drawArrays
and drawElements
.
(OpenGL ES 3.0.3 §2.8.3)
This section describes changes made to the WebGL API relative to the OpenGL ES 3.0 API to improve portability across various operating systems and devices.
WebGL buffer type | Binding points that set this type |
---|---|
undefined | none |
element array | ELEMENT_ARRAY_BUFFER |
other data | all binding points except ELEMENT_ARRAY_BUFFER, COPY_READ_BUFFER and COPY_WRITE_BUFFER |
In the WebGL 2 API, buffers have their WebGL buffer type initially set to undefined. Calling
bindBuffer
, bindBufferRange
or bindBufferBase
with the
target
argument set to any buffer binding point except COPY_READ_BUFFER
or
COPY_WRITE_BUFFER
will then set the WebGL buffer type of the buffer being bound according
to the table above.
Any call to one of these functions which attempts to bind a WebGLBuffer that has the element
array WebGL buffer type to a binding point that falls under other data, or bind a
WebGLBuffer which has the other data WebGL buffer type to ELEMENT_ARRAY_BUFFER
will generate an INVALID_OPERATION
error, and the state of the binding point will remain
untouched.
This restriction implies that a given buffer object may contain either indices or other data, but not both.
These restrictions are similar to buffer object binding restrictions in the WebGL 1 specification.
In addition, a buffer can not be simultaneously bound to a transform feedback buffer binding point
and another buffer binding point in the WebGL 2 API. Attempting to violate this rule generates an
INVALID_OPERATION
error, and the state of the binding point will remain untouched.
Attempting to use copyBufferSubData
to copy between buffers that have
element array and other data WebGL buffer types as specified in section
Buffer Object Binding generates an
INVALID_OPERATION
error and no copying is performed. Copying data into a buffer which
has the undefined WebGL buffer type sets its WebGL buffer type to the WebGL buffer type of
the source buffer.
The value of the MAX_COLOR_ATTACHMENTS parameter must be equal to that of the MAX_DRAW_BUFFERS parameter.
Accessing binary representations of compiled shader programs is not supported in the WebGL 2 API.
This includes OpenGL ES 3.0 GetProgramBinary
, ProgramBinary
, and
ProgramParameteri
entry points. In addition, querying the program binary length with
getProgramParameter
, and querying program binary formats with getParameter
are not supported in the WebGL 2 API.
In addition to the range checking specified in the WebGL 1.0 specification section
Enabled Vertex Attributes and Range Checking,
indices referenced by drawElements
, drawRangeElements
or
drawElementsInstanced
that are greater than the MAX_ELEMENT_INDEX
parameter
cause the draw call to generate an INVALID_OPERATION
error even if they lie within the
storage of the bound buffer. Range checking is not performed for indices that trigger primitive
restart if primitive restart is enabled. The range checking specified for drawArrays
in
the WebGL 1.0 API is also applied to drawArraysInstanced
in the WebGL 2.0 API.
In the WebGL 2 API, attempting to draw with drawArrays
, drawElements
,
drawRangeElements
or their instanced variants generates an INVALID_OPERATION
error if there is not at least one enabled vertex attribute array that has a divisor of zero and is
bound to an active generic attribute value in the program used for the draw command.
In the WebGL 2 API, attempting to draw with drawArrays
, drawElements
,
drawRangeElements
or their instanced variants generates an INVALID_OPERATION
error if any active uniform block in the program used for the draw command is not backed by a
sufficiently large buffer object.
WebGL always has a default framebuffer. The FRAMEBUFFER_UNDEFINED
enumerant is removed
from the WebGL 2 API.
In the WebGL 2 API, the enumerants ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH
,
TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH
, UNIFORM_BLOCK_NAME_LENGTH
, and
UNIFORM_NAME_LENGTH
are removed in addition to similar
enumerants removed in the WebGL 1.0 API.
In the WebGL 2 API, trying to perform a clear when there is a mismatch between the type of the
specified clear value and the type of a buffer that is being cleared generates an
INVALID_OPERATION
error instead of producing undefined results.
All texture offset values passed to texture lookup functions in GLSL are clamped to the range
between the implementation-defined parameters MIN_PROGRAM_TEXEL_OFFSET
and
MAX_PROGRAM_TEXEL_OFFSET
inclusive.
Texel fetches that have undefined results in the OpenGL ES 3.0 API must return zero, or a texture source color of (0, 0, 0, 1) in the case of a texel fetch from an incomplete texture in the WebGL 2 API.
A fragment shader written in The OpenGL ES Shading Language, Version 1.00, that statically assigns a
value to gl_FragData[n]
where n
does not equal constant value 0 must fail
to compile in the WebGL 2 API. This is to achieve consistency with The OpenGL ES 3.0 specification
section 4.2.1 (OpenGL ES 3.0.3 §4.2.1)
and The OpenGL ES Shading Language 3.00 specification section 1.5 (GLSL ES 3.00 §1.5).
As in the OpenGL ES 3.0 API, multiple fragment shader outputs are only supported for GLSL ES 3.00
shaders in the WebGL 2 API.
The texImage3D
entry point is removed from the WebGL 2.0 API. Defining 3D texture images
is supported with texStorage3D
and compressedTexImage3D
.
texStorage2D
should also be considered a preferred alternative to
texImage2D
, even though texImage2D
is supported in the WebGL 2.0 API.
The MapBufferRange
entry point is removed from the WebGL 2.0 API. The following enum values are removed together with it: BUFFER_ACCESS_FLAGS
, BUFFER_MAP_LENGTH
, BUFFER_MAP_OFFSET
.