File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,19 @@ func (g Instance) EnumerateAdapters(options *InstanceEnumerateAdapterOptons) []*
4141 return []* Adapter {a }
4242}
4343
44+ // SurfaceDescriptor must contain a valid HTML canvas element on web.
4445type SurfaceDescriptor struct {
46+ // Canvas must be specified.
47+ Canvas js.Value
48+
4549 Label string
4650}
4751
4852func (g Instance ) CreateSurface (descriptor * SurfaceDescriptor ) * Surface {
49- 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" )
5057 return & Surface {jsContext }
5158}
5259
You can’t perform that action at this time.
0 commit comments