mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
opengl: Add Resume() and Pause()
This commit is contained in:
parent
a96a00b545
commit
f03a99e89a
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user