• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.WebGL46
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.WebGL74
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&nbsp;\|&nbsp;OffscreenCanvas | 是 |
437| drawingBufferWidth | GLsizei | 是 |
438| drawingBufferHeight | GLsizei | 是 |
439
440
441### 方法
442
443  | 方法 | 返回值类型 |
444| -------- | -------- |
445| getContextAttributes() | WebGLContextAttributes&nbsp;\|&nbsp;null |
446| isContextLost() | boolean |
447| getSupportedExtensions() | string[]&nbsp;\|&nbsp;null |
448| getExtension(name:&nbsp;string) | any |
449| activeTexture(texture:&nbsp;GLenum) | void |
450| attachShader(program:&nbsp;WebGLProgram,&nbsp;shader:&nbsp;WebGLShader) | void |
451| bindAttribLocation(program:&nbsp;WebGLProgram,&nbsp;index:&nbsp;GLuint,&nbsp;name:&nbsp;string) | void |
452| bindBuffer(target:&nbsp;GLenum,&nbsp;buffer:&nbsp;WebGLBuffer&nbsp;\|&nbsp;null) | void |
453| bindFramebuffer(target:&nbsp;GLenum,&nbsp;framebuffer:&nbsp;WebGLFramebuffer&nbsp;\|&nbsp;null) | void |
454| bindRenderbuffer(target:&nbsp;GLenum,&nbsp;renderbuffer:&nbsp;WebGLRenderbuffer&nbsp;\|&nbsp;null) | void |
455| bindTexture(target:&nbsp;GLenum,&nbsp;texture:&nbsp;WebGLTexture&nbsp;\|&nbsp;null) | void |
456| blendColor(red:&nbsp;GLclampf,&nbsp;green:&nbsp;GLclampf,&nbsp;blue:&nbsp;GLclampf,&nbsp;alpha:&nbsp;GLclampf) | void |
457| blendEquation(mode:&nbsp;GLenum) | void |
458| blendEquationSeparate(modeRGB:&nbsp;GLenum,&nbsp;modeAlpha:&nbsp;GLenum) | void |
459| blendFunc(sfactor:&nbsp;GLenum,&nbsp;dfactor:&nbsp;GLenum) | void |
460| blendFuncSeparate(srcRGB:&nbsp;GLenum,&nbsp;dstRGB:&nbsp;GLenum,&nbsp;srcAlpha:&nbsp;GLenum,&nbsp;dstAlpha:&nbsp;GLenum) | void |
461| checkFramebufferStatus(target:&nbsp;GLenum) | GLenum |
462| clear(mask:&nbsp;GLbitfield) | void |
463| clearColor(red:&nbsp;GLclampf,&nbsp;green:&nbsp;GLclampf,&nbsp;blue:&nbsp;GLclampf,&nbsp;alpha:&nbsp;GLclampf) | void |
464| clearDepth(depth:&nbsp;GLclampf) | void |
465| clearStencil(s:&nbsp;GLint) | void |
466| colorMask(red:&nbsp;GLboolean,&nbsp;green:&nbsp;GLboolean,&nbsp;blue:&nbsp;GLboolean,&nbsp;alpha:&nbsp;GLboolean) | void |
467| compileShader(shader:&nbsp;WebGLShader) | void |
468| copyTexImage2D(target:&nbsp;GLenum,&nbsp;level:&nbsp;GLint,&nbsp;internalformat:&nbsp;GLenum,&nbsp;x:&nbsp;GLint,&nbsp;y:&nbsp;GLint,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei,&nbsp;border:&nbsp;GLint) | void |
469| copyTexSubImage2D(target:&nbsp;GLenum,&nbsp;level:&nbsp;GLint,&nbsp;xoffset:&nbsp;GLint,&nbsp;yoffset:&nbsp;GLint,&nbsp;x:&nbsp;GLint,&nbsp;y:&nbsp;GLint,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei) | void |
470| createBuffer() | WebGLBuffer&nbsp;\|&nbsp;null |
471| createFramebuffer() | WebGLFramebuffer&nbsp;\|&nbsp;null |
472| createProgram() | WebGLProgram&nbsp;\|&nbsp;null |
473| createRenderbuffer() | WebGLRenderbuffer&nbsp;\|&nbsp;null |
474| createShader(type:&nbsp;GLenum) | WebGLShader&nbsp;\|&nbsp;null |
475| createTexture() | WebGLTexture&nbsp;\|&nbsp;null |
476| cullFace(mode:&nbsp;GLenum) | void |
477| deleteBuffer(buffer:&nbsp;WebGLBuffer&nbsp;\|&nbsp;null) | void |
478| deleteFramebuffer(framebuffer:&nbsp;WebGLFramebuffer&nbsp;\|&nbsp;null) | void |
479| deleteProgram(program:&nbsp;WebGLProgram&nbsp;\|&nbsp;null) | void |
480| deleteRenderbuffer(renderbuffer:&nbsp;WebGLRenderbuffer&nbsp;\|&nbsp;null) | void |
481| deleteShader(shader:&nbsp;WebGLShader&nbsp;\|&nbsp;null) | void |
482| deleteTexture(texture:&nbsp;WebGLTexture&nbsp;\|&nbsp;null) | void |
483| depthFunc(func:&nbsp;GLenum) | void |
484| depthMask(flag:&nbsp;GLboolean) | void |
485| depthRange(zNear:&nbsp;GLclampf,&nbsp;zFar:&nbsp;GLclampf) | void |
486| detachShader(program:&nbsp;WebGLProgram,&nbsp;shader:&nbsp;WebGLShader) | void |
487| disable(cap:&nbsp;GLenum) | void |
488| disableVertexAttribArray(index:&nbsp;GLuint) | void |
489| drawArrays(mode:&nbsp;GLenum,&nbsp;first:&nbsp;GLint,&nbsp;count:&nbsp;GLsizei) | void |
490| drawElements(mode:&nbsp;GLenum,&nbsp;count:&nbsp;GLsizei,&nbsp;type:&nbsp;GLenum,&nbsp;offset:&nbsp;GLintptr) | void |
491| enable(cap:&nbsp;GLenum) | void |
492| enableVertexAttribArray(index:&nbsp;GLuint) | void |
493| finish() | void |
494| flush() | void |
495| framebufferRenderbuffer(target:&nbsp;GLenum,&nbsp;attachment:&nbsp;GLenum,&nbsp;renderbuffertarget:&nbsp;GLenum,&nbsp;renderbuffer:&nbsp;WebGLRenderbuffer&nbsp;\|&nbsp;null) | void |
496| framebufferTexture2D(target:&nbsp;GLenum,&nbsp;attachment:&nbsp;GLenum,&nbsp;textarget:&nbsp;GLenum,&nbsp;texture:&nbsp;WebGLTexture&nbsp;\|&nbsp;null,&nbsp;level:&nbsp;GLint) | void |
497| frontFace(mode:&nbsp;GLenum) | void |
498| generateMipmap(target:&nbsp;GLenum) | void |
499| getActiveAttrib(program:&nbsp;WebGLProgram,&nbsp;index:&nbsp;GLuint) | WebGLActiveInfo&nbsp;\|&nbsp;null |
500| getActiveUniform(program:&nbsp;WebGLProgram,&nbsp;index:&nbsp;GLuint) | WebGLActiveInfo&nbsp;\|&nbsp;null |
501| getAttachedShaders(program:&nbsp;WebGLProgram) | WebGLShader[]&nbsp;\|&nbsp;null |
502| getAttribLocation(program:&nbsp;WebGLProgram,&nbsp;name:&nbsp;string) | GLint |
503| getBufferParameter(target:&nbsp;GLenum,&nbsp;pname:&nbsp;GLenum) | any |
504| getParameter(pname:&nbsp;GLenum) | any |
505| getError() | GLenum |
506| getFramebufferAttachmentParameter(target:&nbsp;GLenum,&nbsp;attachment:&nbsp;GLenum,&nbsp;pname:&nbsp;GLenum) | any |
507| getProgramParameter(program:&nbsp;WebGLProgram,&nbsp;pname:&nbsp;GLenum) | any |
508| getProgramInfoLog(program:&nbsp;WebGLProgram) | string&nbsp;\|&nbsp;null |
509| getRenderbufferParameter(target:&nbsp;GLenum,&nbsp;pname:&nbsp;GLenum) | any |
510| getShaderParameter(shader:&nbsp;WebGLShader,&nbsp;pname:&nbsp;GLenum) | any |
511| getShaderPrecisionFormat(shadertype:&nbsp;GLenum,&nbsp;precisiontype:&nbsp;GLenum) | WebGLShaderPrecisionFormat&nbsp;\|&nbsp;null |
512| getShaderInfoLog(shader:&nbsp;WebGLShader) | string&nbsp;\|&nbsp;null |
513| getShaderSource(shader:&nbsp;WebGLShader) | string&nbsp;\|&nbsp;null |
514| getTexParameter(target:&nbsp;GLenum,&nbsp;pname:&nbsp;GLenum) | any |
515| getUniform(program:&nbsp;WebGLProgram,&nbsp;location:&nbsp;WebGLUniformLocation) | any |
516| getUniformLocation(program:&nbsp;WebGLProgram,&nbsp;name:&nbsp;string) | WebGLUniformLocation&nbsp;\|&nbsp;null |
517| getVertexAttrib(index:&nbsp;GLuint,&nbsp;pname:&nbsp;GLenum) | any |
518| getVertexAttribOffset(index:&nbsp;GLuint,&nbsp;pname:&nbsp;GLenum) | GLintptr |
519| hint(target:&nbsp;GLenum,&nbsp;mode:&nbsp;GLenum) | void |
520| isBuffer(buffer:&nbsp;WebGLBuffer&nbsp;\|&nbsp;null) | GLboolean |
521| isEnabled(cap:&nbsp;GLenum) | GLboolean |
522| isFramebuffer(framebuffer:&nbsp;WebGLFramebuffer&nbsp;\|&nbsp;null) | GLboolean |
523| isProgram(program:&nbsp;WebGLProgram&nbsp;\|&nbsp;null) | GLboolean |
524| isRenderbuffer(renderbuffer:&nbsp;WebGLRenderbuffer&nbsp;\|&nbsp;null) | GLboolean |
525| isShader(shader:&nbsp;WebGLShader&nbsp;\|&nbsp;null) | GLboolean |
526| isTexture(texture:&nbsp;WebGLTexture&nbsp;\|&nbsp;null) | GLboolean |
527| lineWidth(width:&nbsp;GLfloat) | void |
528| linkProgram(program:&nbsp;WebGLProgram) | void |
529| pixelStorei(pname:&nbsp;GLenum,&nbsp;param:&nbsp;GLint&nbsp;\|&nbsp;GLboolean) | void |
530| polygonOffset(factor:&nbsp;GLfloat,&nbsp;units:&nbsp;GLfloat) | void |
531| renderbufferStorage(target:&nbsp;GLenum,&nbsp;internalformat:&nbsp;GLenum,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei) | void |
532| sampleCoverage(value:&nbsp;GLclampf,&nbsp;invert:&nbsp;GLboolean) | void |
533| scissor(x:&nbsp;GLint,&nbsp;y:&nbsp;GLint,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei) | void |
534| shaderSource(shader:&nbsp;WebGLShader,&nbsp;source:&nbsp;string) | void |
535| stencilFunc(func:&nbsp;GLenum,&nbsp;ref:&nbsp;GLint,&nbsp;mask:&nbsp;GLuint) | void |
536| stencilFuncSeparate(face:&nbsp;GLenum,&nbsp;func:&nbsp;GLenum,&nbsp;ref:&nbsp;GLint,&nbsp;mask:&nbsp;GLuint) | void |
537| stencilMask(mask:&nbsp;GLuint) | void |
538| stencilMaskSeparate(face:&nbsp;GLenum,&nbsp;mask:&nbsp;GLuint) | void |
539| stencilOp(fail:&nbsp;GLenum,&nbsp;zfail:&nbsp;GLenum,&nbsp;zpass:&nbsp;GLenum) | void |
540| stencilOpSeparate(face:&nbsp;GLenum,&nbsp;fail:&nbsp;GLenum,&nbsp;zfail:&nbsp;GLenum,&nbsp;zpass:&nbsp;GLenum) | void |
541| texParameterf(target:&nbsp;GLenum,&nbsp;pname:&nbsp;GLenum,&nbsp;param:&nbsp;GLfloat) | void |
542| texParameteri(target:&nbsp;GLenum,&nbsp;pname:&nbsp;GLenum,&nbsp;param:&nbsp;GLint) | void |
543| uniform1f(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;x:&nbsp;GLfloat) | void |
544| uniform2f(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;x:&nbsp;GLfloat,&nbsp;y:&nbsp;GLfloat) | void |
545| uniform3f(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;x:&nbsp;GLfloat,&nbsp;y:&nbsp;GLfloat,&nbsp;z:&nbsp;GLfloat) | void |
546| uniform4f(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;x:&nbsp;GLfloat,&nbsp;y:&nbsp;GLfloat,&nbsp;z:&nbsp;GLfloat,&nbsp;w:&nbsp;GLfloat) | void |
547| uniform1i(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;x:&nbsp;GLint) | void |
548| uniform2i(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;x:&nbsp;GLint,&nbsp;y:&nbsp;GLint) | void |
549| uniform3i(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;x:&nbsp;GLint,&nbsp;y:&nbsp;GLint,&nbsp;z:&nbsp;GLint) | void |
550| uniform4i(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;x:&nbsp;GLint,&nbsp;y:&nbsp;GLint,&nbsp;z:&nbsp;GLint,&nbsp;w:&nbsp;GLint) | void |
551| useProgram(program:&nbsp;WebGLProgram&nbsp;\|&nbsp;null) | void |
552| validateProgram(program:&nbsp;WebGLProgram) | void |
553| vertexAttrib1f(index:&nbsp;GLuint,&nbsp;x:&nbsp;GLfloat) | void |
554| vertexAttrib2f(index:&nbsp;GLuint,&nbsp;x:&nbsp;GLfloat,&nbsp;y:&nbsp;GLfloat) | void |
555| vertexAttrib3f(index:&nbsp;GLuint,&nbsp;x:&nbsp;GLfloat,&nbsp;y:&nbsp;GLfloat,&nbsp;z:&nbsp;GLfloat) | void |
556| vertexAttrib4f(index:&nbsp;GLuint,&nbsp;x:&nbsp;GLfloat,&nbsp;y:&nbsp;GLfloat,&nbsp;z:&nbsp;GLfloat,&nbsp;w:&nbsp;GLfloat) | void |
557| vertexAttrib1fv(index:&nbsp;GLuint,&nbsp;values:&nbsp;Float32List) | void |
558| vertexAttrib2fv(index:&nbsp;GLuint,&nbsp;values:&nbsp;Float32List) | void |
559| vertexAttrib3fv(index:&nbsp;GLuint,&nbsp;values:&nbsp;Float32List) | void |
560| vertexAttrib4fv(index:&nbsp;GLuint,&nbsp;values:&nbsp;Float32List) | void |
561| vertexAttribPointer(index:&nbsp;GLuint,&nbsp;size:&nbsp;GLint,&nbsp;type:&nbsp;GLenum,&nbsp;normalized:&nbsp;GLboolean,&nbsp;stride:&nbsp;GLsizei,&nbsp;offset:&nbsp;GLintptr) | void |
562| viewport(x:&nbsp;GLint,&nbsp;y:&nbsp;GLint,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei) | void |
563
564
565## WebGLRenderingContextOverloads
566
567WebGLRenderingContextOverloads
568
569  | 方法 | 返回值类型 |
570| -------- | -------- |
571| bufferData(target:&nbsp;GLenum,&nbsp;size:&nbsp;GLsizeiptr,&nbsp;usage:&nbsp;GLenum) | void |
572| bufferData(target:&nbsp;GLenum,&nbsp;data:&nbsp;BufferSource&nbsp;\|&nbsp;null,&nbsp;usage:&nbsp;GLenum) | void |
573| bufferSubData(target:&nbsp;GLenum,&nbsp;offset:&nbsp;GLintptr,&nbsp;data:&nbsp;BufferSource) | void |
574| compressedTexImage2D(target:&nbsp;GLenum,&nbsp;level:&nbsp;GLint,&nbsp;internalformat:&nbsp;GLenum,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei,&nbsp;border:&nbsp;GLint,&nbsp;data:&nbsp;ArrayBufferView) | void |
575| compressedTexSubImage2D(target:&nbsp;GLenum,&nbsp;level:&nbsp;GLint,&nbsp;xoffset:&nbsp;GLint,&nbsp;yoffset:&nbsp;GLint,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei,&nbsp;format:&nbsp;GLenum,&nbsp;data:&nbsp;ArrayBufferView) | void |
576| readPixels(x:&nbsp;GLint,&nbsp;y:&nbsp;GLint,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei,&nbsp;format:&nbsp;GLenum,&nbsp;type:&nbsp;GLenum,&nbsp;pixels:&nbsp;ArrayBufferView&nbsp;\|&nbsp;null) | void; |
577| texImage2D(target:&nbsp;GLenum,&nbsp;level:&nbsp;GLint,&nbsp;internalformat:&nbsp;GLint,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei,&nbsp;border:&nbsp;GLint,&nbsp;format:&nbsp;GLenum,&nbsp;type:&nbsp;GLenum,&nbsp;pixels:&nbsp;ArrayBufferView&nbsp;\|&nbsp;null) | void |
578| texImage2D(target:&nbsp;GLenum,&nbsp;level:&nbsp;GLint,&nbsp;internalformat:&nbsp;GLint,&nbsp;format:&nbsp;GLenum,&nbsp;type:&nbsp;GLenum,&nbsp;source:&nbsp;TexImageSource) | void |
579| texSubImage2D(target:&nbsp;GLenum,&nbsp;level:&nbsp;GLint,&nbsp;xoffset:&nbsp;GLint,&nbsp;yoffset:&nbsp;GLint,&nbsp;width:&nbsp;GLsizei,&nbsp;height:&nbsp;GLsizei,&nbsp;format:&nbsp;GLenum,&nbsp;type:&nbsp;GLenum,&nbsp;pixels:&nbsp;ArrayBufferView&nbsp;\|&nbsp;null) | void |
580| texSubImage2D(target:&nbsp;GLenum,&nbsp;level:&nbsp;GLint,&nbsp;xoffset:&nbsp;GLint,&nbsp;yoffset:&nbsp;GLint,&nbsp;format:&nbsp;GLenum,&nbsp;type:&nbsp;GLenum,&nbsp;source:&nbsp;TexImageSource) | void |
581| uniform1fv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;v:&nbsp;Float32List) | void |
582| uniform2fv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;v:&nbsp;Float32List) | void |
583| uniform3fv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;v:&nbsp;Float32List) | void |
584| uniform4fv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;v:&nbsp;Float32List) | void |
585| uniform1iv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;v:&nbsp;Int32List) | void |
586| uniform2iv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;v:&nbsp;Int32List) | void |
587| uniform3iv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;v:&nbsp;Int32List) | void |
588| uniform4iv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;v:&nbsp;Int32List) | void |
589| uniformMatrix2fv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;transpose:&nbsp;GLboolean,&nbsp;value:&nbsp;Float32List) | void |
590| uniformMatrix3fv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;transpose:&nbsp;GLboolean,&nbsp;value:&nbsp;Float32List) | void |
591| uniformMatrix4fv(location:&nbsp;WebGLUniformLocation&nbsp;\|&nbsp;null,&nbsp;transpose:&nbsp;GLboolean,&nbsp;value:&nbsp;Float32List) | void |
592