WebGL2RenderingContext
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since â¨2021å¹´9æâ©.
* Some parts of this feature may have varying levels of support.
å®éªæ§: è¿æ¯ä¸é¡¹å®éªæ§ææ¯
å¨å°å
¶ç¨äºç产ä¹åï¼è¯·ä»ç»æ£æ¥æµè§å¨å
¼å®¹æ§è¡¨æ ¼ã
WebGL2RenderingContext æ¥å£å¨åºå±ä½¿ç¨äº OpenGL ES 3.0 为 HTML ç <canvas> å
ç´ æä¾äºç»å¾ä¸ä¸æã
è¦è·å该æ¥å£çå®ä¾å¯¹è±¡éè¦è°ç¨ä¸ä¸ª <canvas> æ ç¾å¯¹è±¡ç getContext() 彿°ï¼å¹¶å° "webgl2" ä½ä¸ºåæ°ä¼ éï¼
var canvas = document.getElementById("myCanvas");
var gl = canvas.getContext("webgl2");
夿³¨ï¼WebGL 2 æ¯ WebGL 1 çæ©å±ã WebGL2RenderingContext æ¥å£å®ç°äº WebGLRenderingContext æ¥å£çæææåãæä¸äº WebGL 1 ä¸ä¸æä¸çæ¹æ³å¨ä½¿ç¨ WebGL 2 ä¸ä¸æçæ¶åå¯ä»¥æ¥åéå å¼ãä½ å¯ä»¥éè¿ WebGL 1 çåè页äºè§£è¿äºä¿¡æ¯ã
è¿ä¸ª WebGL æç¨ 䏿ä¾äºå ³äºå¦ä½å¼å§ä½¿ç¨ WebGL çæ´å¤ä¿¡æ¯ã示ä¾ä»¥åèµæºã
常é
请ç WebGL 常é 页é¢ã
ç¶æä¿¡æ¯
WebGL2RenderingContext.getIndexedParameter()-
è¿åæå®ç®æ çç´¢å¼å¼ã
ç¼å²åº
WebGL2RenderingContext.copyBufferSubData()-
å°ç¼å²åºçé¨åæ°æ®å¤å¶å°å¦ä¸ä¸ªç¼å²åºã
WebGL2RenderingContext.getBufferSubData()-
ä»ç¼å²åºä¸è¯»åæ°æ®ï¼ç¶åå°å ¶åå ¥å°
ArrayBufferæSharedArrayBufferä¸ã
帧ç¼å²åº
WebGL2RenderingContext.blitFramebuffer()-
å°ä¸ä¸ªåç´ åä»è¯»å帧ç¼å²åºä¼ è¾å°ç»å¶å¸§ç¼å²åºã
WebGL2RenderingContext.framebufferTextureLayer()-
éçä¸ä¸ªåå±çæè´¨å°å¸§ç¼å²åºã
WebGL2RenderingContext.invalidateFramebuffer()-
使éçå°ç¼å²åºçå 容失æã
WebGL2RenderingContext.invalidateSubFramebuffer()-
使éçå°ç¼å²åºçé¨åå 容失æã
WebGL2RenderingContext.readBuffer()-
éæ©ä¸ä¸ªé¢è²ç¼å²ä½ä¸ºåç´ ç sourceã
渲æç¼å²åº
WebGL2RenderingContext.getInternalformatParameter()-
Returns information about implementation-dependent support for internal formats.
WebGL2RenderingContext.renderbufferStorageMultisample()-
Creates and initializes a renderbuffer object's data store and allows specifying the number of samples to be used.
纹ç
WebGL2RenderingContext.texStorage2D()-
Specifies all levels of two-dimensional texture storage.
WebGL2RenderingContext.texStorage3D()-
Specifies all levels of a three-dimensional texture or two-dimensional array texture.
WebGL2RenderingContext.texImage3D()-
Specifies a three-dimensional texture image.
WebGL2RenderingContext.texSubImage3D()-
Specifies a sub-rectangle of the current 3D texture.
WebGL2RenderingContext.copyTexSubImage3D()-
Copies pixels from the current
WebGLFramebufferinto an existing 3D texture sub-image. WebGL2RenderingContext.compressedTexImage3D()-
Specifies a three-dimensional texture image in a compressed format.
WebGL2RenderingContext.compressedTexSubImage3D()-
Specifies a three-dimensional sub-rectangle for a texture image in a compressed format.
ç¨åºåçè²å¨
WebGL2RenderingContext.getFragDataLocation()-
Returns the binding of color numbers to user-defined varying out variables.
Uniforms å Attributes
WebGL2RenderingContext.uniform[1234][fiu][v]()-
æå®ä¸ä¸ª uniform åéã
WebGL2RenderingContext.uniformMatrix[1234][fv]()-
æå®ä¸ä¸ª uniform ç©éµåéã
WebGL2RenderingContext.vertexAttribI[iuv]()-
Methods specifying integer values for generic vertex attributes.
WebGL2RenderingContext.vertexAttribIPointer()-
Specifies integer data formats and locations of vertex attributes in a vertex attributes array.
ç»å¾ç¼å²åº
WebGL2RenderingContext.vertexAttribDivisor()-
Modifies the rate at which generic vertex attributes advance when rendering multiple instances of primitives with
gl.drawArraysInstanced()andgl.drawElementsInstanced(). WebGL2RenderingContext.drawArraysInstanced()-
Renders primitives from array data. In addition, it can execute multiple instances of the range of elements.
WebGL2RenderingContext.drawElementsInstanced()-
Renders primitives from array data. In addition, it can execute multiple instances of a set of elements.
WebGL2RenderingContext.drawRangeElements()-
Renders primitives from array data in a given range.
WebGL2RenderingContext.drawBuffers()-
Specifies a list of color buffers to be drawn into.
WebGL2RenderingContext.clearBuffer[fiuv]()-
Clears buffers from the currently bound framebuffer.
æ¥è¯¢å¯¹è±¡
Methods for working with WebGLQuery objects.
WebGL2RenderingContext.createQuery()-
å建ä¸ä¸ªæ°ç
WebGLQuery对象ã WebGL2RenderingContext.deleteQuery()-
å é¤ä¸ä¸ªæå®ç
WebGLQuery对象ã WebGL2RenderingContext.isQuery()-
Returns
trueif a given object is a validWebGLQueryobject. WebGL2RenderingContext.beginQuery()-
å¼å§ä¸ä¸ªå¼æ¥æ¥è¯¢ã
WebGL2RenderingContext.endQuery()-
Marks the end of an asynchronous query.
WebGL2RenderingContext.getQuery()-
è¿åä¸ä¸ªæå®ç®æ ç
WebGLQuery对象ã WebGL2RenderingContext.getQueryParameter()-
è¿åå ³äºä¸ä¸ªæ¥è¯¢çä¿¡æ¯ã
éæ ·å¯¹è±¡
WebGL2RenderingContext.createSampler()-
Creates a new
WebGLSamplerobject. WebGL2RenderingContext.deleteSampler()-
Deletes a given
WebGLSamplerobject. WebGL2RenderingContext.bindSampler()-
Binds a given
WebGLSamplerto a texture unit. WebGL2RenderingContext.isSampler()-
Returns
trueif a given object is a validWebGLSamplerobject. WebGL2RenderingContext.samplerParameter[if]()-
Sets sampler parameters.
WebGL2RenderingContext.getSamplerParameter()-
Returns sampler parameter information.
åæ¥å¯¹è±¡
WebGL2RenderingContext.fenceSync()-
å建ä¸ä¸ª
WebGLSync对象并æå ¥å° GL å½ä»¤æµä¸ã WebGL2RenderingContext.isSync()-
Returns
trueif the passed object is a validWebGLSyncobject. WebGL2RenderingContext.deleteSync()-
å é¤ä¸ä¸ªæå®ç
WebGLSync对象ã WebGL2RenderingContext.clientWaitSync()-
Blocks and waits for a
WebGLSyncobject to become signaled or a given timeout to be passed. WebGL2RenderingContext.waitSync()-
Returns immediately, but waits on the GL server until the given
WebGLSyncobject is signaled. WebGL2RenderingContext.getSyncParameter()-
æ ¹æ®ä¸ä¸ª
WebGLSync对象è¿ååæ°ä¿¡æ¯ã
忢åé¦
WebGL2RenderingContext.createTransformFeedback()-
å建并åå§å
WebGLTransformFeedback对象ã WebGL2RenderingContext.deleteTransformFeedback()-
å é¤ä¸ä¸ªæå®ç
WebGLTransformFeedback对象ã WebGL2RenderingContext.isTransformFeedback()-
Returns
trueif the passed object is a validWebGLTransformFeedbackobject. WebGL2RenderingContext.bindTransformFeedback()-
Binds a passed
WebGLTransformFeedbackobject to the current GL state. WebGL2RenderingContext.beginTransformFeedback()-
Starts a transform feedback operation.
WebGL2RenderingContext.endTransformFeedback()-
Ends a transform feedback operation.
WebGL2RenderingContext.transformFeedbackVaryings()-
Specifies values to record in
WebGLTransformFeedbackbuffers. WebGL2RenderingContext.getTransformFeedbackVarying()-
Returns information about varying variables from
WebGLTransformFeedbackbuffers. WebGL2RenderingContext.pauseTransformFeedback()-
Pauses a transform feedback operation.
WebGL2RenderingContext.resumeTransformFeedback()-
Resumes a transform feedback operation.
Uniform ç¼å²å¯¹è±¡
WebGL2RenderingContext.bindBufferBase()-
Binds a given
WebGLBufferto a given binding point (target) at a givenindex. WebGL2RenderingContext.bindBufferRange()-
Binds a range of a given
WebGLBufferto a given binding point (target) at a givenindex. WebGL2RenderingContext.getUniformIndices()-
Retrieves the indices of a number of uniforms within a
WebGLProgram. WebGL2RenderingContext.getActiveUniforms()-
Retrieves information about active uniforms within a
WebGLProgram. WebGL2RenderingContext.getUniformBlockIndex()-
Retrieves the index of a uniform block within a
WebGLProgram. WebGL2RenderingContext.getActiveUniformBlockParameter()-
Retrieves information about an active uniform block within a
WebGLProgram. WebGL2RenderingContext.getActiveUniformBlockName()-
Retrieves the name of the active uniform block at a given index within a
WebGLProgram. WebGL2RenderingContext.uniformBlockBinding()-
Assigns binding points for active uniform blocks.
é¡¶ç¹æ°ç»å¯¹è±¡
Methods for working with WebGLVertexArrayObject (VAO) objects.
WebGL2RenderingContext.createVertexArray()-
å建ä¸ä¸ªæ°ç
WebGLVertexArrayObjectã WebGL2RenderingContext.deleteVertexArray()-
å é¤ä¸ä¸ªæå®ç
WebGLVertexArrayObjectã WebGL2RenderingContext.isVertexArray()-
妿ä¸ä¸ªæå®ç
WebGLVertexArrayObject对象ææåè¿åtrueã WebGL2RenderingContext.bindVertexArray()-
ç»å®ä¸ä¸ªæå®ç
WebGLVertexArrayObjectå°ç¼å²ã
è§è
| Specification |
|---|
| WebGL 2.0 Specification > # 3.7 > |