Debian Codegraph @

shiny/driver/gldriver/context.go

raw symbols SCIP
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build !android
6
7 package gldriver
8
9 import (
10 "runtime"
11
12 "golang.org/x/mobile/gl"
13 )
14
15 // NewContext creates an OpenGL ES context with a dedicated processing thread.
16 func NewContext() (gl.Context, error) {
17 glctx, worker := gl.NewContext()
18
19 errCh := make(chan error)
20 workAvailable := worker.WorkAvailable()
21 go func() {
22 runtime.LockOSThread()
23 err := surfaceCreate()
24 errCh <- err
25 if err != nil {
26 return
27 }
28
29 for range workAvailable {
30 worker.DoWork()
31 }
32 }()
33 if err := <-errCh; err != nil {
34 return nil, err
35 }
36 return glctx, nil
37 }