From f7fa4ed8f9bee95cfa919d0a86af5b9df4ff6977 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 5 Nov 2018 00:44:27 +0900 Subject: [PATCH] opengl: Refactoring --- internal/opengl/context.go | 2 +- internal/opengl/context_desktop.go | 4 ---- internal/opengl/context_js.go | 4 ---- internal/opengl/context_mobile.go | 8 ++------ 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/internal/opengl/context.go b/internal/opengl/context.go index 6a749edc1..91a7bb6dd 100644 --- a/internal/opengl/context.go +++ b/internal/opengl/context.go @@ -74,7 +74,7 @@ type Context struct { context } -var theContext *Context +var theContext = &Context{} func GetContext() *Context { return theContext diff --git a/internal/opengl/context_desktop.go b/internal/opengl/context_desktop.go index 4d6909c50..764208b50 100644 --- a/internal/opengl/context_desktop.go +++ b/internal/opengl/context_desktop.go @@ -78,10 +78,6 @@ type context struct { init bool } -func init() { - theContext = &Context{} -} - func (c *Context) reset() error { if err := mainthread.Run(func() error { if c.init { diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index be843a696..6794ddfb8 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -119,10 +119,6 @@ type context struct { lastProgramID programID } -func init() { - theContext = &Context{} -} - func (c *Context) ensureGL() { if c.gl != (js.Value{}) { return diff --git a/internal/opengl/context_mobile.go b/internal/opengl/context_mobile.go index f539dc888..88d1a0c9d 100644 --- a/internal/opengl/context_mobile.go +++ b/internal/opengl/context_mobile.go @@ -76,15 +76,11 @@ type context struct { } func Init() { - c := &Context{} - c.gl, c.worker = mgl.NewContext() - theContext = c + theContext.gl, theContext.worker = mgl.NewContext() } func InitWithContext(context mgl.Context) { - c := &Context{} - c.gl = context - theContext = c + theContext.gl = context } func (c *Context) DoWork(chError <-chan error, chDone <-chan struct{}) error {