Skip to content

Commit 151b7af

Browse files
committed
examples/triangle: update to new self-made canvas structure
1 parent 0559249 commit 151b7af

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

examples/triangle/js.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,17 @@ func (w window) GetSize() (int, int) {
1717
}
1818

1919
func main() {
20-
s, err := InitState(&window{}, &wgpu.SurfaceDescriptor{})
20+
document := js.Global().Get("document")
21+
canvas := document.Call("createElement", "canvas")
22+
document.Get("body").Call("appendChild", canvas)
23+
24+
w := &window{}
25+
width, height := w.GetSize()
26+
canvas.Set("width", width)
27+
canvas.Set("height", height)
28+
canvas.Set("style", "width:100vw; height:100vh")
29+
30+
s, err := InitState(w, &wgpu.SurfaceDescriptor{Canvas: canvas})
2131
if err != nil {
2232
panic(err)
2333
}

0 commit comments

Comments
 (0)