We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 15b811c commit 0559249Copy full SHA for 0559249
1 file changed
wgpu/instance_js.go
@@ -41,12 +41,19 @@ func (g Instance) EnumerateAdapters(options *InstanceEnumerateAdapterOptons) []*
41
return []*Adapter{a}
42
}
43
44
+// SurfaceDescriptor must contain a valid HTML canvas element on web.
45
type SurfaceDescriptor struct {
46
+ // Canvas must be specified.
47
+ Canvas js.Value
48
+
49
Label string
50
51
52
func (g Instance) CreateSurface(descriptor *SurfaceDescriptor) *Surface {
- jsContext := js.Global().Get("document").Call("querySelector", "canvas").Call("getContext", "webgpu")
53
+ if descriptor.Canvas.IsUndefined() {
54
+ panic("wgpu.Instance.CreateSurface: descriptor.Canvas must be specified")
55
+ }
56
+ jsContext := descriptor.Canvas.Call("getContext", "webgpu")
57
return &Surface{jsContext}
58
59
0 commit comments