opengl: Add Resume() and Pause()

This commit is contained in:
Hajime Hoshi 2016-06-10 01:19:10 +09:00
parent a96a00b545
commit f03a99e89a
4 changed files with 42 additions and 0 deletions

View File

@ -96,10 +96,12 @@ func (c *graphicsContext) Pause() error {
if err := graphics.Finalize(ui.GLContext()); err != nil {
return err
}
ui.GLContext().Pause()
return nil
}
func (c *graphicsContext) Resume() error {
ui.GLContext().Resume()
if !c.imageTasksDone {
return nil
}

View File

@ -104,6 +104,19 @@ func (c *Context) Init() error {
return nil
}
func (c *Context) Pause() {
c.locationCache = newLocationCache()
c.lastFramebuffer = ZeroFramebuffer
c.lastViewportWidth = 0
c.lastViewportHeight = 0
c.lastCompositeMode = CompositeModeUnknown
}
func (c *Context) Resume() {
gl.Enable(gl.BLEND)
c.BlendFunc(CompositeModeSourceOver)
}
func (c *Context) BlendFunc(mode CompositeMode) {
c.RunOnContextThread(func() error {
if c.lastCompositeMode == mode {

View File

@ -118,6 +118,20 @@ func (c *Context) init() {
c.BlendFunc(CompositeModeSourceOver)
}
func (c *Context) Pause() {
c.locationCache = newLocationCache()
c.lastFramebuffer = ZeroFramebuffer
c.lastViewportWidth = 0
c.lastViewportHeight = 0
c.lastCompositeMode = CompositeModeUnknown
}
func (c *Context) Resume() {
gl := c.gl
gl.Enable(gl.BLEND)
c.BlendFunc(CompositeModeSourceOver)
}
func (c *Context) BlendFunc(mode CompositeMode) {
if c.lastCompositeMode == mode {
return

View File

@ -80,6 +80,19 @@ func NewContext() (*Context, error) {
return c, nil
}
func (c *Context) Pause() {
c.locationCache = newLocationCache()
c.lastFramebuffer = ZeroFramebuffer
c.lastViewportWidth = 0
c.lastViewportHeight = 0
c.lastCompositeMode = CompositeModeUnknown
}
func (c *Context) Resume() {
c.gl.Enable(mgl.BLEND)
c.BlendFunc(CompositeModeSourceOver)
}
func (c *Context) WaitUntilInitializingDone() {
// TODO: Call this function at an approriate place
<-c.initialized