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