Debian Codegraph @

.cargo/vendor/wasm-bindgen/guide/src/examples/webgl.md

raw
1 # WebGL Example
2
3 [View full source code][code] or [view the compiled example online][online]
4
5 [online]: https://rustwasm.github.io/wasm-bindgen/exbuild/webgl/
6 [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/webgl
7
8 This example draws a triangle to the screen using the WebGL API.
9
10 ## `Cargo.toml`
11
12 The `Cargo.toml` enables features necessary to obtain and use a WebGL
13 rendering context.
14
15 ```toml
16 {{#include ../../../examples/webgl/Cargo.toml}}
17 ```
18
19 ## `src/lib.rs`
20
21 This source file handles all of the necessary logic to obtain a rendering
22 context, compile shaders, fill a buffer with vertex coordinates, and draw a
23 triangle to the screen.
24
25 ```rust
26 {{#include ../../../examples/webgl/src/lib.rs}}
27 ```