Create basic WebGL example

This commit is contained in:
Ben Merritt
2018-09-15 23:28:15 -07:00
parent 285c734a6a
commit 426671d83c
12 changed files with 247 additions and 0 deletions

View File

@ -61,6 +61,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)
--------------------------------------------------------------------------------

View 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}}
```