webgl_rs/rendering_context.rs
1//! Bindings for all objects and method associated with WebGL2
2//!
3//! Documentation taken straight from https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext
4//! and https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext
5use data_view::{Buffer, Image};
6use glenum::*;
7use wasm_bindgen::prelude::*;
8
9#[wasm_bindgen]
10#[derive(Clone, Copy)]
11extern "C" {
12 pub type HTMLDocument;
13 static document: HTMLDocument;
14
15 #[wasm_bindgen(method, js_name = getElementById)]
16 fn get_element_by_id(this: &HTMLDocument, id: &str) -> HTMLCanvasElement;
17
18 pub type HTMLCanvasElement;
19 #[wasm_bindgen(method)]
20 fn get_context(this: &HTMLCanvasElement, context: &str) -> WebGL2RenderingContext;
21}
22
23impl WebGL2RenderingContext {
24 pub fn new(id: &str) -> WebGL2RenderingContext {
25 document.get_element_by_id(id).get_context("webgl2")
26 }
27
28 /// Returns the size of the currently bound buffer in bytes
29 ///
30 /// # Arguments
31 /// * `target` - specifying the target buffer object.
32 pub fn buffer_size(&self, target: BufferKind) -> i32 {
33 self._get_buffer_parameter_i32(target, BufferParameter::Size)
34 }
35
36 /// Returns the usage of the currently bound buffer
37 ///
38 /// # Arguments
39 /// * `target` - specifying the target buffer object.
40 pub fn buffer_usage(&self, target: BufferKind) -> DataHint {
41 self._get_buffer_parameter_enum(target, BufferParameter::Usage)
42 }
43
44 /// Returns the internal format of the currently bound renderbuffer
45 ///
46 /// # Arguments
47 /// * `target` - specifying the target renderbuffer object.
48 pub fn renderbuffer_internal_format(&self, target: RenderbufferKind) -> RenderbufferFormat {
49 self._get_renderbuffer_parameter_enum(target, RenderbufferParameter::Format)
50 }
51
52 /// Returns the width of the image of the currently bound renderbuffer.
53 ///
54 /// # Arguments
55 /// * `target` - specifying the target renderbuffer object.
56 pub fn renderbuffer_width(&self, target: RenderbufferKind) -> i32 {
57 self._get_renderbuffer_parameter_i32(target, RenderbufferParameter::Width)
58 }
59
60 /// Returns the height of the image of the currently bound renderbuffer.
61 ///
62 /// # Arguments
63 /// * `target` - specifying the target renderbuffer object.
64 pub fn renderbuffer_height(&self, target: RenderbufferKind) -> i32 {
65 self._get_renderbuffer_parameter_i32(target, RenderbufferParameter::Height)
66 }
67
68 /// Returns the resolution size (in bits) for the green color.
69 ///
70 /// # Arguments
71 /// * `target` - specifying the target renderbuffer object.
72 pub fn renderbuffer_green_size(&self, target: RenderbufferKind) -> i32 {
73 self._get_renderbuffer_parameter_i32(target, RenderbufferParameter::GreenSize)
74 }
75
76 /// Returns the resolution size (in bits) for the blue color.
77 ///
78 /// # Arguments
79 /// * `target` - specifying the target renderbuffer object.
80 pub fn renderbuffer_blue_size(&self, target: RenderbufferKind) -> i32 {
81 self._get_renderbuffer_parameter_i32(target, RenderbufferParameter::BlueSize)
82 }
83
84 /// Returns the resolution size (in bits) for the red color.
85 ///
86 /// # Arguments
87 /// * `target` - specifying the target renderbuffer object.
88 pub fn renderbuffer_red_size(&self, target: RenderbufferKind) -> i32 {
89 self._get_renderbuffer_parameter_i32(target, RenderbufferParameter::RedSize)
90 }
91
92 /// Returns the resolution size (in bits) for the alpha component.
93 ///
94 /// # Arguments
95 /// * `target` - specifying the target renderbuffer object.
96 pub fn renderbuffer_alpha_size(&self, target: RenderbufferKind) -> i32 {
97 self._get_renderbuffer_parameter_i32(target, RenderbufferParameter::AlphaSize)
98 }
99
100 /// Returns the resolution size (in bits) for the depth component.
101 ///
102 /// # Arguments
103 /// * `target` - specifying the target renderbuffer object.
104 pub fn renderbuffer_depth_size(&self, target: RenderbufferKind) -> i32 {
105 self._get_renderbuffer_parameter_i32(target, RenderbufferParameter::DepthSize)
106 }
107
108 /// Returns the resolution size (in bits) for the stencil component.
109 ///
110 /// # Arguments
111 /// * `target` - specifying the target renderbuffer object.
112 pub fn renderbuffer_stencil_size(&self, target: RenderbufferKind) -> i32 {
113 self._get_renderbuffer_parameter_i32(target, RenderbufferParameter::StencilSize)
114 }
115
116 /// Returns the number of samples of the image of the currently bound renderbuffer.
117 ///
118 /// # Arguments
119 /// * `target` - specifying the target renderbuffer object.
120 pub fn renderbuffer_samples(&self, target: RenderbufferKind) -> i32 {
121 self._get_renderbuffer_parameter_i32(target, RenderbufferParameter::Samples)
122 }
123
124 /// Returns the texture magnification filter
125 ///
126 /// # Arguments
127 /// * `target` - specifying the binding point (target).
128 pub fn texture_mag_filter(&self, target: TextureKind) -> TextureMagFilter {
129 self._get_tex_parameter_enum1(target, TextureParameter::MagFilter)
130 }
131
132 /// Returns the texture minification filter
133 ///
134 /// # Arguments
135 /// * `target` - specifying the binding point (target).
136 pub fn texture_min_filter(&self, target: TextureKind) -> TextureMinFilter {
137 self._get_tex_parameter_enum2(target, TextureParameter::MinFilter)
138 }
139
140 /// Returns the wrapping function for texture coordinate s
141 ///
142 /// # Arguments
143 /// * `target` - specifying the binding point (target).
144 pub fn texture_wrap_s(&self, target: TextureKind) -> TextureWrap {
145 self._get_tex_parameter_enum3(target, TextureParameter::WrapS)
146 }
147
148 /// Returns the wrapping function for texture coordinate t
149 ///
150 /// # Arguments
151 /// * `target` - specifying the binding point (target).
152 pub fn texture_wrap_t(&self, target: TextureKind) -> TextureWrap {
153 self._get_tex_parameter_enum3(target, TextureParameter::WrapS)
154 }
155
156 /// Returns the texture mipmap level
157 ///
158 /// # Arguments
159 /// * `target` - specifying the binding point (target).
160 pub fn texture_base_level(&self, target: TextureKind) -> i32 {
161 self._get_tex_parameter_i32(target, TextureParameter::BaseLevel)
162 }
163
164 /// Returns the texture comparison function
165 ///
166 /// # Arguments
167 /// * `target` - specifying the binding point (target).
168 pub fn texture_compare_func(&self, target: TextureKind) -> DepthTest {
169 self._get_tex_parameter_enum4(target, TextureParameter::CompareFunc)
170 }
171
172 /// Returns the texture comparison mode
173 ///
174 /// # Arguments
175 /// * `target` - specifying the binding point (target).
176 pub fn texture_compare_mode(&self, target: TextureKind) -> CompareMode {
177 self._get_tex_parameter_enum5(target, TextureParameter::CompareMode)
178 }
179
180 /// Returns whether the texture format and size is immutable
181 ///
182 /// # Arguments
183 /// * `target` - specifying the binding point (target).
184 pub fn texture_immutable_format(&self, target: TextureKind) -> bool {
185 self._get_tex_parameter_bool(target, TextureParameter::ImmutableFormat)
186 }
187
188 /// Returns the immutable levels for a texture
189 ///
190 /// # Arguments
191 /// * `target` - specifying the binding point (target).
192 pub fn texture_immutable_levels(&self, target: TextureKind) -> u32 {
193 self._get_tex_parameter_u32(target, TextureParameter::ImmutableLevels)
194 }
195
196 /// Returns the maximum texture mipmap array level
197 ///
198 /// # Arguments
199 /// * `target` - specifying the binding point (target).
200 pub fn texture_max_level(&self, target: TextureKind) -> i32 {
201 self._get_tex_parameter_i32(target, TextureParameter::MaxLevel)
202 }
203
204 /// Returns the texture maximum level-of-detail value
205 ///
206 /// # Arguments
207 /// * `target` - specifying the binding point (target).
208 pub fn texture_max_lod(&self, target: TextureKind) -> f32 {
209 self._get_tex_parameter_f32(target, TextureParameter::MaxLod)
210 }
211
212 /// Returns the texture minimum level-of-detail value
213 ///
214 /// # Arguments
215 /// * `target` - specifying the binding point (target).
216 pub fn texture_min_lod(&self, target: TextureKind) -> f32 {
217 self._get_tex_parameter_f32(target, TextureParameter::MinLod)
218 }
219
220 /// Returns the wrapping function for texture coordinate r
221 ///
222 /// # Arguments
223 /// * `target` - specifying the binding point (target).
224 pub fn texture_wrap_r(&self, target: TextureKind) -> TextureWrap {
225 self._get_tex_parameter_enum3(target, TextureParameter::WrapS)
226 }
227
228 /// Initializes and creates the buffer object's data store.
229 ///
230 /// # Arguments
231 /// * `target` - specifying the binding point (target)
232 /// * `src_data` - the source data to be stored in the buffer
233 /// * `usage` - specifying the usage pattern of the data store.
234 pub fn buffer_data<B: Buffer>(&self, target: BufferKind, src_data: &B, usage: DataHint) {
235 src_data.buffer_data(self, target, usage);
236 }
237
238 /// Updates a subset of a buffer object's data store.
239 ///
240 /// # Arguments
241 /// * `target` - specifying the binding point (target)
242 /// * `offset` - specifying an offset in bytes where the data replacement will start.
243 /// * `src_data` - the source data to be stored in the buffer
244 pub fn buffer_sub_data<B: Buffer>(&self, target: BufferKind, offset: i64, src_data: &B) {
245 src_data.buffer_sub_data(self, target, offset);
246 }
247
248 /// Specifies and loads a two-dimensional texture image.
249 ///
250 /// # Arguments
251 /// * `target` - specifying the binding point (target) of the active texture.
252 /// * `level` - specifying the level of detail. Level 0 is the base image level and level n is the nth
253 /// mipmap reduction level.
254 /// * `internalformat` - specifying the color components in the texture.
255 /// * `width` - specifying the width of the texture.
256 /// * `height` - specifying the height of the texture.
257 /// * `format` - specifying the format of the texel data. To view the combinations possible see
258 /// https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
259 /// * `pixel_type` - specifying the data type of the texel data.
260 /// * `src_data` - pixel source for the texture
261 pub fn tex_image_2d<I: Image>(
262 &self,
263 target: TextureBindPoint,
264 level: u32,
265 internalformat: PixelCopyFormat,
266 width: u32,
267 height: u32,
268 format: PixelCopyFormat,
269 pixel_type: PixelType,
270 src_data: &I,
271 ) -> Result<(), JsValue> {
272 src_data.tex_image_2d(
273 self,
274 target,
275 level,
276 internalformat,
277 width,
278 height,
279 format,
280 pixel_type,
281 )
282 }
283
284 /* FIXME save for later
285 pub fn compressed_tex_image_2d(
286 &self,
287 target: TextureBindPoint,
288 level: u32,
289 internalformat: CompressedFormat,
290 width: u32,
291 height: u32,
292 pixels: I,
293 ) -> Result<(), JsValue> {
294 pixels.compressed_tex_image_2d(self, target, level, internalformat, width, height)
295 }*/
296
297 /// Specifies a sub-rectangle of the current texture.
298 ///
299 /// # Arguments
300 /// * `target` - specifying the binding point (target) of the active texture.
301 /// * `level` - specifying the level of detail. Level 0 is the base image level and level n is the nth
302 /// mipmap reduction level.
303 /// * `xoffset` - specifying the lower left texel x coordinate of a width-wide by height-wide rectangular subregion of the texture array.
304 /// * `yoffset` - specifying the lower left texel y coordinate of a width-wide by height-wide rectangular subregion of the texture array.
305 /// * `width` - specifying the width of the texture.
306 /// * `height` - specifying the height of the texture.
307 /// * `format` - specifying the format of the texel data. To view the combinations possible see
308 /// https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
309 /// * `pixel_type` - specifying the data type of the texel data.
310 /// * `pixels` - pixel source for the texture
311 pub fn tex_sub_image_2d<I: Image>(
312 &self,
313 target: TextureBindPoint,
314 level: u32,
315 xoffset: u32,
316 yoffset: u32,
317 width: u32,
318 height: u32,
319 format: PixelCopyFormat,
320 pixel_type: PixelType,
321 pixels: &I,
322 ) -> Result<(), JsValue> {
323 pixels.tex_sub_image_2d(
324 self, target, level, xoffset, yoffset, width, height, format, pixel_type,
325 )
326 }
327
328 /// Reads a block of pixels from a specified rectangle of the current color framebuffer into an array object.
329 ///
330 /// # Arguments
331 /// * `x` - specifying the first horizontal pixel that is read from the lower left corner of a rectangular block of pixels.
332 /// * `y` - specifying the first vertical pixel that is read from the lower left corner of a rectangular block of pixels.
333 /// * `width` - specifying the width of the rectangle.
334 /// * `height` - specifying the height of the rectangle.
335 /// * `format` - specifying the format of the pixel data.
336 /// * `pixel_type` - specifying the data type of the pixel data.
337 /// * `pixels` - An array object to read data into. The array type must match the type of the type parameter.
338 pub fn read_pixels<I: Image>(
339 &self,
340 x: u32,
341 y: u32,
342 width: u32,
343 height: u32,
344 format: PixelReadFormat,
345 pixel_type: PixelType,
346 pixels: &mut I,
347 ) -> Result<(), JsValue> {
348 pixels.read_pixels(self, x, y, width, height, format, pixel_type)
349 }
350
351 pub fn get_buffer_sub_data<B: Buffer>(
352 &self,
353 target: BufferKind,
354 src_offset: i64,
355 dst_data: &mut B,
356 dst_offset: u32,
357 length: u32,
358 ) -> Result<(), JsValue> {
359 dst_data.get_buffer_sub_data(self, target, src_offset, dst_offset, length)
360 }
361
362 // TODO loading -> tex_image_3d, tex_sub_image_3d, compressed_tex_image_2d, compressed_tex_sub_image_2d, compressed_tex_image_3d, compressed_tex_sub_image_3d, clear_buffer_uiv, clear_buffer_iv, clear_buffer_fv
363}
364
365/// WebGL2RenderingContext
366#[wasm_bindgen]
367#[derive(Clone, Copy)]
368extern "C" {
369 /// The WebGL2RenderingContext interface provides the OpenGL ES 3.0 rendering context
370 /// for the drawing surface of an HTML <canvas> element.
371 #[derive(Clone)]
372 pub type WebGL2RenderingContext;
373
374 /// The `WebGLRenderingContext.canvas` property is a read-only reference to the `HTMLCanvasElement`
375 /// or `OffscreenCanvas` object that is associated with the context. It might be null if it is not
376 /// associated with a <canvas> element or an `OffscreenCanvas` object.
377 #[wasm_bindgen(method, getter)]
378 pub fn canvas(this: &WebGL2RenderingContext) -> HTMLCanvasElement;
379
380 /// The read-only `WebGLRenderingContext.drawingBufferWidth` property represents the actual width
381 /// of the current drawing buffer. It should match the width attribute of the `<canvas>` element
382 /// associated with this context, but might differ if the implementation is not able to provide
383 /// the requested width.
384 #[wasm_bindgen(method, getter = drawingBufferWidth)]
385 pub fn drawing_buffer_width(this: &WebGL2RenderingContext) -> u32;
386
387 /// The read-only `WebGLRenderingContext.drawingBufferHeight` property represents the actual height
388 /// of the current drawing buffer. It should match the height attribute of the `<canvas>` element
389 /// associated with this context, but might differ if the implementation is not able to provide
390 /// the requested height.
391 #[wasm_bindgen(method, getter = drawingBufferHeight)]
392 pub fn drawing_buffer_height(this: &WebGL2RenderingContext) -> u32;
393
394 // WebGL1 methods
395
396 /// The `WebGLRenderingContext.getContextAttributes()` method returns a `WebGLContextAttributes`
397 /// object that contains the actual context parameters. Might return `null`, if the context is lost.
398 /* FIXME: the object is not defined when imported
399 #[wasm_bindgen(method, js_name = getContextAttributes)]
400 pub fn get_context_attributes(this: &WebGL2RenderingContext) -> WebGLContextAttributes;
401 */
402
403 /// The WebGLRenderingContext.isContextLost() method returns a Boolean indicating whether or not
404 /// the WebGL context has been lost.
405 #[wasm_bindgen(method, js_name = isContextLost)]
406 pub fn is_context_lost(this: &WebGL2RenderingContext) -> bool;
407
408 /// The `WebGLRenderingContext.scissor()` method of the WebGL API sets a scissor box, which limits
409 /// the drawing to a specified rectangle.
410 #[wasm_bindgen(method)]
411 pub fn scissor(this: &WebGL2RenderingContext, x: i32, y: i32, width: u32, height: u32);
412
413 /// The `WebGLRenderingContext.viewport()` method of the WebGL API sets the viewport, which
414 /// specifies the affine transformation of x and y from normalized device coordinates to window
415 /// coordinates.
416 #[wasm_bindgen(method)]
417 pub fn viewport(this: &WebGL2RenderingContext, x: i32, y: i32, width: u32, height: u32);
418
419 /// The `WebGLRenderingContext.activeTexture()` method of the WebGL API specifies which texture
420 /// unit to make active.
421 #[wasm_bindgen(method, js_name = activeTexture)]
422 pub fn active_texture(this: &WebGL2RenderingContext, texture: TextureUnit);
423
424 /// The `WebGLRenderingContext.blendColor()` method of the WebGL API is used to set the source and
425 /// destination blending factors.
426 #[wasm_bindgen(method, js_name = blendColor)]
427 pub fn blend_color(this: &WebGL2RenderingContext, red: f32, green: f32, blue: f32, alpha: f32);
428
429 /// The `WebGLRenderingContext.blendEquation()` method of the WebGL API is used to set both the RGB
430 /// blend equation and alpha blend equation to a single equation.
431 ///
432 /// The blend equation determines how a new pixel is combined with a pixel already in the
433 /// WebGLFramebuffer.
434 #[wasm_bindgen(method, js_name = blendEquation)]
435 pub fn blend_equation(this: &WebGL2RenderingContext, mode: BlendEquation);
436
437 /// The `WebGLRenderingContext.blendEquationSeparate()` method of the WebGL API is used to set
438 /// the RGB blend equation and alpha blend equation separately.
439 ///
440 /// The blend equation determines how a new pixel is combined with a pixel already in the
441 /// WebGLFramebuffer.
442 #[wasm_bindgen(method, js_name = blendEquationSeparate)]
443 pub fn blend_equation_separate(
444 this: &WebGL2RenderingContext,
445 mode_rgb: BlendEquation,
446 mode_alpha: BlendEquation,
447 );
448
449 /// The `WebGLRenderingContext.blendFunc()` method of the WebGL API defines which function is used
450 /// for blending pixel arithmetic.
451 #[wasm_bindgen(method, js_name = blendFunc)]
452 pub fn blend_func(this: &WebGL2RenderingContext, sfactor: BlendMode, dfactor: BlendMode);
453
454 /// The `WebGLRenderingContext.blendFuncSeparate()` method of the WebGL API defines which function
455 /// is used for blending pixel arithmetic for RGB and alpha components separately.
456 #[wasm_bindgen(method, js_name = blendFuncSeparate)]
457 pub fn blend_func_separate(
458 this: &WebGL2RenderingContext,
459 src_rgb: BlendMode,
460 dst_rgb: BlendMode,
461 src_alpha: BlendMode,
462 dst_alpha: BlendMode,
463 );
464
465 /// The `WebGLRenderingContext.clearColor()` method of the WebGL API specifies the color values
466 /// used when clearing color buffers.
467 ///
468 /// This specifies what color values to use when calling the clear() method. The values are clamped
469 /// between 0 and 1.
470 #[wasm_bindgen(method, js_name = clearColor)]
471 pub fn clear_color(this: &WebGL2RenderingContext, red: f32, green: f32, blue: f32, alpha: f32);
472
473 /// The `WebGLRenderingContext.clearDepth()` method of the WebGL API specifies the clear value for
474 /// the depth buffer.
475 ///
476 /// This specifies what depth value to use when calling the clear() method. The value is clamped
477 /// between 0 and 1.
478 #[wasm_bindgen(method, js_name = clearDepth)]
479 pub fn clear_depth(this: &WebGL2RenderingContext, depth: f32);
480
481 /// The `WebGLRenderingContext.clearStencil()` method of the WebGL API specifies the clear value
482 /// for the stencil buffer.
483 ///
484 /// This specifies what stencil value to use when calling the clear() method.
485 #[wasm_bindgen(method, js_name = clearStencil)]
486 pub fn clear_stencil(this: &WebGL2RenderingContext, s: i32);
487
488 /// The `WebGLRenderingContext.colorMask()` method of the WebGL API sets which color components
489 /// to enable or to disable when drawing or rendering to a WebGLFramebuffer.
490 #[wasm_bindgen(method, js_name = colorMask)]
491 pub fn color_mask(
492 this: &WebGL2RenderingContext,
493 red: bool,
494 green: bool,
495 blue: bool,
496 alpha: bool,
497 );
498
499 /// The `WebGLRenderingContext.cullFace()` method of the WebGL API specifies whether or not
500 /// front- and/or back-facing polygons can be culled.
501 #[wasm_bindgen(method, js_name = cullFace)]
502 pub fn cull_face(this: &WebGL2RenderingContext, mode: Culling);
503
504 /// The `WebGLRenderingContext.depthFunc()` method of the WebGL API specifies a function that
505 /// compares incoming pixel depth to the current depth buffer value.
506 #[wasm_bindgen(method, js_name = depthFunc)]
507 pub fn depth_func(this: &WebGL2RenderingContext, func: DepthTest);
508
509 /// The `WebGLRenderingContext.depthMask()` method of the WebGL API sets whether writing
510 /// into the depth buffer is enabled or disabled.
511 #[wasm_bindgen(method, js_name = depthMask)]
512 pub fn depth_mask(this: &WebGL2RenderingContext, flag: bool);
513
514 /// The `WebGLRenderingContext.depthRange()` method of the WebGL API specifies the depth
515 /// range mapping from normalized device coordinates to window or viewport coordinates.
516 #[wasm_bindgen(method, js_name = depthRange)]
517 pub fn depth_range(this: &WebGL2RenderingContext, z_near: f32, z_far: f32);
518
519 /// The `WebGLRenderingContext.disable()` method of the WebGL API disables specific WebGL
520 /// capabilities for this context.
521 #[wasm_bindgen(method)]
522 pub fn disable(this: &WebGL2RenderingContext, cap: Flag);
523
524 /// The `WebGLRenderingContext.enable()` method of the WebGL API enables specific WebGL
525 /// capabilities for this context.
526 #[wasm_bindgen(method)]
527 pub fn enable(this: &WebGL2RenderingContext, cap: Flag);
528
529 /// The `WebGLRenderingContext.frontFace()` method of the WebGL API specifies whether polygons
530 /// are front- or back-facing by setting a winding orientation.
531 #[wasm_bindgen(method, js_name = frontFace)]
532 pub fn front_face(this: &WebGL2RenderingContext, mode: FrontFaceDirection);
533
534 /// The `WebGLRenderingContext.getParameter()` method of the WebGL API returns a value for the
535 /// passed parameter name.
536 //#[wasm_bindgen(method, js_name = getParameter)]
537 // TODO save for later, this is a very convoluted method
538 //pub fn get_parameter(this: &WebGL2RenderingContext, pname: )
539
540 /// The `WebGLRenderingContext.getError()` method of the WebGL API returns error information.
541 #[wasm_bindgen(method, js_name = getError)]
542 pub fn get_error(this: &WebGL2RenderingContext) -> Error;
543
544 /// The `WebGLRenderingContext.hint()` method of the WebGL API specifies hints for certain behaviors.
545 /// The interpretation of these hints depend on the implementation.
546 #[wasm_bindgen(method)]
547 pub fn hint(this: &WebGL2RenderingContext, target: HintTarget, mode: HintMode);
548
549 /// The `WebGLRenderingContext.isEnabled()` method of the WebGL API tests whether a specific WebGL
550 /// capability is enabled or not for this context.
551 ///
552 /// By default, all capabilities except `gl.DITHER` are disabled.
553 #[wasm_bindgen(method, js_name = isEnabled)]
554 pub fn is_enabled(this: &WebGL2RenderingContext, cap: Flag);
555
556 /// The `WebGLRenderingContext.lineWidth()` method of the WebGL API sets the line width of rasterized lines.
557 #[wasm_bindgen(method, js_name = lineWidth)]
558 pub fn line_width(this: &WebGL2RenderingContext, width: f32);
559
560 /// The `WebGLRenderingContext.pixelStorei()` method of the WebGL API specifies the pixel storage modes.
561 #[wasm_bindgen(method, js_name = pixelStorei)]
562 pub fn pixel_storei(this: &WebGL2RenderingContext, pname: PixelStorageMode, param: i32);
563
564 /// The `WebGLRenderingContext.polygonOffset()` method of the WebGL API specifies the scale factors and
565 /// units to calculate depth values.
566 ///
567 /// The offset is added before the depth test is performed and before the value is written into the depth buffer.
568 #[wasm_bindgen(method, js_name = polygonOffset)]
569 pub fn polygon_offset(this: &WebGL2RenderingContext, factor: f32, units: f32);
570
571 /// The `WebGLRenderingContext.sampleCoverage()` method of the WebGL API specifies multi-sample coverage parameters
572 /// for anti-aliasing effects.
573 #[wasm_bindgen(method, js_name = sampleCoverage)]
574 pub fn sample_coverage(this: &WebGL2RenderingContext, value: f32, invert: bool);
575
576 /// The `WebGLRenderingContext.stencilFunc()` method of the WebGL API sets the front and back function and
577 /// reference value for stencil testing.
578 ///
579 /// Stencilling enables and disables drawing on a per-pixel basis. It is typically used in multipass rendering
580 /// to achieve special effects.
581 #[wasm_bindgen(method, js_name = stencilFunc)]
582 pub fn stencil_func(
583 this: &WebGL2RenderingContext,
584 func: StencilTest,
585 reference: i32,
586 mask: u32,
587 );
588
589 /// The `WebGLRenderingContext.stencilFuncSeparate()` method of the WebGL API sets the front and/or back
590 /// function and reference value for stencil testing.
591 ///
592 /// Stencilling enables and disables drawing on a per-pixel basis. It is typically used in multipass rendering to achieve special effects.
593 #[wasm_bindgen(method, js_name = stencilFuncSeparate)]
594 pub fn stencil_func_separate(
595 this: &WebGL2RenderingContext,
596 face: Culling,
597 func: StencilTest,
598 reference: i32,
599 mask: u32,
600 );
601
602 /// The `WebGLRenderingContext.stencilMask()` method of the WebGL API controls enabling and disabling
603 /// of both the front and back writing of individual bits in the stencil planes.
604 ///
605 /// The `WebGLRenderingContext.stencilMaskSeparate()` method can set front and back stencil writemasks
606 /// to different values.
607 #[wasm_bindgen(method, js_name = stencilMask)]
608 pub fn stencil_mask(this: &WebGL2RenderingContext, mask: u32);
609
610 /// The `WebGLRenderingContext.stencilMaskSeparate()` method of the WebGL API controls enabling and
611 /// disabling of front and/or back writing of individual bits in the stencil planes.
612 ///
613 /// The `WebGLRenderingContext.stencilMask()` method can set both, the front and back stencil writemasks
614 /// to one value at the same time.
615 #[wasm_bindgen(method, js_name = stencilMaskSeparate)]
616 pub fn stencil_mask_separate(this: &WebGL2RenderingContext, face: Culling, mask: u32);
617
618 /// The `WebGLRenderingContext.stencilOp()` method of the WebGL API sets both the front and back-facing
619 /// stencil test actions.
620 #[wasm_bindgen(method, js_name = stencilOp)]
621 pub fn stencil_op(
622 this: &WebGL2RenderingContext,
623 fail: StencilAction,
624 zfail: StencilAction,
625 zpass: StencilAction,
626 );
627
628 /// The `WebGLRenderingContext.stencilOpSeparate()` method of the WebGL API sets the front and/or
629 /// back-facing stencil test actions.
630 #[wasm_bindgen(method, js_name = stencilOpSeparate)]
631 pub fn stencil_op_separate(
632 this: &WebGL2RenderingContext,
633 face: Culling,
634 fail: StencilAction,
635 zfail: StencilAction,
636 zpass: StencilAction,
637 );
638
639 /// Binding for `WebGLRenderingContext.bufferData()` when data has type `[u8]`
640 #[wasm_bindgen(method, js_name = bufferData)]
641 pub(crate) fn _buffer_data_u8(
642 this: &WebGL2RenderingContext,
643 target: BufferKind,
644 src_data: &[u8],
645 usage: DataHint,
646 );
647 /// Binding for `WebGLRenderingContext.bufferData()` when data has type `[i8]`
648 #[wasm_bindgen(method, js_name = bufferData)]
649 pub(crate) fn _buffer_data_i8(
650 this: &WebGL2RenderingContext,
651 target: BufferKind,
652 src_data: &[i8],
653 usage: DataHint,
654 );
655 /// Binding for `WebGLRenderingContext.bufferData()` when data has type `[u16]`
656 #[wasm_bindgen(method, js_name = bufferData)]
657 pub(crate) fn _buffer_data_u16(
658 this: &WebGL2RenderingContext,
659 target: BufferKind,
660 src_data: &[u16],
661 usage: DataHint,
662 );
663 /// Binding for `WebGLRenderingContext.bufferData()` when data has type `[i16]`
664 #[wasm_bindgen(method, js_name = bufferData)]
665 pub(crate) fn _buffer_data_i16(
666 this: &WebGL2RenderingContext,
667 target: BufferKind,
668 src_data: &[i16],
669 usage: DataHint,
670 );
671 /// Binding for `WebGLRenderingContext.bufferData()` when data has type `[u32]`
672 #[wasm_bindgen(method, js_name = bufferData)]
673 pub(crate) fn _buffer_data_u32(
674 this: &WebGL2RenderingContext,
675 target: BufferKind,
676 src_data: &[u32],
677 usage: DataHint,
678 );
679 /// Binding for `WebGLRenderingContext.bufferData()` when data has type `[i32]`
680 #[wasm_bindgen(method, js_name = bufferData)]
681 pub(crate) fn _buffer_data_i32(
682 this: &WebGL2RenderingContext,
683 target: BufferKind,
684 src_data: &[i32],
685 usage: DataHint,
686 );
687 /// Binding for `WebGLRenderingContext.bufferData()` when data has type `[f32]`
688 #[wasm_bindgen(method, js_name = bufferData)]
689 pub(crate) fn _buffer_data_f32(
690 this: &WebGL2RenderingContext,
691 target: BufferKind,
692 src_data: &[f32],
693 usage: DataHint,
694 );
695 /// Binding for `WebGLRenderingContext.bufferData()` when data has type `[f64]`
696 #[wasm_bindgen(method, js_name = bufferData)]
697 pub(crate) fn _buffer_data_f64(
698 this: &WebGL2RenderingContext,
699 target: BufferKind,
700 src_data: &[f64],
701 usage: DataHint,
702 );
703
704 //TODO buffer_data, buffer_sub_data with offset
705
706 /// Binding for `WebGLRenderingContext.bufferSubData()` when data type is `[u8]`
707 #[wasm_bindgen(method, js_name = bufferSubData)]
708 pub(crate) fn _buffer_sub_data_u8(
709 this: &WebGL2RenderingContext,
710 target: BufferKind,
711 offset: i64,
712 srcData: &[u8],
713 );
714 /// Binding for `WebGLRenderingContext.bufferSubData()` when data type is `[i8]`
715 #[wasm_bindgen(method, js_name = bufferSubData)]
716 pub(crate) fn _buffer_sub_data_i8(
717 this: &WebGL2RenderingContext,
718 target: BufferKind,
719 offset: i64,
720 srcData: &[i8],
721 );
722 /// Binding for `WebGLRenderingContext.bufferSubData()` when data type is `[u16]`
723 #[wasm_bindgen(method, js_name = bufferSubData)]
724 pub(crate) fn _buffer_sub_data_u16(
725 this: &WebGL2RenderingContext,
726 target: BufferKind,
727 offset: i64,
728 srcData: &[u16],
729 );
730 /// Binding for `WebGLRenderingContext.bufferSubData()` when data type is `[i16]`
731 #[wasm_bindgen(method, js_name = bufferSubData)]
732 pub(crate) fn _buffer_sub_data_i16(
733 this: &WebGL2RenderingContext,
734 target: BufferKind,
735 offset: i64,
736 srcData: &[i16],
737 );
738 /// Binding for `WebGLRenderingContext.bufferSubData()` when data type is `[u32]`
739 #[wasm_bindgen(method, js_name = bufferSubData)]
740 pub(crate) fn _buffer_sub_data_u32(
741 this: &WebGL2RenderingContext,
742 target: BufferKind,
743 offset: i64,
744 srcData: &[u32],
745 );
746 /// Binding for `WebGLRenderingContext.bufferSubData()` when data type is `[i32]`
747 #[wasm_bindgen(method, js_name = bufferSubData)]
748 pub(crate) fn _buffer_sub_data_i32(
749 this: &WebGL2RenderingContext,
750 target: BufferKind,
751 offset: i64,
752 srcData: &[i32],
753 );
754 /// Binding for `WebGLRenderingContext.bufferSubData()` when data type is `[f32]`
755 #[wasm_bindgen(method, js_name = bufferSubData)]
756 pub(crate) fn _buffer_sub_data_f32(
757 this: &WebGL2RenderingContext,
758 target: BufferKind,
759 offset: i64,
760 srcData: &[f32],
761 );
762 /// Binding for `WebGLRenderingContext.bufferSubData()` when data type is `[f64]`
763 #[wasm_bindgen(method, js_name = bufferSubData)]
764 pub(crate) fn _buffer_sub_data_f64(
765 this: &WebGL2RenderingContext,
766 target: BufferKind,
767 offset: i64,
768 srcData: &[f64],
769 );
770
771 /// Binding for `WebGLRenderingContext.getBufferParameter()` when return type is `i32`
772 #[wasm_bindgen(method, js_name = getBufferParameter)]
773 fn _get_buffer_parameter_i32(
774 this: &WebGL2RenderingContext,
775 target: BufferKind,
776 pname: BufferParameter,
777 ) -> i32;
778 /// Binding for `WebGLRenderingContext.getBufferParameter()` when return type is `enum`
779 #[wasm_bindgen(method, js_name = getBufferParameter)]
780 fn _get_buffer_parameter_enum(
781 this: &WebGL2RenderingContext,
782 target: BufferKind,
783 pname: BufferParameter,
784 ) -> DataHint;
785
786 /// The `WebGLRenderingContext.checkFramebufferStatus()` method of the WebGL API returns the completeness
787 /// status of the WebGLFramebuffer object.
788 #[wasm_bindgen(method, js_name = checkFramebufferStatus)]
789 pub fn check_framebuffer_status(this: &WebGL2RenderingContext, target: FramebufferKind)
790 -> bool;
791
792 // TODO getFramebufferAttachmentParameter()
793 // later because of awful return structure
794
795 /// Binding for `WebGLRenderingContext.readPixels()` when type of data is `[u8]`
796 #[wasm_bindgen(method, js_name = readPixels, catch)]
797 pub(crate) fn _read_pixels_u8(
798 this: &WebGL2RenderingContext,
799 x: u32,
800 y: u32,
801 width: u32,
802 height: u32,
803 format: PixelReadFormat,
804 pixel_type: PixelType,
805 pixels: &mut [u8],
806 ) -> Result<(), JsValue>;
807 /// Binding for `WebGLRenderingContext.readPixels()` when type of data is `[i8]`
808 #[wasm_bindgen(method, js_name = readPixels, catch)]
809 pub(crate) fn _read_pixels_i8(
810 this: &WebGL2RenderingContext,
811 x: u32,
812 y: u32,
813 width: u32,
814 height: u32,
815 format: PixelReadFormat,
816 pixel_type: PixelType,
817 pixels: &mut [i8],
818 ) -> Result<(), JsValue>;
819 /// Binding for `WebGLRenderingContext.readPixels()` when type of data is `[u16]`
820 #[wasm_bindgen(method, js_name = readPixels, catch)]
821 pub(crate) fn _read_pixels_u16(
822 this: &WebGL2RenderingContext,
823 x: u32,
824 y: u32,
825 width: u32,
826 height: u32,
827 format: PixelReadFormat,
828 pixel_type: PixelType,
829 pixels: &mut [u16],
830 ) -> Result<(), JsValue>;
831 /// Binding for `WebGLRenderingContext.readPixels()` when type of data is `[i16]`
832 #[wasm_bindgen(method, js_name = readPixels, catch)]
833 pub(crate) fn _read_pixels_i16(
834 this: &WebGL2RenderingContext,
835 x: u32,
836 y: u32,
837 width: u32,
838 height: u32,
839 format: PixelReadFormat,
840 pixel_type: PixelType,
841 pixels: &mut [i16],
842 ) -> Result<(), JsValue>;
843 /// Binding for `WebGLRenderingContext.readPixels()` when type of data is `[u32]`
844 #[wasm_bindgen(method, js_name = readPixels, catch)]
845 pub(crate) fn _read_pixels_u32(
846 this: &WebGL2RenderingContext,
847 x: u32,
848 y: u32,
849 width: u32,
850 height: u32,
851 format: PixelReadFormat,
852 pixel_type: PixelType,
853 pixels: &mut [u32],
854 ) -> Result<(), JsValue>;
855 /// Binding for `WebGLRenderingContext.readPixels()` when type of data is `[i32]`
856 #[wasm_bindgen(method, js_name = readPixels, catch)]
857 pub(crate) fn _read_pixels_i32(
858 this: &WebGL2RenderingContext,
859 x: u32,
860 y: u32,
861 width: u32,
862 height: u32,
863 format: PixelReadFormat,
864 pixel_type: PixelType,
865 pixels: &mut [i32],
866 ) -> Result<(), JsValue>;
867 /// Binding for `WebGLRenderingContext.readPixels()` when type of data is `[f32]`
868 #[wasm_bindgen(method, js_name = readPixels, catch)]
869 pub(crate) fn _read_pixels_f32(
870 this: &WebGL2RenderingContext,
871 x: u32,
872 y: u32,
873 width: u32,
874 height: u32,
875 format: PixelReadFormat,
876 pixel_type: PixelType,
877 pixels: &mut [f32],
878 ) -> Result<(), JsValue>;
879
880 /// Binding for `WebGLRenderingContext.getRenderbufferParameter()` when return type is `i32`
881 #[wasm_bindgen(method, js_name = getRenderbufferParameter)]
882 fn _get_renderbuffer_parameter_i32(
883 this: &WebGL2RenderingContext,
884 target: RenderbufferKind,
885 pname: RenderbufferParameter,
886 ) -> i32;
887 /// Binding for `WebGLRenderingContext.getRenderbufferParameter()` when return type is `i32`
888 #[wasm_bindgen(method, js_name = getRenderbufferParameter)]
889 fn _get_renderbuffer_parameter_enum(
890 this: &WebGL2RenderingContext,
891 target: RenderbufferKind,
892 pname: RenderbufferParameter,
893 ) -> RenderbufferFormat;
894
895 /// The `WebGLRenderingContext.renderbufferStorage()` method of the WebGL API creates and initializes
896 /// a renderbuffer object's data store.
897 #[wasm_bindgen(method, js_name = renderbufferStorage)]
898 pub fn renderbuffer_storage(
899 this: &WebGL2RenderingContext,
900 target: RenderbufferKind,
901 internalFormat: RenderbufferFormat,
902 width: u32,
903 height: u32,
904 );
905
906 /// The `WebGLRenderingContext.copyTexImage2D()` method of the WebGL API copies pixels from the current
907 /// WebGLFramebuffer into a 2D texture image.
908 #[wasm_bindgen(method, js_name = copyTexImage2D)]
909 pub fn copy_tex_image_2d(
910 this: &WebGL2RenderingContext,
911 target: TextureBindPoint,
912 level: u32,
913 internalformat: PixelCopyFormat,
914 x: i32,
915 y: i32,
916 width: u32,
917 height: u32,
918 border: u32,
919 );
920
921 /// The `WebGLRenderingContext.copyTexSubImage2D()` method of the WebGL API copies pixels from the current
922 /// WebGLFramebuffer into an existing 2D texture sub-image.
923 #[wasm_bindgen(method, js_name = copyTexSubImage2D)]
924 pub fn copy_tex_sub_image_2d(
925 this: &WebGL2RenderingContext,
926 target: TextureBindPoint,
927 level: u32,
928 xoffset: i32,
929 yoffset: i32,
930 x: i32,
931 y: i32,
932 width: u32,
933 height: u32,
934 );
935
936 /// The `WebGLRenderingContext.generateMipmap()` method of the WebGL API generates a set of mipmaps for a
937 /// WebGLTexture object.
938 ///
939 /// Mipmaps are used to create distance with objects. A higher-resolution mipmap is used for objects that
940 /// are closer, and a lower-resolution mipmap is used for objects that are farther away. It starts with the
941 /// resolution of the texture image and halves the resolution until a 1x1 dimension texture image is created.
942 #[wasm_bindgen(method, js_name = generateMipmap)]
943 pub fn generate_mipmap(this: &WebGL2RenderingContext, target: TextureKind);
944
945 /// Binding for `WebGLRenderingContext.getTexParameter` when return type is `i32`
946 #[wasm_bindgen(method, js_name = getTexParameter)]
947 fn _get_tex_parameter_i32(
948 this: &WebGL2RenderingContext,
949 target: TextureKind,
950 pname: TextureParameter,
951 ) -> i32;
952 /// Binding for `WebGLRenderingContext.getTexParameter` when return type is `u32`
953 #[wasm_bindgen(method, js_name = getTexParameter)]
954 fn _get_tex_parameter_u32(
955 this: &WebGL2RenderingContext,
956 target: TextureKind,
957 pname: TextureParameter,
958 ) -> u32;
959 /// Binding for `WebGLRenderingContext.getTexParameter` when return type is `f32`
960 #[wasm_bindgen(method, js_name = getTexParameter)]
961 fn _get_tex_parameter_f32(
962 this: &WebGL2RenderingContext,
963 target: TextureKind,
964 pname: TextureParameter,
965 ) -> f32;
966 /// Binding for `WebGLRenderingContext.getTexParameter` when return type is `bool`
967 #[wasm_bindgen(method, js_name = getTexParameter)]
968 fn _get_tex_parameter_bool(
969 this: &WebGL2RenderingContext,
970 target: TextureKind,
971 pname: TextureParameter,
972 ) -> bool;
973 /// Binding for `WebGLRenderingContext.getTexParameter` when return type is `TextureMagFilter`
974 #[wasm_bindgen(method, js_name = getTexParameter)]
975 fn _get_tex_parameter_enum1(
976 this: &WebGL2RenderingContext,
977 target: TextureKind,
978 pname: TextureParameter,
979 ) -> TextureMagFilter;
980 /// Binding for `WebGLRenderingContext.getTexParameter` when return type is `TextureMinFilter`
981 #[wasm_bindgen(method, js_name = getTexParameter)]
982 fn _get_tex_parameter_enum2(
983 this: &WebGL2RenderingContext,
984 target: TextureKind,
985 pname: TextureParameter,
986 ) -> TextureMinFilter;
987 /// Binding for `WebGLRenderingContext.getTexParameter` when return type is `TextureWrap`
988 #[wasm_bindgen(method, js_name = getTexParameter)]
989 fn _get_tex_parameter_enum3(
990 this: &WebGL2RenderingContext,
991 target: TextureKind,
992 pname: TextureParameter,
993 ) -> TextureWrap;
994 /// Binding for `WebGLRenderingContext.getTexParameter` when return type is `DepthTest`
995 #[wasm_bindgen(method, js_name = getTexParameter)]
996 fn _get_tex_parameter_enum4(
997 this: &WebGL2RenderingContext,
998 target: TextureKind,
999 pname: TextureParameter,
1000 ) -> DepthTest;
1001 /// Binding for `WebGLRenderingContext.getTexParameter` when return type is `CompareMode`
1002 #[wasm_bindgen(method, js_name = getTexParameter)]
1003 fn _get_tex_parameter_enum5(
1004 this: &WebGL2RenderingContext,
1005 target: TextureKind,
1006 pname: TextureParameter,
1007 ) -> CompareMode;
1008
1009 /// Binding for `WebGLRenderingContext.texImage2D()` if data has type `[u8]`.
1010 #[wasm_bindgen(method, js_name = texImage2D, catch)]
1011 pub(crate) fn _tex_image_2d_u8(
1012 this: &WebGL2RenderingContext,
1013 target: TextureBindPoint,
1014 level: u32,
1015 internalformat: PixelCopyFormat,
1016 width: u32,
1017 height: u32,
1018 border: u32,
1019 format: PixelCopyFormat,
1020 pixel_type: PixelType,
1021 src_data: &[u8],
1022 ) -> Result<(), JsValue>;
1023 /// Binding for `WebGLRenderingContext.texImage2D()` if data has type `[8]`.
1024 #[wasm_bindgen(method, js_name = texImage2D, catch)]
1025 pub(crate) fn _tex_image_2d_i8(
1026 this: &WebGL2RenderingContext,
1027 target: TextureBindPoint,
1028 level: u32,
1029 internalformat: PixelCopyFormat,
1030 width: u32,
1031 height: u32,
1032 border: u32,
1033 format: PixelCopyFormat,
1034 pixel_type: PixelType,
1035 src_data: &[i8],
1036 ) -> Result<(), JsValue>;
1037 /// Binding for `WebGLRenderingContext.texImage2D()` if data has type `[u16]`.
1038 #[wasm_bindgen(method, js_name = texImage2D, catch)]
1039 pub(crate) fn _tex_image_2d_u16(
1040 this: &WebGL2RenderingContext,
1041 target: TextureBindPoint,
1042 level: u32,
1043 internalformat: PixelCopyFormat,
1044 width: u32,
1045 height: u32,
1046 border: u32,
1047 format: PixelCopyFormat,
1048 pixel_type: PixelType,
1049 src_data: &[u16],
1050 ) -> Result<(), JsValue>;
1051 /// Binding for `WebGLRenderingContext.texImage2D()` if data has type `[i16]`.
1052 #[wasm_bindgen(method, js_name = texImage2D, catch)]
1053 pub(crate) fn _tex_image_2d_i16(
1054 this: &WebGL2RenderingContext,
1055 target: TextureBindPoint,
1056 level: u32,
1057 internalformat: PixelCopyFormat,
1058 width: u32,
1059 height: u32,
1060 border: u32,
1061 format: PixelCopyFormat,
1062 pixel_type: PixelType,
1063 src_data: &[i16],
1064 ) -> Result<(), JsValue>;
1065 /// Binding for `WebGLRenderingContext.texImage2D()` if data has type `[u32]`.
1066 #[wasm_bindgen(method, js_name = texImage2D, catch)]
1067 pub(crate) fn _tex_image_2d_u32(
1068 this: &WebGL2RenderingContext,
1069 target: TextureBindPoint,
1070 level: u32,
1071 internalformat: PixelCopyFormat,
1072 width: u32,
1073 height: u32,
1074 border: u32,
1075 format: PixelCopyFormat,
1076 pixel_type: PixelType,
1077 src_data: &[u32],
1078 ) -> Result<(), JsValue>;
1079 /// Binding for `WebGLRenderingContext.texImage2D()` if data has type `[i32]`.
1080 #[wasm_bindgen(method, js_name = texImage2D, catch)]
1081 pub(crate) fn _tex_image_2d_i32(
1082 this: &WebGL2RenderingContext,
1083 target: TextureBindPoint,
1084 level: u32,
1085 internalformat: PixelCopyFormat,
1086 width: u32,
1087 height: u32,
1088 border: u32,
1089 format: PixelCopyFormat,
1090 pixel_type: PixelType,
1091 src_data: &[i32],
1092 ) -> Result<(), JsValue>;
1093 /// Binding for `WebGLRenderingContext.texImage2D()` if data has type `[f32]`.
1094 #[wasm_bindgen(method, js_name = texImage2D, catch)]
1095 pub(crate) fn _tex_image_2d_f32(
1096 this: &WebGL2RenderingContext,
1097 target: TextureBindPoint,
1098 level: u32,
1099 internalformat: PixelCopyFormat,
1100 width: u32,
1101 height: u32,
1102 border: u32,
1103 format: PixelCopyFormat,
1104 pixel_type: PixelType,
1105 src_data: &[f32],
1106 ) -> Result<(), JsValue>;
1107
1108 // Binding for `WebGLRenderingContext.texSubImage2D()` if data has type `[u8]`.
1109 #[wasm_bindgen(method, js_name = texSubImage2D, catch)]
1110 pub(crate) fn _tex_sub_image_2d_u8(
1111 this: &WebGL2RenderingContext,
1112 target: TextureBindPoint,
1113 level: u32,
1114 xoffset: u32,
1115 yoffset: u32,
1116 width: u32,
1117 height: u32,
1118 format: PixelCopyFormat,
1119 pixel_type: PixelType,
1120 pixels: &[u8],
1121 ) -> Result<(), JsValue>;
1122 // Binding for `WebGLRenderingContext.texSubImage2D()` if data has type `[i8]`.
1123 #[wasm_bindgen(method, js_name = texSubImage2D, catch)]
1124 pub(crate) fn _tex_sub_image_2d_i8(
1125 this: &WebGL2RenderingContext,
1126 target: TextureBindPoint,
1127 level: u32,
1128 xoffset: u32,
1129 yoffset: u32,
1130 width: u32,
1131 height: u32,
1132 format: PixelCopyFormat,
1133 pixel_type: PixelType,
1134 pixels: &[i8],
1135 ) -> Result<(), JsValue>;
1136 // Binding for `WebGLRenderingContext.texSubImage2D()` if data has type `[u16]`.
1137 #[wasm_bindgen(method, js_name = texSubImage2D, catch)]
1138 pub(crate) fn _tex_sub_image_2d_u16(
1139 this: &WebGL2RenderingContext,
1140 target: TextureBindPoint,
1141 level: u32,
1142 xoffset: u32,
1143 yoffset: u32,
1144 width: u32,
1145 height: u32,
1146 format: PixelCopyFormat,
1147 pixel_type: PixelType,
1148 pixels: &[u16],
1149 ) -> Result<(), JsValue>;
1150 // Binding for `WebGLRenderingContext.texSubImage2D()` if data has type `[i16]`.
1151 #[wasm_bindgen(method, js_name = texSubImage2D, catch)]
1152 pub(crate) fn _tex_sub_image_2d_i16(
1153 this: &WebGL2RenderingContext,
1154 target: TextureBindPoint,
1155 level: u32,
1156 xoffset: u32,
1157 yoffset: u32,
1158 width: u32,
1159 height: u32,
1160 format: PixelCopyFormat,
1161 pixel_type: PixelType,
1162 pixels: &[i16],
1163 ) -> Result<(), JsValue>;
1164 // Binding for `WebGLRenderingContext.texSubImage2D()` if data has type `[u32]`.
1165 #[wasm_bindgen(method, js_name = texSubImage2D, catch)]
1166 pub(crate) fn _tex_sub_image_2d_u32(
1167 this: &WebGL2RenderingContext,
1168 target: TextureBindPoint,
1169 level: u32,
1170 xoffset: u32,
1171 yoffset: u32,
1172 width: u32,
1173 height: u32,
1174 format: PixelCopyFormat,
1175 pixel_type: PixelType,
1176 pixels: &[u32],
1177 ) -> Result<(), JsValue>;
1178 // Binding for `WebGLRenderingContext.texSubImage2D()` if data has type `[i32]`.
1179 #[wasm_bindgen(method, js_name = texSubImage2D, catch)]
1180 pub(crate) fn _tex_sub_image_2d_i32(
1181 this: &WebGL2RenderingContext,
1182 target: TextureBindPoint,
1183 level: u32,
1184 xoffset: u32,
1185 yoffset: u32,
1186 width: u32,
1187 height: u32,
1188 format: PixelCopyFormat,
1189 pixel_type: PixelType,
1190 pixels: &[i32],
1191 ) -> Result<(), JsValue>;
1192 // Binding for `WebGLRenderingContext.texSubImage2D()` if data has type `[f32]`.
1193 #[wasm_bindgen(method, js_name = texSubImage2D, catch)]
1194 pub(crate) fn _tex_sub_image_2d_f32(
1195 this: &WebGL2RenderingContext,
1196 target: TextureBindPoint,
1197 level: u32,
1198 xoffset: u32,
1199 yoffset: u32,
1200 width: u32,
1201 height: u32,
1202 format: PixelCopyFormat,
1203 pixel_type: PixelType,
1204 pixels: &[f32],
1205 ) -> Result<(), JsValue>;
1206
1207 /// The `WebGLRenderingContext.texParameter[fi]()` methods of the WebGL API set texture parameters.
1208 // FIXME: not idiomatic needs set_ prefix
1209 #[wasm_bindgen(method, js_name = texParameterf)]
1210 pub fn tex_parameter_f(
1211 this: &WebGL2RenderingContext,
1212 target: TextureKind,
1213 pname: TextureParameter,
1214 param: f32,
1215 );
1216
1217 /// The `WebGLRenderingContext.texParameter[fi]()` methods of the WebGL API set texture parameters.
1218 #[wasm_bindgen(method, js_name = texParameterf)]
1219 pub fn tex_parameter_i(
1220 this: &WebGL2RenderingContext,
1221 target: TextureKind,
1222 pname: TextureParameter,
1223 param: i32,
1224 );
1225
1226 /// The `WebGLRenderingContext.getShaderPrecisionFormat()` method of the WebGL API returns a new WebGLShaderPrecisionFormat
1227 /// object describing the range and precision for the specified shader numeric format.
1228 #[wasm_bindgen(method, js_name = getShaderPrecisionFormat)]
1229 pub fn get_shader_precision_format(
1230 this: &WebGL2RenderingContext,
1231 shader_type: ShaderKind,
1232 precision_type: ShaderPrecision,
1233 ) -> WebGLShaderPrecisionFormat;
1234
1235 /// The `WebGLRenderingContext.disableVertexAttribArray()` method of the WebGL API turns the generic
1236 /// vertex attribute array off at a given index position.
1237 #[wasm_bindgen(method, js_name = disableVertexAttribArray)]
1238 pub fn disable_vertex_attrib_array(this: &WebGL2RenderingContext, index: u32);
1239
1240 /// The `WebGLRenderingContext method enableVertexAttribArray()`, part of the WebGL API, turns on the generic
1241 /// vertex attribute array at the specified index into the list of attribute arrays.
1242 #[wasm_bindgen(method, js_name = enableVertexAttribArray)]
1243 pub fn enable_vertex_attrib_array(this: &WebGL2RenderingContext, index: u32);
1244
1245 /// The `WebGLRenderingContext.getVertexAttrib()` method of the WebGL API returns information about a vertex
1246 /// attribute at a given position.
1247 /* FIXME: a lot of different return value possibilities
1248 #[wasm_bindgen(method, js_name = getVertexAttrib)]
1249 pub fn get_vertex_attrib(this: &WebGL2RenderingContext, index: u32, pname: );
1250 */
1251
1252 /// The `WebGLRenderingContext.getVertexAttribOffset()` method of the WebGL API returns the address of a
1253 /// specified vertex attribute.
1254 // FIXME: pname can only be gl.VERTEX_ATTRIB_ARRAY_POINTER
1255 #[wasm_bindgen(method, js_name = getVertexAttribOffset)]
1256 pub fn get_vertex_attrib_offset(
1257 this: &WebGL2RenderingContext,
1258 index: u32,
1259 pname: VertexAttrib,
1260 ) -> i64;
1261
1262 /// The WebGLRenderingContext.vertexAttrib[1234]f[v]() methods of the WebGL API specify constant values for generic vertex attributes.
1263 #[wasm_bindgen(method, js_name = vertexAttrib1f)]
1264 pub fn vertex_attrib_1f(this: &WebGL2RenderingContext, index: u32, v0: f32);
1265
1266 /// The WebGLRenderingContext.vertexAttrib[1234]f[v]() methods of the WebGL API specify constant values for generic vertex attributes.
1267 #[wasm_bindgen(method, js_name = vertexAttrib2f)]
1268 pub fn vertex_attrib_2f(this: &WebGL2RenderingContext, index: u32, v0: f32, v1: f32);
1269
1270 /// The WebGLRenderingContext.vertexAttrib[1234]f[v]() methods of the WebGL API specify constant values for generic vertex attributes.
1271 #[wasm_bindgen(method, js_name = vertexAttrib3f)]
1272 pub fn vertex_attrib_3f(this: &WebGL2RenderingContext, index: u32, v0: f32, v1: f32, v2: f32);
1273
1274 /// The WebGLRenderingContext.vertexAttrib[1234]f[v]() methods of the WebGL API specify constant values for generic vertex attributes.
1275 #[wasm_bindgen(method, js_name = vertexAttrib4f)]
1276 pub fn vertex_attrib_4f(
1277 this: &WebGL2RenderingContext,
1278 index: u32,
1279 v0: f32,
1280 v1: f32,
1281 v2: f32,
1282 v3: f32,
1283 );
1284
1285 /// The WebGLRenderingContext.vertexAttrib[1234]f[v]() methods of the WebGL API specify constant values for generic vertex attributes.
1286 #[wasm_bindgen(method, js_name = vertexAttrib1fv)]
1287 pub fn vertex_attrib_1fv(this: &WebGL2RenderingContext, index: u32, value: Vec<f32>);
1288
1289 /// The WebGLRenderingContext.vertexAttrib[1234]f[v]() methods of the WebGL API specify constant values for generic vertex attributes.
1290 #[wasm_bindgen(method, js_name = vertexAttrib2fv)]
1291 pub fn vertex_attrib_2fv(this: &WebGL2RenderingContext, index: u32, value: Vec<f32>);
1292
1293 /// The WebGLRenderingContext.vertexAttrib[1234]f[v]() methods of the WebGL API specify constant values for generic vertex attributes.
1294 #[wasm_bindgen(method, js_name = vertexAttrib3fv)]
1295 pub fn vertex_attrib_3fv(this: &WebGL2RenderingContext, index: u32, value: Vec<f32>);
1296
1297 /// The WebGLRenderingContext.vertexAttrib[1234]f[v]() methods of the WebGL API specify constant values for generic vertex attributes.
1298 #[wasm_bindgen(method, js_name = vertexAttrib4fv)]
1299 pub fn vertex_attrib_4fv(this: &WebGL2RenderingContext, index: u32, value: Vec<f32>);
1300
1301 /// The `WebGLRenderingContext.vertexAttribPointer()` method of the WebGL API binds the buffer currently
1302 /// bound to gl.ARRAY_BUFFER to a generic vertex attribute of the current vertex buffer object and specifies
1303 /// its layout.
1304 #[wasm_bindgen(method, js_name = vertexAttribPointer)]
1305 pub fn vertex_attrib_pointer(
1306 this: &WebGL2RenderingContext,
1307 index: u32,
1308 size: AttributeSize,
1309 attribute_type: AttributeType,
1310 normalized: bool,
1311 stride: u8,
1312 offset: i32,
1313 );
1314
1315 /// The `WebGLRenderingContext.clear()` method of the WebGL API clears buffers to preset values.
1316 ///
1317 /// The preset values can be set by clearColor(), clearDepth() or clearStencil().
1318 ///
1319 /// The scissor box, dithering, and buffer writemasks can affect the clear() method.
1320 #[wasm_bindgen(method)]
1321 pub fn clear(this: &WebGL2RenderingContext, mask: BufferBit);
1322
1323 /// The `WebGLRenderingContext.drawArrays()` method of the WebGL API renders primitives from array data.
1324 #[wasm_bindgen(method, js_name = drawArrays)]
1325 pub fn draw_arrays(this: &WebGL2RenderingContext, mode: Primitives, first: u32, count: u32);
1326
1327 /// The `WebGLRenderingContext.drawElements()` method of the WebGL API renders primitives from array data.
1328 // FIXME: datatype enum has elements that can provoke errors
1329 #[wasm_bindgen(method, js_name = drawElements)]
1330 pub fn draw_elements(
1331 this: &WebGL2RenderingContext,
1332 mode: Primitives,
1333 count: u32,
1334 data_type: DataType,
1335 offset: i64,
1336 );
1337
1338 /// The `WebGLRenderingContext.finish()` method of the WebGL API blocks execution until all previously
1339 /// called commands are finished.
1340 #[wasm_bindgen(method)]
1341 pub fn finish(this: &WebGL2RenderingContext);
1342
1343 /// The `WebGLRenderingContext.flush()` method of the WebGL API empties different buffer commands, causing
1344 /// all commands to be executed as quickly as possible.
1345 #[wasm_bindgen(method)]
1346 pub fn flush(this: &WebGL2RenderingContext);
1347
1348 // WebGL2 methods
1349
1350 //TODO: getIndexedParameter
1351
1352 /// The `WebGL2RenderingContext.copyBufferSubData()` method of the WebGL 2 API copies part of the data of a
1353 /// buffer to another buffer.
1354 #[wasm_bindgen(method, js_name = copyBufferSubData)]
1355 pub fn copy_buffer_sub_data(
1356 this: &WebGL2RenderingContext,
1357 readTarget: BufferKind,
1358 writeTarget: BufferKind,
1359 readOffset: i64,
1360 writeOffset: i64,
1361 size: u32,
1362 );
1363
1364 /// Binding for `WebGL2RenderingContext.getBufferSubData()` when data type is `[u8]`
1365 #[wasm_bindgen(method, js_name = getBufferSubData, catch)]
1366 pub(crate) fn _get_buffer_sub_data_u8(
1367 this: &WebGL2RenderingContext,
1368 target: BufferKind,
1369 src_offset: i64,
1370 dst_data: &mut [u8],
1371 dst_offset: u32,
1372 length: u32,
1373 ) -> Result<(), JsValue>;
1374 /// Binding for `WebGL2RenderingContext.getBufferSubData()` when data type is `[i8]`
1375 #[wasm_bindgen(method, js_name = getBufferSubData, catch)]
1376 pub(crate) fn _get_buffer_sub_data_i8(
1377 this: &WebGL2RenderingContext,
1378 target: BufferKind,
1379 src_offset: i64,
1380 dst_data: &mut [i8],
1381 dst_offset: u32,
1382 length: u32,
1383 ) -> Result<(), JsValue>;
1384 /// Binding for `WebGL2RenderingContext.getBufferSubData()` when data type is `[u16]`
1385 #[wasm_bindgen(method, js_name = getBufferSubData, catch)]
1386 pub(crate) fn _get_buffer_sub_data_u16(
1387 this: &WebGL2RenderingContext,
1388 target: BufferKind,
1389 src_offset: i64,
1390 dst_data: &mut [u16],
1391 dst_offset: u32,
1392 length: u32,
1393 ) -> Result<(), JsValue>;
1394 /// Binding for `WebGL2RenderingContext.getBufferSubData()` when data type is `[i16]`
1395 #[wasm_bindgen(method, js_name = getBufferSubData, catch)]
1396 pub(crate) fn _get_buffer_sub_data_i16(
1397 this: &WebGL2RenderingContext,
1398 target: BufferKind,
1399 src_offset: i64,
1400 dst_data: &mut [i16],
1401 dst_offset: u32,
1402 length: u32,
1403 ) -> Result<(), JsValue>;
1404 /// Binding for `WebGL2RenderingContext.getBufferSubData()` when data type is `[u32]`
1405 #[wasm_bindgen(method, js_name = getBufferSubData, catch)]
1406 pub(crate) fn _get_buffer_sub_data_u32(
1407 this: &WebGL2RenderingContext,
1408 target: BufferKind,
1409 src_offset: i64,
1410 dst_data: &mut [u32],
1411 dst_offset: u32,
1412 length: u32,
1413 ) -> Result<(), JsValue>;
1414 /// Binding for `WebGL2RenderingContext.getBufferSubData()` when data type is `[i32]`
1415 #[wasm_bindgen(method, js_name = getBufferSubData, catch)]
1416 pub(crate) fn _get_buffer_sub_data_i32(
1417 this: &WebGL2RenderingContext,
1418 target: BufferKind,
1419 src_offset: i64,
1420 dst_data: &mut [i32],
1421 dst_offset: u32,
1422 length: u32,
1423 ) -> Result<(), JsValue>;
1424 /// Binding for `WebGL2RenderingContext.getBufferSubData()` when data type is `[f32]`
1425 #[wasm_bindgen(method, js_name = getBufferSubData, catch)]
1426 pub(crate) fn _get_buffer_sub_data_f32(
1427 this: &WebGL2RenderingContext,
1428 target: BufferKind,
1429 src_offset: i64,
1430 dst_data: &mut [f32],
1431 dst_offset: u32,
1432 length: u32,
1433 ) -> Result<(), JsValue>;
1434 /// Binding for `WebGL2RenderingContext.getBufferSubData()` when data type is `[f64]`
1435 #[wasm_bindgen(method, js_name = getBufferSubData, catch)]
1436 pub(crate) fn _get_buffer_sub_data_f64(
1437 this: &WebGL2RenderingContext,
1438 target: BufferKind,
1439 src_offset: i64,
1440 dst_data: &mut [f64],
1441 dst_offset: u32,
1442 length: u32,
1443 ) -> Result<(), JsValue>;
1444
1445 /// The `WebGL2RenderingContext.blitFramebuffer()` method of the WebGL 2 API transfers a block of pixels from the
1446 /// read framebuffer to the draw framebuffer.
1447 #[wasm_bindgen(method, js_name = blitFramebuffer)]
1448 pub fn blit_framebuffer(
1449 this: &WebGL2RenderingContext,
1450 srcX0: i32,
1451 srcY0: i32,
1452 srcX1: i32,
1453 srcY1: i32,
1454 dstX0: i32,
1455 dstY0: i32,
1456 dstX1: i32,
1457 dstY1: i32,
1458 mask: BufferBit,
1459 filter: TextureMagFilter,
1460 );
1461
1462 /// The `WebGL2RenderingContext.invalidateFramebuffer()` method of the WebGL 2 API invalidates the contents
1463 /// of attachments in a framebuffer.
1464 /* FIXME: currently not supported by wasm_bindgen
1465 #[wasm_bindgen(method, js_name = invalidateFramebuffer)]
1466 pub fn invalidate_framebuffer(
1467 this: &WebGL2RenderingContext,
1468 target: FramebufferKind,
1469 attachments: &[Attachment],
1470 );*/
1471
1472 //FIXME: invalidateSubFramebuffer same issue as invalidateFramebuffer
1473
1474 /// The `WebGL2RenderingContext.readBuffer()` method of the WebGL 2 API selects a color buffer as the source
1475 /// for pixels for subsequent calls to copyTexImage2D, copyTexSubImage2D, copyTexSubImage3D or readPixels.
1476 #[wasm_bindgen(method, js_name = readBuffer)]
1477 pub fn read_buffer(this: &WebGL2RenderingContext, src: ColorBuffer);
1478
1479 /// The `WebGL2RenderingContext.getInternalformatParameter()` method of the WebGL 2 API returns information
1480 /// about implementation-dependent support for internal formats.
1481 /// FIXME: not sure about internal_format enum
1482 #[wasm_bindgen(method, js_name = getInternalformatParameter)]
1483 pub fn get_internal_format_parameter(
1484 this: &WebGL2RenderingContext,
1485 target: RenderbufferKind,
1486 internal_format: RenderbufferFormat,
1487 pname: InformationType,
1488 ) -> Vec<i32>;
1489
1490 /// The `WebGL2RenderingContext.renderbufferStorageMultisample()` method of the WebGL 2 API returns creates
1491 /// and initializes a renderbuffer object's data store and allows specifying a number of samples to be used.
1492 #[wasm_bindgen(method, js_name = renderbufferStorageMultisample)]
1493 pub fn renderbuffer_storage_multisample(
1494 this: &WebGL2RenderingContext,
1495 target: RenderbufferKind,
1496 samples: u32,
1497 internal_format: RenderbufferFormat,
1498 width: u32,
1499 height: u32,
1500 );
1501
1502 /// The `WebGL2RenderingContext.texStorage2D()` method of the WebGL API specifies all levels of two-dimensional
1503 /// texture storage.
1504 /// FIXME: revisit internal format
1505 #[wasm_bindgen(method, js_name = texStorage2D)]
1506 pub fn tex_storage_2d(
1507 this: &WebGL2RenderingContext,
1508 target: Texture2DKind,
1509 levels: u32,
1510 internal_format: RenderbufferFormat,
1511 width: u32,
1512 height: u32,
1513 );
1514
1515 /// The `WebGL2RenderingContext.texStorage3D()` method of the WebGL API specifies all levels of a three-dimensional
1516 /// texture or two-dimensional array texture.
1517 /// FIXME: revisit internal format
1518 #[wasm_bindgen(method, js_name = texStorage3D)]
1519 pub fn tex_storage_3d(
1520 this: &WebGL2RenderingContext,
1521 target: Texture3DKind,
1522 levels: u32,
1523 internalformat: RenderbufferFormat,
1524 width: u32,
1525 height: u32,
1526 depth: u32,
1527 );
1528
1529 /// The `WebGLRenderingContext.texImage3D()` method of the WebGL API specifies a three-dimensional texture image.
1530 /// FIXME: revisit internalformat, format, data_type
1531 /// FIXME: border is always 0
1532 /// FIXME: different src types
1533 #[wasm_bindgen(method, js_name = texImage3D)]
1534 pub fn tex_image_3d(
1535 this: &WebGL2RenderingContext,
1536 target: Texture3DKind,
1537 level: u32,
1538 internalformat: RenderbufferFormat,
1539 width: u32,
1540 height: u32,
1541 depth: u32,
1542 border: u32,
1543 format: RenderbufferFormat,
1544 data_type: RenderbufferFormat,
1545 srcData: Vec<u8>,
1546 srcOffset: u32,
1547 );
1548
1549 /// The `WebGL2RenderingContext.texSubImage3D()` method of the WebGL API specifies a sub-rectangle of the current texture.
1550 /// FIXME: revisit format, data_type
1551 /// FIXME: srcdata more types
1552 #[wasm_bindgen(method, js_name = texSubImage3D)]
1553 pub fn tex_sub_image_3d(
1554 this: &WebGL2RenderingContext,
1555 target: Texture3DKind,
1556 level: u32,
1557 xoffset: u32,
1558 yoffset: u32,
1559 zoffset: u32,
1560 width: u32,
1561 height: u32,
1562 depth: u32,
1563 format: RenderbufferFormat,
1564 data_type: RenderbufferFormat,
1565 srcData: Vec<u8>,
1566 srcOffset: u32,
1567 );
1568
1569 /// The `WebGL2RenderingContext.copyTexSubImage3D()` method of the WebGL API copies pixels from the current WebGLFramebuffer
1570 /// into an existing 3D texture sub-image.
1571 #[wasm_bindgen(method, js_name = copyTexSubImage3D)]
1572 pub fn copy_tex_sub_image_3d(
1573 this: &WebGL2RenderingContext,
1574 target: Texture3DKind,
1575 level: u32,
1576 xoffset: u32,
1577 yoffset: u32,
1578 zoffset: u32,
1579 x: u32,
1580 y: u32,
1581 width: u32,
1582 height: u32,
1583 );
1584
1585 /// The `WebGL2RenderingContext.vertexAttribI4[u]i[v]()` methods of the WebGL 2 API specify integer values for
1586 /// generic vertex attributes.
1587 #[wasm_bindgen(method, js_name = vertexAttribI4i)]
1588 pub fn vertex_attrib_i_4i(
1589 this: &WebGL2RenderingContext,
1590 index: u32,
1591 v0: i32,
1592 v1: i32,
1593 v2: i32,
1594 v3: i32,
1595 );
1596
1597 /// The `WebGL2RenderingContext.vertexAttribI4[u]i[v]()` methods of the WebGL 2 API specify integer values for
1598 /// generic vertex attributes.
1599 #[wasm_bindgen(method, js_name = vertexAttribI4ui)]
1600 pub fn vertex_attrib_i_4ui(
1601 this: &WebGL2RenderingContext,
1602 index: u32,
1603 v0: u32,
1604 v1: u32,
1605 v2: u32,
1606 v3: u32,
1607 );
1608
1609 /// The `WebGL2RenderingContext.vertexAttribI4[u]i[v]()` methods of the WebGL 2 API specify integer values for
1610 /// generic vertex attributes.
1611 #[wasm_bindgen(method, js_name = vertexAttribI4iv)]
1612 pub fn vertex_attrib_i_4iv(this: &WebGL2RenderingContext, index: u32, value: Vec<i32>);
1613
1614 /// The `WebGL2RenderingContext.vertexAttribI4[u]i[v]()` methods of the WebGL 2 API specify integer values for
1615 /// generic vertex attributes.
1616 #[wasm_bindgen(method, js_name = vertexAttribI4uiv)]
1617 pub fn vertex_attrib_i_4uiv(this: &WebGL2RenderingContext, index: u32, value: Vec<u32>);
1618
1619 /// The `WebGL2RenderingContext.vertexAttribIPointer()` method of the WebGL 2 API specifies integer data formats
1620 /// and locations of vertex attributes in a vertex attributes array.
1621 /// FIXME: revisit data_type
1622 #[wasm_bindgen(method, js_name = vertexAttribIPointer)]
1623 pub fn vertex_attrib_i_pointer(
1624 this: &WebGL2RenderingContext,
1625 index: u32,
1626 size: AttributeSize,
1627 data_type: AttributeType,
1628 stride: u32,
1629 offset: i64,
1630 );
1631
1632 /// The `WebGL2RenderingContext.vertexAttribDivisor()` method of the WebGL 2 API modifies the rate at which generic
1633 /// vertex attributes advance when rendering multiple instances of primitives with gl.drawArraysInstanced() and gl.drawElementsInstanced().
1634 #[wasm_bindgen(method, js_name = vertexAttribDivisor)]
1635 pub fn vertex_attrib_divisor(this: &WebGL2RenderingContext, index: u32, divisor: u32);
1636
1637 /// The `WebGL2RenderingContext.drawArraysInstanced()` method of the WebGL 2 API renders primitives from array data like the gl.drawArrays()
1638 /// method. In addition, it can execute multiple instances of the range of elements.
1639 #[wasm_bindgen(method, js_name = drawArraysInstanced)]
1640 pub fn draw_arrays_instanced(
1641 this: &WebGL2RenderingContext,
1642 mode: Primitives,
1643 first: i32,
1644 count: u32,
1645 instanceCount: u32,
1646 );
1647
1648 /// The `WebGL2RenderingContext.drawElementsInstanced()` method of the WebGL 2 API renders primitives from array data like the gl.drawElements()
1649 /// method. In addition, it can execute multiple instances of a set of elements.
1650 /// FIXME: revisit data_type
1651 #[wasm_bindgen(method, js_name = drawElementsInstanced)]
1652 pub fn draw_elements_instanced(
1653 this: &WebGL2RenderingContext,
1654 mode: Primitives,
1655 count: u32,
1656 data_type: AttributeType,
1657 offset: i64,
1658 instanceCount: u32,
1659 );
1660
1661 /// The `WebGL2RenderingContext.drawRangeElements()` method of the WebGL API renders primitives from array data in a given range.
1662 /// FIXME: revisit data_type
1663 #[wasm_bindgen(method, js_name = drawRangeElements)]
1664 pub fn draw_range_elements(
1665 this: &WebGL2RenderingContext,
1666 mode: Primitives,
1667 start: u32,
1668 end: u32,
1669 count: u32,
1670 data_type: AttributeType,
1671 offset: i64,
1672 );
1673
1674 /// The `WebGL2RenderingContext.drawBuffers()` method of the WebGL 2 API defines draw buffers to which fragment
1675 /// colors are written into. The draw buffer settings are part of the state of the currently bound framebuffer
1676 /// or the drawingbuffer if no framebuffer is bound.
1677 /* FIXME: currently wasm_bindgen doesn not support Vec<T>
1678 #[wasm_bindgen(method, js_name = drawBuffers)]
1679 pub fn draw_buffers(this: &WebGL2RenderingContext, buffers: Vec<ColorBuffer>);
1680 */
1681
1682 /// The `WebGL2RenderingContext.clearBuffer[fiuv]()` methods of the WebGL 2 API clear buffers from the currently
1683 /// bound framebuffer.
1684 /// FIXME values is array of rgba
1685 #[wasm_bindgen(method, js_name = clearBufferfv)]
1686 pub fn clear_buffer_fv(
1687 this: &WebGL2RenderingContext,
1688 buffer: BufferBit,
1689 drawbuffer: i32,
1690 values: Vec<u8>,
1691 srcOffset: u32,
1692 );
1693
1694 /// The `WebGL2RenderingContext.clearBuffer[fiuv]()` methods of the WebGL 2 API clear buffers from the currently
1695 /// bound framebuffer.
1696 /// FIXME values is array of rgba
1697 #[wasm_bindgen(method, js_name = clearBufferiv)]
1698 pub fn clear_buffer_iv(
1699 this: &WebGL2RenderingContext,
1700 buffer: BufferBit,
1701 drawbuffer: i32,
1702 values: Vec<u8>,
1703 srcOffset: u32,
1704 );
1705
1706 /// The `WebGL2RenderingContext.clearBuffer[fiuv]()` methods of the WebGL 2 API clear buffers from the currently
1707 /// bound framebuffer.
1708 /// FIXME values is array of rgba
1709 #[wasm_bindgen(method, js_name = clearBufferuiv)]
1710 pub fn clear_buffer_uiv(
1711 this: &WebGL2RenderingContext,
1712 buffer: BufferBit,
1713 drawbuffer: i32,
1714 values: Vec<u8>,
1715 srcOffset: u32,
1716 );
1717
1718 /// The `WebGL2RenderingContext.clearBuffer[fiuv]()` methods of the WebGL 2 API clear buffers from the currently
1719 /// bound framebuffer.
1720 /// FIXME buffer can only be DEPTH_STENCIL
1721 #[wasm_bindgen(method, js_name = clearBufferfv)]
1722 pub fn clear_buffer_fi(
1723 this: &WebGL2RenderingContext,
1724 buffer: BufferBit,
1725 drawbuffer: i32,
1726 depth: f32,
1727 stencil: i32,
1728 );
1729
1730 /// The WebGL2RenderingContext.beginTransformFeedback() method of the WebGL 2 API starts a transform feedback operation.
1731 #[wasm_bindgen(method, js_name = beginTransformFeedback)]
1732 pub fn begin_transform_feedback(
1733 this: &WebGL2RenderingContext,
1734 primitive_mode: TransformFeedbackMode,
1735 );
1736
1737 /// The WebGL2RenderingContext.endTransformFeedback() method of the WebGL 2 API ends a transform feedback operation.
1738 #[wasm_bindgen(method, js_name = endTransformFeedback)]
1739 pub fn end_transform_feedback(this: &WebGL2RenderingContext);
1740
1741 /// The `WebGL2RenderingContext.transformFeedbackVaryings()` method of the WebGL 2 API specifies values to record in
1742 /// WebGLTransformFeedback buffers.
1743 /* FIXME: Vec of string currently not supported by wasm_bindgen
1744 #[wasm_bindgen(method, js_name = transformFeedbackVaryings)]
1745 pub fn transform_feedback_varyings(
1746 this: &WebGL2RenderingContext,
1747 program: WebGLProgram,
1748 varyings: Vec<String>,
1749 buffer_mode: TransformFeedbackBufferMode,
1750 );*/
1751
1752 /// The WebGL2RenderingContext.pauseTransformFeedback() method of the WebGL 2 API pauses a transform feedback operation.
1753 #[wasm_bindgen(method, js_name = pauseTransformFeedback)]
1754 pub fn pause_transform_feedback(this: &WebGL2RenderingContext);
1755
1756 /// The WebGL2RenderingContext.resumeTransformFeedback() method of the WebGL 2 API resumes a transform feedback operation.
1757 #[wasm_bindgen(method, js_name = resumeTransformFeedback)]
1758 pub fn resume_transform_feedback(this: &WebGL2RenderingContext);
1759
1760 /// The `WebGL2RenderingContext.endQuery()` method of the WebGL 2 API marks the end of a given
1761 /// query target.
1762 #[wasm_bindgen(method, js_name = endQuery)]
1763 pub fn end_query(this: &WebGL2RenderingContext, target: QueryTarget);
1764
1765// The `WebGL2RenderingContext.getUniformIndices()` method of the WebGL 2 API retrieves the indices of a number of uniforms
1766 // within a WebGLProgram.
1767 /* FIXME: vec<string> not yet supported
1768 #[wasm_bindgen(method, js_name = getUniformIndices)]
1769 pub fn get_uniform_indices(this: &WebGL2RenderingContext, program: WebGLProgram, uniformNames: Vec<String>);
1770 */
1771
1772// TODO getActiveUniforms
1773
1774// TODO getAcitveUniformBlockParameter
1775
1776// Binding for `WebGLRenderingContext.compressedTexImage2D` when data type is `[u8]`
1777 /* FIXME save for later
1778 #[wasm_bindgen(method, js_name = compressedTexImage2D, catch)]
1779 pub(crate) fn _compressed_tex_image_2d_u8(
1780 this: &WebGL2RenderingContext,
1781 target: TextureBindPoint,
1782 level: u32,
1783 internalformat: CompressedFormat,
1784 width: u32,
1785 height: u32,
1786 border: u32,
1787 pixels: &[u8],
1788 ) -> Result<(), JsValue>;
1789*/
1790}
1791
1792// WebGLContextAttributes
1793/* FIXME: not found when exported
1794#[wasm_bindgen]
1795#[derive(Clone, Copy)]
1796extern "C" {
1797 pub type WebGLContextAttributes;
1798 #[wasm_bindgen(method, getter)]
1799 pub fn alpha(this: &WebGLContextAttributes) -> bool;
1800 #[wasm_bindgen(method, getter)]
1801 pub fn antialias(this: &WebGLContextAttributes) -> bool;
1802 #[wasm_bindgen(method, getter)]
1803 pub fn depth(this: &WebGLContextAttributes) -> bool;
1804 #[wasm_bindgen(method, getter = premultipliedAlpha)]
1805 pub fn premultiplied_alpha(this: &WebGLContextAttributes) -> bool;
1806 #[wasm_bindgen(method, getter = preserveDrawingBuffer)]
1807 pub fn preserve_drawing_buffer(this: &WebGLContextAttributes) -> bool;
1808 #[wasm_bindgen(method, getter)]
1809 pub fn stencil(this: &WebGLContextAttributes) -> bool;
1810 #[wasm_bindgen(method, getter = failIfMajorPerformanceCaveat )]
1811 pub fn fail_if_major_performance_caveat(this: &WebGLContextAttributes) -> bool;
1812 #[wasm_bindgen(method, getter = powerPreference)]
1813 pub fn power_preference(this: &WebGLContextAttributes) -> String;
1814}
1815*/
1816
1817/// WebGLShaderPrecisionFormat;
1818#[wasm_bindgen]
1819#[derive(Clone, Copy)]
1820extern "C" {
1821 pub type WebGLShaderPrecisionFormat;
1822
1823 /// The base 2 log of the absolute value of the minimum value that can be represented.
1824 #[wasm_bindgen(method, getter = rangeMin)]
1825 pub fn range_min(this: &WebGLShaderPrecisionFormat) -> u32;
1826
1827 /// The base 2 log of the absolute value of the maximum value that can be represented.
1828 #[wasm_bindgen(method, getter = rangeMax)]
1829 pub fn range_max(this: &WebGLShaderPrecisionFormat) -> u32;
1830
1831 /// The number of bits of precision that can be represented. For integer formats this value is always 0.
1832 #[wasm_bindgen(method, getter)]
1833 pub fn precision(this: &WebGLShaderPrecisionFormat) -> u32;
1834}