1# WebGL 2 3WebGL提供图形绘制的能力,包括对当前绘制图形的位置、颜色等进行处理。 4 5WebGL标准图形API,对应OpenGL ES 2.0特性集。更多信息请参考[WebGL™标准](https://www.khronos.org/registry/webgl/specs/latest/1.0/)。 6 7> **说明:** 8> 9> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 10> 11> WebGL遵循OpenGL协议,不支持多线程调用。 12> 13> 目前该功能仅支持使用兼容JS的类Web开发范式开发。 14 15 16## 调用方式 17 18hml内创建canvas,示例如下: 19 20 21```html 22<!--xxx.hml--> 23<div class="container"> 24 <canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas> 25 <button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button> 26</div> 27``` 28 29js内获取canvas实例,示例如下: 30 31 32```js 33// 获取canvas组件实例 34const el = this.$refs.canvas1; 35// 从canvas组件实例获取WebGL上下文 36const gl = el.getContext('webgl'); 37// 调用WebGL API 38gl.clearColor(0.0, 0.0, 0.0, 1.0); 39``` 40 41 42## Type 43 44**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL。 45 46 **表1** Type 47 48| 名称 | 类型 | 49| -------- | -------- | 50| GLenum | number | 51| GLboolean | boolean | 52| GLbitfield | number | 53| GLbyte | number | 54| GLshort | number | 55| GLint | number | 56| GLsizei | number | 57| GLintptr | number | 58| GLsizeiptr | number | 59| GLubyte | number | 60| GLushort | number | 61| GLuint | number | 62| GLfloat | number | 63| GLclampf | number | 64| TexImageSource | ImageData | 65| Float32List | array | 66| Int32List | array | 67| WebGLPowerPreference | string | 68 69 70## Interface 71 72**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Graphic.Graphic2D.WebGL。 73 74 **表2** Interface 75 76| 名称 | 77| -------- | 78| [WebGLContextAttributes](#webglcontextattributes) | 79| WebGLBuffer | 80| WebGLFrameBuffer | 81| WebGLProgram | 82| WebGLRenderbuffer | 83| WebGLShader | 84| WebGLTexture | 85| WebGLUniformLocation | 86| [WebGLActiveInfo](#webglactiveinfo) | 87| [WebGLShaderPrecisionFormat](#webglshaderprecisionformat) | 88| [WebGLRenderingContextBase](#webglrenderingcontextbase) | 89| [WebGLRenderingContextOverloads](#webglrenderingcontextoverloads) | 90 91 92## WebGLContextAttributes 93 94WebGLContextAttributes 95 96 97 | 名称 | 参数类型 | 必填 | 98| -------- | -------- | -------- | 99| alpha | boolean | 否 | 100| depth | boolean | 否 | 101| stencil | boolean | 否 | 102| antialias | boolean | 否 | 103| premultipliedAlpha | boolean | 否 | 104| preserveDrawingBuffer | boolean | 否 | 105| powerPreference | WebGLPowerPreference | 否 | 106| failIfMajorPerformanceCaveat | boolean | 否 | 107| desynchronized | boolean | 否 | 108 109 110## WebGLActiveInfo 111 112WebGLActiveInfo 113 114 | 名称 | 参数类型 | 必填 | 115| -------- | -------- | -------- | 116| size | GLint | 是 | 117| type | GLenum | 是 | 118| name | string | 是 | 119 120 121## WebGLShaderPrecisionFormat 122 123WebGLShaderPrecisionFormat 124 125 | 名称 | 参数类型 | 必填 | 126| -------- | -------- | -------- | 127| rangeMin | GLint | 是 | 128| rangeMax | GLint | 是 | 129| precision | GLint | 是 | 130 131 132## WebGLRenderingContextBase 133 134WebGLRenderingContextBase 135 136 137### 属性 138 139 | 名称 | 参数类型 | 必填 | 140| -------- | -------- | -------- | 141| DEPTH_BUFFER_BIT | GLenum | 是 | 142| STENCIL_BUFFER_BIT | GLenum | 是 | 143| COLOR_BUFFER_BIT | GLenum | 是 | 144| POINTS | GLenum | 是 | 145| LINES | GLenum | 是 | 146| LINE_LOOP | GLenum | 是 | 147| LINE_STRIP | GLenum | 是 | 148| TRIANGLES | GLenum | 是 | 149| TRIANGLE_STRIP | GLenum | 是 | 150| TRIANGLE_FAN | GLenum | 是 | 151| ZERO | GLenum | 是 | 152| ONE | GLenum | 是 | 153| SRC_COLOR | GLenum | 是 | 154| ONE_MINUS_SRC_COLOR | GLenum | 是 | 155| SRC_ALPHA | GLenum | 是 | 156| ONE_MINUS_SRC_ALPHA | GLenum | 是 | 157| DST_ALPHA | GLenum | 是 | 158| ONE_MINUS_DST_ALPHA | GLenum | 是 | 159| DST_COLOR | GLenum | 是 | 160| ONE_MINUS_DST_COLOR | GLenum | 是 | 161| SRC_ALPHA_SATURATE | GLenum | 是 | 162| FUNC_ADD | GLenum | 是 | 163| BLEND_EQUATION | GLenum | 是 | 164| BLEND_EQUATION_RGB | GLenum | 是 | 165| BLEND_EQUATION_ALPHA | GLenum | 是 | 166| FUNC_SUBTRACT | GLenum | 是 | 167| FUNC_REVERSE_SUBTRACT | GLenum | 是 | 168| BLEND_DST_RGB | GLenum | 是 | 169| BLEND_SRC_RGB | GLenum | 是 | 170| BLEND_DST_ALPHA | GLenum | 是 | 171| BLEND_SRC_ALPHA | GLenum | 是 | 172| CONSTANT_COLOR | GLenum | 是 | 173| ONE_MINUS_CONSTANT_COLOR | GLenum | 是 | 174| CONSTANT_ALPHA | GLenum | 是 | 175| ONE_MINUS_CONSTANT_ALPHA | GLenum | 是 | 176| BLEND_COLOR | GLenum | 是 | 177| ARRAY_BUFFER | GLenum | 是 | 178| ELEMENT_ARRAY_BUFFER | GLenum | 是 | 179| ARRAY_BUFFER_BINDING | GLenum | 是 | 180| ELEMENT_ARRAY_BUFFER_BINDING | GLenum | 是 | 181| STREAM_DRAW | GLenum | 是 | 182| STATIC_DRAW | GLenum | 是 | 183| DYNAMIC_DRAW | GLenum | 是 | 184| BUFFER_SIZE | GLenum | 是 | 185| BUFFER_USAGE | GLenum | 是 | 186| CURRENT_VERTEX_ATTRIB | GLenum | 是 | 187| FRONT | GLenum | 是 | 188| BACK | GLenum | 是 | 189| FRONT_AND_BACK | GLenum | 是 | 190| CULL_FACE | GLenum | 是 | 191| BLEND | GLenum | 是 | 192| DITHER | GLenum | 是 | 193| STENCIL_TEST | GLenum | 是 | 194| DEPTH_TEST | GLenum | 是 | 195| SCISSOR_TEST | GLenum | 是 | 196| POLYGON_OFFSET_FILL | GLenum | 是 | 197| SAMPLE_ALPHA_TO_COVERAGE | GLenum | 是 | 198| SAMPLE_COVERAGE | GLenum | 是 | 199| NO_ERROR | GLenum | 是 | 200| INVALID_ENUM | GLenum | 是 | 201| INVALID_VALUE | GLenum | 是 | 202| INVALID_OPERATION | GLenum | 是 | 203| OUT_OF_MEMORY | GLenum | 是 | 204| CW | GLenum | 是 | 205| CCW | GLenum | 是 | 206| LINE_WIDTH | GLenum | 是 | 207| ALIASED_POINT_SIZE_RANGE | GLenum | 是 | 208| ALIASED_LINE_WIDTH_RANGE | GLenum | 是 | 209| CULL_FACE_MODE | GLenum | 是 | 210| FRONT_FACE | GLenum | 是 | 211| DEPTH_RANGE | GLenum | 是 | 212| DEPTH_WRITEMASK | GLenum | 是 | 213| DEPTH_CLEAR_VALUE | GLenum | 是 | 214| DEPTH_FUNC | GLenum | 是 | 215| STENCIL_CLEAR_VALUE | GLenum | 是 | 216| STENCIL_FUNC | GLenum | 是 | 217| STENCIL_FAIL | GLenum | 是 | 218| STENCIL_PASS_DEPTH_FAIL | GLenum | 是 | 219| STENCIL_PASS_DEPTH_PASS | GLenum | 是 | 220| STENCIL_REF | GLenum | 是 | 221| STENCIL_VALUE_MASK | GLenum | 是 | 222| STENCIL_WRITEMASK | GLenum | 是 | 223| STENCIL_BACK_FUNC | GLenum | 是 | 224| STENCIL_BACK_FAIL | GLenum | 是 | 225| STENCIL_BACK_PASS_DEPTH_FAIL | GLenum | 是 | 226| STENCIL_BACK_PASS_DEPTH_PASS | GLenum | 是 | 227| STENCIL_BACK_REF | GLenum | 是 | 228| STENCIL_BACK_VALUE_MASK | GLenum | 是 | 229| STENCIL_BACK_WRITEMASK | GLenum | 是 | 230| VIEWPORT | GLenum | 是 | 231| SCISSOR_BOX | GLenum | 是 | 232| COLOR_CLEAR_VALUE | GLenum | 是 | 233| COLOR_WRITEMASK | GLenum | 是 | 234| UNPACK_ALIGNMENT | GLenum | 是 | 235| PACK_ALIGNMENT | GLenum | 是 | 236| MAX_TEXTURE_SIZE | GLenum | 是 | 237| MAX_VIEWPORT_DIMS | GLenum | 是 | 238| SUBPIXEL_BITS | GLenum | 是 | 239| RED_BITS | GLenum | 是 | 240| GREEN_BITS | GLenum | 是 | 241| BLUE_BITS | GLenum | 是 | 242| ALPHA_BITS | GLenum | 是 | 243| DEPTH_BITS | GLenum | 是 | 244| STENCIL_BITS | GLenum | 是 | 245| POLYGON_OFFSET_UNITS | GLenum | 是 | 246| POLYGON_OFFSET_FACTOR | GLenum | 是 | 247| TEXTURE_BINDING_2D | GLenum | 是 | 248| SAMPLE_BUFFERS | GLenum | 是 | 249| SAMPLES | GLenum | 是 | 250| SAMPLE_COVERAGE_VALUE | GLenum | 是 | 251| SAMPLE_COVERAGE_INVERT | GLenum | 是 | 252| COMPRESSED_TEXTURE_FORMATS | GLenum | 是 | 253| DONT_CARE | GLenum | 是 | 254| FASTEST | GLenum | 是 | 255| NICEST | GLenum | 是 | 256| GENERATE_MIPMAP_HINT | GLenum | 是 | 257| BYTE | GLenum | 是 | 258| UNSIGNED_BYTE | GLenum | 是 | 259| SHORT | GLenum | 是 | 260| UNSIGNED_SHORT | GLenum | 是 | 261| INT | GLenum | 是 | 262| UNSIGNED_INT | GLenum | 是 | 263| FLOAT | GLenum | 是 | 264| DEPTH_COMPONENT | GLenum | 是 | 265| ALPHA | GLenum | 是 | 266| RGB | GLenum | 是 | 267| RGBA | GLenum | 是 | 268| LUMINANCE | GLenum | 是 | 269| LUMINANCE_ALPHA | GLenum | 是 | 270| UNSIGNED_SHORT_4_4_4_4 | GLenum | 是 | 271| UNSIGNED_SHORT_5_5_5_1 | GLenum | 是 | 272| UNSIGNED_SHORT_5_6_5 | GLenum | 是 | 273| FRAGMENT_SHADER | GLenum | 是 | 274| VERTEX_SHADER | GLenum | 是 | 275| MAX_VERTEX_ATTRIBS | GLenum | 是 | 276| MAX_VERTEX_UNIFORM_VECTORS | GLenum | 是 | 277| MAX_VARYING_VECTORS | GLenum | 是 | 278| MAX_COMBINED_TEXTURE_IMAGE_UNITS | GLenum | 是 | 279| MAX_VERTEX_TEXTURE_IMAGE_UNITS | GLenum | 是 | 280| MAX_TEXTURE_IMAGE_UNITS | GLenum | 是 | 281| MAX_FRAGMENT_UNIFORM_VECTORS | GLenum | 是 | 282| SHADER_TYPE | GLenum | 是 | 283| DELETE_STATUS | GLenum | 是 | 284| LINK_STATUS | GLenum | 是 | 285| VALIDATE_STATUS | GLenum | 是 | 286| ATTACHED_SHADERS | GLenum | 是 | 287| ACTIVE_UNIFORMS | GLenum | 是 | 288| ACTIVE_ATTRIBUTES | GLenum | 是 | 289| SHADING_LANGUAGE_VERSION | GLenum | 是 | 290| CURRENT_PROGRAM | GLenum | 是 | 291| NEVER | GLenum | 是 | 292| LESS | GLenum | 是 | 293| EQUAL | GLenum | 是 | 294| LEQUAL | GLenum | 是 | 295| GREATER | GLenum | 是 | 296| NOTEQUAL | GLenum | 是 | 297| GEQUAL | GLenum | 是 | 298| ALWAYS | GLenum | 是 | 299| KEEP | GLenum | 是 | 300| REPLACE | GLenum | 是 | 301| INCR | GLenum | 是 | 302| DECR | GLenum | 是 | 303| INVERT | GLenum | 是 | 304| INCR_WRAP | GLenum | 是 | 305| DECR_WRAP | GLenum | 是 | 306| VENDOR | GLenum | 是 | 307| RENDERER | GLenum | 是 | 308| VERSION | GLenum | 是 | 309| NEAREST | GLenum | 是 | 310| LINEAR | GLenum | 是 | 311| NEAREST_MIPMAP_NEAREST | GLenum | 是 | 312| LINEAR_MIPMAP_NEAREST | GLenum | 是 | 313| NEAREST_MIPMAP_LINEAR | GLenum | 是 | 314| LINEAR_MIPMAP_LINEAR | GLenum | 是 | 315| TEXTURE_MIN_FILTER | GLenum | 是 | 316| TEXTURE_WRAP_S | GLenum | 是 | 317| TEXTURE_WRAP_T | GLenum | 是 | 318| TEXTURE_2D | GLenum | 是 | 319| TEXTURE | GLenum | 是 | 320| TEXTURE_CUBE_MAP | GLenum | 是 | 321| TEXTURE_BINDING_CUBE_MAP | GLenum | 是 | 322| TEXTURE_CUBE_MAP_POSITIVE_X | GLenum | 是 | 323| TEXTURE_CUBE_MAP_NEGATIVE_X | GLenum | 是 | 324| TEXTURE_CUBE_MAP_POSITIVE_Y | GLenum | 是 | 325| TEXTURE_CUBE_MAP_NEGATIVE_Y | GLenum | 是 | 326| TEXTURE_CUBE_MAP_POSITIVE_Z | GLenum | 是 | 327| TEXTURE_CUBE_MAP_NEGATIVE_Z | GLenum | 是 | 328| MAX_CUBE_MAP_TEXTURE_SIZE | GLenum | 是 | 329| TEXTURE0 | GLenum | 是 | 330| TEXTURE1 | GLenum | 是 | 331| TEXTURE2 | GLenum | 是 | 332| TEXTURE3 | GLenum | 是 | 333| TEXTURE4 | GLenum | 是 | 334| TEXTURE5 | GLenum | 是 | 335| TEXTURE6 | GLenum | 是 | 336| TEXTURE7 | GLenum | 是 | 337| TEXTURE8 | GLenum | 是 | 338| TEXTURE9 | GLenum | 是 | 339| TEXTURE10 | GLenum | 是 | 340| TEXTURE11 | GLenum | 是 | 341| TEXTURE12 | GLenum | 是 | 342| TEXTURE13 | GLenum | 是 | 343| TEXTURE14 | GLenum | 是 | 344| TEXTURE15 | GLenum | 是 | 345| TEXTURE16 | GLenum | 是 | 346| TEXTURE17 | GLenum | 是 | 347| TEXTURE18 | GLenum | 是 | 348| TEXTURE19 | GLenum | 是 | 349| TEXTURE20 | GLenum | 是 | 350| TEXTURE21 | GLenum | 是 | 351| TEXTURE22 | GLenum | 是 | 352| TEXTURE23 | GLenum | 是 | 353| TEXTURE24 | GLenum | 是 | 354| TEXTURE25 | GLenum | 是 | 355| TEXTURE26 | GLenum | 是 | 356| TEXTURE27 | GLenum | 是 | 357| TEXTURE28 | GLenum | 是 | 358| TEXTURE29 | GLenum | 是 | 359| TEXTURE30 | GLenum | 是 | 360| TEXTURE31 | GLenum | 是 | 361| ACTIVE_TEXTURE | GLenum | 是 | 362| REPEAT | GLenum | 是 | 363| CLAMP_TO_EDGE | GLenum | 是 | 364| MIRRORED_REPEAT | GLenum | 是 | 365| FLOAT_VEC2 | GLenum | 是 | 366| FLOAT_VEC3 | GLenum | 是 | 367| FLOAT_VEC4 | GLenum | 是 | 368| INT_VEC2 | GLenum | 是 | 369| INT_VEC3 | GLenum | 是 | 370| INT_VEC4 | GLenum | 是 | 371| BOOL | GLenum | 是 | 372| BOOL_VEC2 | GLenum | 是 | 373| BOOL_VEC3 | GLenum | 是 | 374| BOOL_VEC4 | GLenum | 是 | 375| FLOAT_MAT2 | GLenum | 是 | 376| FLOAT_MAT3 | GLenum | 是 | 377| FLOAT_MAT4 | GLenum | 是 | 378| SAMPLER_2D | GLenum | 是 | 379| SAMPLER_CUBE | GLenum | 是 | 380| VERTEX_ATTRIB_ARRAY_ENABLED | GLenum | 是 | 381| VERTEX_ATTRIB_ARRAY_SIZE | GLenum | 是 | 382| VERTEX_ATTRIB_ARRAY_STRIDE | GLenum | 是 | 383| VERTEX_ATTRIB_ARRAY_TYPE | GLenum | 是 | 384| VERTEX_ATTRIB_ARRAY_NORMALIZED | GLenum | 是 | 385| VERTEX_ATTRIB_ARRAY_POINTER | GLenum | 是 | 386| VERTEX_ATTRIB_ARRAY_BUFFER_BINDING | GLenum | 是 | 387| IMPLEMENTATION_COLOR_READ_TYPE | GLenum | 是 | 388| IMPLEMENTATION_COLOR_READ_FORMAT | GLenum | 是 | 389| COMPILE_STATUS | GLenum | 是 | 390| LOW_FLOAT | GLenum | 是 | 391| MEDIUM_FLOAT | GLenum | 是 | 392| HIGH_FLOAT | GLenum | 是 | 393| LOW_INT | GLenum | 是 | 394| MEDIUM_INT | GLenum | 是 | 395| HIGH_INT | GLenum | 是 | 396| FRAMEBUFFER | GLenum | 是 | 397| RENDERBUFFER | GLenum | 是 | 398| RGBA4 | GLenum | 是 | 399| RGB5_A1 | GLenum | 是 | 400| RGB565 | GLenum | 是 | 401| DEPTH_COMPONENT16 | GLenum | 是 | 402| STENCIL_INDEX8 | GLenum | 是 | 403| DEPTH_STENCIL | GLenum | 是 | 404| RENDERBUFFER_WIDTH | GLenum | 是 | 405| RENDERBUFFER_HEIGHT | GLenum | 是 | 406| RENDERBUFFER_INTERNAL_FORMAT | GLenum | 是 | 407| RENDERBUFFER_RED_SIZE | GLenum | 是 | 408| RENDERBUFFER_GREEN_SIZE | GLenum | 是 | 409| RENDERBUFFER_BLUE_SIZE | GLenum | 是 | 410| RENDERBUFFER_ALPHA_SIZE | GLenum | 是 | 411| RENDERBUFFER_DEPTH_SIZE | GLenum | 是 | 412| RENDERBUFFER_STENCIL_SIZE | GLenum | 是 | 413| FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE | GLenum | 是 | 414| FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL | GLenum | 是 | 415| FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE | GLenum | 是 | 416| COLOR_ATTACHMENT0 | GLenum | 是 | 417| DEPTH_ATTACHMENT | GLenum | 是 | 418| STENCIL_ATTACHMENT | GLenum | 是 | 419| DEPTH_STENCIL_ATTACHMENT | GLenum | 是 | 420| NONE | GLenum | 是 | 421| FRAMEBUFFER_COMPLETE | GLenum | 是 | 422| FRAMEBUFFER_INCOMPLETE_ATTACHMENT | GLenum | 是 | 423| FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT | GLenum | 是 | 424| FRAMEBUFFER_INCOMPLETE_DIMENSIONS | GLenum | 是 | 425| FRAMEBUFFER_UNSUPPORTED | GLenum | 是 | 426| FRAMEBUFFER_BINDING | GLenum | 是 | 427| RENDERBUFFER_BINDING | GLenum | 是 | 428| MAX_RENDERBUFFER_SIZE | GLenum | 是 | 429| INVALID_FRAMEBUFFER_OPERATION | GLenum | 是 | 430| UNPACK_FLIP_Y_WEBGL | GLenum | 是 | 431| UNPACK_PREMULTIPLY_ALPHA_WEBGL | GLenum | 是 | 432| CONTEXT_LOST_WEBGL | GLenum | 是 | 433| UNPACK_COLORSPACE_CONVERSION_WEBGL | GLenum | 是 | 434| BROWSER_DEFAULT_WEBGL | GLenum | 是 | 435| canvas | HTMLCanvasElement \| OffscreenCanvas | 是 | 436| drawingBufferWidth | GLsizei | 是 | 437| drawingBufferHeight | GLsizei | 是 | 438 439 440### 方法 441 442 | 方法 | 返回值类型 | 443| -------- | -------- | 444| getContextAttributes() | WebGLContextAttributes \| null | 445| isContextLost() | boolean | 446| getSupportedExtensions() | string[] \| null | 447| getExtension(name: string) | any | 448| activeTexture(texture: GLenum) | void | 449| attachShader(program: WebGLProgram, shader: WebGLShader) | void | 450| bindAttribLocation(program: WebGLProgram, index: GLuint, name: string) | void | 451| bindBuffer(target: GLenum, buffer: WebGLBuffer \| null) | void | 452| bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer \| null) | void | 453| bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | 454| bindTexture(target: GLenum, texture: WebGLTexture \| null) | void | 455| blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | 456| blendEquation(mode: GLenum) | void | 457| blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum) | void | 458| blendFunc(sfactor: GLenum, dfactor: GLenum) | void | 459| blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum) | void | 460| checkFramebufferStatus(target: GLenum) | GLenum | 461| clear(mask: GLbitfield) | void | 462| clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | 463| clearDepth(depth: GLclampf) | void | 464| clearStencil(s: GLint) | void | 465| colorMask(red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean) | void | 466| compileShader(shader: WebGLShader) | void | 467| copyTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint) | void | 468| copyTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | 469| createBuffer() | WebGLBuffer \| null | 470| createFramebuffer() | WebGLFramebuffer \| null | 471| createProgram() | WebGLProgram \| null | 472| createRenderbuffer() | WebGLRenderbuffer \| null | 473| createShader(type: GLenum) | WebGLShader \| null | 474| createTexture() | WebGLTexture \| null | 475| cullFace(mode: GLenum) | void | 476| deleteBuffer(buffer: WebGLBuffer \| null) | void | 477| deleteFramebuffer(framebuffer: WebGLFramebuffer \| null) | void | 478| deleteProgram(program: WebGLProgram \| null) | void | 479| deleteRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | void | 480| deleteShader(shader: WebGLShader \| null) | void | 481| deleteTexture(texture: WebGLTexture \| null) | void | 482| depthFunc(func: GLenum) | void | 483| depthMask(flag: GLboolean) | void | 484| depthRange(zNear: GLclampf, zFar: GLclampf) | void | 485| detachShader(program: WebGLProgram, shader: WebGLShader) | void | 486| disable(cap: GLenum) | void | 487| disableVertexAttribArray(index: GLuint) | void | 488| drawArrays(mode: GLenum, first: GLint, count: GLsizei) | void | 489| drawElements(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr) | void | 490| enable(cap: GLenum) | void | 491| enableVertexAttribArray(index: GLuint) | void | 492| finish() | void | 493| flush() | void | 494| framebufferRenderbuffer(target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | 495| framebufferTexture2D(target: GLenum, attachment: GLenum, textarget: GLenum, texture: WebGLTexture \| null, level: GLint) | void | 496| frontFace(mode: GLenum) | void | 497| generateMipmap(target: GLenum) | void | 498| getActiveAttrib(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | 499| getActiveUniform(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | 500| getAttachedShaders(program: WebGLProgram) | WebGLShader[] \| null | 501| getAttribLocation(program: WebGLProgram, name: string) | GLint | 502| getBufferParameter(target: GLenum, pname: GLenum) | any | 503| getParameter(pname: GLenum) | any | 504| getError() | GLenum | 505| getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum) | any | 506| getProgramParameter(program: WebGLProgram, pname: GLenum) | any | 507| getProgramInfoLog(program: WebGLProgram) | string \| null | 508| getRenderbufferParameter(target: GLenum, pname: GLenum) | any | 509| getShaderParameter(shader: WebGLShader, pname: GLenum) | any | 510| getShaderPrecisionFormat(shadertype: GLenum, precisiontype: GLenum) | WebGLShaderPrecisionFormat \| null | 511| getShaderInfoLog(shader: WebGLShader) | string \| null | 512| getShaderSource(shader: WebGLShader) | string \| null | 513| getTexParameter(target: GLenum, pname: GLenum) | any | 514| getUniform(program: WebGLProgram, location: WebGLUniformLocation) | any | 515| getUniformLocation(program: WebGLProgram, name: string) | WebGLUniformLocation \| null | 516| getVertexAttrib(index: GLuint, pname: GLenum) | any | 517| getVertexAttribOffset(index: GLuint, pname: GLenum) | GLintptr | 518| hint(target: GLenum, mode: GLenum) | void | 519| isBuffer(buffer: WebGLBuffer \| null) | GLboolean | 520| isEnabled(cap: GLenum) | GLboolean | 521| isFramebuffer(framebuffer: WebGLFramebuffer \| null) | GLboolean | 522| isProgram(program: WebGLProgram \| null) | GLboolean | 523| isRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | GLboolean | 524| isShader(shader: WebGLShader \| null) | GLboolean | 525| isTexture(texture: WebGLTexture \| null) | GLboolean | 526| lineWidth(width: GLfloat) | void | 527| linkProgram(program: WebGLProgram) | void | 528| pixelStorei(pname: GLenum, param: GLint \| GLboolean) | void | 529| polygonOffset(factor: GLfloat, units: GLfloat) | void | 530| renderbufferStorage(target: GLenum, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | 531| sampleCoverage(value: GLclampf, invert: GLboolean) | void | 532| scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | 533| shaderSource(shader: WebGLShader, source: string) | void | 534| stencilFunc(func: GLenum, ref: GLint, mask: GLuint) | void | 535| stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint) | void | 536| stencilMask(mask: GLuint) | void | 537| stencilMaskSeparate(face: GLenum, mask: GLuint) | void | 538| stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum) | void | 539| stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum) | void | 540| texParameterf(target: GLenum, pname: GLenum, param: GLfloat) | void | 541| texParameteri(target: GLenum, pname: GLenum, param: GLint) | void | 542| uniform1f(location: WebGLUniformLocation \| null, x: GLfloat) | void | 543| uniform2f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat) | void | 544| uniform3f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat) | void | 545| uniform4f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | 546| uniform1i(location: WebGLUniformLocation \| null, x: GLint) | void | 547| uniform2i(location: WebGLUniformLocation \| null, x: GLint, y: GLint) | void | 548| uniform3i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint) | void | 549| uniform4i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint, w: GLint) | void | 550| useProgram(program: WebGLProgram \| null) | void | 551| validateProgram(program: WebGLProgram) | void | 552| vertexAttrib1f(index: GLuint, x: GLfloat) | void | 553| vertexAttrib2f(index: GLuint, x: GLfloat, y: GLfloat) | void | 554| vertexAttrib3f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat) | void | 555| vertexAttrib4f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | 556| vertexAttrib1fv(index: GLuint, values: Float32List) | void | 557| vertexAttrib2fv(index: GLuint, values: Float32List) | void | 558| vertexAttrib3fv(index: GLuint, values: Float32List) | void | 559| vertexAttrib4fv(index: GLuint, values: Float32List) | void | 560| vertexAttribPointer(index: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr) | void | 561| viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | 562 563 564## WebGLRenderingContextOverloads 565 566WebGLRenderingContextOverloads 567 568 | 方法 | 返回值类型 | 569| -------- | -------- | 570| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | 571| bufferData(target: GLenum, data: BufferSource \| null, usage: GLenum) | void | 572| bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource) | void | 573| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView) | void | 574| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView) | void | 575| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | 576| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | 577| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | 578| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | 579| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | 580| uniform1fv(location: WebGLUniformLocation \| null, v: Float32List) | void | 581| uniform2fv(location: WebGLUniformLocation \| null, v: Float32List) | void | 582| uniform3fv(location: WebGLUniformLocation \| null, v: Float32List) | void | 583| uniform4fv(location: WebGLUniformLocation \| null, v: Float32List) | void | 584| uniform1iv(location: WebGLUniformLocation \| null, v: Int32List) | void | 585| uniform2iv(location: WebGLUniformLocation \| null, v: Int32List) | void | 586| uniform3iv(location: WebGLUniformLocation \| null, v: Int32List) | void | 587| uniform4iv(location: WebGLUniformLocation \| null, v: Int32List) | void | 588| uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | 589| uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | 590| uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | 591