When the getContext() method of a canvas element is to return a new object for the contextId webgl2 [CANVASCONTEXTS], the user agent must ...
WebGL2.0Specification
Editor'sDraftSatJan809:58:412022+0800
Thisversion:
https://www.khronos.org/registry/webgl/specs/latest/2.0/
WebIDL:https://www.khronos.org/registry/webgl/specs/latest/2.0/webgl2.idl
Latestversion:
https://www.khronos.org/registry/webgl/specs/latest/2.0/
WebIDL:https://www.khronos.org/registry/webgl/specs/latest/2.0/webgl2.idl
Previousversion:
https://www.khronos.org/registry/webgl/specs/1.0.2/
WebIDL:https://www.khronos.org/registry/webgl/specs/1.0.2/webgl.idl
Editors:
DeanJackson
(AppleInc.)
JeffGilbert
(MozillaCorp.)
Copyright©2015KhronosGroup
Abstract
ThisisVersion2.0oftheWebGLSpecification.
Thisspecificationdescribesanadditionalrenderingcontextandsupport
objectsforthe
HTML5canvaselement[CANVAS].
ThiscontextallowsrenderingusinganAPIthatconformscloselytotheOpenGLES3.0API.
Thisdocumentshouldbereadasanextensiontothe
WebGL1.0specification.Itwillonlydescribethedifferencesfrom1.0.
Statusofthisdocument
Thisdocumentisaneditor'sdraft.Donotcitethisdocumentasotherthanworkin
progress.
Feedback
Publicdiscussionofthisspecificationiswelcomeon
[email protected]
(instructions,archives).
Pleasefilebugsagainstthespecificationoritsconformancetestsin
theissuetracker.Pullrequests
arewelcomeagainsttheGithub
repository.
Tableofcontents
Introduction
WebGL™isanimmediatemode3DrenderingAPIdesignedfortheweb.ThisisVersion2ofthe
WebGLspecification.ItisderivedfromOpenGL®ES3.0,andprovidessimilarrendering
functionality,butinanHTMLcontext.
WebGL2.0isnotentirelybackwardscompatiblewithWebGL1.0.Existingerror-freecontentwritten
againstthecoreWebGL1.0specificationwithoutextensionswilloftenruninWebGL2.0without
modification,butthisisnotalwaysthecase.Allexceptionstobackwardscompatibilityare
recordedintheBackwardsIncompatibilitysection.
Toaccessthenewbehaviorprovidedinthisspecification,thecontentexplicitlyrequests
anewcontext(detailsbelow).
Conventions
ManyfunctionsdescribedinthisdocumentcontainlinkstoOpenGLES
manpages.Whileeveryeffortismadetomakethesepagesmatchthe
OpenGLES3.0specification[GLES30],
theymaycontainerrors.Inthecaseofacontradiction,theOpenGL
ES3.0specificationisthefinalauthority.
Theremainingsectionsofthisdocumentareintendedtobereadinconjunction
withtheOpenGLES3.0specification(3.0.6atthetimeofthiswriting,available
fromtheKhronosOpenGLESAPIRegistry).
Unlessotherwisespecified,thebehaviorofeachmethodisdefinedbythe
OpenGLES3.0specification.ThisspecificationmaydivergefromOpenGLES3.0
inordertoensureinteroperabilityorsecurity,oftendefiningareasthat
OpenGLES3.0leavesimplementation-defined.Thesedifferencesaresummarizedinthe
DifferencesBetweenWebGLandOpenGLES3.0section.
ContextCreationandDrawingBufferPresentation
BeforeusingtheWebGLAPI,theauthormustobtainaWebGLRenderingContext
objectforagivenHTMLCanvasElement[CANVAS]or
OffscreenCanvas[OFFSCREENCANVAS]asdescribed
below.ThisobjectisusedtomanageOpenGLstateandrendertothedrawingbuffer,which
mustbecreatedatthetimeofcontextcreation.
ContextCreation
EachWebGLRenderingContextandWebGL2RenderingContexthasan
associatedcanvas,setuponcreation,whichis
acanvas[CANVAS]oroffscreen
canvas[OFFSCREENCANVAS].
EachWebGLRenderingContextandWebGL2RenderingContexthascontext
creationparameters,setuponcreation,in
aWebGLContextAttributesobject.
EachWebGLRenderingContextandWebGL2RenderingContexthasactual
contextparameters,seteachtimethedrawingbufferiscreated,in
aWebGLContextAttributesobject.
EachWebGLRenderingContextandWebGL2RenderingContexthasawebgl
contextlostflag,whichisinitiallyunset.
WhenthegetContext()methodofacanvaselementistoreturna
newobjectfor
thecontextIdwebgl2[CANVASCONTEXTS],
theuseragentmustperformthefollowingsteps:
CreateanewWebGL2RenderingContextobject,context.
Letcontext'scanvasbethecanvasoroffscreen
canvasthegetContext()methodisassociatedwith.
CreateanewWebGLContextAttributesobject,contextAttributes.
IfgetContext()wasinvokedwithasecondargument,options,set
theattributesofcontextAttributesfromthosespecifiedinoptions.
Createadrawingbufferusingthesettings
specifiedincontextAttributes,andassociatethedrawingbuffer
withcontext.
Ifdrawingbuffercreationfailed,performthefollowingsteps:
FireaWebGLcontextcreation
erroratcanvas.
Returnnullandterminatethesesteps.
CreateanewWebGLContextAttributesobject,actualAttributes.
SettheattributesofactualAttributesbasedonthepropertiesofthenewly
createddrawingbuffer.
Setcontext'scontextcreation
parameterstocontextAttributes.
Setcontext'sactualcontext
parameterstoactualAttributes.
Returncontext.
TheDrawingBuffer
DifferentfromWebGL1.0,thedepth,stencil,and
antialiasattributesinWebGL2.0mustbeobeyedbytheWebGL
implementation.
DOMInterfaces
Thissectiondescribestheinterfacesandfunctionalityaddedtothe
DOMtosupportruntimeaccesstothefunctionalitydescribedabove.
Types
ThefollowingtypesareintroducedinWebGL2.0.
typedeflonglongGLint64;
typedefunsignedlonglongGLuint64;
WebGLQuery
TheWebGLQueryinterfacerepresentsanOpenGLQueryObject.
TheunderlyingobjectiscreatedasifbycallingglGenQueries
(OpenGLES3.0.6§2.14,
manpage)
,
madeactiveasifbycallingglBeginQuery
(OpenGLES3.0.6§2.14,
manpage)
,
concludedasifbycallingglEndQuery
(OpenGLES3.0.6§2.14,
manpage)
anddestroyedasifbycallingglDeleteQueries
(OpenGLES3.0.6§2.14,
manpage)
.
[Exposed=(Window,Worker)]
interfaceWebGLQuery:WebGLObject{
};
WebGLSampler
TheWebGLSamplerinterfacerepresentsanOpenGLSamplerObject.
TheunderlyingobjectiscreatedasifbycallingglGenSamplers
(OpenGLES3.0.6§3.8.2,
manpage)
,
boundasifbycallingglBindSampler
(OpenGLES3.0.6§3.8.2,
manpage)
anddestroyedasifbycallingglDeleteSamplers
(OpenGLES3.0.6§3.8.2,
manpage)
.
[Exposed=(Window,Worker)]
interfaceWebGLSampler:WebGLObject{
};
WebGLSync
TheWebGLSyncinterfacerepresentsanOpenGLSyncObject.
TheunderlyingobjectiscreatedasifbycallingglFenceSync
(OpenGLES3.0.6§5.2,
manpage)
,
blockedonasifbycallingglClientWaitSync
(OpenGLES3.0.6§5.2.1,
manpage)
,
waitedoninternaltoGLasifbycallingglWaitSync
(OpenGLES3.0.6§5.2.1,
manpage)
,
queriedasifbycallingglGetSynciv
(OpenGLES3.0.6§6.1.8,
manpage)
,
anddestroyedasifbycallingglDeleteSync
(OpenGLES3.0.6§5.2,
manpage)
.
[Exposed=(Window,Worker)]
interfaceWebGLSync:WebGLObject{
};
WebGLTransformFeedback
TheWebGLTransformFeedbackinterfacerepresentsanOpenGLTransformFeedbackObject.
TheunderlyingobjectiscreatedasifbycallingglGenTransformFeedbacks
(OpenGLES3.0.6§2.15.1,
manpage)
,
boundasifbycallingglBindTransformFeedback
(OpenGLES3.0.6§2.15.1,
manpage)
anddestroyedasifbycallingglDeleteTransformFeedbacks
(OpenGLES3.0.6§2.15.1,
manpage)
.
[Exposed=(Window,Worker)]
interfaceWebGLTransformFeedback:WebGLObject{
};
WebGLVertexArrayObject
TheWebGLVertexArrayObjectinterfacerepresentsanOpenGLVertexArrayObject.
TheunderlyingobjectiscreatedasifbycallingglGenVertexArrays
(OpenGLES3.0.6§2.10,
manpage)
,
boundasifbycallingglBindVertexArray
(OpenGLES3.0.6§2.10,
manpage)
anddestroyedasifbycallingglDeleteVertexArrays
(OpenGLES3.0.6§2.10,
manpage)
.
[Exposed=(Window,Worker)]
interfaceWebGLVertexArrayObject:WebGLObject{
};
TheWebGLcontext
TheWebGL2RenderingContextrepresentstheAPIallowing
OpenGLES3.0stylerenderingintothecanvaselement.
typedef([AllowShared]Uint32Arrayorsequence)Uint32List;
interfacemixinWebGL2RenderingContextBase
{
constGLenumREAD_BUFFER=0x0C02;
constGLenumUNPACK_ROW_LENGTH=0x0CF2;
constGLenumUNPACK_SKIP_ROWS=0x0CF3;
constGLenumUNPACK_SKIP_PIXELS=0x0CF4;
constGLenumPACK_ROW_LENGTH=0x0D02;
constGLenumPACK_SKIP_ROWS=0x0D03;
constGLenumPACK_SKIP_PIXELS=0x0D04;
constGLenumCOLOR=0x1800;
constGLenumDEPTH=0x1801;
constGLenumSTENCIL=0x1802;
constGLenumRED=0x1903;
constGLenumRGB8=0x8051;
constGLenumRGBA8=0x8058;
constGLenumRGB10_A2=0x8059;
constGLenumTEXTURE_BINDING_3D=0x806A;
constGLenumUNPACK_SKIP_IMAGES=0x806D;
constGLenumUNPACK_IMAGE_HEIGHT=0x806E;
constGLenumTEXTURE_3D=0x806F;
constGLenumTEXTURE_WRAP_R=0x8072;
constGLenumMAX_3D_TEXTURE_SIZE=0x8073;
constGLenumUNSIGNED_INT_2_10_10_10_REV=0x8368;
constGLenumMAX_ELEMENTS_VERTICES=0x80E8;
constGLenumMAX_ELEMENTS_INDICES=0x80E9;
constGLenumTEXTURE_MIN_LOD=0x813A;
constGLenumTEXTURE_MAX_LOD=0x813B;
constGLenumTEXTURE_BASE_LEVEL=0x813C;
constGLenumTEXTURE_MAX_LEVEL=0x813D;
constGLenumMIN=0x8007;
constGLenumMAX=0x8008;
constGLenumDEPTH_COMPONENT24=0x81A6;
constGLenumMAX_TEXTURE_LOD_BIAS=0x84FD;
constGLenumTEXTURE_COMPARE_MODE=0x884C;
constGLenumTEXTURE_COMPARE_FUNC=0x884D;
constGLenumCURRENT_QUERY=0x8865;
constGLenumQUERY_RESULT=0x8866;
constGLenumQUERY_RESULT_AVAILABLE=0x8867;
constGLenumSTREAM_READ=0x88E1;
constGLenumSTREAM_COPY=0x88E2;
constGLenumSTATIC_READ=0x88E5;
constGLenumSTATIC_COPY=0x88E6;
constGLenumDYNAMIC_READ=0x88E9;
constGLenumDYNAMIC_COPY=0x88EA;
constGLenumMAX_DRAW_BUFFERS=0x8824;
constGLenumDRAW_BUFFER0=0x8825;
constGLenumDRAW_BUFFER1=0x8826;
constGLenumDRAW_BUFFER2=0x8827;
constGLenumDRAW_BUFFER3=0x8828;
constGLenumDRAW_BUFFER4=0x8829;
constGLenumDRAW_BUFFER5=0x882A;
constGLenumDRAW_BUFFER6=0x882B;
constGLenumDRAW_BUFFER7=0x882C;
constGLenumDRAW_BUFFER8=0x882D;
constGLenumDRAW_BUFFER9=0x882E;
constGLenumDRAW_BUFFER10=0x882F;
constGLenumDRAW_BUFFER11=0x8830;
constGLenumDRAW_BUFFER12=0x8831;
constGLenumDRAW_BUFFER13=0x8832;
constGLenumDRAW_BUFFER14=0x8833;
constGLenumDRAW_BUFFER15=0x8834;
constGLenumMAX_FRAGMENT_UNIFORM_COMPONENTS=0x8B49;
constGLenumMAX_VERTEX_UNIFORM_COMPONENTS=0x8B4A;
constGLenumSAMPLER_3D=0x8B5F;
constGLenumSAMPLER_2D_SHADOW=0x8B62;
constGLenumFRAGMENT_SHADER_DERIVATIVE_HINT=0x8B8B;
constGLenumPIXEL_PACK_BUFFER=0x88EB;
constGLenumPIXEL_UNPACK_BUFFER=0x88EC;
constGLenumPIXEL_PACK_BUFFER_BINDING=0x88ED;
constGLenumPIXEL_UNPACK_BUFFER_BINDING=0x88EF;
constGLenumFLOAT_MAT2x3=0x8B65;
constGLenumFLOAT_MAT2x4=0x8B66;
constGLenumFLOAT_MAT3x2=0x8B67;
constGLenumFLOAT_MAT3x4=0x8B68;
constGLenumFLOAT_MAT4x2=0x8B69;
constGLenumFLOAT_MAT4x3=0x8B6A;
constGLenumSRGB=0x8C40;
constGLenumSRGB8=0x8C41;
constGLenumSRGB8_ALPHA8=0x8C43;
constGLenumCOMPARE_REF_TO_TEXTURE=0x884E;
constGLenumRGBA32F=0x8814;
constGLenumRGB32F=0x8815;
constGLenumRGBA16F=0x881A;
constGLenumRGB16F=0x881B;
constGLenumVERTEX_ATTRIB_ARRAY_INTEGER=0x88FD;
constGLenumMAX_ARRAY_TEXTURE_LAYERS=0x88FF;
constGLenumMIN_PROGRAM_TEXEL_OFFSET=0x8904;
constGLenumMAX_PROGRAM_TEXEL_OFFSET=0x8905;
constGLenumMAX_VARYING_COMPONENTS=0x8B4B;
constGLenumTEXTURE_2D_ARRAY=0x8C1A;
constGLenumTEXTURE_BINDING_2D_ARRAY=0x8C1D;
constGLenumR11F_G11F_B10F=0x8C3A;
constGLenumUNSIGNED_INT_10F_11F_11F_REV=0x8C3B;
constGLenumRGB9_E5=0x8C3D;
constGLenumUNSIGNED_INT_5_9_9_9_REV=0x8C3E;
constGLenumTRANSFORM_FEEDBACK_BUFFER_MODE=0x8C7F;
constGLenumMAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=0x8C80;
constGLenumTRANSFORM_FEEDBACK_VARYINGS=0x8C83;
constGLenumTRANSFORM_FEEDBACK_BUFFER_START=0x8C84;
constGLenumTRANSFORM_FEEDBACK_BUFFER_SIZE=0x8C85;
constGLenumTRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=0x8C88;
constGLenumRASTERIZER_DISCARD=0x8C89;
constGLenumMAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=0x8C8A;
constGLenumMAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=0x8C8B;
constGLenumINTERLEAVED_ATTRIBS=0x8C8C;
constGLenumSEPARATE_ATTRIBS=0x8C8D;
constGLenumTRANSFORM_FEEDBACK_BUFFER=0x8C8E;
constGLenumTRANSFORM_FEEDBACK_BUFFER_BINDING=0x8C8F;
constGLenumRGBA32UI=0x8D70;
constGLenumRGB32UI=0x8D71;
constGLenumRGBA16UI=0x8D76;
constGLenumRGB16UI=0x8D77;
constGLenumRGBA8UI=0x8D7C;
constGLenumRGB8UI=0x8D7D;
constGLenumRGBA32I=0x8D82;
constGLenumRGB32I=0x8D83;
constGLenumRGBA16I=0x8D88;
constGLenumRGB16I=0x8D89;
constGLenumRGBA8I=0x8D8E;
constGLenumRGB8I=0x8D8F;
constGLenumRED_INTEGER=0x8D94;
constGLenumRGB_INTEGER=0x8D98;
constGLenumRGBA_INTEGER=0x8D99;
constGLenumSAMPLER_2D_ARRAY=0x8DC1;
constGLenumSAMPLER_2D_ARRAY_SHADOW=0x8DC4;
constGLenumSAMPLER_CUBE_SHADOW=0x8DC5;
constGLenumUNSIGNED_INT_VEC2=0x8DC6;
constGLenumUNSIGNED_INT_VEC3=0x8DC7;
constGLenumUNSIGNED_INT_VEC4=0x8DC8;
constGLenumINT_SAMPLER_2D=0x8DCA;
constGLenumINT_SAMPLER_3D=0x8DCB;
constGLenumINT_SAMPLER_CUBE=0x8DCC;
constGLenumINT_SAMPLER_2D_ARRAY=0x8DCF;
constGLenumUNSIGNED_INT_SAMPLER_2D=0x8DD2;
constGLenumUNSIGNED_INT_SAMPLER_3D=0x8DD3;
constGLenumUNSIGNED_INT_SAMPLER_CUBE=0x8DD4;
constGLenumUNSIGNED_INT_SAMPLER_2D_ARRAY=0x8DD7;
constGLenumDEPTH_COMPONENT32F=0x8CAC;
constGLenumDEPTH32F_STENCIL8=0x8CAD;
constGLenumFLOAT_32_UNSIGNED_INT_24_8_REV=0x8DAD;
constGLenumFRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=0x8210;
constGLenumFRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=0x8211;
constGLenumFRAMEBUFFER_ATTACHMENT_RED_SIZE=0x8212;
constGLenumFRAMEBUFFER_ATTACHMENT_GREEN_SIZE=0x8213;
constGLenumFRAMEBUFFER_ATTACHMENT_BLUE_SIZE=0x8214;
constGLenumFRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=0x8215;
constGLenumFRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=0x8216;
constGLenumFRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=0x8217;
constGLenumFRAMEBUFFER_DEFAULT=0x8218;
constGLenumUNSIGNED_INT_24_8=0x84FA;
constGLenumDEPTH24_STENCIL8=0x88F0;
constGLenumUNSIGNED_NORMALIZED=0x8C17;
constGLenumDRAW_FRAMEBUFFER_BINDING=0x8CA6;/*SameasFRAMEBUFFER_BINDING*/
constGLenumREAD_FRAMEBUFFER=0x8CA8;
constGLenumDRAW_FRAMEBUFFER=0x8CA9;
constGLenumREAD_FRAMEBUFFER_BINDING=0x8CAA;
constGLenumRENDERBUFFER_SAMPLES=0x8CAB;
constGLenumFRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=0x8CD4;
constGLenumMAX_COLOR_ATTACHMENTS=0x8CDF;
constGLenumCOLOR_ATTACHMENT1=0x8CE1;
constGLenumCOLOR_ATTACHMENT2=0x8CE2;
constGLenumCOLOR_ATTACHMENT3=0x8CE3;
constGLenumCOLOR_ATTACHMENT4=0x8CE4;
constGLenumCOLOR_ATTACHMENT5=0x8CE5;
constGLenumCOLOR_ATTACHMENT6=0x8CE6;
constGLenumCOLOR_ATTACHMENT7=0x8CE7;
constGLenumCOLOR_ATTACHMENT8=0x8CE8;
constGLenumCOLOR_ATTACHMENT9=0x8CE9;
constGLenumCOLOR_ATTACHMENT10=0x8CEA;
constGLenumCOLOR_ATTACHMENT11=0x8CEB;
constGLenumCOLOR_ATTACHMENT12=0x8CEC;
constGLenumCOLOR_ATTACHMENT13=0x8CED;
constGLenumCOLOR_ATTACHMENT14=0x8CEE;
constGLenumCOLOR_ATTACHMENT15=0x8CEF;
constGLenumFRAMEBUFFER_INCOMPLETE_MULTISAMPLE=0x8D56;
constGLenumMAX_SAMPLES=0x8D57;
constGLenumHALF_FLOAT=0x140B;
constGLenumRG=0x8227;
constGLenumRG_INTEGER=0x8228;
constGLenumR8=0x8229;
constGLenumRG8=0x822B;
constGLenumR16F=0x822D;
constGLenumR32F=0x822E;
constGLenumRG16F=0x822F;
constGLenumRG32F=0x8230;
constGLenumR8I=0x8231;
constGLenumR8UI=0x8232;
constGLenumR16I=0x8233;
constGLenumR16UI=0x8234;
constGLenumR32I=0x8235;
constGLenumR32UI=0x8236;
constGLenumRG8I=0x8237;
constGLenumRG8UI=0x8238;
constGLenumRG16I=0x8239;
constGLenumRG16UI=0x823A;
constGLenumRG32I=0x823B;
constGLenumRG32UI=0x823C;
constGLenumVERTEX_ARRAY_BINDING=0x85B5;
constGLenumR8_SNORM=0x8F94;
constGLenumRG8_SNORM=0x8F95;
constGLenumRGB8_SNORM=0x8F96;
constGLenumRGBA8_SNORM=0x8F97;
constGLenumSIGNED_NORMALIZED=0x8F9C;
constGLenumCOPY_READ_BUFFER=0x8F36;
constGLenumCOPY_WRITE_BUFFER=0x8F37;
constGLenumCOPY_READ_BUFFER_BINDING=0x8F36;/*SameasCOPY_READ_BUFFER*/
constGLenumCOPY_WRITE_BUFFER_BINDING=0x8F37;/*SameasCOPY_WRITE_BUFFER*/
constGLenumUNIFORM_BUFFER=0x8A11;
constGLenumUNIFORM_BUFFER_BINDING=0x8A28;
constGLenumUNIFORM_BUFFER_START=0x8A29;
constGLenumUNIFORM_BUFFER_SIZE=0x8A2A;
constGLenumMAX_VERTEX_UNIFORM_BLOCKS=0x8A2B;
constGLenumMAX_FRAGMENT_UNIFORM_BLOCKS=0x8A2D;
constGLenumMAX_COMBINED_UNIFORM_BLOCKS=0x8A2E;
constGLenumMAX_UNIFORM_BUFFER_BINDINGS=0x8A2F;
constGLenumMAX_UNIFORM_BLOCK_SIZE=0x8A30;
constGLenumMAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=0x8A31;
constGLenumMAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=0x8A33;
constGLenumUNIFORM_BUFFER_OFFSET_ALIGNMENT=0x8A34;
constGLenumACTIVE_UNIFORM_BLOCKS=0x8A36;
constGLenumUNIFORM_TYPE=0x8A37;
constGLenumUNIFORM_SIZE=0x8A38;
constGLenumUNIFORM_BLOCK_INDEX=0x8A3A;
constGLenumUNIFORM_OFFSET=0x8A3B;
constGLenumUNIFORM_ARRAY_STRIDE=0x8A3C;
constGLenumUNIFORM_MATRIX_STRIDE=0x8A3D;
constGLenumUNIFORM_IS_ROW_MAJOR=0x8A3E;
constGLenumUNIFORM_BLOCK_BINDING=0x8A3F;
constGLenumUNIFORM_BLOCK_DATA_SIZE=0x8A40;
constGLenumUNIFORM_BLOCK_ACTIVE_UNIFORMS=0x8A42;
constGLenumUNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=0x8A43;
constGLenumUNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=0x8A44;
constGLenumUNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=0x8A46;
constGLenumINVALID_INDEX=0xFFFFFFFF;
constGLenumMAX_VERTEX_OUTPUT_COMPONENTS=0x9122;
constGLenumMAX_FRAGMENT_INPUT_COMPONENTS=0x9125;
constGLenumMAX_SERVER_WAIT_TIMEOUT=0x9111;
constGLenumOBJECT_TYPE=0x9112;
constGLenumSYNC_CONDITION=0x9113;
constGLenumSYNC_STATUS=0x9114;
constGLenumSYNC_FLAGS=0x9115;
constGLenumSYNC_FENCE=0x9116;
constGLenumSYNC_GPU_COMMANDS_COMPLETE=0x9117;
constGLenumUNSIGNALED=0x9118;
constGLenumSIGNALED=0x9119;
constGLenumALREADY_SIGNALED=0x911A;
constGLenumTIMEOUT_EXPIRED=0x911B;
constGLenumCONDITION_SATISFIED=0x911C;
constGLenumWAIT_FAILED=0x911D;
constGLenumSYNC_FLUSH_COMMANDS_BIT=0x00000001;
constGLenumVERTEX_ATTRIB_ARRAY_DIVISOR=0x88FE;
constGLenumANY_SAMPLES_PASSED=0x8C2F;
constGLenumANY_SAMPLES_PASSED_CONSERVATIVE=0x8D6A;
constGLenumSAMPLER_BINDING=0x8919;
constGLenumRGB10_A2UI=0x906F;
constGLenumINT_2_10_10_10_REV=0x8D9F;
constGLenumTRANSFORM_FEEDBACK=0x8E22;
constGLenumTRANSFORM_FEEDBACK_PAUSED=0x8E23;
constGLenumTRANSFORM_FEEDBACK_ACTIVE=0x8E24;
constGLenumTRANSFORM_FEEDBACK_BINDING=0x8E25;
constGLenumTEXTURE_IMMUTABLE_FORMAT=0x912F;
constGLenumMAX_ELEMENT_INDEX=0x8D6B;
constGLenumTEXTURE_IMMUTABLE_LEVELS=0x82DF;
constGLint64TIMEOUT_IGNORED=-1;
/*WebGL-specificenums*/
constGLenumMAX_CLIENT_WAIT_TIMEOUT_WEBGL=0x9247;
/*Bufferobjects*/
undefinedcopyBufferSubData(GLenumreadTarget,GLenumwriteTarget,GLintptrreadOffset,
GLintptrwriteOffset,GLsizeiptrsize);
//MapBufferRange,inparticularitsread-onlyandwrite-onlymodes,
//cannotbeexposedsafelytoJavaScript.GetBufferSubData
//replacesitforthepurposeoffetchingdatabackfromtheGPU.
undefinedgetBufferSubData(GLenumtarget,GLintptrsrcByteOffset,[AllowShared]ArrayBufferViewdstBuffer,
optionalGLuintdstOffset=0,optionalGLuintlength=0);
/*Framebufferobjects*/
undefinedblitFramebuffer(GLintsrcX0,GLintsrcY0,GLintsrcX1,GLintsrcY1,GLintdstX0,GLintdstY0,
GLintdstX1,GLintdstY1,GLbitfieldmask,GLenumfilter);
undefinedframebufferTextureLayer(GLenumtarget,GLenumattachment,WebGLTexture?texture,GLintlevel,
GLintlayer);
undefinedinvalidateFramebuffer(GLenumtarget,sequenceattachments);
undefinedinvalidateSubFramebuffer(GLenumtarget,sequenceattachments,
GLintx,GLinty,GLsizeiwidth,GLsizeiheight);
undefinedreadBuffer(GLenumsrc);
/*Renderbufferobjects*/
anygetInternalformatParameter(GLenumtarget,GLenuminternalformat,GLenumpname);
undefinedrenderbufferStorageMultisample(GLenumtarget,GLsizeisamples,GLenuminternalformat,
GLsizeiwidth,GLsizeiheight);
/*Textureobjects*/
undefinedtexStorage2D(GLenumtarget,GLsizeilevels,GLenuminternalformat,GLsizeiwidth,
GLsizeiheight);
undefinedtexStorage3D(GLenumtarget,GLsizeilevels,GLenuminternalformat,GLsizeiwidth,
GLsizeiheight,GLsizeidepth);
undefinedtexImage3D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,GLsizeiheight,
GLsizeidepth,GLintborder,GLenumformat,GLenumtype,GLintptrpboOffset);
undefinedtexImage3D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,GLsizeiheight,
GLsizeidepth,GLintborder,GLenumformat,GLenumtype,
TexImageSourcesource);//MaythrowDOMException
undefinedtexImage3D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,GLsizeiheight,
GLsizeidepth,GLintborder,GLenumformat,GLenumtype,[AllowShared]ArrayBufferView?srcData);
undefinedtexImage3D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,GLsizeiheight,
GLsizeidepth,GLintborder,GLenumformat,GLenumtype,[AllowShared]ArrayBufferViewsrcData,
GLuintsrcOffset);
undefinedtexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLintzoffset,
GLsizeiwidth,GLsizeiheight,GLsizeidepth,GLenumformat,GLenumtype,
GLintptrpboOffset);
undefinedtexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLintzoffset,
GLsizeiwidth,GLsizeiheight,GLsizeidepth,GLenumformat,GLenumtype,
TexImageSourcesource);//MaythrowDOMException
undefinedtexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLintzoffset,
GLsizeiwidth,GLsizeiheight,GLsizeidepth,GLenumformat,GLenumtype,
[AllowShared]ArrayBufferView?srcData,optionalGLuintsrcOffset=0);
undefinedcopyTexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLintzoffset,
GLintx,GLinty,GLsizeiwidth,GLsizeiheight);
undefinedcompressedTexImage3D(GLenumtarget,GLintlevel,GLenuminternalformat,GLsizeiwidth,
GLsizeiheight,GLsizeidepth,GLintborder,GLsizeiimageSize,GLintptroffset);
undefinedcompressedTexImage3D(GLenumtarget,GLintlevel,GLenuminternalformat,GLsizeiwidth,
GLsizeiheight,GLsizeidepth,GLintborder,[AllowShared]ArrayBufferViewsrcData,
optionalGLuintsrcOffset=0,optionalGLuintsrcLengthOverride=0);
undefinedcompressedTexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLintzoffset,GLsizeiwidth,GLsizeiheight,GLsizeidepth,
GLenumformat,GLsizeiimageSize,GLintptroffset);
undefinedcompressedTexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLintzoffset,GLsizeiwidth,GLsizeiheight,GLsizeidepth,
GLenumformat,[AllowShared]ArrayBufferViewsrcData,
optionalGLuintsrcOffset=0,
optionalGLuintsrcLengthOverride=0);
/*Programsandshaders*/
[WebGLHandlesContextLoss]GLintgetFragDataLocation(WebGLProgramprogram,DOMStringname);
/*Uniforms*/
undefineduniform1ui(WebGLUniformLocation?location,GLuintv0);
undefineduniform2ui(WebGLUniformLocation?location,GLuintv0,GLuintv1);
undefineduniform3ui(WebGLUniformLocation?location,GLuintv0,GLuintv1,GLuintv2);
undefineduniform4ui(WebGLUniformLocation?location,GLuintv0,GLuintv1,GLuintv2,GLuintv3);
undefineduniform1uiv(WebGLUniformLocation?location,Uint32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform2uiv(WebGLUniformLocation?location,Uint32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform3uiv(WebGLUniformLocation?location,Uint32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform4uiv(WebGLUniformLocation?location,Uint32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniformMatrix3x2fv(WebGLUniformLocation?location,GLbooleantranspose,Float32Listdata,
optionalGLuintsrcOffset=0,optionalGLuintsrcLength=0);
undefineduniformMatrix4x2fv(WebGLUniformLocation?location,GLbooleantranspose,Float32Listdata,
optionalGLuintsrcOffset=0,optionalGLuintsrcLength=0);
undefineduniformMatrix2x3fv(WebGLUniformLocation?location,GLbooleantranspose,Float32Listdata,
optionalGLuintsrcOffset=0,optionalGLuintsrcLength=0);
undefineduniformMatrix4x3fv(WebGLUniformLocation?location,GLbooleantranspose,Float32Listdata,
optionalGLuintsrcOffset=0,optionalGLuintsrcLength=0);
undefineduniformMatrix2x4fv(WebGLUniformLocation?location,GLbooleantranspose,Float32Listdata,
optionalGLuintsrcOffset=0,optionalGLuintsrcLength=0);
undefineduniformMatrix3x4fv(WebGLUniformLocation?location,GLbooleantranspose,Float32Listdata,
optionalGLuintsrcOffset=0,optionalGLuintsrcLength=0);
/*Vertexattribs*/
undefinedvertexAttribI4i(GLuintindex,GLintx,GLinty,GLintz,GLintw);
undefinedvertexAttribI4iv(GLuintindex,Int32Listvalues);
undefinedvertexAttribI4ui(GLuintindex,GLuintx,GLuinty,GLuintz,GLuintw);
undefinedvertexAttribI4uiv(GLuintindex,Uint32Listvalues);
undefinedvertexAttribIPointer(GLuintindex,GLintsize,GLenumtype,GLsizeistride,GLintptroffset);
/*Writingtothedrawingbuffer*/
undefinedvertexAttribDivisor(GLuintindex,GLuintdivisor);
undefineddrawArraysInstanced(GLenummode,GLintfirst,GLsizeicount,GLsizeiinstanceCount);
undefineddrawElementsInstanced(GLenummode,GLsizeicount,GLenumtype,GLintptroffset,GLsizeiinstanceCount);
undefineddrawRangeElements(GLenummode,GLuintstart,GLuintend,GLsizeicount,GLenumtype,GLintptroffset);
/*MultipleRenderTargets*/
undefineddrawBuffers(sequencebuffers);
undefinedclearBufferfv(GLenumbuffer,GLintdrawbuffer,Float32Listvalues,
optionalGLuintsrcOffset=0);
undefinedclearBufferiv(GLenumbuffer,GLintdrawbuffer,Int32Listvalues,
optionalGLuintsrcOffset=0);
undefinedclearBufferuiv(GLenumbuffer,GLintdrawbuffer,Uint32Listvalues,
optionalGLuintsrcOffset=0);
undefinedclearBufferfi(GLenumbuffer,GLintdrawbuffer,GLfloatdepth,GLintstencil);
/*QueryObjects*/
WebGLQuery?createQuery();
undefineddeleteQuery(WebGLQuery?query);
[WebGLHandlesContextLoss]GLbooleanisQuery(WebGLQuery?query);
undefinedbeginQuery(GLenumtarget,WebGLQueryquery);
undefinedendQuery(GLenumtarget);
WebGLQuery?getQuery(GLenumtarget,GLenumpname);
anygetQueryParameter(WebGLQueryquery,GLenumpname);
/*SamplerObjects*/
WebGLSampler?createSampler();
undefineddeleteSampler(WebGLSampler?sampler);
[WebGLHandlesContextLoss]GLbooleanisSampler(WebGLSampler?sampler);
undefinedbindSampler(GLuintunit,WebGLSampler?sampler);
undefinedsamplerParameteri(WebGLSamplersampler,GLenumpname,GLintparam);
undefinedsamplerParameterf(WebGLSamplersampler,GLenumpname,GLfloatparam);
anygetSamplerParameter(WebGLSamplersampler,GLenumpname);
/*Syncobjects*/
WebGLSync?fenceSync(GLenumcondition,GLbitfieldflags);
[WebGLHandlesContextLoss]GLbooleanisSync(WebGLSync?sync);
undefineddeleteSync(WebGLSync?sync);
GLenumclientWaitSync(WebGLSyncsync,GLbitfieldflags,GLuint64timeout);
undefinedwaitSync(WebGLSyncsync,GLbitfieldflags,GLint64timeout);
anygetSyncParameter(WebGLSyncsync,GLenumpname);
/*TransformFeedback*/
WebGLTransformFeedback?createTransformFeedback();
undefineddeleteTransformFeedback(WebGLTransformFeedback?tf);
[WebGLHandlesContextLoss]GLbooleanisTransformFeedback(WebGLTransformFeedback?tf);
undefinedbindTransformFeedback(GLenumtarget,WebGLTransformFeedback?tf);
undefinedbeginTransformFeedback(GLenumprimitiveMode);
undefinedendTransformFeedback();
undefinedtransformFeedbackVaryings(WebGLProgramprogram,sequencevaryings,GLenumbufferMode);
WebGLActiveInfo?getTransformFeedbackVarying(WebGLProgramprogram,GLuintindex);
undefinedpauseTransformFeedback();
undefinedresumeTransformFeedback();
/*UniformBufferObjectsandTransformFeedbackBuffers*/
undefinedbindBufferBase(GLenumtarget,GLuintindex,WebGLBuffer?buffer);
undefinedbindBufferRange(GLenumtarget,GLuintindex,WebGLBuffer?buffer,GLintptroffset,GLsizeiptrsize);
anygetIndexedParameter(GLenumtarget,GLuintindex);
sequence?getUniformIndices(WebGLProgramprogram,sequenceuniformNames);
anygetActiveUniforms(WebGLProgramprogram,sequenceuniformIndices,GLenumpname);
GLuintgetUniformBlockIndex(WebGLProgramprogram,DOMStringuniformBlockName);
anygetActiveUniformBlockParameter(WebGLProgramprogram,GLuintuniformBlockIndex,GLenumpname);
DOMString?getActiveUniformBlockName(WebGLProgramprogram,GLuintuniformBlockIndex);
undefineduniformBlockBinding(WebGLProgramprogram,GLuintuniformBlockIndex,GLuintuniformBlockBinding);
/*VertexArrayObjects*/
WebGLVertexArrayObject?createVertexArray();
undefineddeleteVertexArray(WebGLVertexArrayObject?vertexArray);
[WebGLHandlesContextLoss]GLbooleanisVertexArray(WebGLVertexArrayObject?vertexArray);
undefinedbindVertexArray(WebGLVertexArrayObject?array);
};
interfacemixinWebGL2RenderingContextOverloads
{
//WebGL1:
undefinedbufferData(GLenumtarget,GLsizeiptrsize,GLenumusage);
undefinedbufferData(GLenumtarget,[AllowShared]BufferSource?srcData,GLenumusage);
undefinedbufferSubData(GLenumtarget,GLintptrdstByteOffset,[AllowShared]BufferSourcesrcData);
//WebGL2:
undefinedbufferData(GLenumtarget,[AllowShared]ArrayBufferViewsrcData,GLenumusage,GLuintsrcOffset,
optionalGLuintlength=0);
undefinedbufferSubData(GLenumtarget,GLintptrdstByteOffset,[AllowShared]ArrayBufferViewsrcData,
GLuintsrcOffset,optionalGLuintlength=0);
//WebGL1legacyentrypoints:
undefinedtexImage2D(GLenumtarget,GLintlevel,GLintinternalformat,
GLsizeiwidth,GLsizeiheight,GLintborder,GLenumformat,
GLenumtype,[AllowShared]ArrayBufferView?pixels);
undefinedtexImage2D(GLenumtarget,GLintlevel,GLintinternalformat,
GLenumformat,GLenumtype,TexImageSourcesource);//MaythrowDOMException
undefinedtexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLsizeiwidth,GLsizeiheight,
GLenumformat,GLenumtype,[AllowShared]ArrayBufferView?pixels);
undefinedtexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLenumformat,GLenumtype,TexImageSourcesource);//MaythrowDOMException
//WebGL2entrypoints:
undefinedtexImage2D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,GLsizeiheight,
GLintborder,GLenumformat,GLenumtype,GLintptrpboOffset);
undefinedtexImage2D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,GLsizeiheight,
GLintborder,GLenumformat,GLenumtype,
TexImageSourcesource);//MaythrowDOMException
undefinedtexImage2D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,GLsizeiheight,
GLintborder,GLenumformat,GLenumtype,[AllowShared]ArrayBufferViewsrcData,
GLuintsrcOffset);
undefinedtexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLsizeiwidth,
GLsizeiheight,GLenumformat,GLenumtype,GLintptrpboOffset);
undefinedtexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLsizeiwidth,
GLsizeiheight,GLenumformat,GLenumtype,
TexImageSourcesource);//MaythrowDOMException
undefinedtexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLsizeiwidth,
GLsizeiheight,GLenumformat,GLenumtype,[AllowShared]ArrayBufferViewsrcData,
GLuintsrcOffset);
undefinedcompressedTexImage2D(GLenumtarget,GLintlevel,GLenuminternalformat,GLsizeiwidth,
GLsizeiheight,GLintborder,GLsizeiimageSize,GLintptroffset);
undefinedcompressedTexImage2D(GLenumtarget,GLintlevel,GLenuminternalformat,GLsizeiwidth,
GLsizeiheight,GLintborder,[AllowShared]ArrayBufferViewsrcData,
optionalGLuintsrcOffset=0,optionalGLuintsrcLengthOverride=0);
undefinedcompressedTexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLsizeiwidth,GLsizeiheight,GLenumformat,GLsizeiimageSize,GLintptroffset);
undefinedcompressedTexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLsizeiwidth,GLsizeiheight,GLenumformat,
[AllowShared]ArrayBufferViewsrcData,
optionalGLuintsrcOffset=0,
optionalGLuintsrcLengthOverride=0);
undefineduniform1fv(WebGLUniformLocation?location,Float32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform2fv(WebGLUniformLocation?location,Float32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform3fv(WebGLUniformLocation?location,Float32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform4fv(WebGLUniformLocation?location,Float32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform1iv(WebGLUniformLocation?location,Int32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform2iv(WebGLUniformLocation?location,Int32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform3iv(WebGLUniformLocation?location,Int32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniform4iv(WebGLUniformLocation?location,Int32Listdata,optionalGLuintsrcOffset=0,
optionalGLuintsrcLength=0);
undefineduniformMatrix2fv(WebGLUniformLocation?location,GLbooleantranspose,Float32Listdata,
optionalGLuintsrcOffset=0,optionalGLuintsrcLength=0);
undefineduniformMatrix3fv(WebGLUniformLocation?location,GLbooleantranspose,Float32Listdata,
optionalGLuintsrcOffset=0,optionalGLuintsrcLength=0);
undefineduniformMatrix4fv(WebGLUniformLocation?location,GLbooleantranspose,Float32Listdata,
optionalGLuintsrcOffset=0,optionalGLuintsrcLength=0);
/*Readingbackpixels*/
//WebGL1:
undefinedreadPixels(GLintx,GLinty,GLsizeiwidth,GLsizeiheight,GLenumformat,GLenumtype,
[AllowShared]ArrayBufferView?dstData);
//WebGL2:
undefinedreadPixels(GLintx,GLinty,GLsizeiwidth,GLsizeiheight,GLenumformat,GLenumtype,
GLintptroffset);
undefinedreadPixels(GLintx,GLinty,GLsizeiwidth,GLsizeiheight,GLenumformat,GLenumtype,
[AllowShared]ArrayBufferViewdstData,GLuintdstOffset);
};
[Exposed=(Window,Worker)]
interfaceWebGL2RenderingContext
{
};
WebGL2RenderingContextincludesWebGLRenderingContextBase;
WebGL2RenderingContextincludesWebGL2RenderingContextBase;
WebGL2RenderingContextincludesWebGL2RenderingContextOverloads;
Morebindingpoints
voidbindBuffer(GLenumtarget,WebGLBuffer?buffer)
(OpenGLES3.0.6§2.10.1,
manpage)
BindsthegivenWebGLBufferobjecttothegivenbindingpoint(target).targetisgiveninthefollowingtable:
target
ARRAY_BUFFER
COPY_READ_BUFFER
COPY_WRITE_BUFFER
ELEMENT_ARRAY_BUFFER
PIXEL_PACK_BUFFER
PIXEL_UNPACK_BUFFER
TRANSFORM_FEEDBACK_BUFFER
UNIFORM_BUFFER
Iftargetisnotinthetableabove,generatesanINVALID_ENUMerror.
RefertoBufferObjectBindingrestrictionsbelow.
voidbindFramebuffer(GLenumtarget,WebGLFramebuffer?framebuffer)
(OpenGLES3.0.6§4.4.1,
manpage)
BindsthegivenWebGLFramebufferobjecttothegivenbindingpoint(target).targetisgiveninthefollowingtable:
target
FRAMEBUFFER
READ_FRAMEBUFFER
DRAW_FRAMEBUFFER
Iftargetisnotinthetableabove,generatesanINVALID_ENUMerror.
voidbindTexture(GLenumtarget,WebGLTexture?texture)
(OpenGLES3.0.6§3.8.1,
manpage)
BindsthegivenWebGLTextureobjecttothegivenbindingpoint(target).targetisgiveninthefollowingtable:
target
TEXTURE_2D
TEXTURE_3D
TEXTURE_2D_ARRAY
TEXTURE_CUBE_MAP
Iftargetisnotinthetableabove,generatesanINVALID_ENUMerror.
Settingandgettingstate
anygetParameter(GLenumpname)
(OpenGLES3.0.6§6.1.1,
glGetOpenGLES3.0manpage,
glGetStringOpenGLES3.0manpage)
Returnthevalueforthepassedpname.Aswellassupportingall
thepname/typevaluesfromWebGL1.0,thefollowingparametersaresupported:
pnamereturnedtype
COPY_READ_BUFFER_BINDINGWebGLBuffer
COPY_WRITE_BUFFER_BINDINGWebGLBuffer
DRAW_BUFFERiGLenum
DRAW_FRAMEBUFFER_BINDINGWebGLFramebuffer
FRAGMENT_SHADER_DERIVATIVE_HINTGLenum
MAX_3D_TEXTURE_SIZEGLint
MAX_ARRAY_TEXTURE_LAYERSGLint
MAX_CLIENT_WAIT_TIMEOUT_WEBGLGLint64
MAX_COLOR_ATTACHMENTSGLint
MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTSGLint64
MAX_COMBINED_UNIFORM_BLOCKSGLint
MAX_COMBINED_VERTEX_UNIFORM_COMPONENTSGLint64
MAX_DRAW_BUFFERSGLint
MAX_ELEMENT_INDEXGLint64
MAX_ELEMENTS_INDICESGLint
MAX_ELEMENTS_VERTICESGLint
MAX_FRAGMENT_INPUT_COMPONENTSGLint
MAX_FRAGMENT_UNIFORM_BLOCKSGLint
MAX_FRAGMENT_UNIFORM_COMPONENTSGLint
MAX_PROGRAM_TEXEL_OFFSETGLint
MAX_SAMPLESGLint
MAX_SERVER_WAIT_TIMEOUTGLint64
MAX_TEXTURE_LOD_BIASGLfloat
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTSGLint
MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBSGLint
MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTSGLint
MAX_UNIFORM_BLOCK_SIZEGLint64
MAX_UNIFORM_BUFFER_BINDINGSGLint
MAX_VARYING_COMPONENTSGLint
MAX_VERTEX_OUTPUT_COMPONENTSGLint
MAX_VERTEX_UNIFORM_BLOCKSGLint
MAX_VERTEX_UNIFORM_COMPONENTSGLint
MIN_PROGRAM_TEXEL_OFFSETGLint
PACK_ROW_LENGTHGLint
PACK_SKIP_PIXELSGLint
PACK_SKIP_ROWSGLint
PIXEL_PACK_BUFFER_BINDINGWebGLBuffer
PIXEL_UNPACK_BUFFER_BINDINGWebGLBuffer
RASTERIZER_DISCARDGLboolean
READ_BUFFERGLenum
READ_FRAMEBUFFER_BINDINGWebGLFramebuffer
SAMPLER_BINDINGWebGLSampler
TEXTURE_BINDING_2D_ARRAYWebGLTexture
TEXTURE_BINDING_3DWebGLTexture
TRANSFORM_FEEDBACK_ACTIVEGLboolean
TRANSFORM_FEEDBACK_BINDINGWebGLTransformFeedback
TRANSFORM_FEEDBACK_BUFFER_BINDINGWebGLBuffer
TRANSFORM_FEEDBACK_PAUSEDGLboolean
UNIFORM_BUFFER_BINDINGWebGLBuffer
UNIFORM_BUFFER_OFFSET_ALIGNMENTGLint
UNPACK_IMAGE_HEIGHTGLint
UNPACK_ROW_LENGTHGLint
UNPACK_SKIP_IMAGESGLint
UNPACK_SKIP_PIXELSGLint
UNPACK_SKIP_ROWSGLint
VERTEX_ARRAY_BINDINGWebGLVertexArrayObject
Allqueriesreturningsequencesortypedarraysreturnanewobjecteachtime.
IfpnameisnotinthetableaboveandisnotoneofparameternamessupportedbyWebGL1.0,generatesanINVALID_ENUMerrorandreturnsnull.
ThefollowingpnameargumentsreturnastringdescribingsomeaspectofthecurrentWebGLimplementation:
VERSION
ReturnsaversionorreleasenumberoftheformWebGL2.0.
SHADING_LANGUAGE_VERSION
ReturnsaversionorreleasenumberoftheformWebGLGLSLES3.00.
ForRED_BITS,GREEN_BITS,BLUE_BITS,andALPHA_BITS,ifactivecolorattachmentsofthedrawframebufferdonothaveidenticalformats,generatesanINVALID_OPERATIONerrorandreturns0.
anygetIndexedParameter(GLenumtarget,GLuintindex)
(OpenGLES3.0.6§6.1.1,
glGetOpenGLES3.0manpage)
Returntheindexedvalueforthepassedtarget.Thetypereturnedisthenaturaltypefortherequestedpname,
asgiveninthefollowingtable:
targetreturnedtype
TRANSFORM_FEEDBACK_BUFFER_BINDINGWebGLBuffer
TRANSFORM_FEEDBACK_BUFFER_SIZEGLsizeiptr
TRANSFORM_FEEDBACK_BUFFER_STARTGLintptr
UNIFORM_BUFFER_BINDINGWebGLBuffer
UNIFORM_BUFFER_SIZEGLsizeiptr
UNIFORM_BUFFER_STARTGLintptr
Iftargetisnotinthetableabove,generatesanINVALID_ENUMerror.
Ifindexisoutsideofthevalidrangefortheindexedstatetarget,generatesanINVALID_VALUEerror.
IfanOpenGLerrorisgenerated,returnsnull.
GLbooleanisEnabled(GLenumcap)
(OpenGLES3.0.6§6.1.1,
OpenGLES3.0manpage)
InadditiontoallofthecapvaluesfromWebGL1.0,RASTERIZER_DISCARDissupported.
voidpixelStorei(GLenumpname,GLintparam)
(OpenGLES3.0.6§3.7.1,
OpenGLES3.0manpage)
InadditiontotheparametersfromWebGL1.0,theWebGL2.0specificationacceptsthefollowingextraparameters:
pname
PACK_ROW_LENGTH
PACK_SKIP_PIXELS
PACK_SKIP_ROWS
UNPACK_ROW_LENGTH
UNPACK_IMAGE_HEIGHT
UNPACK_SKIP_PIXELS
UNPACK_SKIP_ROWS
UNPACK_SKIP_IMAGES
Bufferobjects
voidbufferData(GLenumtarget,[AllowShared]ArrayBufferViewsrcData,GLenumusage,GLuintsrcOffset,optionalGLuintlength=0);
(OpenGLES3.0.6§2.10.2,
manpage)
SetthesizeofthecurrentlyboundWebGLBufferobject,thencopyasub-regionofsrcDatatothebufferobject.
Letbufbethebufferboundtotarget.
Iflengthis0:
IfsrcDataisaDataView,letcopyLengthbesrcData.byteLength-srcOffset;thetypedelementsinthetextbelowarebytes.
Otherwise,letcopyLengthbesrcData.length-srcOffset.
Otherwise,letcopyLengthbelength.
IfsrcDataisaDataView,setthesizeofbuftocopyLength;otherwise,setthesizeofbuftocopyLength*srcData.BYTES_PER_ELEMENT.
IfsrcDataisaDataView,letelementSizebe1;otherwise,letelementSizebesrcData.BYTES_PER_ELEMENT.
IfcopyLengthisgreaterthanzero,copycopyLengthtypedelements
(eachofsizeelementSize)fromsrcDataintobuf,
readingsrcDatastartingatelementindexsrcOffset.
IfcopyLengthis0,nodataiswrittentobuf,butthisdoes
notcauseaGLerrortobegenerated.
IfnoWebGLBufferisboundtotarget,generatesanINVALID_OPERATIONerror.
IfsrcOffsetisgreaterthansrcData.length(orsrcData.byteLengthforDataView),generatesanINVALID_VALUEerror.
IfsrcOffset+copyLengthisgreaterthansrcData.length(orsrcData.byteLengthforDataView),generatesanINVALID_VALUEerror.
Ifanyerrorisgenerated,buf'ssizeisunmodified,andnodataiswrittentoit.
voidbufferSubData(GLenumtarget,GLintptrdstByteOffset,[AllowShared]ArrayBufferViewsrcData,GLuintsrcOffset,optionalGLuintlength=0);
(OpenGLES3.0.6§2.10.2,
manpage)
Copyasub-regionofsrcDatatothecurrentlyboundWebGLBufferobject.
Letbufbethebufferboundtotarget.
Iflengthis0:
IfsrcDataisaDataView,letcopyLengthbesrcData.byteLength-srcOffset;thetypedelementsinthetextbelowarebytes.
Otherwise,letcopyLengthbesrcData.length-srcOffset.
Otherwise,letcopyLengthbelength.
IfsrcDataisaDataView,letcopyByteLengthbecopyLength;otherwise,letcopyByteLengthbecopyLength*srcData.BYTES_PER_ELEMENT.
IfsrcDataisaDataView,letelementSizebe1;otherwise,letelementSizebesrcData.BYTES_PER_ELEMENT.
IfcopyLengthisgreaterthanzero,copycopyLengthtypedelements
(eachofsizeelementSize)fromsrcDataintobuf,
readingsrcDatastartingatelementindexsrcOffset,and
writingbufstartingatbyteoffsetdstByteOffset.
IfcopyLengthis0,nodataiswrittentobuf,butthisdoes
notcauseaGLerrortobegenerated.
IfnoWebGLBufferisboundtotarget,generatesanINVALID_OPERATIONerror.
IfdstByteOffsetislessthanzero,generatesanINVALID_VALUEerror.
IfdstByteOffset+copyByteLengthisgreaterthanthesizeofbuf,generatesanINVALID_VALUEerror.
IfsrcOffsetisgreaterthansrcData.length(orsrcData.byteLengthforDataView),generatesanINVALID_VALUEerror.
IfsrcOffset+copyLengthisgreaterthansrcData.length(orsrcData.byteLengthforDataView),generatesanINVALID_VALUEerror.
Ifanyerrorisgenerated,nodataiswrittentobuf.
anygetBufferParameter(GLenumtarget,GLenumpname)
(OpenGLES3.0.6§6.1.9,
manpage)
Returnthevalueforthepassedpname.InadditiontosupportingqueryingwiththepnameBUFFER_USAGE
asinWebGL1.0,queryingwiththepnameBUFFER_SIZEreturnsthebuffersizeasavalueoftype
GLsizeiptr.
voidcopyBufferSubData(GLenumreadTarget,GLenumwriteTarget,GLintptrreadOffset,GLintptrwriteOffset,GLsizeiptrsize)
(OpenGLES3.0.6§2.10.5,
manpage)
CopypartofthedataofthebufferboundtoreadTargettothebufferboundtowriteTarget.
SeeCopyingBuffersforrestrictionsimposedbytheWebGL2.0API.
undefinedgetBufferSubData(GLenumtarget,GLintptrsrcByteOffset,
[AllowShared]ArrayBufferViewdstBuffer,
optionalGLuintdstOffset=0,
optionalGLuintlength=0)
ReadsbackdatafromtheboundWebGLBufferintodstBuffer.
Letbufbethebufferboundtotarget.
Iflengthis0:
IfdstBufferisaDataView,letcopyLengthbedstBuffer.byteLength-dstOffset;thetypedelementsinthetextbelowarebytes.
Otherwise,letcopyLengthbedstBuffer.length-dstOffset.
Otherwise,letcopyLengthbelength.
IfdstBufferisaDataView,letcopyByteLengthbecopyLength;otherwise,letcopyByteLengthbecopyLength*dstBuffer.BYTES_PER_ELEMENT.
IfdstBufferisaDataView,letelementSizebe1;otherwise,letelementSizebedstBuffer.BYTES_PER_ELEMENT.
IfcopyLengthisgreaterthanzero,
copycopyLengthtypedelements(eachofsizeelementSize)
frombufintodstBuffer,
readingbufstartingatbyteindexsrcByteOffsetand
writingintodstBufferstartingatelementindexdstOffset.
IfcopyLengthis0,nodataiswrittentodstBuffer,but
thisdoesnotcauseaGLerrortobegenerated.
IfnoWebGLBufferisboundtotarget,
generatesanINVALID_OPERATIONerror.
IftargetisTRANSFORM_FEEDBACK_BUFFER,
andanytransformfeedbackobjectiscurrentlyactive,
generatesanINVALID_OPERATIONerror.
IfdstOffsetisgreaterthandstBuffer.length
(ordstBuffer.byteLengthinthecaseofDataView),generates
anINVALID_VALUEerror.
IfdstOffset+copyLengthisgreaterthandstBuffer.length
(ordstBuffer.byteLengthinthecaseofDataView),generates
anINVALID_VALUEerror.
IfsrcByteOffsetislessthanzero,
generatesanINVALID_VALUEerror.
IfsrcByteOffset+copyByteLengthisgreaterthanthesize
ofbuf,generatesanINVALID_OPERATIONerror.
Ifanyerrorisgenerated,nodataiswrittentodstBuffer.
IfthebufferiswrittenandreadsequentiallybyotheroperationsandgetBufferSubData,
itistheresponsibilityoftheWebGLAPItoensurethatdataareaccessedconsistently.Thisapplies
evenifthebufferiscurrentlyboundtoatransformfeedbackbindingpoint.
Thisisablockingoperation,asWebGLmustcompletelyfinishall
previouswritesintothesourcebufferinordertoreturnaresult.
Inmulti-processWebGLimplementations,getBufferSubData
canalsoincuranexpensiveinter-processround-triptofetchthe
resultfromtheremoteprocess.
Theusermaybeabletoavoidthesecostsbysignallingintentto
readbackfromthebuffer:
InsertafenceSyncafterwritingtothesource
buffer,andwaitforittopassbeforeperformingthe
getBufferSubDataoperation.
Allocatebufferswitha_READusagehintiftheyare
tobeusedasareadbacksource.(Avoidoveruseofbuffers
allocatedwith_READusagehints,astheymayincur
overheadinmaintainingashadowcopyofthebufferdata.)
Framebufferobjects
[WebGLHandlesContextLoss]GLenumcheckFramebufferStatus(GLenumtarget)
(OpenGLES3.0.6§4.4.4.2,
manpage)
OnlydifferencesfromcheckFramebufferStatusinWebGL1.0aredescribedhere.
targetmustbeDRAW_FRAMEBUFFER,READ_FRAMEBUFFERorFRAMEBUFFER.FRAMEBUFFERisequivalenttoDRAW_FRAMEBUFFER.
ReturnsFRAMEBUFFER_UNSUPPORTEDifdepthandstencilattachments,ifpresent,arenotthesameimage.SeeFramebufferObjectAttachmentsfordetaileddiscussion.
ReturnsFRAMEBUFFER_INCOMPLETE_MULTISAMPLEifthevaluesofRENDERBUFFER_SAMPLESaredifferentamongattachedrenderbuffers,orarenon-zeroiftheattachedimagesareamixofrenderbuffersandtextures.
ReturnsFRAMEBUFFER_INCOMPLETE_DIMENSIONSifattachedimageshavedifferentwidth,height,anddepth(for3Dtextures)orarraysize(for2Darraytextures).SeecheckFramebufferStatusmayreturnFRAMEBUFFER_INCOMPLETE_DIMENSIONS.
ReturnsFRAMEBUFFER_UNSUPPORTEDifthesameimageisattachedtomorethanonecolor
attachmentpoint.SeeFramebuffercolorattachments.
anygetFramebufferAttachmentParameter(GLenumtarget,GLenumattachment,GLenumpname)
(OpenGLES3.0.6§6.1.13,
similartoglGetFramebufferAttachmentParameteriv)
Returnthevalueforthepassedpnamegiventhepassedtargetandattachment.Thetype
returnedisthenaturaltypefortherequestedpname,asgiveninthefollowingtable:
pnamereturnedtype
FRAMEBUFFER_ATTACHMENT_ALPHA_SIZEGLint
FRAMEBUFFER_ATTACHMENT_BLUE_SIZEGLint
FRAMEBUFFER_ATTACHMENT_COLOR_ENCODINGGLenum
FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPEGLenum
FRAMEBUFFER_ATTACHMENT_DEPTH_SIZEGLint
FRAMEBUFFER_ATTACHMENT_GREEN_SIZEGLint
FRAMEBUFFER_ATTACHMENT_OBJECT_NAMEWebGLRenderbufferorWebGLTexture
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPEGLenum
FRAMEBUFFER_ATTACHMENT_RED_SIZEGLint
FRAMEBUFFER_ATTACHMENT_STENCIL_SIZEGLint
FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACEGLint
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYERGLint
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVELGLint
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
IfanOpenGLerrorisgenerated,returnsnull.
IfattachmentisDEPTH_STENCIL_ATTACHMENTanddifferentimagesareattachedtothedepthandstencilattachmentpoints,generatesanINVALID_OPERATIONerror.SeeFramebufferObjectAttachmentsfordetaileddiscussion.
voidblitFramebuffer(GLintsrcX0,GLintsrcY0,GLintsrcX1,GLintsrcY1,GLintdstX0,GLintdstY0,GLintdstX1,GLintdstY1,GLbitfieldmask,GLenumfilter)
(OpenGLES3.0.6§4.3.3,
manpage)
Transferarectangleofpixelvaluesfromoneregionofthereadframebuffertoanotherinthedraw
framebuffer.IfthevalueofSAMPLE_BUFFERSforthereadframebufferisoneandthevalueof
SAMPLE_BUFFERSforthedrawframebufferiszero,thesamplescorrespondingtoeachpixellocationin
thesourceareconvertedtoasinglesamplebeforebeingwrittentothedestination.
Anydistinationpixelwho'scentercorrespondstoapointoutsidethesourcebufferremainuntouched.
WhenblittingtothecolorattachmentoftheWebGLcontext'sdefaultbackbuffer,acontext
createdwithalpha:falseisconsideredtohaveinternal
formatRGB8,whileacontextcreatedwithalpha:trueisconsidered
tohaveinternalformatRGBA8.
Ifthisfunctionattemptstoblittoamissingattachmentofacompleteframebuffer,nothingis
blittedtothatattachmentandnoerrorisgenerated
perDrawingtoaMissingAttachment.
Ifthisfunctionattemptstoreadfromamissingattachmentofacompleteframebuffer,andatleastone
drawbufferhasanimagetobeblitted,anINVALID_OPERATIONerrorisgenerated
perReadingfromaMissingAttachment.
voidframebufferTextureLayer(GLenumtarget,GLenumattachment,WebGLTexture?texture,GLintlevel,GLintlayer)
(OpenGLES3.0.6§4.4.2.4,
manpage)
IftexturewasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
voidinvalidateFramebuffer(GLenumtarget,sequenceattachments)
(OpenGLES3.0.6§4.5,
manpage)
EquivalenttocallinginvalidateSubFramebufferwithxandy
setto0andwidthandheightsettothelargestframebufferobject's
attachments'widthandheight.
voidinvalidateSubFramebuffer(GLenumtarget,sequenceattachments,GLintx,GLinty,GLsizeiwidth,GLsizeiheight)
(OpenGLES3.0.6§4.5,
manpage)
SignaltheGLthatitneednotpreserveallcontentsofaboundframebufferobject.
voidreadBuffer(GLenumsrc)
(OpenGLES3.0.6§4.3.1,
manpage)
Specifyacolorbufferofthereadframebufferasthereadbuffer.
Renderbufferobjects
anygetInternalformatParameter(GLenumtarget,GLenuminternalformat,GLenumpname)
(OpenGLES3.0.6§6.1.15,
manpage)
Returnthevalueforthepassedpnamegiventhepassedtargetandinternalformat.Thetype
returnedisgiveninthefollowingtable:
pnamereturnedtype
SAMPLESInt32Array
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
IfanOpenGLerrorisgenerated,returnsnull.
EachqueryforSAMPLESreturnsanewtypedarrayobjectinstance.
anygetRenderbufferParameter(GLenumtarget,GLenumpname)
(OpenGLES2.0§6.1.14,
similartoglGetRenderbufferParameteriv)
Returnthevalueforthepassedpnamegiventhepassedtarget.Thetypereturnedisthenatural
typefortherequestedpname,asgiveninthefollowingtable:
pnamereturnedtype
RENDERBUFFER_WIDTHGLint
RENDERBUFFER_HEIGHTGLint
RENDERBUFFER_INTERNAL_FORMATGLenum
RENDERBUFFER_RED_SIZEGLint
RENDERBUFFER_GREEN_SIZEGLint
RENDERBUFFER_BLUE_SIZEGLint
RENDERBUFFER_ALPHA_SIZEGLint
RENDERBUFFER_DEPTH_SIZEGLint
RENDERBUFFER_SAMPLESGLint
RENDERBUFFER_STENCIL_SIZEGLint
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
IfanOpenGLerrorisgenerated,returnsnull.
voidrenderbufferStorage(GLenumtarget,GLenuminternalformat,GLsizeiwidth,GLsizeiheight)
(OpenGLES3.0.6§4.4.2.1,
manpage)
AcceptsinternalformatsfromOpenGLES3.0asdetailedinthespecificationandmanpage.
TobebackwardcompatiblewithWebGL1,alsoacceptsinternalformatDEPTH_STENCIL,whichshouldbemappedtoDEPTH24_STENCIL8byimplementations.
voidrenderbufferStorageMultisample(GLenumtarget,GLsizeisamples,GLenuminternalformat,GLsizeiwidth,GLsizeiheight)
(OpenGLES3.0.6§4.4.2.1,
manpage)
GeneratesINVALID_OPERATIONwhen`internalFormat==DEPTH_STENCIL&&samples>0`.
Textureobjects
Textureobjectsprovidestorageandstatefortexturingoperations.IfnoWebGLTextureisbound
(e.g.,passingnullor0tobindTexture)thenattemptstomodifyorquerythetextureobjectshall
generateanINVALID_OPERATIONerror.Thisisindicatedinthefunctionsbelowincases
whereTheOpenGLES3.0specificationallowsthefunctiontochangethedefaulttexture.
anygetTexParameter(GLenumtarget,GLenumpname)
(OpenGLES3.0.6§6.1.3,
manpage)
Returnthevalueforthepassedpnamegiventhepassedtarget.Thetypereturnedisthenaturaltypeforthe
requestedpname,asgiveninthefollowingtable:
pnamereturnedtype
TEXTURE_BASE_LEVELGLint
TEXTURE_COMPARE_FUNCGLenum
TEXTURE_COMPARE_MODEGLenum
TEXTURE_IMMUTABLE_FORMATGLboolean
TEXTURE_IMMUTABLE_LEVELSGLuint
TEXTURE_MAG_FILTERGLenum
TEXTURE_MAX_LEVELGLint
TEXTURE_MAX_LODGLfloat
TEXTURE_MIN_FILTERGLenum
TEXTURE_MIN_LODGLfloat
TEXTURE_WRAP_RGLenum
TEXTURE_WRAP_SGLenum
TEXTURE_WRAP_TGLenum
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
IfanattemptismadetocallthisfunctionwithnoWebGLTexturebound(seeabove),generatesan
INVALID_OPERATIONerror.
IfanOpenGLerrorisgenerated,returnsnull.
voidtexParameterf(GLenumtarget,GLenumpname,GLfloatparam)
(OpenGLES3.0.6§3.8.7,
manpage)
Setthevalueforthepassedpnamegiventhepassedtarget.pnameisgiveninthefollowingtable:
pname
TEXTURE_BASE_LEVEL
TEXTURE_COMPARE_FUNC
TEXTURE_COMPARE_MODE
TEXTURE_MAG_FILTER
TEXTURE_MAX_LEVEL
TEXTURE_MAX_LOD
TEXTURE_MIN_FILTER
TEXTURE_MIN_LOD
TEXTURE_WRAP_R
TEXTURE_WRAP_S
TEXTURE_WRAP_T
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
IfanattemptismadetocallthisfunctionwithnoWebGLTexturebound(seeabove),generatesan
INVALID_OPERATIONerror.
voidtexParameteri(GLenumtarget,GLenumpname,GLintparam)
(OpenGLES3.0.6§3.8.7,
manpage)
Setthevalueforthepassedpnamegiventhepassedtarget.pnameisthissamewiththatoftexParameterf,asgiveninthetableabove.
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
IfanattemptismadetocallthisfunctionwithnoWebGLTexturebound(seeabove),generatesan
INVALID_OPERATIONerror.
voidtexStorage2D(GLenumtarget,GLsizeilevels,GLenuminternalformat,GLsizeiwidth,GLsizeiheight)
(OpenGLES3.0.6§3.8.4,
manpage)
Specifyallthelevelsofatwo-dimensionalorcube-maptextureatthesametime.
Theimagecontentsaresetasifabufferofsufficientsizeinitializedto0wouldbepassedto
eachtexImage2D(orcompressedTexImage2Dforcompressedformats)callinthepseudocodein
TheOpenGLES3.0specificationsection3.8.4
(OpenGLES3.0.6§3.8.4).
texStorage2Dshouldbeconsideredapreferredalternativeto
texImage2D.ItmayhavelowermemorycoststhantexImage2Dinsome
implementations.
voidtexStorage3D(GLenumtarget,GLsizeilevels,GLenuminternalformat,GLsizeiwidth,GLsizeiheight,GLsizeidepth)
(OpenGLES3.0.6§3.8.4,
manpage)
Specifyallthelevelsofathree-dimensionaltextureortwo-dimensionalarraytexture.
Theimagecontentsaresetasifabufferofsufficientsizeinitializedto0wouldbepassedto
eachtexImage3D(orcompressedTexImage3Dforcompressedformats)callinthepseudocodein
TheOpenGLES3.0specificationsection3.8.4
(OpenGLES3.0.6§3.8.4).
undefinedtexImage2D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,
GLsizeiheight,GLintborder,GLenumformat,GLenumtype,
[AllowShared]ArrayBufferViewsrcData,GLuintsrcOffset)
(OpenGLES3.0.6§3.8.3,
manpage)
OnlydifferencesfromtexImage2DinWebGL1.0aredescribedhere.
IfaWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
SizedinternalformatsaresupportedinWebGL2.0andinternalformatisnolongerrequiredtobethesameasformat.Instead,thecombinationofinternalformat,format,andtypemustbelistedinTable1or2frommanpage.
IftypeisspecifiedasFLOAT_32_UNSIGNED_INT_24_8_REV,
srcDatamustbenull;otherwise,generatesanINVALID_OPERATION
error.
ThetypeofsrcDatamustmatchthetypeaccordingtothefollowing
table;otherwise,generatesanINVALID_OPERATIONerror:
typeofsrcDatatype
Int8ArrayBYTE
Uint8ArrayUNSIGNED_BYTE
Uint8ClampedArrayUNSIGNED_BYTE
Int16ArraySHORT
Uint16ArrayUNSIGNED_SHORT
Uint16ArrayUNSIGNED_SHORT_5_6_5
Uint16ArrayUNSIGNED_SHORT_5_5_5_1
Uint16ArrayUNSIGNED_SHORT_4_4_4_4
Int32ArrayINT
Uint32ArrayUNSIGNED_INT
Uint32ArrayUNSIGNED_INT_5_9_9_9_REV
Uint32ArrayUNSIGNED_INT_2_10_10_10_REV
Uint32ArrayUNSIGNED_INT_10F_11F_11F_REV
Uint32ArrayUNSIGNED_INT_24_8
Uint16ArrayHALF_FLOAT
Float32ArrayFLOAT
Ifpixelstoreparameterconstraintsarenotmet,
generatesanINVALID_OPERATIONerror.
ReadingfromsrcDatabeginssrcOffsetelementsinto
srcData.(ElementsarebytesforUint8Array,int32sforInt32Array,etc.)
Ifthere'snotenoughdatainsrcDatastartingatsrcOffset,
generateINVALID_OPERATION.
[throws]
undefinedtexImage2D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,
GLsizeiheight,GLintborder,GLenumformat,GLenumtype,
TexImageSourcesource)//MaythrowDOMException
(OpenGLES3.0.6§3.8.3,
manpage)
OnlydifferencesfromtexImage2DinWebGL1.0aredescribedhere.
ConversiontonewformatsintroducedinWebGL2.0isperformedaccordingtothefollowingtable.
SourceDOMImageFormat
TargetWebGLFormat
RED
RG
Grayscale(1channel)
R=sourceGray
R=sourceGrayG=0
Grayscale+Alpha(2channels)
R=sourceGray
R=sourceGrayG=0
Color(3channels)Color+Alpha(4channels)
R=sourceRed
R=sourceRedG=sourceGreen
UploadingsubregionsofelementsisdetailedinPixel
storeparametersforuploadsfromTexImageSource.
IfaWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
SizedinternalformatsaresupportedinWebGL2.0andinternalformatisnolongerrequiredtobethesameasformat.Instead,thecombinationofinternalformat,format,andtypemustbelistedinthefollowingtable:
InternalFormatFormatType
RGBRGBUNSIGNED_BYTEUNSIGNED_SHORT_5_6_5
RGBARGBAUNSIGNED_BYTE,UNSIGNED_SHORT_4_4_4_4UNSIGNED_SHORT_5_5_5_1
LUMINANCE_ALPHALUMINANCE_ALPHAUNSIGNED_BYTE
LUMINANCELUMINANCEUNSIGNED_BYTE
ALPHAALPHAUNSIGNED_BYTE
R8REDUNSIGNED_BYTE
R16FREDHALF_FLOATFLOAT
R32FREDFLOAT
R8UIRED_INTEGERUNSIGNED_BYTE
RG8RGUNSIGNED_BYTE
RG16FRGHALF_FLOATFLOAT
RG32FRGFLOAT
RG8UIRG_INTEGERUNSIGNED_BYTE
RGB8RGBUNSIGNED_BYTE
SRGB8RGBUNSIGNED_BYTE
RGB565RGBUNSIGNED_BYTEUNSIGNED_SHORT_5_6_5
R11F_G11F_B10FRGBUNSIGNED_INT_10F_11F_11F_REVHALF_FLOATFLOAT
RGB9_E5RGBHALF_FLOATFLOAT
RGB16FRGBHALF_FLOATFLOAT
RGB32FRGBFLOAT
RGB8UIRGB_INTEGERUNSIGNED_BYTE
RGBA8RGBAUNSIGNED_BYTE
SRGB8_ALPHA8RGBAUNSIGNED_BYTE
RGB5_A1RGBAUNSIGNED_BYTEUNSIGNED_SHORT_5_5_5_1
RGB10_A2RGBAUNSIGNED_INT_2_10_10_10_REV
RGBA4RGBAUNSIGNED_BYTEUNSIGNED_SHORT_4_4_4_4
RGBA16FRGBAHALF_FLOATFLOAT
RGBA32FRGBAFLOAT
RGBA8UIRGBA_INTEGERUNSIGNED_BYTE
WhenthedatasourceisaDOMelement(HTMLImageElement,HTMLCanvasElement,orHTMLVideoElement),orisanImageBitmap,ImageData,orOffscreenCanvasobject,commonlyeachchannel'srepresentationisanunsignedintegertypeofatleast8bits.Convertingsuchrepresentationtosignedintegersorunsignedintegerswithmorebitsisnotclearlydefined.Forexample,whenconvertingRGBA8toRGBA16UI,itisunclearwhetherornottheintentionistoscaleupvaluestothefullrangeofa16-bitunsignedinteger.Therefore,onlyconvertingtounsignedintegerofatmost8bits,halffloat,orfloatisallowed.
voidtexImage2D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,GLsizeiheight,GLintborder,GLenumformat,GLenumtype,GLintptroffset)
(OpenGLES3.0.6§3.8.3,
manpage)
UploaddatatothecurrentlyboundWebGLTexturefromtheWebGLBufferboundtothePIXEL_UNPACK_BUFFERtarget.
offsetisthebyteoffsetintotheWebGLBuffer'sdatastore;generatesanINVALID_VALUEifit'slessthan0.
Thecombinationofformat,type,andWebGLTexture'sinternalformatmustbelistedinTable1or2frommanpage.
IfanattemptismadetocallthefunctionwithnoWebGLTexturebound,generatesanINVALID_OPERATIONerror.
IfnoWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
Ifpixelstoreparameterconstraintsarenotmet,
generatesanINVALID_OPERATIONerror.
undefinedtexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLsizeiwidth,GLsizeiheight,GLenumformat,GLenumtype,
[AllowShared]ArrayBufferViewsrcData,GLuintsrcOffset)
(OpenGLES3.0.6§3.8.5,
manpage)
OnlydifferencesfromtexSubImage2DinWebGL1.0aredescribedhere.
IfaWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
Thecombinationofformat,type,andWebGLTexture'sinternalformatmustbelistedinTable1or2frommanpage.
ThetypeofsrcDatamustmatchthetypeaccordingtotheabovetable;otherwise,generatesan
INVALID_OPERATIONerror.
SeePixelStorageParametersforWebGL-specificpixelstorageparametersthataffectthebehaviorofthisfunction.
Ifpixelstoreparameterconstraintsarenotmet,
generatesanINVALID_OPERATIONerror.
ReadingfromsrcDatabeginssrcOffsetelementsinto
srcData.(ElementsarebytesforUint8Array,int32sforInt32Array,etc.)
Ifthere'snotenoughdatainsrcDatastartingatsrcOffset,
generateINVALID_OPERATION.
undefinedtexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLsizeiwidth,GLsizeiheight,GLenumformat,GLenumtype,
TexImageSourcesource)//MaythrowDOMException
(OpenGLES3.0.6§3.8.5,
manpage)
OnlydifferencesfromtexSubImage2DinWebGL1.0aredescribedhere.
UploadingsubregionsofelementsisdetailedinPixel
storeparametersforuploadsfromTexImageSource.
IfaWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
Thecombinationofformat,type,andWebGLTexture'sinternalformatmustbelistedinthistable.
undefinedtexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLsizeiwidth,GLsizeiheight,GLenumformat,GLenumtype,
GLintptroffset)
(OpenGLES3.0.6§3.8.5,
manpage)
Updatesasub-rectangleofthecurrentlyboundWebGLTexturewithdatafromtheWebGLBufferboundtoPIXEL_UNPACK_BUFFERtarget.
offsetisthebyteoffsetintotheWebGLBuffer'sdatastore;generatesanINVALID_VALUEerrorifit'slessthan0.
IfanattemptismadetocallthefunctionwithnoWebGLTexturebound,generatesanINVALID_OPERATIONerror.
IfnoWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
Ifpixelstoreparameterconstraintsarenotmet,
generatesanINVALID_OPERATIONerror.
voidtexImage3D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,
GLsizeiheight,GLsizeidepth,GLintborder,GLenumformat,GLenumtype,
[AllowShared]ArrayBufferView?srcData)
voidtexImage3D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,
GLsizeiheight,GLsizeidepth,GLintborder,GLenumformat,GLenumtype,
[AllowShared]ArrayBufferViewsrcData,GLuintsrcOffset)
(OpenGLES3.0.6§3.8.3,
manpage)
Allocatesandinitializesthespecifiedmipmaplevelofathree-dimensionalortwo-dimensionalarraytexture.
IfaWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
IfsrcDataisnull,abufferofsufficientsizeinitializedto0ispassed.
Thecombinationofinternalformat,format,andtypemustbelistedinTable1or2frommanpage.
IftypeisspecifiedasFLOAT_32_UNSIGNED_INT_24_8_REV,
srcDatamustbenull;otherwise,generatesanINVALID_OPERATION
error.
IfsrcDataisnon-null,thetypeofsrcDatamustmatchthetype
accordingtotheabovetable;otherwise,
generateanINVALID_OPERATIONerror.
IfanattemptismadetocallthisfunctionwithnoWebGLTexturebound(seeabove),generatesanINVALID_OPERATIONerror.
SeePixelStorageParametersforWebGL-specificpixelstorageparametersthataffectthebehaviorofthisfunction.
Ifpixelstoreparameterconstraintsarenotmet,
generatesanINVALID_OPERATIONerror.
ReadingfromsrcDatabeginssrcOffsetelementsinto
srcData.(ElementsarebytesforUint8Array,int32sforInt32Array,etc.)
Ifthere'snotenoughdatainsrcDatastartingatsrcOffset,
generateINVALID_OPERATION.
ItisrecommendedtousetexStorage3DinsteadoftexImage3Dtoallocatethree-dimensionaltextures.texImage3DmayimposeahighermemorycostcomparedtotexStorage3Dinsomeimplementations.
undefinedtexImage3D(GLenumtarget,GLintlevel,GLenuminternalformat,GLsizeiwidth,
GLsizeiheight,GLsizeidepth,GLintborder,GLenumformat,GLenumtype,
TexImageSourcesource)//MaythrowDOMException
(OpenGLES3.0.6§3.8.3,
manpage)
UpdatearectangularsubregionofthecurrentlyboundWebGLTexture.
UploadingsubregionsofelementsisdetailedinPixel
storeparametersforuploadsfromTexImageSource.
SeetexImage2Dfortheinterpretationoftheformatandtypearguments,andnotesontheUNPACK_PREMULTIPLY_ALPHA_WEBGLpixelstorageparameter.
SeePixelStorageParametersforWebGL-specificpixelstorageparametersthataffectthebehaviorofthisfunctionwhenitiscalledwithanyargumenttypeotherthanImageBitmap.
ThefirstpixeltransferredfromthesourcetotheWebGLimplementationcorrespondstotheupperleftcornerofthesource.ThisbehaviorismodifiedbytheUNPACK_FLIP_Y_WEBGLpixelstorageparameter,exceptforImageBitmaparguments,asdescribedintheabovementionedsection.
Thecombinationofformat,type,andWebGLTexture'sinternalformatmustbelistedinthistable.
IfanattemptismadetocallthisfunctionwithnoWebGLTexturebound(seeabove),generatesanINVALID_OPERATIONerror.
IfaWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
IfthisfunctioniscalledwithanImageDatawhosedataattributehasbeenneutered,anINVALID_VALUEerrorisgenerated.
IfthisfunctioniscalledwithanImageBitmapthathasbeenneutered,anINVALID_VALUEerrorisgenerated.
IfthisfunctioniscalledwithanHTMLImageElementorHTMLVideoElementwhoseorigindiffersfromtheoriginofthecontainingDocument,orwithanHTMLCanvasElement,ImageBitmap,orOffscreenCanvaswhosebitmap'sorigin-cleanflagissettofalse,aSECURITY_ERRexceptionmustbethrown.SeeOriginRestrictions.
voidtexImage3D(GLenumtarget,GLintlevel,GLintinternalformat,GLsizeiwidth,GLsizeiheight,GLsizeidepth,GLintborder,GLenumformat,GLenumtype,GLintptroffset)
(OpenGLES3.0.6§3.8.3,
manpage)
UploaddatatothecurrentlyboundWebGLTexturefromtheWebGLBufferboundtothePIXEL_UNPACK_BUFFERtarget.
offsetisthebyteoffsetintotheWebGLBuffer'sdatastore;generatesanINVALID_VALUEerrorifit'slessthan0.
IfanattemptismadetocallthefunctionwithnoWebGLTexturebound,generatesanINVALID_OPERATIONerror.
IfnoWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
Ifpixelstoreparameterconstraintsarenotmet,
generatesanINVALID_OPERATIONerror.
undefinedtexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLintzoffset,GLsizeiwidth,GLsizeiheight,GLsizeidepth,
GLenumformat,GLenumtype,[AllowShared]ArrayBufferView?srcData,
optionalGLuintsrcOffset=0)
(OpenGLES3.0.6§3.8.5,
manpage)
UpdatearectangularsubregionofthecurrentlyboundWebGLTexture.
IfanattemptismadetocallthisfunctionwithnoWebGLTexturebound(seeabove),generatesanINVALID_OPERATIONerror.
IfaWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
Thecombinationofformat,type,andWebGLTexture'sinternalformatmustbelistedinTable1or2frommanpage.
IftypeisFLOAT_32_UNSIGNED_INT_24_8_REV,generatesanINVALID_ENUMerror.
ThetypeofsrcDatamustmatchthetypeaccordingtotheabovetable;otherwise,generatesan
INVALID_OPERATIONerror.
IfsrcDataisnon-nullbutitssizeislessthanwhatisrequiredbythespecifiedwidth,height,depth,format,type,andpixelstorageparameters,generatesanINVALID_OPERATIONerror.
SeePixelStorageParametersforWebGL-specificpixelstorageparametersthataffectthebehaviorofthisfunction.
Ifpixelstoreparameterconstraintsarenotmet,
generatesanINVALID_OPERATIONerror.
ReadingfromsrcDatabeginssrcOffsetelementsinto
srcData.(ElementsarebytesforUint8Array,int32sforInt32Array,etc.)
Ifthere'snotenoughdatainsrcDatastartingatsrcOffset,
generateINVALID_OPERATION.
undefinedtexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLintzoffset,GLsizeiwidth,GLsizeiheight,GLsizeidepth,
GLenumformat,GLenumtype,
TexImageSourcesource)//MaythrowDOMException
(OpenGLES3.0.6§3.8.5,
manpage)
UpdatearectangularsubregionofthecurrentlyboundWebGLTexture.
UploadingsubregionsofelementsisdetailedinPixel
storeparametersforuploadsfromTexImageSource.
SeetexImage2Dfortheinterpretationoftheformatandtypearguments,andnotesontheUNPACK_PREMULTIPLY_ALPHA_WEBGLpixelstorageparameter.
SeePixelStorageParametersforWebGL-specificpixelstorageparametersthataffectthebehaviorofthisfunctionwhenitiscalledwithanyargumenttypeotherthanImageBitmap.
ThefirstpixeltransferredfromthesourcetotheWebGLimplementationcorrespondstotheupperleftcornerofthesource.ThisbehaviorismodifiedbytheUNPACK_FLIP_Y_WEBGLpixelstorageparameter,exceptforImageBitmaparguments,asdescribedintheabovementionedsection.
Thecombinationofformat,type,andWebGLTexture'sinternalformatmustbelistedinthistable.
IfanattemptismadetocallthisfunctionwithnoWebGLTexturebound(seeabove),generatesanINVALID_OPERATIONerror.
IfaWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
IfthisfunctioniscalledwithanImageDatawhosedataattributehasbeenneutered,anINVALID_VALUEerrorisgenerated.
IfthisfunctioniscalledwithanImageBitmapthathasbeenneutered,anINVALID_VALUEerrorisgenerated.
IfthisfunctioniscalledwithanHTMLImageElementorHTMLVideoElementwhoseorigindiffersfromtheoriginofthecontainingDocument,orwithanHTMLCanvasElement,ImageBitmap,orOffscreenCanvaswhosebitmap'sorigin-cleanflagissettofalse,aSECURITY_ERRexceptionmustbethrown.SeeOriginRestrictions.
voidtexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLintzoffset,GLsizeiwidth,GLsizeiheight,GLsizeidepth,GLenumformat,GLenumtype,GLintptroffset)
(OpenGLES3.0.6§3.8.5,
manpage)
Updatesasub-rectangleofthecurrentlyboundWebGLTexturewithdatafromtheWebGLBufferboundtoPIXEL_UNPACK_BUFFERtarget.
offsetisthebyteoffsetintotheWebGLBuffer'sdatastore;generatesanINVALID_VALUEerrorifit'slessthan0.
IfanattemptismadetocallthefunctionwithnoWebGLTexturebound,generatesanINVALID_OPERATIONerror.
IfnoWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
Ifpixelstoreparameterconstraintsarenotmet,
generatesanINVALID_OPERATIONerror.
voidcopyTexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLintzoffset,GLintx,GLinty,GLsizeiwidth,GLsizeiheight)
(OpenGLES3.0.6§3.8.5,
manpage)
IfanattemptismadetocallthisfunctionwithnoWebGLTexturebound(seeabove),an
INVALID_OPERATIONerrorisgenerated.
Foranypixellyingoutsidetheframebuffer,thecorrespondingdestinationpixelremains
untouched;seeReadingPixelsOutside
theFramebuffer.
Ifthisfunctionattemptstoreadfromamissingattachmentofacompleteframebuffer,
anINVALID_OPERATIONerrorisgenerated
perReadingfromaMissingAttachment.
undefinedcompressedTexImage2D(GLenumtarget,GLintlevel,GLenuminternalformat,
GLsizeiwidth,GLsizeiheight,GLintborder,
[AllowShared]ArrayBufferViewsrcData,
optionalGLuintsrcOffset=0,
optionalGLuintsrcLengthOverride=0)
(OpenGLES3.0.6§3.8.6,
manpage)
ReadingfromsrcDatabeginssrcOffsetelementsinto
srcData.(ElementsarebytesforUint8Array,int32sforInt32Array,etc.)
IfsrcOffset>srcData.length,generatesanINVALID_VALUEerror.
srcLengthOverridedefaultstosrcData.length-srcOffset.
Ifthere'snotenoughdatainsrcDatastartingatsrcOffset,or
iftheamountofdatapassedinisnotconsistentwiththeformat,dimensions,and
contentsofthecompressedimage,generatesanINVALID_VALUEerror.
undefinedcompressedTexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLsizeiwidth,GLsizeiheight,GLenumformat,
[AllowShared]ArrayBufferViewsrcData,
optionalGLuintsrcOffset=0,
optionalGLuintsrcLengthOverride=0)
(OpenGLES3.0.6§3.8.6,
manpage)
ReadingfromsrcDatabeginssrcOffsetelementsinto
srcData.(ElementsarebytesforUint8Array,int32sforInt32Array,etc.)
IfsrcOffset>srcData.length,generatesanINVALID_VALUEerror.
srcLengthOverridedefaultstosrcData.length-srcOffset.
Ifthere'snotenoughdatainsrcDatastartingatsrcOffset,or
iftheamountofdatapassedinisnotconsistentwiththeformat,dimensions,and
contentsofthecompressedimage,generatesanINVALID_VALUEerror.
undefinedcompressedTexImage3D(GLenumtarget,GLintlevel,GLenuminternalformat,
GLsizeiwidth,GLsizeiheight,GLsizeidepth,GLintborder,
[AllowShared]ArrayBufferViewsrcData,
optionalGLuintsrcOffset=0,
optionalGLuintsrcLengthOverride=0)
(OpenGLES3.0.6§3.8.6,
manpage)
ReadingfromsrcDatabeginssrcOffsetelementsinto
srcData.(ElementsarebytesforUint8Array,int32sforInt32Array,etc.)
IfsrcOffset>srcData.length,generatesanINVALID_VALUEerror.
srcLengthOverridedefaultstosrcData.length-srcOffset.
Ifthere'snotenoughdatainsrcDatastartingatsrcOffset,or
iftheamountofdatapassedinisnotconsistentwiththeformat,dimensions,and
contentsofthecompressedimage,generatesanINVALID_VALUEerror.
undefinedcompressedTexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,
GLintzoffset,GLsizeiwidth,GLsizeiheight,GLsizeidepth,
GLenumformat,[AllowShared]ArrayBufferViewsrcData,
optionalGLuintsrcOffset=0,
optionalGLuintsrcLengthOverride=0)
(OpenGLES3.0.6§3.8.6,
manpage)
ReadingfromsrcDatabeginssrcOffsetelementsinto
srcData.(ElementsarebytesforUint8Array,int32sforInt32Array,etc.)
IfsrcOffset>srcData.length,generatesanINVALID_VALUEerror.
srcLengthOverridedefaultstosrcData.length-srcOffset.
Ifthere'snotenoughdatainsrcDatastartingatsrcOffset,or
iftheamountofdatapassedinisnotconsistentwiththeformat,dimensions,and
contentsofthecompressedimage,generatesanINVALID_VALUEerror.
Thissectionappliestotheabovefourentrypoints.
IfanattemptismadetocallthesefunctionswithnoWebGLTexturebound(seeabove),generatesanINVALID_OPERATIONerror.
IfaWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
TheETC2andEACtextureformatsdefinedinOpenGLES3.0arenotavailableinWebGL2.0.
voidcompressedTexImage2D(GLenumtarget,GLintlevel,GLenuminternalformat,GLsizeiwidth,GLsizeiheight,GLintborder,GLsizeiimageSize,GLintptroffset)
(OpenGLES3.0.6§3.8.6,
manpage)
voidcompressedTexSubImage2D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLsizeiwidth,GLsizeiheight,GLenumformat,GLsizeiimageSize,GLintptroffset)
(OpenGLES3.0.6§3.8.6,
manpage)
voidcompressedTexImage3D(GLenumtarget,GLintlevel,GLenuminternalformat,GLsizeiwidth,GLsizeiheight,GLsizeidepth,GLintborder,GLsizeiimageSize,GLintptroffset)
(OpenGLES3.0.6§3.8.6,
manpage)
voidcompressedTexSubImage3D(GLenumtarget,GLintlevel,GLintxoffset,GLintyoffset,GLintzoffset,GLsizeiwidth,GLsizeiheight,GLsizeidepth,GLenumformat,GLsizeiimageSize,GLintptroffset)
(OpenGLES3.0.6§3.8.6,
manpage)
Thissectionappliestotheabovefourentrypoints.
IfanattemptismadetocallthesefunctionswithnoWebGLTexturebound(seeabove),generatesanINVALID_OPERATIONerror.
IfnoWebGLBufferisboundtothePIXEL_UNPACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
offsetisthebyteoffsetintotheWebGLBuffer'sdatastore;generatesanINVALID_VALUEerrorifit'slessthan0.
TheETC2andEACtextureformatsdefinedinOpenGLES3.0arenotavailableinWebGL2.0.
ProgramsandShaders
[WebGLHandlesContextLoss]GLintgetFragDataLocation(WebGLProgramprogram,DOMStringname)
(OpenGLES3.0.6§3.9.2.3,
manpage)
IfprogramwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerrorandreturns-1.
anygetProgramParameter(WebGLProgram?program,GLenumpname)
(OpenGLES3.0.6§6.1.12,
manpage)
IfprogramwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerrorandreturnsnull.
Returnthevalueforthepassedpnamegiventhepassedprogram.Thetypereturnedisthenatural
typefortherequestedpname,asgiveninthefollowingtable:
pnamereturnedtype
DELETE_STATUSGLboolean
LINK_STATUSGLboolean
VALIDATE_STATUSGLboolean
ATTACHED_SHADERSGLint
ACTIVE_ATTRIBUTESGLint
ACTIVE_UNIFORMSGLint
TRANSFORM_FEEDBACK_BUFFER_MODEGLenum
TRANSFORM_FEEDBACK_VARYINGSGLint
ACTIVE_UNIFORM_BLOCKSGLint
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerrorandreturnsnull.
ReturnsnullifanyOpenGLerrorsaregeneratedduringtheexecutionofthis
function.
Uniformsandattributes
anygetUniform(WebGLProgramprogram,WebGLUniformLocationlocation)
(OpenGLES3.0.6§6.1.12,
manpage)
Ifeitherprogramorlocationweregeneratedbya
differentWebGL2RenderingContextthanthisone,generates
anINVALID_OPERATIONerror.
Returntheuniformvalueatthepassedlocationinthepassedprogram.Thetypereturnedisdependent
ontheuniformtype.ThetypesreturnedforthenewuniformtypesinWebGL2.0aregiveninthe
followingtable:
uniformtypereturnedtype
uintGLuint
uvec2Uint32Array(with2elements)
uvec3Uint32Array(with3elements)
uvec4Uint32Array(with4elements)
mat2x3Float32Array(with6elements)
mat2x4Float32Array(with8elements)
mat3x2Float32Array(with6elements)
mat3x4Float32Array(with12elements)
mat4x2Float32Array(with8elements)
mat4x3Float32Array(with12elements)
anysamplertypeGLint
ThetypesreturnedfortheuniformtypessharedwithWebGL1.0arethesameasinWebGL1.0.
voiduniform[1234]ui(WebGLUniformLocation?location,...)
voiduniform[1234]uiv(WebGLUniformLocation?location,...)
voiduniformMatrix[234]x[234]fv(WebGLUniformLocation?location,...)
(OpenGLES3.0.6§2.12.6,
manpage)
Eachoftheuniform*functionsabovesetsthespecifieduniformoruniformstothevalues
provided.Ifthepassedlocationisnotnullandwasnotobtainedfromthe
currentlyusedprogramviaanearliercalltogetUniformLocation,
anINVALID_OPERATIONerrorwillbegenerated.Ifthepassed
locationisnull,thedatapassedinwillbesilentlyignoredandnouniform
variableswillbechanged.
Ifthearraypassedtoanyofthevectorforms(thoseendinginv)hasan
invalidlength,anINVALID_VALUEerrorwillbegenerated.Thelengthisinvalid
ifitistooshortfororisnotanintegermultipleoftheassignedtype.
InoverloadswithasrcLengtharg:
IfsrcLengthis0,itdefaultsto
data.length-srcOffset.
IfsrcOffset+srcLengthislongerthan
data.length,generateINVALID_VALUE.
voidvertexAttribI4[u]i(GLuintindex,...)
voidvertexAttribI4[u]iv(GLuintindex,...)
(OpenGLES3.0.6§2.8,
manpage)
Setsthevertexattributeatthepassedindextothegivenconstantintegervalue.Valuessetviathe
vertexAttribareguaranteedtobereturnedfromthegetVertexAttribfunction
withtheCURRENT_VERTEX_ATTRIBparam,eveniftherehavebeeninterveningcallsto
drawArraysordrawElements.
Ifthearraypassedtoanyofthevectorforms(thoseendinginv)istoo
short,anINVALID_VALUEerrorwillbegenerated.
voidvertexAttribIPointer(GLuintindex,GLintsize,GLenumtype,GLsizeistride,GLintptroffset)
(OpenGLES3.0.6§2.9,
manpage)
AssigntheWebGLBufferobjectcurrentlyboundtotheARRAY_BUFFERtargettothevertex
attributeatthepassedindex.Valuesarealwaysleftasintegervalues.Sizeisnumberof
componentsperattribute.Strideandoffsetareinunitsofbytes.Passedstrideandoffset
mustbeappropriateforthepassedtypeandsizeoranINVALID_OPERATIONerror
willbegenerated;seeBufferOffset
andStrideRequirements.Ifoffsetisnegative,anINVALID_VALUEerrorwill
begenerated.IfnoWebGLBufferisboundtotheARRAY_BUFFERtargetandoffset
isnon-zero,anINVALID_OPERATIONerrorwillbegenerated.InWebGL,the
maximumsupportedstrideis255;seeVertex
AttributeDataStride.
anygetVertexAttrib(GLuintindex,GLenumpname)
(OpenGLES3.0.6§6.1.12,
manpage)
Returntheinformationrequestedinpnameaboutthevertexattributeatthepassedindex.The
typereturnedisdependentontheinformationrequested,asshowninthefollowingtable:
pnamereturnedtype
VERTEX_ATTRIB_ARRAY_BUFFER_BINDINGWebGLBuffer
VERTEX_ATTRIB_ARRAY_ENABLEDGLboolean
VERTEX_ATTRIB_ARRAY_SIZEGLint
VERTEX_ATTRIB_ARRAY_STRIDEGLint
VERTEX_ATTRIB_ARRAY_TYPEGLenum
VERTEX_ATTRIB_ARRAY_NORMALIZEDGLboolean
CURRENT_VERTEX_ATTRIBOneofFloat32Array,Int32ArrayorUint32Array(eachwith4elements)
VERTEX_ATTRIB_ARRAY_INTEGERGLboolean
VERTEX_ATTRIB_ARRAY_DIVISORGLint
ForCURRENT_VERTEX_ATTRIB,thereturntypeisdictatedbythemostrecentcall
tothevertexAttribfamilyoffunctionsforthegivenindex.Thatis,if
vertexAttribI4i*wasused,thereturntypewillbeInt32Array;IfvertexAttribI4ui*
wasused,thereturntypewillbeUint32Array;Otherwise,Float32Array.
Allqueriesreturningsequencesortypedarraysreturnanewobjecteachtime.
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
IfanOpenGLerrorisgenerated,returnsnull.
Writingtothedrawingbuffer
voidclear(GLbitfieldmask)
(OpenGLES3.0.6§4.2.3,
manpage)
Clearbufferstopresetvalues.Ifanintegercolorbufferisamongthebuffersthatwouldbe
cleared,anINVALID_OPERATIONerrorisgeneratedandnothingiscleared.
voidvertexAttribDivisor(GLuintindex,GLuintdivisor)
(OpenGLES3.0.6§2.9,
manpage)
Settherateatwhichthevertexattributeidentifiedbyindexadvanceswhendrawing.
voiddrawArrays(GLenummode,GLintfirst,GLsizeicount)
(OpenGLES3.0.6§2.9.3,
manpage)
voiddrawElements(GLenummode,GLsizeicount,GLenumtype,GLintptroffset)
(OpenGLES3.0.6§2.9.3,
manpage)
voiddrawArraysInstanced(GLenummode,GLintfirst,GLsizeicount,GLsizeiinstanceCount)
(OpenGLES3.0.6§2.9.3,
manpage)
DrawinstanceCountinstancesofgeometryusingthecurrentlyenabledvertexattributes.
Vertexattributeswhichhaveanon-zerodivisoradvanceonceeverydivisorinstances.
voiddrawElementsInstanced(GLenummode,GLsizeicount,GLenumtype,GLintptroffset,GLsizeiinstanceCount)
(OpenGLES3.0.6§2.9.3,
manpage)
DrawinstanceCountinstancesofgeometryusingthecurrentlyboundelementarraybuffer.
Vertexattributeswhichhaveanon-zerodivisoradvanceonceeverydivisorinstances.
voiddrawRangeElements(GLenummode,GLuintstart,GLuintend,GLsizeicount,GLenumtype,GLintptroffset)
(OpenGLES3.0.6§2.9.3,
manpage)
Drawusingthecurrentlyboundelementarraybuffer.Allerrorconditionsspecifiedfor
drawElementsinthesectionWriting
tothedrawingbufferoftheWebGL1.0specificationapply.
Inaddition,ifindicesusedtodrawareoutsidetherangeof[start,end],animeplementation
caneitherguaranteethebehaviorsdefinedinOut-of-Range
ArrayAccesses,orsimplydiscardtheargumentsstartandendandcalldrawElements
instead.Ineithersituation,noGLerrorsshouldbegeneratedforthiscause.
DuringcallstodrawElements,drawArrays,drawRangeElementsandtheir
instancedvariants,WebGL2.0performsadditionalerrorcheckingbeyondthatspecifiedinOpenGLES3.0:
IftheCURRENT_PROGRAMisnull,anINVALID_OPERATIONerrorwillbegenerated;
RangeChecking;
ActiveUniformBlockBacking;
VertexAttribfunctionmustmatchshaderattributetype.
Readingbackpixels
PixelsinthecurrentframebuffercanbereadbackintoanArrayBufferViewobjectora
WebGLBufferboundtothePIXEL_PACK_BUFFERtarget.
OnlydifferencesfromReadingbackpixelsinWebGL1.0aredescribedhere.
undefinedreadPixels(GLintx,GLinty,GLsizeiwidth,GLsizeiheight,GLenumformat,
GLenumtype,[AllowShared]ArrayBufferViewdstData,GLuintdstOffset)
(OpenGLES3.0§4.3.2,
manpage)
IfaWebGLBufferisboundtothePIXEL_PACK_BUFFERtarget,generatesanINVALID_OPERATIONerror.
Ifpixelstoreparameterconstraintsarenotmet,
generatesanINVALID_OPERATIONerror.
IfdstDatadoesn'thaveenoughspaceforthereadoperationstartingat
dstOffset,generateINVALID_OPERATION.
Thisisablockingoperation,asWebGLmustcompletelyfinishall
previousrenderingoperationsintothesourceframebufferinorder
toreturnaresult.Inmulti-processWebGLimplementations,italso
incursanexpensiveinter-processround-triptofetchtheresult
fromtheremoteprocess.
ConsiderinsteadusingreadPixelsintoa
PIXEL_PACK_BUFFER.UsegetBufferSubData
toreadthedatafromthatbuffer.
(SeegetBufferSubDataforhowtoavoidblockingin
thatcall.)
voidreadPixels(GLintx,GLinty,GLsizeiwidth,GLsizeiheight,GLenumformat,GLenumtype,GLintptroffset)
(OpenGLES3.0§4.3.2,
manpage)
IfnoWebGLBufferisboundtothePIXEL_PACK_BUFFERtarget,generatesan
INVALID_OPERATIONerror.
offsetisthebyteoffsetintotheWebGLBuffer'sdatastore;generatesan
INVALID_VALUEerrorifit'slessthan0.Iftheremainderofthe
WebGLBuffer'sdatastoreisnotlargeenoughtoretrieveallofthepixelsinthe
specifiedrectangletakingintoaccountpixelstoremodes,generatesan
INVALID_OPERATION.
Multiplerendertargets
voiddrawBuffers(sequencebuffers)
(OpenGLES3.0.6§4.2.1,
manpage)
Definethedrawbufferstowhichallfragmentcolorsarewritten.
voidclearBufferfv(GLenumbuffer,GLintdrawbuffer,Float32Listvalues,
optionalGLuintsrcOffset=0);
voidclearBufferiv(GLenumbuffer,GLintdrawbuffer,Int32Listvalues,
optionalGLuintsrcOffset=0);
voidclearBufferuiv(GLenumbuffer,GLintdrawbuffer,Uint32Listvalues,
optionalGLuintsrcOffset=0);
voidclearBufferfi(GLenumbuffer,GLintdrawbuffer,GLfloatdepth,GLintstencil);
(OpenGLES3.0.6§4.2.3,
manpage)
Seteverypixelinthespecifiedbuffertoaconstantvalue.TheclearBuffer
functionthatshouldbeusedforacolorbufferdependsonthetypeofthecolorbuffer,
giveninthefollowingtable:
TypeofbufferclearBufferfunction
floatingpointclearBufferfv
fixedpointclearBufferfv
signedintegerclearBufferiv
unsignedintegerclearBufferuiv
IfbufferisCOLOR_BUFFERandthefunctionisnotchosenaccordingtothe
abovetable,anINVALID_OPERATIONerrorisgeneratedandnothingiscleared.
ForArrayBufferViewentrypoints,ifthere'snotenoughelementsinvalues
startingatsrcOffset,generateINVALID_VALUE.
clearBufferfimaybeusedtoclearthedepthandstencilbuffers.
buffermustbeDEPTH_STENCILanddrawBuffermustbe
zero.depthandstencilarethedepthandstencilvalues,
respectively.
Ifthisfunctionattemptstoclearamissingattachmentofacompleteframebuffer,nothing
isclearedandnoerrorisgenerated
perDrawingtoaMissingAttachment.
Queryobjects
WebGLQuery?createQuery()
(OpenGLES3.0.6§2.14,
manpage)
CreateaWebGLQueryobjectandinitializeitwithaqueryobjectnameasifbycallingglGenQueries.
voiddeleteQuery(WebGLQuery?query)
(OpenGLES3.0.6§2.14,
manpage)
IfquerywasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Markfordeletionthequeryobjectcontainedinthepassed
WebGLQuery,asifbycallingglDeleteQueries.
Iftheobjecthasalreadybeenmarkedfordeletion,thecallhasnoeffect.Notethat
underlyingGLobjectwillbeautomaticallymarkedfordeletionwhentheJSobjectis
destroyed,howeverthismethodallowsauthorstomarkanobjectfordeletionearly.
[WebGLHandlesContextLoss]GLbooleanisQuery(WebGLQuery?query)
(OpenGLES3.0.6§6.1.7,
manpage)
ReturntrueifthepassedWebGLQueryisvalidandfalseotherwise.
ReturnsfalseifthequerywasgeneratedbyadifferentWebGL2RenderingContext
thanthisone.
Returnsfalseifthequery'sinvalidated
flagisset.
voidbeginQuery(GLenumtarget,WebGLQueryquery)
(OpenGLES3.0.6§2.14,
manpage)
IfquerywasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Beginanasynchronousquery.Targetindicatesthetypeofquerytobeperformed.
voidendQuery(GLenumtarget)
(OpenGLES3.0.6§2.14,
manpage)
Marktheendofthesequenceofcommandstobetrackedforthequerytypegivenby
target.Whenthefinalqueryresultisavailable,thequeryobjectisupdated
toindicatethisandtheresultmayberetrievedbycallinggetQueryParameter.
WebGLQuery?getQuery(GLenumtarget,GLenumpname)
(OpenGLES3.0.6§6.1.7,
manpage)
Returnsinformationaboutaquerytargettarget,whichmustbeone
ofANY_SAMPLES_PASSEDorANY_SAMPLES_PASSED_CONSERVATIVEfor
occlusionqueries,orTRANSFORM_FEEDBACK_PRIMITIVES_WRITTENforprimitive
queries.pnamespecifiesthesymbolicnameofaqueryobjecttarget
parameter.CurrentlyitmustbeCURRENT_QUERY,andreturnseitherthe
currentlyactivequeryforthetarget,ornull.
Iftargetorpnamearenotinthelistabove,generates
anINVALID_ENUMerrorandreturnsnull.
ReturnsnullifanyOpenGLerrorsaregeneratedduringtheexecutionofthis
function.
anygetQueryParameter(WebGLQueryquery,GLenumpname)
(OpenGLES3.0.6§6.1.7,
manpage)
IfquerywasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Returnsaparameterpnameofaqueryobject.QUERY_RESULTreturns
thevalueofthequeryobject'spassedsamplescounter.
QUERY_RESULT_AVAILABLEreturnswhetherthesamplescounterisimmediately
available.Thetypereturnedisthenaturaltypefortherequestedpname,asgiveninthe
followingtable:
pnamereturnedtype
QUERY_RESULTGLuint
QUERY_RESULT_AVAILABLEGLboolean
Ifpnameisnotinthetableabove,generatesanINVALID_ENUM
errorandreturnsnull.
Ifqueryisnotavalidqueryobject,orisacurrentlyactivequeryobject,
generatesanINVALID_OPERATIONerrorandreturnsnull.
ReturnsnullifanyOpenGLerrorsaregeneratedduringtheexecutionofthis
function.
Inordertoensureconsistentbehavioracrossplatforms,queries'resultsmustonlybemade
availablewhentheuseragent'sevent
loopisnotexecutingatask.Inotherwords:
Aquery'sresultmustnotbemadeavailableuntilcontrolhasreturnedtotheuser
agent'smainloop.
Repeatedlyfetchingaquery'sQUERY_RESULT_AVAILABLEparameterinaloop,without
returningcontroltotheuseragent,mustalwaysreturnthesamevalue.
Aquery'sresultmayormaynotbemadeavailablewhencontrolreturnstotheuser
agent'seventloop.ItisnotguaranteedthatusingasinglesetTimeoutcallbackwitha
delayof0,orasinglerequestAnimationFramecallback,willallowsufficienttimefor
theWebGLimplementationtosupplythequery'sresults.
ThischangecomparedtotheOpenGLES3.0specificationisenforcedinordertoprevent
applicationsfromrelyingonbeingabletoissueaqueryandfetchitsresultinthe
sameframe.Inordertoensurebestportabilityamongdevicesandbestperformanceamong
implementations,applicationsmustexpectthatqueries'resultswillbecomeavailable
asynchronously.
Samplerobjects
WebGLSampler?createSampler()
(OpenGLES3.0.6§3.8.2,
manpage)
CreateaWebGLSamplerobjectandinitializeitwithasamplerobjectnameasifby
callingglGenSamplers.
voiddeleteSampler(WebGLSampler?sampler)
(OpenGLES3.0.6§3.8.2,
manpage)
IfsamplerwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Markfordeletionthesamplerobjectcontainedinthepassed
WebGLSampler,asifbycallingglDeleteSamplers.
Iftheobjecthasalreadybeenmarkedfordeletion,thecallhasnoeffect.Notethat
underlyingGLobjectwillbeautomaticallymarkedfordeletionwhentheJSobjectis
destroyed,howeverthismethodallowsauthorstomarkanobjectfordeletionearly.
[WebGLHandlesContextLoss]GLbooleanisSampler(WebGLSampler?sampler)
(OpenGLES3.0.6§6.1.5,
manpage)
ReturntrueifthepassedWebGLSamplerisvalidandfalseotherwise.
Returnsfalseifthesamplerwasgeneratedbya
differentWebGL2RenderingContextthanthisone.
Returnsfalseifthesampler'sinvalidated
flagisset.
voidbindSampler(GLuintunit,WebGLSampler?sampler)
(OpenGLES3.0.6§3.8.2,
manpage)
IfsamplerwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
BindthesamplerobjectcontainedinthepassedWebGLSamplertothetextureunitatthe
passedindex.Ifasamplerisboundtoatextureunit,thesampler'sstatesupersedesthesampling
stateofthetextureboundtothattextureunit.Ifsamplerisnull,the
currentlyboundsamplerisunboundfromthetextureunit.Asinglesamplerobjectmaybeboundto
multipletextureunitssimultaneously.
IfunitisgreaterthanorequaltothevalueofMAX_COMBINED_TEXTURE_IMAGE_UNITS,generatesanINVALID_VALUEerror.
Anattempttobindanobjectmarkedfordeletionwillgeneratean
INVALID_OPERATIONerror,andthecurrentbindingwillremainuntouched.
voidsamplerParameteri(WebGLSamplersampler,GLenumpname,GLintparam)
voidsamplerParameterf(WebGLSamplersampler,GLenumpname,GLfloatparam)
(OpenGLES3.0.6§3.8.2,
manpage)
IfsamplerwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Setthevalueforthepassedpnamegiventhepassedsampler.pnameisgiveninthefollowingtable:
pname
TEXTURE_COMPARE_FUNC
TEXTURE_COMPARE_MODE
TEXTURE_MAG_FILTER
TEXTURE_MAX_LOD
TEXTURE_MIN_FILTER
TEXTURE_MIN_LOD
TEXTURE_WRAP_R
TEXTURE_WRAP_S
TEXTURE_WRAP_T
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
Ifsamplerisnotavalidsamplerobject,generatesanINVALID_OPERATIONerror.
anygetSamplerParameter(WebGLSamplersampler,GLenumpname)
(OpenGLES3.0.6§6.1.5,
manpage)
IfsamplerwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
ReturntheinformationrequestedinpnameaboutthegivenWebGLSampler,passedassampler.The
typereturnedisdependentontheinformationrequested,asshowninthefollowingtable:
pnamereturnedtype
TEXTURE_COMPARE_FUNCGLenum
TEXTURE_COMPARE_MODEGLenum
TEXTURE_MAG_FILTERGLenum
TEXTURE_MAX_LODGLfloat
TEXTURE_MIN_FILTERGLenum
TEXTURE_MIN_LODGLfloat
TEXTURE_WRAP_RGLenum
TEXTURE_WRAP_SGLenum
TEXTURE_WRAP_TGLenum
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
Ifsamplerisnotavalidsamplerobject,generatesanINVALID_OPERATIONerror.
ReturnsnullifanyOpenGLerrorsaregeneratedduringtheexecutionofthisfunction.
Syncobjects
SyncobjectscanbeusedtosynchronizeexecutionbetweentheGLserverandtheclient.
WebGLSync?fenceSync(GLenumcondition,GLbitfieldflags)
(OpenGLES3.0.6§5.2,
manpage)
CreateanewfencesyncobjectandinsertanassociatedfencecommandintheGLcommandstream.
[WebGLHandlesContextLoss]GLbooleanisSync(WebGLSync?sync)
(OpenGLES3.0.6§6.1.8,
manpage)
ReturntrueifthepassedWebGLSyncisvalidandfalseotherwise.
ReturnsfalseifthesyncwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone.
Returnsfalseifthesync'sinvalidated
flagisset.
voiddeleteSync(WebGLSync?sync)
(OpenGLES3.0.6§5.2,
manpage)
IfsyncwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Markfordeletionthesyncobjectcontainedinthepassed
WebGLSync,asifbycallingglDeleteSync.
Iftheobjecthasalreadybeenmarkedfordeletion,thecallhasnoeffect.Notethat
underlyingGLobjectwillbeautomaticallymarkedfordeletionwhentheJSobjectis
destroyed,howeverthismethodallowsauthorstomarkanobjectfordeletionearly.
GLenumclientWaitSync(WebGLSyncsync,GLbitfieldflags,GLuint64timeout)
(OpenGLES3.0.6§5.2.1,
manpage)
IfsyncwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Blockexecutionuntilthepassedsyncobjectissignaledorthespecifiedtimeouthas
passed.timeoutisinunitsofnanoseconds.
Returnsoneoffourstatusvalues.AreturnvalueofALREADY_SIGNALEDindicates
thatsyncwassignaledatthetimeclientWaitSyncwas
called.ALREADY_SIGNALEDwillalwaysbereturnedifsyncwassignaled,even
iftimeoutwaszero.AreturnvalueofTIMEOUT_EXPIREDindicatesthatthespecified
timeoutperiodexpiredbeforesyncwassignaled.AreturnvalueofCONDITION_SATISFIED
indicatesthatsyncwassignaledbeforethetimeoutexpired.Finally,ifanerroroccurs,in
additiontogeneratinganerrorasspecifiedbelow,returnsWAIT_FAILEDwithoutblocking.
flagscontrolscommandflushingbehaviorandmayincludeSYNC_FLUSH_COMMANDS_BIT.If
anyotherbitissetinflagsanINVALID_OPERATIONerroris
generated.IfSYNC_FLUSH_COMMANDS_BITissetinflagsandsyncis
unsignaledwhenclientWaitSynciscalled,thentheequivalentofflushwillbe
performedbeforeblockingonsync.
Asdiscussedinthedifferencessection,WebGLimplementationsmustimposea
shortmaximumtimeouttopreventblockingthemainthreadforlongperiodsoftime.The
implementation-definedtimeoutmaybequeriedbycallinggetParameterwiththe
argumentMAX_CLIENT_WAIT_TIMEOUT_WEBGL.Iftimeoutislargerthanthis
implementation-definedtimeoutthenanINVALID_OPERATIONerrorisgenerated.
Theimplementation-definedmaximumtimeoutisnotspecified.Itshouldbesetlowenoughtokeepapplications
fromcompromisinginteractivitybywaitingforlongperiodsoftime.Itisacceptableforanimplementationto
imposeazeromaximumtimeout.WebGLapplicationsshouldnotuseclientWaitSynctoblockexecutionforlong
periodsoftime.
ReturnsWAIT_FAILEDifanyOpenGLerrorsaregeneratedduringtheexecutionofthis
function.
Inordertoensureconsistentbehavioracrossplatforms,syncobjectsmayonlytransition
tothesignaledstatewhentheuser
agent'sevent
loopisnotexecutingatask.Inotherwords:
clientWaitSyncmustnotreturnCONDITION_SATISFIEDorALREADY_SIGNALEDforanewly
createdsyncobjectuntilcontrolhasreturnedtotheuseragent'smainloop.
voidwaitSync(WebGLSyncsync,GLbitfieldflags,GLint64timeout)
(OpenGLES3.0.6§5.2.1,
manpage)
IfsyncwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Returnimmediately,butwaitontheGLserveruntilthepassedsyncobjectissignaledoran
implementation-dependenttimeouthaspassed.Thepassedtimeoutmustbesetto
TIMEOUT_IGNORED.
IntheabsenceofthepossibilityofsynchronizingbetweenmultipleGLcontexts,callingwaitSynciseffectivelyano-op.
anygetSyncParameter(WebGLSyncsync,GLenumpname)
(OpenGLES3.0.6§6.1.8,
manpage)
IfsyncwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
ReturnthevalueforthepassedpnamegiventhepassedWebGLSyncobject.Thetypereturnedisthenatural
typefortherequestedpname,asgiveninthefollowingtable:
pnamereturnedtype
OBJECT_TYPEGLenum
SYNC_STATUSGLenum
SYNC_CONDITIONGLenum
SYNC_FLAGSGLbitfield
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerrorandreturnsnull.
ReturnsnullifanyOpenGLerrorsaregeneratedduringtheexecutionofthis
function.
Inordertoensureconsistentbehavioracrossplatforms,syncobjectsmayonly
transitiontothesignaledstatewhentheuseragent'sevent
loopisnotexecutingatask.Inotherwords:
Asyncobjectmustnotbecomesignaleduntilcontrolhasreturnedtotheuser
agent'smainloop.
Repeatedlyfetchingasyncobject'sSYNC_STATUSparameterinaloop,without
returningcontroltotheuseragent,mustalwaysreturnthesamevalue.
Transformfeedback
Transformfeedbackmodecapturesthevaluesofoutputvariableswrittenbythevertexshader.The
verticesarecapturedbeforeflatshadingandclipping.Thetransformedverticesmaybeoptionally
discardedafterbeingstoredintooneormorebufferobjects,ortheycanbepassedondowntothe
clippingstageforfurtherprocessing.Thesetofoutputvariablescapturedisdeterminedwhena
programislinked.
Ifanyoutputvariableisspecifiedtobestreamedtoatransformfeedbackbufferobjectbutnotactually
writtenbyavertexshader,thevalueissetto0.See
Transformfeedbackprimitivecapture.
WebGLTransformFeedback?createTransformFeedback()
(OpenGLES3.0.6§2.15.1,
similartoglGenTransformFeedbacks)
CreateaWebGLTransformFeedbackobjectandinitializeitwithatransformfeedbackobjectnameasifby
callingglGenTransformFeedbacks.
voiddeleteTransformFeedback(WebGLTransformFeedback?transformFeedback)
(OpenGLES3.0.6§2.15.1,
similartoglDeleteTransformFeedbacks)
IftransformFeedbackwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Markfordeletionthetransformfeedbackobjectcontainedinthepassed
WebGLTransformFeedback,asifbycalling
glDeleteTransformFeedbacks.
Iftheobjecthasalreadybeenmarkedfordeletion,thecallhasnoeffect.Notethat
underlyingGLobjectwillbeautomaticallymarkedfordeletionwhentheJSobjectis
destroyed,howeverthismethodallowsauthorstomarkanobjectfordeletionearly.
[WebGLHandlesContextLoss]GLbooleanisTransformFeedback(WebGLTransformFeedback?transformFeedback)
(OpenGLES3.0.6§6.1.11,
manpage)
ReturntrueifthepassedWebGLTransformFeedbackisvalidandfalseotherwise.
Returnsfalseifthetransformfeedbackwasgeneratedbya
differentWebGL2RenderingContextthanthisone.
Returnsfalseifthetransformfeedback'sinvalidated
flagisset.
voidbindTransformFeedback(GLenumtarget,WebGLTransformFeedback?transformFeedback)
(OpenGLES3.0.6§2.15.1,
manpage)
IftransformFeedbackwasgeneratedbya
differentWebGL2RenderingContextthanthisone,generates
anINVALID_OPERATIONerror.
BindthegivenWebGLTransformFeedbackobject.
IftransformFeedbackisnull,thedefaulttransformfeedbackobjectprovidedbythecontext
isbound.
Anattempttobindanobjectmarkedfordeletionwillgeneratean
INVALID_OPERATIONerror,andthecurrentbindingwillremainuntouched.
voidbeginTransformFeedback(GLenumprimitiveMode)
(OpenGLES3.0.6§2.15.2,
manpage)
voidendTransformFeedback()
(OpenGLES3.0.6§2.15.2,
manpage)
voidpauseTransformFeedback()
(OpenGLES3.0.6§2.15.2,
manpage)
voidresumeTransformFeedback()
(OpenGLES3.0.6§2.15.2,
manpage)
voidtransformFeedbackVaryings(WebGLProgramprogram,sequencevaryings,GLenumbufferMode)
(OpenGLES3.0.6§2.12.8,
manpage)
IfprogramwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
WebGLActiveInfo?getTransformFeedbackVarying(WebGLProgramprogram,GLuintindex)
(OpenGLES3.0.6§2.12.8,
manpage)
IfprogramwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerrorandreturnsnull.
UniformBufferobjects
Uniformbufferobjectsprovidethestoragefornameduniformblocks,sothevaluesofactiveuniforms
innameduniformblocksmaybechangedbymodifyingthecontentsofthebufferobject.
voidbindBufferBase(GLenumtarget,GLuintindex,WebGLBuffer?buffer)
(OpenGLES3.0.6§2.10.1.1,
manpage)
IfbufferwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
BindsthegivenWebGLBufferobjecttothebindingpointatindexofthearrayoftargets
specifiedbytarget.
voidbindBufferRange(GLenumtarget,GLuintindex,WebGLBuffer?buffer,GLintptroffset,GLsizeiptrsize)
(OpenGLES3.0.6§2.10.1.1,
manpage)
IfbufferwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
BindsarangeoftheWebGLBufferobjectbufferrepresentedbyoffsetandsize
tothebindingpointatindexofthearrayoftargetsspecifiedbytarget.
sequence?getUniformIndices(WebGLProgramprogram,sequenceuniformNames)
(OpenGLES3.0.6§2.12.6,
manpage)
Ifprogramwasgeneratedbyadifferent
WebGL2RenderingContextthanthisone,generates
anINVALID_OPERATIONerror.
Retrievestheindicesofanumberofuniformswithinprogram.
ReturnsnullifanyOpenGLerrorsaregeneratedduringtheexecutionofthis
function.
anygetActiveUniforms(WebGLProgramprogram,sequenceuniformIndices,GLenumpname)
(OpenGLES3.0.6§2.12.6,
manpage)
IfprogramwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Queriesthevalueoftheparameternamedpnameforeachoftheuniformswithinprogramwhoseindices
arespecifiedinthearrayofuniformIndices.Thetypereturnedisthenaturaltypefortherequested
pname,asgiveninthefollowingtable:
pnamereturnedtype
UNIFORM_TYPEsequence
UNIFORM_SIZEsequence
UNIFORM_BLOCK_INDEXsequence
UNIFORM_OFFSETsequence
UNIFORM_ARRAY_STRIDEsequence
UNIFORM_MATRIX_STRIDEsequence
UNIFORM_IS_ROW_MAJORsequence
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
ReturnsnullifanyOpenGLerrorsaregeneratedduringtheexecutionofthis
function.
GLuintgetUniformBlockIndex(WebGLProgramprogram,DOMStringuniformBlockName)
(OpenGLES3.0.6§2.12.6,
manpage)
IfprogramwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Retrievestheindexofauniformblockwithinprogram.
anygetActiveUniformBlockParameter(WebGLProgramprogram,GLuintuniformBlockIndex,GLenumpname)
(OpenGLES3.0.6§2.12.6,
manpage)
IfprogramwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Retrievesinformationaboutanactiveuniformblockwithinprogram.Thetypereturnedisthenaturaltypefortherequested
pname,asgiveninthefollowingtable:
pnamereturnedtype
UNIFORM_BLOCK_BINDINGGLuint
UNIFORM_BLOCK_DATA_SIZEGLuint
UNIFORM_BLOCK_ACTIVE_UNIFORMSGLuint
UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICESUint32Array
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADERGLboolean
UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADERGLboolean
Ifpnameisnotinthetableabove,generatesanINVALID_ENUMerror.
IfuniformBlockIndexisnotanactiveblockuniformforprogramorgreaterthanorequaltothe
valueofACTIVE_UNIFORM_BLOCKS,generatesanINVALID_VALUEerror.
IfanOpenGLerrorisgenerated,returnsnull.
DOMString?getActiveUniformBlockName(WebGLProgramprogram,GLuintuniformBlockIndex)
(OpenGLES3.0.6§2.12.6,
manpage)
IfprogramwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
RetrievesthenameoftheactiveuniformblockatuniformBlockIndexwithinprogram.
voiduniformBlockBinding(WebGLProgramprogram,GLuintuniformBlockIndex,GLuintuniformBlockBinding)
(OpenGLES3.0.6§2.12.6.5,
manpage)
IfprogramwasgeneratedbyadifferentWebGL2RenderingContext
thanthisone,generatesanINVALID_OPERATIONerror.
Assignsbindingpointsforactiveuniformblocks.
VertexArrayobjects
VertexArrayobjects(sometimesreferredtoasVAOs)encapsulateallstaterelatedtothe
definitionofdatausedbythevertexprocessor.
voidbindVertexArray(WebGLVertexArrayObject?vertexArray)
(OpenGLES3.0.6§2.11,
manpage)
IfvertexArraywasgeneratedbya
differentWebGL2RenderingContextthanthisone,generates
anINVALID_OPERATIONerror.
BindthegivenWebGLVertexArrayObjectobject.
IfvertexArrayisnull,thedefaultvertexarrayprovidedbythecontext
isbound.
AnattempttobindadeletedvertexarraywillgenerateaINVALID_OPERATIONerror,and
thecurrentbindingwillremainuntouched.
WebGLVertexArrayObject?createVertexArray()
(OpenGLES3.0.6§2.11,
similartoglGenVertexArrays)
CreateaWebGLVertexArrayObjectobjectandinitializeitwithavertexarrayobjectnameasifby
callingglGenVertexArrays.
voiddeleteVertexArray(WebGLVertexArrayObject?vertexArray)
(OpenGLES3.0.6§2.11,
similartoglDeleteVertexArrays)
IfvertexArraywasgeneratedbya
differentWebGL2RenderingContextthanthisone,generates
anINVALID_OPERATIONerror.
Markfordeletionthevertexarrayobjectcontainedinthepassed
WebGLVertexArrayObject,asifbycalling
glDeleteVertexArrays.
Iftheobjecthasalreadybeenmarkedfordeletion,thecallhasnoeffect.Notethat
underlyingGLobjectwillbeautomaticallymarkedfordeletionwhentheJSobjectis
destroyed,howeverthismethodallowsauthorstomarkanobjectfordeletionearly.
[WebGLHandlesContextLoss]GLbooleanisVertexArray(WebGLVertexArrayObject?vertexArray)
(OpenGLES3.0.6§6.1.10,
manpage)
ReturntrueifthepassedWebGLVertexArrayObjectisvalidandfalseotherwise.
ReturnsfalseifthevertexarraywasgeneratedbyadifferentWebGL2RenderingContext
thanthisone.
Returnsfalseifthevertexarray'sinvalidated
flagisset.
OtherdifferencesBetweenWebGL2.0andWebGL1.0
NeedsupdateforWebGL2.0
BackwardsIncompatibility
Errors
TheWebGL2.0APImaybehavedifferentlyincaseswheretheWebGL1.0APIgeneratesanerror.
CodewrittenagainsttheWebGL1.0APIthatgenerateserrorsisnotguaranteedtobe
forward-compatiblewithWebGL2.0.
Extensions
SomeextensionsthatmayhavebeensupportedintheWebGL1.0APIareremovedfromtheWebGL
2.0API.Formoredetails,seethe
WebGLExtensionRegistry.
ExtensionsaretypicallyremovedonlyifequivalentfunctionalityisavailableintheWebGL
2.0APIeitherinthecorespecificationorinanimprovedextension.Whenanapplication
usingWebGL1.0extensionsismodifiedtorunontheWebGL2.0API,itisoftenpossibleto
createadummyextensionobjectforeachofthepromotedextensionswhichsimply
redirectscallstotheappropriateWebGL2.0APIfunctions.Iftheapplicationisusingshader
languageextensions,portingshaderstoGLSLES3.00istypicallyrequired.
Non-Power-of-TwoTextureAccess
TextureaccessworksintheWebGL2.0APIasintheOpenGLES3.0API.Inotherwords,
unliketheWebGL1.0API,therearenospecialrestrictionsonnonpowerof2textures.All
mipmappingandallwrappingmodesaresupportedfornon-power-of-twoimages.
PrimitiveRestartisAlwaysEnabled
SeesectionPRIMITIVE_RESTART_FIXED_INDEXisalwaysenabled.
FramebufferObjectAttachments
InWebGL1.0,DEPTH_STENCIL_ATTACHMENTisanalternativeattachmentpointotherthanDEPTH_ATTACHMENTandSTENCIL_ATTACHMENT.InWebGL2.0,however,DEPTH_STENCIL_ATTACHMENTisconsideredanaliasforDEPTH_ATTACHMENT+STENCIL_ATTACHMENT,i.e.,thesameimageisattachedtobothDEPTH_ATTACHMENTandSTENCIL_ATTACHMENT,overwritingtheoriginalimagesattachedtothetwoattachmentpoints.
Considerthefollowingsequenceofactions:
attachrenderbuffer1toDEPTH_ATTACHMENT;
attachrenderbuffer2toDEPTH_STENCIL_ATTACHMENT;
attachnulltoDEPTH_STENCIL_ATTACHMENT.
InWebGL1.0,theframebufferendsupwithrenderbuffer1attachedtoDEPTH_ATTACHMENTandnoimageattachedtoSTENCIL_ATTACHMENT;inWebGL2.0,however,neitherDEPTH_ATTACHMENTnorSTENCIL_ATTACHMENThasanimageattached.
TheconstraintsdefinedinFramebufferObjectAttachmentsnolongerapplyinWebGL2.0.
Ifdifferentimagesareboundtothedepthandstencilattachmentpoints,checkFramebufferStatusreturnsFRAMEBUFFER_UNSUPPORTED,andgetFramebufferAttachmentParameterwithattachmentofDEPTH_STENCIL_ATTACHMENTgeneratesanINVALID_OPERATIONerror.
TextureTypeinTexSubImage2DCalls
IntheWebGL1.0API,thetypeargumentpassedtotexSubImage2Dmust
matchthetypeusedtooriginallydefinethetextureobject(i.e.,usingtexImage2D).
IntheWebGL2.0API,thisrestrictionhasbeenlifted.
Out-of-boundsBehaviorsincopyTexSubImage2DandreadPixelscalls
InWebGL1.0,
ReadingPixelsOutsidetheFramebuffer,itisrequiredthat
copyTexSubImage2DandreadPixelsdonottouch
thecorrespondingdestinationrangeforout-of-boundpixels.
InWebGL2.0,whenaPACK_BUFFERobjectisboundand
PACK_ROW_LENGTHisnotzeroandlessthanwidth,
orwhenaUNPACK_BUFFERobjectisboundand
UNPACK_ROW_LENGTHisnotzeroandlessthanwidth
orUNPACK_IMAGE_HEIGHTisnotzeroandlessthanheight,
packing/unpackingarow/imagemayextendtothenextrow/image.Ifthat
portionisout-of-bounds,thevaluesmaychangeaccordingly.
ColorconversionincopyTex{Sub}Image2D
InWebGL1.0(OpenGLES2.0),itisallowedforthecomponentsizesof
internalformattobelessthanthecorrespondingcomponentsizes
ofthesourcebuffer'sinternalformat.However,inWebGL2.0(OpenGLES3.0),
ifinternalformatissized,itscomponentsizesmustexactly
matchthecorrespondingcomponentsizesofthesourcebuffer'seffective
internalformat.
InbothWebGL1.0and2.0,sourcebuffercomponentscanbedroppedduringthe
conversiontointernalformat,butnewcomponentscannotbeadded.
getFramebufferAttachmentParameterwithFRAMEBUFFER_ATTACHMENT_OBJECT_NAME
IfgetFramebufferAttachmentParameteriscalledwithpname
FRAMEBUFFER_ATTACHMENT_OBJECT_NAMEandattachmenthasno
imageattached,inWebGL1.0/ES2.0,itgeneratesanINVALID_OPERATION;
inWebGL2.0/ES3.0,itgeneratesnoerrorandnullisreturned.
NewFeaturesSupportedintheWebGL2.0API
Pixelbufferobjects(OpenGLES3.0.6§3.7.1andOpenGLES3.0.6§4.3)
Primitiverestart(OpenGLES3.0.6§2.9.1)
Rasterizerdiscard(OpenGLES3.0.6§3.1)
GLSLES3.00support
InadditiontosupportingTheOpenGLESShadingLanguage,Version1.00,theWebGL2.0APIalsoaccepts
shaderswritteninTheOpenGLESShadingLanguage,Version3.00
[GLES30GLSL],withsomerestrictions.
AshaderreferencingstatevariablesorfunctionsthatareavailableinotherversionsofGLSL,
suchasthatfoundinversionsofOpenGLforthedesktop,mustnotbeallowedtoload.
AsintheWebGL1.0API,identifiersstartingwith"webgl_"and"_webgl_"arereservedforuseby
WebGL.Ashaderwhichdeclaresafunction,variable,structurename,orstructurefieldstartingwith
theseprefixesmustnotbeallowedtoload.
MaximumGLSLTokenSize
WebGL1.0supportstokensupto256charactersinlength.WebGL2.0followsTheOpenGLESShadingLanguage,Version3.00
(OpenGLES3.0.6§1.5.1)
andallowstokensupto1024charactersinlengthforbothESSL1andESSL3shaders.Shaderscontainingtokenslongerthan1024charactersmustfailtocompile.
MaximumUniformandAttributeLocationLengths
WebGL2.0imposesalimitof1024charactersonthelengthsofuniformandattributelocations.
VertexAttributeDivisor
IntheWebGL2.0API,vertexattributeswhichhaveanon-zerodivisordonotadvanceduringcallsto
drawArraysanddrawElements.
(OpenGLES3.0.6§2.9.3)
DifferencesBetweenWebGLandOpenGLES3.0
ThissectiondescribeschangesmadetotheWebGLAPIrelativetothe
OpenGLES3.0APItoimproveportabilityacrossvariousoperating
systemsanddevices.
BufferObjectBinding
WebGLbuffertype
Bindingpointsthatsetthistype
undefined
none
elementarray
ELEMENT_ARRAY_BUFFER
otherdata
allbindingpointsexceptELEMENT_ARRAY_BUFFER,COPY_READ_BUFFERandCOPY_WRITE_BUFFER
IntheWebGL2.0API,buffershavetheirWebGLbuffertypeinitiallysettoundefined.Calling
bindBuffer,bindBufferRangeorbindBufferBasewiththe
targetargumentsettoanybufferbindingpointexceptCOPY_READ_BUFFERor
COPY_WRITE_BUFFERwillthensettheWebGLbuffertypeofthebufferbeingbound
accordingtothetableabove.Bindingabufferwithtypeundefinedto
theCOPY_READ_BUFFERorCOPY_WRITE_BUFFERbindingpointswillset
itstypetootherdata.
Anycalltooneofthesefunctionswhichattemptstobindadeletedbufferwillgeneratea
INVALID_OPERATIONerror,andthebindingwillremainuntouched.
AnycalltooneofthesefunctionswhichattemptstobindaWebGLBufferthathastheelement
arrayWebGLbuffertypetoabindingpointthatfallsunderotherdata,orbinda
WebGLBufferwhichhastheotherdataWebGLbuffertypetoELEMENT_ARRAY_BUFFER
willgenerateanINVALID_OPERATIONerror,andthestateofthebindingpointwillremain
untouched.
Thisrestrictionimpliesthatagivenbufferobjectmaycontaineitherindicesorotherdata,but
notboth.
Theserestrictionsaresimilartobufferobjectbinding
restrictionsintheWebGL1.0specification.
ThisrestrictionhasbeenaddedtopreventwritingtoindexbuffersontheGPU,whichwouldmake
doinganyCPU-sidechecksonindexdataprohibitivelyexpensive.Handlingindexbuffersasdifferent
fromotherbufferdataalsomapsbettertotheDirect3DAPI.
CopyingBuffers
AttemptingtousecopyBufferSubDatatocopybetweenbuffersthathave
elementarrayandotherdataWebGLbuffertypesasspecifiedinsection
BufferObjectBindinggeneratesan
INVALID_OPERATIONerrorandnocopyingisperformed.
SameaswithBufferObjectBindingrestrictionsabove.
PreventingundefinedbehaviorwithTransformFeedback
AbufferwhichissimultaneouslyboundtoaTRANSFORM_FEEDBACK_BUFFERbindingpointinthecurrently
boundtransformfeedbackobjectandanyotherbindingpointintheWebGLAPIcannotbeused.Any
attempteduseofsuchadoubleboundbufferfailswithanINVALID_OPERATIONerror,
regardlessofwhethertransformfeedbackisenabled.Forexample,readPixelstoaPIXEL_PACK_BUFFER
willfailifthebufferisalsoboundtothecurrenttransformfeedbackobject.
Ifanerrorwerenotgenerated,thevaluesreadorwrittenwouldbeundefined.
(
OpenGLES3.0.6§2.15.2)
Incasethesamebufferisboundtomorethanonebindingpointintheactivetransformfeedback,
beginTransformFeedbackgeneratesanINVALID_OPERATIONerror.
ThiscanhappenonlyinSEPARATE_ATTRIBSmode.
ThisisarestrictionfromD3D11,wherewritingtwodifferentstreamstothesamebufferisnot
allowed.
DrawBuffers
ThevalueoftheMAX_COLOR_ATTACHMENTSparametermustbeequaltothatoftheMAX_DRAW_BUFFERS
parameter.
Thereisnousecasefortheseparametersbeingdifferent.
IfanESSL1fragmentshaderwritestoneithergl_FragColornorgl_FragData,
thevaluesofthefragmentcolorsfollowingshaderexecutionareuntouched.Ifcorrespondingoutput
variablesarenotdefinedinanESSL3fragmentshader,thevaluesofthefragmentcolorsfollowing
shaderexecutionareuntouched.
Alluser-definedoutputvariablesdefaulttozeroiftheyarenotwrittenduringashaderexecution.
Foroptimalperformance,anoutputarrayshouldnotincludeanyelementsthatarenotaccessed.
Ifthevalueswrittenbythefragmentshaderdonotmatchtheformat(s)ofthecorresponding
colorbuffer(s)(forexample,theoutputvariableisaninteger,butthecorrespondingcolor
bufferhasafloating-pointformat,orviceversa),andthecolorbufferstatesarenotsetto
NONEbyDrawBuffers,drawsgenerateanINVALID_OPERATIONerror;
ifthecolorbufferstatesaresettoNONEbyDrawBuffers,theyremainuntouched.
Ifanydrawbufferwithanattachmentdoesnothaveadefinedfragmentshaderoutput,draws
generateINVALID_OPERATION,unlessall4channelsofcolorMaskaresettofalse.
NoProgramBinaries
AccessingbinaryrepresentationsofcompiledshaderprogramsisnotsupportedintheWebGL2.0API.
ThisincludesOpenGLES3.0GetProgramBinary,ProgramBinary,and
ProgramParameterientrypoints.Inaddition,queryingtheprogrambinarylengthwith
getProgramParameter,andqueryingprogrambinaryformatswithgetParameter
arenotsupportedintheWebGL2.0API.
RangeChecking
InadditiontotherangecheckingspecifiedintheWebGL1.0specificationsection
EnabledVertexAttributesandRangeChecking,
indicesreferencedbydrawElements,drawRangeElementsor
drawElementsInstancedthataregreaterthantheMAX_ELEMENT_INDEXparameter
causethedrawcalltogenerateanINVALID_OPERATIONerroreveniftheyliewithinthe
storageoftheboundbuffer.Rangecheckingisnotperformedforindicesthattriggerprimitive
restartifprimitiverestartisenabled.TherangecheckingspecifiedfordrawArraysin
theWebGL1.0APIisalsoappliedtodrawArraysInstancedintheWebGL2.0API.
TheOpenGLrobustnessextensionsdonotspecifywhathappensifindicesaboveMAX_ELEMENT_INDEXare
used,sopassingthemtothedriverisrisky.OnplatformswhereMAX_ELEMENT_INDEXisthesameas
themaximumunsignedintegervaluethissectionwillhavenoeffect.
ActiveUniformBlockBacking
IntheWebGL2.0API,attemptingtodrawwithdrawArrays,drawElements,
drawRangeElementsortheirinstancedvariantsgeneratesanINVALID_OPERATION
errorifanyactiveuniformblockintheprogramusedforthedrawcommandisnotbackedbya
sufficientlylargebufferobject.
InOpenGL,insufficientuniformblockbackingisallowedtocauseGLinterruptionortermination.
SeeOpenGLES3.0specificationsection2.12.6
(
OpenGLES3.0.6§2.12.6),under"UniformBufferObjectBindings."
DefaultFramebuffer
WebGLalwayshasadefaultframebuffer.TheFRAMEBUFFER_UNDEFINEDenumerantisremoved
fromtheWebGL2.0API.
StringLengthQueries
IntheWebGL2.0API,theenumerantsACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH,
TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH,UNIFORM_BLOCK_NAME_LENGTH,and
UNIFORM_NAME_LENGTHareremovedinadditiontosimilar
enumerantsremovedintheWebGL1.0API.
InvalidClears
IntheWebGL2.0API,tryingtoperformaclearwhenthereisamismatchbetweenthetypeofthe
specifiedclearvalueandthetypeofabufferthatisbeingclearedgeneratesan
INVALID_OPERATIONerrorinsteadofproducingundefinedresults.
InvalidTextureOffsets
AGLSLshaderwhichattemptstouseatextureoffsetvalueoutsidetherangespecifiedby
implementation-definedparametersMIN_PROGRAM_TEXEL_OFFSETand
MAX_PROGRAM_TEXEL_OFFSETintexturelookupfunctionargumentsmustfail
compilationintheWebGL2.0API.
Usinganoffsetoutsidethevalidrangereturnsundefinedresults,soitcannotbeallowed.
TheoffsetmustbeaconstantexpressionaccordingtotheGLSLESspec,socheckingthe
valueagainstthecorrectrangecanbedoneatcompiletime.
TexelFetches
TexelfetchesthathaveundefinedresultsintheOpenGLES3.0APImustreturnzero,oratexture
sourcecolorof(0,0,0,1)inthecaseofatexelfetchfromanincompletetextureintheWebGL2.0
API.
Behaviorofout-of-rangetexelfetchesneedstobetestableinordertoguaranteesecurity.
GLSLES1.00FragmentShaderOutput
AfragmentshaderwritteninTheOpenGLESShadingLanguage,Version1.00,thatstaticallyassignsa
valuetogl_FragData[n]wherendoesnotequalconstantvalue0mustfail
tocompileintheWebGL2.0API.ThisistoachieveconsistencywithTheOpenGLES3.0specification
section4.2.1(OpenGLES3.0.6§4.2.1)
andTheOpenGLESShadingLanguage3.00.6specificationsection1.5(GLSLES3.00.6§1.5).
AsintheOpenGLES3.0API,multiplefragmentshaderoutputsareonlysupportedforGLSLES3.00
shadersintheWebGL2.0API.
NoMapBufferRange
TheMapBufferRange,FlushMappedBufferRange,andUnmapBuffer
entrypointsareremovedfromtheWebGL2.0API.Thefollowingenumvaluesarealsoremoved:
BUFFER_ACCESS_FLAGS,BUFFER_MAP_LENGTH,BUFFER_MAP_OFFSET,
MAP_READ_BIT,MAP_WRITE_BIT,MAP_INVALIDATE_RANGE_BIT,
MAP_INVALIDATE_BUFFER_BIT,MAP_FLUSH_EXPLICIT_BIT,and
MAP_UNSYNCHRONIZED_BIT.
InsteadofusingMapBufferRange,bufferdatamaybereadbyusingthe
getBufferSubDataentrypoint.
TIMEOUT_IGNORED
IntheWebGL2.0APITIMEOUT_IGNOREDisdefinedasaGLint64withthevalue
-1insteadofaGLuint64withthevalue0xFFFFFFFFFFFFFFFF.This
isbecauseJavascriptcannotaccuratelyrepresentanintegerthatlarge.Forthesamereason
waitSynctakesGLint64valuesinsteadofGLuint64fortimeout.
clientWaitSync
IntheWebGL2.0API,WebGLimplementationsmustenforceashortmaximumtimeoutoncallstoclientWaitSyncin
ordertoavoidblockingexecutionofthemainthreadforexcessiveperiodsoftime.Thistimeoutmaybequeried
bycallinggetParameterwiththeargumentMAX_CLIENT_WAIT_TIMEOUT_WEBGL.
Theimplementation-definedmaximumtimeoutisnotspecified.Itisacceptableforanimplementationtoenforcea
zeromaximumtimeout.
VertexAttributeAliasing
WebGL2.0APIimplementationsmuststrictlyfollowGLSLES3.00.6section12.46,which
specifiesthatanyvertexattributealiasingisdisallowed.Asstatedin
[GLES30]p57,GLSLES1.00shadersmaystillalias,asallowedby
theWebGL1.0specsectionAttribute
aliasing.
PRIMITIVE_RESTART_FIXED_INDEXisalwaysenabled
ThePRIMITIVE_RESTART_FIXED_INDEXcontextstate,controlled
withEnable/DisableinOpenGLES3.0,isnotsupportedinWebGL
2.0.Instead,WebGL2.0behavesasthoughthisstatewerealwaysenabled.Thisisa
compatibilitydifferencecomparedtoWebGL1.0.
WhendrawElements,drawElementsInstanced,
ordrawRangeElementsprocessesanindex,iftheindex'svalueisthemaximum
forthedatatype(255forUNSIGNED_BYTEindices,65535
forUNSIGNED_SHORT,or4294967295forUNSIGNED_INT),thenthe
vertexisnotprocessednormally.Instead,itisasifthedrawingcommandendedwiththe
immediatelyprecedingvertex,andanotherdrawingcommandisimmediatelystartedwiththe
sameparameters,butonlytransferringtheimmediatelyfollowingindexthroughtheendof
theoriginallyspecifiedindices.
Thiscompatibilitydifferencewasintroducedinordertoavoidperformancepitfallsin
Direct3DbasedWebGLimplementations.Applicationsandcontentcreationtoolscanbe
adjustedtoavoidusingthemaximumvertexindexiftheprimitiverestartbehaviorisnot
desired.
Notextureswizzles
OpenGLES3.0introducesnewstateontextureobjectsallowingafour-channelswizzle
operationtobespecifiedagainstthetexture.Theswizzleisappliedtoeverytexture
lookupperformedwithinanyshaderreferencingthattexture.Thesetextureswizzlesare
notsupportedinWebGL2.0.TEXTURE_SWIZZLE_*enumvaluesareremovedfrom
theWebGL2.0API.
TextureswizzlescannotbeimplementedinaperformantmanneronDirect3DbasedWebGL
implementations.Applicationsrelyingonthisfunctionalitywouldrunsignificantlymore
slowlyonthoseimplementations.Applicationsarestillabletoswizzleresultsoftexture
fetchesinshadersandswizzletexturedatabeforeuploadingwithoutthisinterface.
Queriesshouldfailonaprogramthatfailedtolink
OpenGLES3.0allowsapplicationstoenumerateandquerypropertiesof
activevariablesandinterfaceblocksofaspecifiedprogramevenif
thatprogramfailedtolink(OpenGLES3.0.6§2.12.3).
InWebGL,thesecommandswillalwaysgenerateanINVALID_OPERATIONerror
onaprogramthatfailedtolink,andnoinformationisreturned.
ThereturnedinformationinOpenGLES3.0isimplementationdependentandmaybeincomplete.
Theerrorconditionisaddedtoensureconsistentbehavioracrossallplatforms.
Colorvaluesfromafragmentshadermustmatchthecolorbufferformat
Colorvalueswrittenbyafragmentshadermaybefloating-point,signedinteger,orunsigned
integer.Ifthevalueswrittenbythefragmentshaderdonotmatchtheformat(s)ofthe
correspondingcolorbuffer(s),theresultisundefinedinOpenGLES3.0(OpenGLES3.0.6§3.9.2.3).InWebGL,generates
anINVALID_OPERATIONerrorinthecorrespondingdrawcall,including
drawArrays,drawElements,drawArraysInstanced
,drawElementsInstanced,anddrawRangeElements.
Ifthecolorbufferhasanormalizedfixed-pointformat,floating-pointcolor
valuesareconvertedtomatchtheformat;generatesnoerrorinsuchsituation.
Asamplertypemustmatchtheinternaltextureformat
Texturelookupfunctionsreturnvaluesasfloatingpoint,unsignedintegerorsignedinteger,
dependingonthesamplertypepassedtothelookupfunction.Ifthewrongsamplertypeis
usedfortextureaccess,i.e.,thesamplertypedoesnotmatchthetextureinternalformat,
thereturnedvaluesareundefinedinOpenGLESShadingLanguage3.00.6
(OpenGLESShadingLanguage3.00.6§8.8).
InWebGL,generatesanINVALID_OPERATIONerrorinthecorrespondingdrawcall,
includingdrawArrays,drawElements,drawArraysInstanced,
drawElementsInstanced,anddrawRangeElements.
Ifthesamplertypeisfloatingpointandtheinternaltextureformatis
normalizedinteger,itisconsideredasamatchandthereturnedvaluesareconvertedto
floatingpointintherange[0,1].
Queries'resultsmustnotbemadeavailableinthecurrentframe
InOpenGLES3.0,iftheappropriateprimitives(e.g.glFinish()oranother
synchronousAPI)arecalled,aquery'sresultmaybemadeavailableinthesameframeitwas
issued.InWebGL,inordertoimproveapplicationportability,aquery'sresultmustnever
bemadeavailabletotheapplicationinthesameframethequerywasissued.Seethe
specificationofgetQueryParameterfordiscussionand
rationale.
GLSLES3.00#extensiondirectivelocation
TheWebGL1.0specificationsection
GLSLES#extensiondirectivelocationonlyappliestoOpenGLESShadingLanguage1.00
shaders.ItdoesnotapplytoshadersthatarewritteninOpenGLESShadingLanguage3.00.
InshaderswritteninOpenGLESShadingLanguage3.00,#extensiondirectives
mustoccurbeforenon-preprocessortokensregardlessofwhatiswrittenintheextension
specification.
ThisisdonetomakeWebGL2.0tofollowthewrittenGLSLES3.00specificationmore
closely.EnforcingtherestrictionmorestrictlythannativeGLESdriversmakesthebehavior
well-defined.
Onlystd140layoutsupportedinuniformblocks
TheGLSLES3.00specificationsupportstheshared,packed,
andstd140layoutqualifiersforuniformblocks,defininghowvariablesare
laidoutinuniformbuffers'storage.Ofthese,theWebGL2.0specificationsupportsonly
thestd140layout,whichisdefined
inOpenGL
ES3.0.6§2.12"VertexShaders",subsection"StandardUniformBlock
Layout".Shadersattemptingtousethesharedorpackedlayout
qualifierswillfaileitherthecompilationorlinkingstages.
Theinitialstateofcompilationisasifthefollowingweredeclared:
layout(std140)uniform;
Thisrestrictionisenforcedtoimproveportabilitybyavoidingexposinguniformblock
layoutsthatarespecifictoonevendor'sGPUs.
DisallowedvariantsofGLSLES3.00operators
IntheWebGL2.0API,thefollowingshadinglanguageconstructsarenotallowedand
attemptingtousethemmustresultinacompileerror:
Ternaryoperatorappliedtovoid,arrays,orstructscontainingarrays
Sequenceoperatorappliedtovoid,arrays,orstructscontainingarrays
ThisrestrictionensureseasyportabilityacrossOpenGLES3.0supportingdevices.
checkFramebufferStatusmayreturnFRAMEBUFFER_INCOMPLETE_DIMENSIONS
Allattachedimagesmuchhavethesamewidthandheight;otherwise,checkFramebufferStatusreturnsFRAMEBUFFER_INCOMPLETE_DIMENSIONS.
InOpenGLES3,attachedimagesforaframebufferneednottohavethesamewidthandheighttobeframebuffercomplete,andFRAMEBUFFER_INCOMPLETE_DIMENSIONSisnotoneofthevalidreturnvaluesforcheckFramebufferStatus.However,inDirect3D11,ontopofwhichOpenGLES3behaviorisemulatedinWindows,allrendertargetsmusthavethesamesizeinalldimensions(seemsdnmanualpage).EmulationoftheES3semanticontopofDirectX11willbeinefficient.InordertohaveconsistentWebGL2.0behaviorsacrossplatforms,itisreasonabletokeeptheOpenGLES2/WebGL1.0restrictionforWebGL2.0thatallattachedimagesmusthavethesamewidthandheight.
Uniformblockmatching
IntheWebGL2.0API,layoutqualifiersrow_majorandcolumn_major
arerequiredtomatchinmatcheduniformblocksevenwhentheyareappliedexclusivelyon
non-matrixvariables.
ThisuniformblockmatchingruleisknowntobeinconsistentacrossOpenGLES3.0
implementations.
Framebuffercontentsafterinvalidation
InOpenGLES3.0,aftercallinginvalidateFramebufferorinvalidateSubFramebuffer,
theaffectedregion'scontentsbecomeeffectivelyundefined.InWebGL2.0,itisrequiredforthecontents
toeitherstayunchangedorbecomeall0.
ItisacceptableforWebGL2.0implementationstomakeinvalidateFramebufferor
invalidateSubFramebufferano-op.
NoArrayBufferViewmatchingtexturetypeFLOAT_32_UNSIGNED_INT_24_8_REV
IntexImage2DandtexImage3DwithArrayBufferView,if
typeisFLOAT_32_UNSIGNED_INT_24_8_REVandsrcDataisnot
null,generatesanINVALID_OPERATION.
IntexSubImage2DandtexSubImage3DwithArrayBufferView,iftypeis
FLOAT_32_UNSIGNED_INT_24_8_REV,generatesanINVALID_ENUM.
VertexAttribfunctionmustmatchshaderattributetype
Ifanyofthefollowingsituationsaretrue,attemptingtodrawwithdrawArrays,
drawElements,drawRangeElementsortheirinstancedvariantsgeneratesan
INVALID_OPERATIONerror:
vertexAttribPointer,vertexAttrib{1234}f,orvertexAttrib{1234}fv
isusedandthebasetypeoftheshaderattributeatslotindexisnot
floating-point(e.g.issignedorunsignedinteger);
vertexAttribIPointerisusedwithtypeUNSIGNED_BYTE,
UNSIGNED_SHORTorUNSIGNED_INT,orvertexAttribI4uior
vertexAttribI4uivisused,andthebasetypeoftheshaderattributeatslot
indexisnotunsignedinteger(e.g.isfloating-pointorsignedinteger);
vertexAttribIPointerisusedwithtypeBYTE,
SHORTorINT,orvertexAttribI4ior
vertexAttribI4ivisused,andthebasetypeoftheshaderattributeatslot
indexisnotsignedinteger(e.g.isfloating-pointorunsignedinteger).
ThisundefinedbehaviorisintheOpenGLES3.0specificationsection2.8
(
OpenGLES3.0.6§2.8).
Transformfeedbackprimitivecapture
Ifanyoutputvariableisspecifiedtobestreamedtoabufferobjectbutnotactually
writtenbyavertexshader,thevalueissetto0.
ThisundefinedbehaviorisintheOpenGLES3.0specificationsection2.15.2
(
OpenGLES3.0.6§2.15.2).
gl_FragDepth
Ifafragmentshaderstaticallyassignsavaluetogl_FragDepth,foranyfragment
wherestatementsassigningavaluetogl_FragDeptharenotexecuted,thevalue0isused.
ThisundefinedbehaviorisintheOpenGLES3.0specificationsection3.9.2
(
OpenGLES3.0.6§3.9.2).
Framebuffercolorattachments
Ifanimageisattachedtomorethanonecolorattachmentpointinaframebuffer,
checkFramebufferStatusreturnsFRAMEBUFFER_UNSUPPORTED.
Animagecanbeanindividualmiplevel,anarrayslice(fromeither2Darray
orcubemaptextures),ora3Dtextureslice.
ThisisalimitationofDirect3D11,ontopofwhichOpenGLES3behaviorisemulatedonWindows.
(seemsdnmanual
page).InordertohaveconsistentWebGL2.0behavioracrossplatforms,itisreasonabletoadd
thislimitationinWebGL2.0forallplatforms.
PixelstoreparametersforuploadsfromTexImageSource
UNPACK_ALIGNMENTandUNPACK_ROW_LENGTHareignored.
UNPACK_ALIGNMENTisspecifiedinbytes,andisimplicitand
implementation-dependentforTexImageSourceobjects.UNPACK_ROW_LENGTHis
currentlyunused.
SubrectselectionispossibleusingUNPACK_params.
UNPACK_SKIP_PIXELSandUNPACK_SKIP_ROWSdeterminetheoriginofthe
subrect,withthewidthandheightargumentsdeterminingthesizeofthesubrect.
For3Dtextures,thewidth,height,anddepth
argumentsspecifyarectangularregionofatexelarraytounpackto.
UNPACK_SKIP_IMAGESandUNPACK_IMAGE_HEIGHTallowselectionof
multipleslicesfromthe2Dsource.UNPACK_IMAGE_HEIGHTdeterminesthestride,
inrows,betweentwoslices.Forexample,aTexImageSource30pixelstallmay
havethetop10andbottom10rowsuploadedintotwoslicesofa3Dtexturebyuploadingwith
heightequalto10,UNPACK_IMAGE_HEIGHTsetto20,and
depthequalto2.IfUNPACK_IMAGE_HEIGHTis0,thestride,in
rows,betweentwoslicesdefaultstoheight.
ForanHTMLImageElement20pixelswide,passingwidth=10for
textureuploadwillcauseonlythelefthalfoftheimagetobeselected,thusuploaded.The
resultingtexturewillhaveawidthof10.If,additionallyinthisexample,
UNPACK_SKIP_PIXELSissetto10,onlytherighthalfoftheimageisselected
forunpack.
Also,UNPACK_SKIP_IMAGESappliesonlyto3Dentrypoints,notto2Dentrypoints.
Lookingatanotherexample,theabove32x48imageofsixcolors,eachofsize16x16,isuploadedto
a3Dtextureofwidth=2,height=1,anddepth=3.
IfUNPACK_SKIP_PIXELSis0,UNPACK_SKIP_ROWSis0,andUNPACK_IMAGE_HEIGHT
is0,theentiretexelarrayissettored.
IfUNPACK_SKIP_PIXELSis16,UNPACK_SKIP_ROWSis16,andUNPACK_IMAGE_HEIGHT
is0,theentiretexelarrayissettoyellow.
IfUNPACK_SKIP_PIXELSis0,UNPACK_SKIP_ROWSis0,andUNPACK_IMAGE_HEIGHT
is16,thefirstsliceofthetexelarrayisred,thesecondsliceisblue,andthethirdsliceispurple.
IfUNPACK_SKIP_PIXELSis16,UNPACK_SKIP_ROWSis0,andUNPACK_IMAGE_HEIGHT
is16,thefirstsliceofthetexelarrayisgreen,thesecondsliceisyellow,andthethirdsliceispink.
Pixelstoreparameterconstraints
Define:
DataStoreWidth:=ROW_LENGTH?ROW_LENGTH:width
DataStoreHeight:=IMAGE_HEIGHT?IMAGE_HEIGHT:height
IfPACK_SKIP_PIXELS+width>DataStoreWidth,readPixels
generatesanINVALID_OPERATIONerror.
IfUNPACK_SKIP_PIXELS+width>DataStoreWidth,
texImage2DandtexSubImage2Dgeneratean
INVALID_OPERATIONerror.ThisdoesnotapplytotexImage2Difno
PIXEL_UNPACK_BUFFERisboundandsrcDataisnull.
IfUNPACK_SKIP_PIXELS+width>DataStoreWidthor
UNPACK_SKIP_ROWS+height>DataStoreHeight,texImage3D
andtexSubImage3DgenerateanINVALID_OPERATIONerror.Thisdoes
notapplytotexImage3DifnoPIXEL_UNPACK_BUFFERisboundand
srcDataisnull.
Theseconstraintsnormalizetheuseoftheseparameterstospecifyasubregionwhere
pixelsarestored.Forexample,inreadPixelscases,ifwewanttostore
pixelstoasubareaoftheentiredatastore,wecanusePACK_ROW_LENGTHto
specifythedatastorewidth,andPACK_SKIP_PIXELS,
PACK_SKIP_ROWS,widthandheighttospecifythesubarea's
xoffset,yoffset,width,andheight.
Thesecontraintsalsoforbidrowandimageoverlap,wherethesituationsarenottestedin
theOpenGLES3.0DEQPtestsuites,andmanydriversbehaveincorrectly.Theyalsoforbid
skippingrandompixelsorrows,butthatcanbeachievedbyadjustingthedatastoreoffset
accordingly.
Further,foruploadsfromTexImageSource,implied
UNPACK_ROW_LENGTHandUNPACK_ALIGNMENTarenotstrictlydefined.
Theserestrictionsensureconsistentandefficientbehaviorregardlessofimplied
UNPACK_params.
IfUNPACK_FLIP_Y_WEBGLorUNPACK_PREMULTIPLY_ALPHA_WEBGLissettotrue,
texImage2DandtexSubImage2DgenerateanINVALID_OPERATIONerror
iftheyuploaddatafromaPIXEL_UNPACK_BUFFER.
IfUNPACK_FLIP_Y_WEBGLorUNPACK_PREMULTIPLY_ALPHA_WEBGLissettotrue,
texImage3DandtexSubImage3DgenerateanINVALID_OPERATIONerror
iftheyuploaddatafromaPIXEL_UNPACK_BUFFERoranon-nullclientside
ArrayBufferView.
NoETC2andEACcompressedtextureformats
OpenGLES3.0requiressupportforthefollowingETC2andEACcompressedtextureformats:
COMPRESSED_R11_EAC,COMPRESSED_SIGNED_R11_EAC,COMPRESSED_RG11_EAC,
COMPRESSED_SIGNED_RG11_EAC,COMPRESSED_RGB8_ETC2,COMPRESSED_SRGB8_ETC2,
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
COMPRESSED_RGBA8_ETC2_EAC,andCOMPRESSED_SRGB8_ALPHA8_ETC2_EAC.
ThesetextureformatsarenotsupportedbydefaultinWebGL2.0.
TheseformatsarenotnativelysupportedbymostdesktopGPUhardware.
Assuch,supportingtheseformatsrequiressoftwaredecompressionineitherthe
WebGLimplementationortheunderlyingdriver.Thisresultsinadrastic
increaseinvideomemoryusage,causingperformancelosseswhichare
invisibletotheWebGLapplication.
OnhardwarewhichsupportstheETC2andEACcompressedtextureformatsnatively
(e.g.mobileOpenGLES3.0+hardware),theymaybeexposedviatheextension
WEBGL_compressed_texture_etc.
ThevalueofUNIFORM_BUFFER_OFFSET_ALIGNMENTmustbedivisibleby4
ThevalueofUNIFORM_BUFFER_OFFSET_ALIGNMENT,asgiveninbasicmachineunits,mustbedivisibleby4.
IfthevalueofUNIFORM_BUFFER_OFFSET_ALIGNMENTwasnotdivisibleby4,itwouldmakeitimpracticaltouploadArrayBufferstouniformbufferswhichareboundwithBindBufferRange.
Syncobjects'resultsmustnotbemadeavailableinthecurrentframe
InOpenGLES3.0,iftheappropriateprimitives(e.g.glFinish()oranother
synchronousAPI)arecalled,asyncobjectmaybesignaledinthesameframeitwas
issued.InWebGL,inordertoimproveapplicationportability,asyncobjectmustnever
transitiontothesignaledstateinthesameframethesyncwasissued.Seethe
specificationofgetSyncParameter
andclientWaitSyncfordiscussionandrationale.
blitFramebufferrectanglewidth/heightlimitations
blitFramebuffer()src*anddst*parametersmustbesetsothattheresulting
widthandheightofthesourceanddestinationrectanglesarelessthanorequaltothe
maximumvaluethatcanbestoredinaGLint.Incasecomputinganyofthewidthorheight
valuesasaGLintresultsinintegeroverflow,blitFramebuffer()generatesan
INVALID_VALUEerror.
Usinglargerthanmax32-bitintsizedrectanglesforblitFramebuffertriggersissueson
mostdesktopOpenGLdrivers,andthereisnogeneralworkaroundforcaseswhere
blitFramebufferisusedtoscaletheframebuffer.
GenerateMipmaprequirespositiveimagedimensions
generateMipmaprequiresthatTEXTURE_BASE_LEVEL'sdimensionsareallpositive.
GLES3.0.6technicallyallowscallingGenerateMipmapon0x0images,thoughcubemapsmustbe
cube-complete,thushavingpositivedimensions.
Thischangesimplifiesimplementationsbyallowingaconceptofbase-level-completenessfor
textures,asotherwiserequiredfornon-mipmap-sampledvalidation.
SinceGenerateMipmaphasnoeffectona0x0texture,andisillegalinWebGL1(0isnota
poweroftwo),thisisaneasyrestrictiontoadd.
Further,GenerateMipmapwouldotherwisebetheonlyentrypointthathastooperateon
undefinedtextureimages,skippinganotherwise-commonvalidation.
deleteQueryimplicitlycallsendQueryifthequeryisactive
InGLES,DeleteQueriesdoesnotimplicitlyendqueries,eveniftheyareactive.
Thisdeviationwasnotoriginallyspecified,butwasimplicitlystandardizedacross
browsersbyconformancetests.
Someimplementationsfoundthisbehaviorsimplertoimplement.
RevertingthisbehaviortomatchtheGLESspecscouldbreakcontent,andatthis
pointit'sbettertospecwhatweimplemented.
Requiredcompressedtextureformats
Implementationsmustsupportatleastonesuiteofcompressedtextureformats.
Implementationsmustsupport:
WEBGL_compressed_texture_etcAND/OR
(
WEBGL_compressed_texture_s3tcAND
WEBGL_compressed_texture_s3tc_srgbAND
EXT_texture_compression_rgtc
)
Tobestsupportourecosystem,werequireimplementationstosupporteitherETC2/EACformats(universalonGLES3orsimilardrivers,likemanyphones)orS3TCformats(universalallotherdrivers).
Thisguaranteestoauthorsthattheycanalwaysusecompressedtextures(includingsrgbvariants)onalldeviceswhilemaintainingsupportforasfewastwodifferentformats.
Thereareroughlyequivalentformatsineachsuiteforthefollowinguses:
Usage
S3TC/RGTCoption(desktop)
ETC2/EACoption(mobile)
R11unsigned
COMPRESSED_RED_RGTC1_EXT
COMPRESSED_R11_EAC
R11signed
COMPRESSED_SIGNED_RED_RGTC1_EXT
COMPRESSED_SIGNED_R11_EAC
RG11unsigned
COMPRESSED_RED_GREEN_RGTC2_EXT
COMPRESSED_RG11_EAC
RG11signed
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT
COMPRESSED_SIGNED_RG11_EAC
RGB8unsigned
COMPRESSED_RGB_S3TC_DXT1_EXT
COMPRESSED_RGB8_ETC2
RGB8sRGB
COMPRESSED_SRGB_S3TC_DXT1_EXT
COMPRESSED_SRGB8_ETC2
RGB8punchthroughunsigned
COMPRESSED_RGBA_S3TC_DXT1_EXT
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
RGB8punchthroughsRGB
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
RGBA8unsigned
COMPRESSED_RGBA_S3TC_DXT5_EXT
COMPRESSED_RGBA8_ETC2_EAC
RGBA8sRGB
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
References
[WEBGL10]
WebGLSpecification1.0.4Editor'sDraft,
DeanJackson,JeffGilbert.
[CANVAS]
HTML5:TheCanvasElement,
WorldWideWebConsortium(W3C).
[OFFSCREENCANVAS]
HTMLLivingStandard-TheOffscreenCanvasinterface,
WHATWG.
[CANVASCONTEXTS]
CanvasContextRegistry,
WHATWG.
[GLES30]
OpenGL®ESVersion3.0.6,
J.Leech,B.Lipchak,August2019.
[GLES30GLSL]
TheOpenGL®ESShadingLanguageVersion3.00.6,
R.Simpson,January2016.
[REGISTRY]
WebGLExtensionRegistry
[RFC2119]
KeywordsforuseinRFCstoIndicateRequirementLevels,
S.Bradner.IETF,March1997.
[WEBIDL]
WebIDL-LivingStandard,
E.Chen,T.Gu,B.Zbarsky,C.McCormack,T.Langel.