opengl: Remove init (desktops)

This commit is contained in:
Hajime Hoshi 2016-07-04 00:47:56 +09:00
parent c2d21bc39f
commit 0d91883fb9
2 changed files with 8 additions and 26 deletions

View File

@ -65,13 +65,11 @@ func init() {
type context struct { type context struct {
funcs chan func() funcs chan func()
init bool
} }
func NewContext() (*Context, error) { func NewContext() (*Context, error) {
c := &Context{ c := &Context{}
locationCache: newLocationCache(),
lastCompositeMode: CompositeModeUnknown,
}
c.funcs = make(chan func()) c.funcs = make(chan func())
return c, nil return c, nil
} }
@ -93,33 +91,20 @@ func (c *Context) RunOnContextThread(f func() error) error {
return err return err
} }
func (c *Context) Init() error { func (c *Context) Reset() error {
if err := c.RunOnContextThread(func() error { if err := c.RunOnContextThread(func() error {
// This initialization must be done after Loop is called. if c.init {
// This is why Init is separated from NewContext. return nil
}
// Note that this initialization must be done after Loop is called.
if err := gl.Init(); err != nil { if err := gl.Init(); err != nil {
return fmt.Errorf("opengl: initializing error %v", err) return fmt.Errorf("opengl: initializing error %v", err)
} }
// Textures' pixel formats are alpha premultiplied. c.init = true
gl.Enable(gl.BLEND)
return nil return nil
}); err != 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 return nil
}); err != nil {
return err
} }
return nil
}
func (c *Context) Reset() error {
c.locationCache = newLocationCache() c.locationCache = newLocationCache()
c.lastFramebuffer = invalidFramebuffer c.lastFramebuffer = invalidFramebuffer
c.lastViewportWidth = 0 c.lastViewportWidth = 0

View File

@ -85,9 +85,6 @@ func initialize() (*opengl.Context, error) {
if err := <-ch; err != nil { if err := <-ch; err != nil {
return nil, err return nil, err
} }
if err := u.context.Init(); err != nil {
return nil, err
}
return u.context, nil return u.context, nil
} }