diff --git a/internal/graphics/opengl/context_desktop.go b/internal/graphics/opengl/context_desktop.go index b235f9955..9d1c557c2 100644 --- a/internal/graphics/opengl/context_desktop.go +++ b/internal/graphics/opengl/context_desktop.go @@ -65,13 +65,11 @@ func init() { type context struct { funcs chan func() + init bool } func NewContext() (*Context, error) { - c := &Context{ - locationCache: newLocationCache(), - lastCompositeMode: CompositeModeUnknown, - } + c := &Context{} c.funcs = make(chan func()) return c, nil } @@ -93,33 +91,20 @@ func (c *Context) RunOnContextThread(f func() error) error { return err } -func (c *Context) Init() error { +func (c *Context) Reset() error { if err := c.RunOnContextThread(func() error { - // This initialization must be done after Loop is called. - // This is why Init is separated from NewContext. - + if c.init { + return nil + } + // Note that this initialization must be done after Loop is called. if err := gl.Init(); err != nil { return fmt.Errorf("opengl: initializing error %v", err) } - // Textures' pixel formats are alpha premultiplied. - gl.Enable(gl.BLEND) + c.init = true return nil }); err != nil { - return err - } - c.BlendFunc(CompositeModeSourceOver) - if err := c.RunOnContextThread(func() error { - f := int32(0) - gl.GetIntegerv(gl.FRAMEBUFFER_BINDING, &f) - c.screenFramebuffer = Framebuffer(f) return nil - }); err != nil { - return err } - return nil -} - -func (c *Context) Reset() error { c.locationCache = newLocationCache() c.lastFramebuffer = invalidFramebuffer c.lastViewportWidth = 0 diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index f6d38eea1..95a2c5b56 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -85,9 +85,6 @@ func initialize() (*opengl.Context, error) { if err := <-ch; err != nil { return nil, err } - if err := u.context.Init(); err != nil { - return nil, err - } return u.context, nil }