graphicsdriver/opengl: Bug fix: compile error on browsers and mobiles

This commit is contained in:
Hajime Hoshi 2018-11-11 04:48:30 +09:00
parent 734aeabc8d
commit aff77d98e4
4 changed files with 17 additions and 13 deletions

View File

@ -75,14 +75,6 @@ type contextImpl struct {
worker mgl.Worker
}
func Init() {
theContext.gl, theContext.worker = mgl.NewContext()
}
func InitWithContext(context mgl.Context) {
theContext.gl = context
}
func (c *context) doWork(chError <-chan error, chDone <-chan struct{}) error {
if c.worker == nil {
panic("not reached")

View File

@ -17,9 +17,9 @@
package opengl
func (d *Driver) IsContextLost() bool {
return theContext.isContextLost()
return d.context.isContextLost()
}
func (d *Driver) RestoreContext() {
theContext.restoreContext()
d.context.restoreContext()
}

View File

@ -16,6 +16,18 @@
package opengl
import (
"golang.org/x/mobile/gl"
)
func (d *Driver) DoWork(chError <-chan error, chDone <-chan struct{}) error {
return theContext.doWork(chError, chDone)
return d.context.doWork(chError, chDone)
}
func (d *Driver) Init() {
d.context.gl, d.context.worker = gl.NewContext()
}
func (d *Driver) InitWithContext(context gl.Context) {
d.context.gl = context
}

View File

@ -152,9 +152,9 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main
if mainloop {
ctx := <-glContextCh
opengl.InitWithContext(ctx)
opengl.GetDriver().InitWithContext(ctx)
} else {
opengl.Init()
opengl.GetDriver().Init()
}
// Force to set the screen size