codecamp

图形的绘制

WebGL2支持图形的绘制,包括对当前绘制图形的位置、颜色等进行处理,其中相对WebGL来说对渲染管道和着色语言进行了增强。

WebGL标准图形API,对应OpenGL ES 3.0特性集。更多信息请参考WebGL™标准

说明

本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

WebGL2遵循OpenGL协议,不支持多线程调用。

目前该功能仅支持使用兼容JS的类Web开发范式开发。

调用方式

hml内创建canvas,示例如下:

  1. <!--xxx.hml-->
  2. <div class="container">
  3. <canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
  4. <button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
  5. </div>

js内获取canvas实例,示例如下:

  1. // 获取canvas组件实例
  2. const el = this.$refs.canvas1;
  3. // 从canvas组件实例获取WebGL上下文
  4. const gl = el.getContext('webgl2');
  5. // 调用WebGL API
  6. gl.clearColor(0.0, 0.0, 0.0, 1.0);

Type

系统能力: 以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL2。

表1 Type

名称类型
GLenumnumber
GLint64number
GLuint64number
Uint32Listarray

Interface

系统能力: 以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL2。

表2 Interface

名称
WebGL2RenderingContextBase
WebGL2RenderingContextOverloads
WebGLQuery
WebGLSampler
WebGLSync
WebGLTransformFeedback
WebGLVertexArrayObject

WebGL2RenderingContextBase

WebGL2RenderingContextBase

属性

名称参数类型必填
READ_BUFFERGLenum
UNPACK_ROW_LENGTHGLenum
UNPACK_SKIP_ROWSGLenum
UNPACK_SKIP_PIXELSGLenum
PACK_ROW_LENGTHGLenum
PACK_SKIP_ROWSGLenum
PACK_SKIP_PIXELSGLenum
COLORGLenum
DEPTHGLenum
STENCILGLenum
REDGLenum
RGB8GLenum
RGBA8GLenum
RGB10_A2GLenum
TEXTURE_BINDING_3DGLenum
UNPACK_SKIP_IMAGESGLenum
UNPACK_IMAGE_HEIGHTGLenum
TEXTURE_3DGLenum
TEXTURE_WRAP_RGLenum
MAX_3D_TEXTURE_SIZEGLenum
UNSIGNED_INT_2_10_10_10_REVGLenum
MAX_ELEMENTS_VERTICESGLenum
MAX_ELEMENTS_INDICESGLenum
TEXTURE_MIN_LODGLenum
TEXTURE_MAX_LODGLenum
TEXTURE_BASE_LEVELGLenum
TEXTURE_MAX_LEVELGLenum
MINGLenum
MAXGLenum
DEPTH_COMPONENT24GLenum
MAX_TEXTURE_LOD_BIASGLenum
TEXTURE_COMPARE_MODEGLenum
TEXTURE_COMPARE_FUNCGLenum
CURRENT_QUERYGLenum
QUERY_RESULTGLenum
QUERY_RESULT_AVAILABLEGLenum
STREAM_READGLenum
STREAM_COPYGLenum
STATIC_READGLenum
STATIC_COPYGLenum
DYNAMIC_READGLenum
DYNAMIC_COPYGLenum
MAX_DRAW_BUFFERSGLenum
DRAW_BUFFER0GLenum
DRAW_BUFFER1GLenum
DRAW_BUFFER2GLenum
DRAW_BUFFER3GLenum
DRAW_BUFFER4GLenum
DRAW_BUFFER5GLenum
DRAW_BUFFER6GLenum
DRAW_BUFFER7GLenum
DRAW_BUFFER8GLenum
DRAW_BUFFER9GLenum
DRAW_BUFFER10GLenum
DRAW_BUFFER11GLenum
DRAW_BUFFER12GLenum
DRAW_BUFFER13GLenum
DRAW_BUFFER14GLenum
DRAW_BUFFER15GLenum
MAX_FRAGMENT_UNIFORM_COMPONENTSGLenum
MAX_VERTEX_UNIFORM_COMPONENTSGLenum
SAMPLER_3DGLenum
SAMPLER_2D_SHADOWGLenum
FRAGMENT_SHADER_DERIVATIVE_HINTGLenum
PIXEL_PACK_BUFFERGLenum
PIXEL_UNPACK_BUFFERGLenum
PIXEL_PACK_BUFFER_BINDINGGLenum
PIXEL_UNPACK_BUFFER_BINDINGGLenum
FLOAT_MAT2x3GLenum
FLOAT_MAT2x4GLenum
FLOAT_MAT3x2GLenum
FLOAT_MAT3x4GLenum
FLOAT_MAT4x2GLenum
FLOAT_MAT4x3GLenum
SRGBGLenum
SRGB8GLenum
SRGB8_ALPHA8GLenum
COMPARE_REF_TO_TEXTUREGLenum
RGBA32FGLenum
RGB32FGLenum
RGBA16FGLenum
RGB16FGLenum
VERTEX_ATTRIB_ARRAY_INTEGERGLenum
MAX_ARRAY_TEXTURE_LAYERSGLenum
MIN_PROGRAM_TEXEL_OFFSETGLenum
MAX_PROGRAM_TEXEL_OFFSETGLenum
MAX_VARYING_COMPONENTSGLenum
TEXTURE_2D_ARRAYGLenum
TEXTURE_BINDING_2D_ARRAYGLenum
R11F_G11F_B10FGLenum
UNSIGNED_INT_10F_11F_11F_REVGLenum
RGB9_E5GLenum
UNSIGNED_INT_5_9_9_9_REVGLenum
TRANSFORM_FEEDBACK_BUFFER_MODEGLenum
MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTSGLenum
TRANSFORM_FEEDBACK_VARYINGSGLenum
TRANSFORM_FEEDBACK_BUFFER_STARTGLenum
TRANSFORM_FEEDBACK_BUFFER_SIZEGLenum
TRANSFORM_FEEDBACK_PRIMITIVES_WRITTENGLenum
RASTERIZER_DISCARDGLenum
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTSGLenum
MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBSGLenum
INTERLEAVED_ATTRIBSGLenum
SEPARATE_ATTRIBSGLenum
TRANSFORM_FEEDBACK_BUFFERGLenum
TRANSFORM_FEEDBACK_BUFFER_BINDINGGLenum
RGBA32UIGLenum
RGB32UIGLenum
RGBA16UIGLenum
RGB16UIGLenum
RGBA8UIGLenum
RGB8UIGLenum
RGBA32IGLenum
RGB32IGLenum
RGBA16IGLenum
RGB16IGLenum
RGBA8IGLenum
RGB8IGLenum
RED_INTEGERGLenum
RGB_INTEGERGLenum
RGBA_INTEGERGLenum
SAMPLER_2D_ARRAYGLenum
SAMPLER_2D_ARRAY_SHADOWGLenum
SAMPLER_CUBE_SHADOWGLenum
UNSIGNED_INT_VEC2GLenum
UNSIGNED_INT_VEC3GLenum
UNSIGNED_INT_VEC4GLenum
INT_SAMPLER_2DGLenum
INT_SAMPLER_3DGLenum
INT_SAMPLER_CUBEGLenum
INT_SAMPLER_2D_ARRAYGLenum
UNSIGNED_INT_SAMPLER_2DGLenum
UNSIGNED_INT_SAMPLER_3DGLenum
UNSIGNED_INT_SAMPLER_CUBEGLenum
UNSIGNED_INT_SAMPLER_2D_ARRAYGLenum
DEPTH_COMPONENT32FGLenum
DEPTH32F_STENCIL8GLenum
FLOAT_32_UNSIGNED_INT_24_8_REVGLenum
FRAMEBUFFER_ATTACHMENT_COLOR_ENCODINGGLenum
FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPEGLenum
FRAMEBUFFER_ATTACHMENT_RED_SIZEGLenum
FRAMEBUFFER_ATTACHMENT_GREEN_SIZEGLenum
FRAMEBUFFER_ATTACHMENT_BLUE_SIZEGLenum
FRAMEBUFFER_ATTACHMENT_ALPHA_SIZEGLenum
FRAMEBUFFER_ATTACHMENT_DEPTH_SIZEGLenum
FRAMEBUFFER_ATTACHMENT_STENCIL_SIZEGLenum
FRAMEBUFFER_DEFAULTGLenum
UNSIGNED_INT_24_8GLenum
DEPTH24_STENCIL8GLenum
UNSIGNED_NORMALIZEDGLenum
DRAW_FRAMEBUFFER_BINDINGGLenum
READ_FRAMEBUFFERGLenum
DRAW_FRAMEBUFFERGLenum
READ_FRAMEBUFFER_BINDINGGLenum
RENDERBUFFER_SAMPLESGLenum
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYERGLenum
MAX_COLOR_ATTACHMENTSGLenum
COLOR_ATTACHMENT1GLenum
COLOR_ATTACHMENT2GLenum
COLOR_ATTACHMENT3GLenum
COLOR_ATTACHMENT4GLenum
COLOR_ATTACHMENT5GLenum
COLOR_ATTACHMENT6GLenum
COLOR_ATTACHMENT7GLenum
COLOR_ATTACHMENT8GLenum
COLOR_ATTACHMENT9GLenum
COLOR_ATTACHMENT10GLenum
COLOR_ATTACHMENT11GLenum
COLOR_ATTACHMENT12GLenum
COLOR_ATTACHMENT13GLenum
COLOR_ATTACHMENT14GLenum
COLOR_ATTACHMENT15GLenum
FRAMEBUFFER_INCOMPLETE_MULTISAMPLEGLenum
MAX_SAMPLESGLenum
HALF_FLOATGLenum
RGGLenum
RG_INTEGERGLenum
R8GLenum
RG8GLenum
R16FGLenum
R32FGLenum
RG16FGLenum
RG32FGLenum
R8IGLenum
R8UIGLenum
R16IGLenum
R16UIGLenum
R32IGLenum
R32UIGLenum
RG8IGLenum
RG8UIGLenum
RG16IGLenum
RG16UIGLenum
RG32IGLenum
RG32UIGLenum
VERTEX_ARRAY_BINDINGGLenum
R8_SNORMGLenum
RG8_SNORMGLenum
RGB8_SNORMGLenum
SIGNED_NORMALIZEDGLenum
COPY_READ_BUFFERGLenum
COPY_WRITE_BUFFERGLenum
COPY_READ_BUFFER_BINDINGGLenum
COPY_WRITE_BUFFER_BINDINGGLenum
UNIFORM_BUFFERGLenum
UNIFORM_BUFFER_BINDINGGLenum
UNIFORM_BUFFER_STARTGLenum
UNIFORM_BUFFER_SIZEGLenum
MAX_VERTEX_UNIFORM_BLOCKSGLenum
MAX_FRAGMENT_UNIFORM_BLOCKSGLenum
MAX_COMBINED_UNIFORM_BLOCKSGLenum
MAX_UNIFORM_BUFFER_BINDINGSGLenum
MAX_UNIFORM_BLOCK_SIZEGLenum
MAX_COMBINED_VERTEX_UNIFORM_COMPONENTSGLenum
MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTSGLenum
UNIFORM_BUFFER_OFFSET_ALIGNMENTGLenum
ACTIVE_UNIFORM_BLOCKSGLenum
UNIFORM_TYPEGLenum
UNIFORM_SIZEGLenum
UNIFORM_BLOCK_INDEXGLenum
UNIFORM_OFFSETGLenum
UNIFORM_ARRAY_STRIDEGLenum
UNIFORM_MATRIX_STRIDEGLenum
UNIFORM_IS_ROW_MAJORGLenum
UNIFORM_BLOCK_BINDINGGLenum
UNIFORM_BLOCK_DATA_SIZEGLenum
UNIFORM_BLOCK_ACTIVE_UNIFORMSGLenum
UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICESGLenum
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADERGLenum
UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADERGLenum
INVALID_INDEXGLenum
MAX_VERTEX_OUTPUT_COMPONENTSGLenum
MAX_FRAGMENT_INPUT_COMPONENTSGLenum
MAX_SERVER_WAIT_TIMEOUTGLenum
OBJECT_TYPEGLenum
SYNC_CONDITIONGLenum
SYNC_STATUSGLenum
SYNC_FLAGSGLenum
SYNC_FENCEGLenum
SYNC_GPU_COMMANDS_COMPLETEGLenum
UNSIGNALEDGLenum
SIGNALEDGLenum
ALREADY_SIGNALEDGLenum
TIMEOUT_EXPIREDGLenum
CONDITION_SATISFIEDGLenum
WAIT_FAILEDGLenum
SYNC_FLUSH_COMMANDS_BITGLenum
VERTEX_ATTRIB_ARRAY_DIVISORGLenum
ANY_SAMPLES_PASSEDGLenum
ANY_SAMPLES_PASSED_CONSERVATIVEGLenum
SAMPLER_BINDINGGLenum
RGB10_A2UIGLenum
INT_2_10_10_10_REVGLenum
TRANSFORM_FEEDBACKGLenum
TRANSFORM_FEEDBACK_PAUSEDGLenum
TRANSFORM_FEEDBACK_ACTIVEGLenum
TRANSFORM_FEEDBACK_BINDINGGLenum
TEXTURE_IMMUTABLE_FORMATGLenum
MAX_ELEMENT_INDEXGLenum
TEXTURE_IMMUTABLE_LEVELSGLenum
TIMEOUT_IGNOREDGLint64
MAX_CLIENT_WAIT_TIMEOUT_WEBGLGLenum

方法

方法返回值类型
copyBufferSubData(readTarget: GLenum, writeTarget: GLenum, readOffset: GLintptr, writeOffset: GLintptr, size: GLsizeiptr)void
getBufferSubData(target: GLenum, srcByteOffset: GLintptr, dstBuffer: ArrayBufferView, dstOffset?: GLuint, length?: GLuint)void
blitFramebuffer(srcX0: GLint, srcY0: GLint, srcX1: GLint, srcY1: GLint, dstX0: GLint, dstY0: GLint, dstX1: GLint, dstY1: GLint, mask: GLbitfield, filter: GLenum)void
framebufferTextureLayer(target: GLenum, attachment: GLenum, texture: WebGLTexture | null, level: GLint, layer: GLint)void
invalidateFramebuffer(target: GLenum, attachments: GLenum[])void
invalidateSubFramebuffer(target: GLenum, attachments: GLenum[], x: GLint, y: GLint, width: GLsizei, height: GLsizei)void
readBuffer(src: GLenum)void
getInternalformatParameter(target: GLenum, internalformat: GLenum, pname: GLenum)any
renderbufferStorageMultisample(target: GLenum, samples: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei)void
texStorage2D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei)void
texStorage3D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei)void
texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr)void
texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource)void
texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView | null)void
texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint)void
texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr)void
texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, source: TexImageSource)void
texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView | null, srcOffset?: GLuint)void
copyTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei)void
compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr)void
compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint)void
compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr)void
compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint)void
getFragDataLocation(program: WebGLProgram, name: string)GLint
uniform1ui(location: WebGLUniformLocation | null, v0: GLuint)void
uniform2ui(location: WebGLUniformLocation | null, v0: GLuint, v1: GLuint)void
uniform3ui(location: WebGLUniformLocation | null, v0: GLuint, v1: GLuint, v2: GLuint)void
uniform4ui(location: WebGLUniformLocation | null, v0: GLuint, v1: GLuint, v2: GLuint, v3: GLuint)void
uniform1uiv(location: WebGLUniformLocation | null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform2uiv(location: WebGLUniformLocation | null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform3uiv(location: WebGLUniformLocation | null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform4uiv(location: WebGLUniformLocation | null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniformMatrix3x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniformMatrix4x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniformMatrix2x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniformMatrix4x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniformMatrix2x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniformMatrix3x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
vertexAttribI4i(index: GLuint, x: GLint, y: GLint, z: GLint, w: GLint)void
vertexAttribI4iv(index: GLuint, values: Int32List)void
vertexAttribI4ui(index: GLuint, x: GLuint, y: GLuint, z: GLuint, w: GLuint)void
vertexAttribI4uiv(index: GLuint, values: Uint32List)void
vertexAttribIPointer(index: GLuint, size: GLint, type: GLenum, stride: GLsizei, offset: GLintptr)void
vertexAttribDivisor(index: GLuint, divisor: GLuint)void
drawArraysInstanced(mode: GLenum, first: GLint, count: GLsizei, instanceCount: GLsizei)void
drawElementsInstanced(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, instanceCount: GLsizei)void
drawRangeElements(mode: GLenum, start: GLuint, end: GLuint, count: GLsizei, type: GLenum, offset: GLintptr)void
drawBuffers(buffers: GLenum[])void
clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Float32List, srcOffset?: GLuint)void
clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Int32List, srcOffset?: GLuint)void
clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Uint32List, srcOffset?: GLuint)void
clearBufferfi(buffer: GLenum, drawbuffer: GLint, depth: GLfloat, stencil: GLint)void
createQuery()WebGLQuery | null
deleteQuery(query: WebGLQuery | null)void
isQuery(query: WebGLQuery | null)GLboolean
beginQuery(target: GLenum, query: WebGLQuery)void
endQuery(target: GLenum)void
getQuery(target: GLenum, pname: GLenum)WebGLQuery | null
getQueryParameter(query: WebGLQuery, pname: GLenum)any
createSampler()WebGLSampler | null
deleteSampler(sampler: WebGLSampler | null)void
isSampler(sampler: WebGLSampler | null)GLboolean
bindSampler(unit: GLuint, sampler: WebGLSampler | null)void
samplerParameteri(sampler: WebGLSampler, pname: GLenum, param: GLint)void
samplerParameterf(sampler: WebGLSampler, pname: GLenum, param: GLfloat)void;
getSamplerParameter(sampler: WebGLSampler, pname: GLenum)any
fenceSync(condition: GLenum, flags: GLbitfield)WebGLSync | null
isSync(sync: WebGLSync | null)GLboolean
deleteSync(sync: WebGLSync | null)void
clientWaitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLuint64)GLenum
waitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLint64)void
getSyncParameter(sync: WebGLSync, pname: GLenum)any
createTransformFeedback()WebGLTransformFeedback | null
deleteTransformFeedback(tf: WebGLTransformFeedback | null)void
isTransformFeedback(tf: WebGLTransformFeedback | null)GLboolean
bindTransformFeedback(target: GLenum, tf: WebGLTransformFeedback | null)void
beginTransformFeedback(primitiveMode: GLenum)void
endTransformFeedback()void
transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: GLenum)void
getTransformFeedbackVarying(program: WebGLProgram, index: GLuint)WebGLActiveInfo | null
pauseTransformFeedback()void
resumeTransformFeedback()void
bindBufferBase(target: GLenum, index: GLuint, buffer: WebGLBuffer | null)void
bindBufferRange(target: GLenum, index: GLuint, buffer: WebGLBuffer | null, offset: GLintptr, size: GLsizeiptr)void
getIndexedParameter(target: GLenum, index: GLuint)any
getUniformIndices(program: WebGLProgram, uniformNames: string[])GLuint[] | null
getActiveUniforms(program: WebGLProgram, uniformIndices: GLuint[], pname: GLenum)any
getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string)GLuint
getActiveUniformBlockParameter(program: WebGLProgram, uniformBlockIndex: GLuint, pname: GLenum)any
getActiveUniformBlockName(program: WebGLProgram, uniformBlockIndex: GLuint)string | null
uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: GLuint, uniformBlockBinding: GLuint)void
createVertexArray()WebGLVertexArrayObject | null
deleteVertexArray(vertexArray: WebGLVertexArrayObject | null)void
isVertexArray(vertexArray: WebGLVertexArrayObject | null)GLboolean
bindVertexArray(array: WebGLVertexArrayObject | null)void

WebGL2RenderingContextOverloads

WebGL2RenderingContextOverloads

方法返回值类型
bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum)void
bufferData(target: GLenum, srcData: BufferSource | null, usage: GLenum)void
bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: BufferSource)void
bufferData(target: GLenum, srcData: ArrayBufferView, usage: GLenum, srcOffset: GLuint, length?: GLuint)void
bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: ArrayBufferView, srcOffset: GLuint, length?: GLuint)void
texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView | null)void
texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource)void
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView | null)void
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource)void
texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr)void
texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource)void
texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint)void
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr)void
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, source: TexImageSource)void
texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint)void
compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr)void
compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint)void
compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr)void
compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint)void
uniform1fv(location: WebGLUniformLocation | null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform2fv(location: WebGLUniformLocation | null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform3fv(location: WebGLUniformLocation | null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform4fv(location: WebGLUniformLocation | null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform1iv(location: WebGLUniformLocation | null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform2iv(location: WebGLUniformLocation | null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform3iv(location: WebGLUniformLocation | null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniform4iv(location: WebGLUniformLocation | null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint)void
readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView | null)void
readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, offset: GLintptr)void
readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView, dstOffset: GLuint)void
图形绘制的能力
音频管理
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

媒体组件

像素

枚举

类型

接口

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }