mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 20:41:24 +00:00
Merge pull request #835 from blm768/webgl-example
Create basic WebGL example
This commit is contained in:
@ -62,6 +62,7 @@
|
||||
- [The `fetch` API](./web-sys/examples/fetch.md)
|
||||
- [2D Canvas](./web-sys/examples/2d-canvas.md)
|
||||
- [WebAudio](./web-sys/examples/web-audio.md)
|
||||
- [WebGL](./web-sys/examples/webgl.md)
|
||||
- [A Simple Paint Program](./web-sys/examples/paint.md)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
25
guide/src/web-sys/examples/webgl.md
Normal file
25
guide/src/web-sys/examples/webgl.md
Normal file
@ -0,0 +1,25 @@
|
||||
# 2D Canvas
|
||||
|
||||
This example draws a triangle to the screen using the WebGL API.
|
||||
|
||||
[See the full source at
|
||||
`wasm-bindgen/examples/webgl`.](https://github.com/rustwasm/wasm-bindgen/tree/master/examples/webgl)
|
||||
|
||||
## `Cargo.toml`
|
||||
|
||||
The `Cargo.toml` enables features necessary to obtain and use a WebGL
|
||||
rendering context.
|
||||
|
||||
```toml
|
||||
{{#include ../../../../examples/webgl/Cargo.toml}}
|
||||
```
|
||||
|
||||
## `src/lib.rs`
|
||||
|
||||
This source file handles all of the necessary logic to obtain a rendering
|
||||
context, compile shaders, fill a buffer with vertex coordinates, and draw a
|
||||
triangle to the screen.
|
||||
|
||||
```rust
|
||||
{{#include ../../../../examples/webgl/src/lib.rs}}
|
||||
```
|
Reference in New Issue
Block a user