mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
ebiten: Bug fix: Set the state of being volatile on SetClearingScreenSkipped
Fixes #1309
This commit is contained in:
parent
8aef1f9080
commit
7ec63acd1d
@ -93,6 +93,10 @@ func (g *Game) Update(screen *ebiten.Image) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyS) {
|
||||
ebiten.SetClearingScreenSkipped(!ebiten.IsClearingScreenSkipped())
|
||||
}
|
||||
|
||||
g.count++
|
||||
return nil
|
||||
}
|
||||
@ -107,7 +111,12 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
op.GeoM.Translate(screenWidth/2, screenHeight/2)
|
||||
screen.DrawImage(gophersImage, op)
|
||||
|
||||
ebitenutil.DebugPrint(screen, "Press Space to force to lose/restore the GL context!\n(Browser only)")
|
||||
msg := `Press Space to force to lose/restore the GL context!
|
||||
(Browser only)
|
||||
|
||||
Press S to switch clearing the screen
|
||||
at the beginning of each frame.`
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
1
run.go
1
run.go
@ -112,6 +112,7 @@ func SetClearingScreenSkipped(skipped bool) {
|
||||
v = 1
|
||||
}
|
||||
atomic.StoreInt32(&isClearingScreenSkipped, v)
|
||||
theUIContext.setClearingScreenSkipped(skipped)
|
||||
}
|
||||
|
||||
// IsClearingScreenSkipped returns true if the frame isn't cleared at the beginning.
|
||||
|
11
uicontext.go
11
uicontext.go
@ -176,7 +176,7 @@ func (c *uiContext) updateOffscreen() {
|
||||
}
|
||||
if c.offscreen == nil {
|
||||
c.offscreen = newImage(sw, sh, FilterDefault)
|
||||
c.offscreen.mipmap.SetVolatile(true)
|
||||
c.offscreen.mipmap.SetVolatile(!IsClearingScreenSkipped())
|
||||
}
|
||||
|
||||
// The window size is automatically adjusted when Run is used.
|
||||
@ -193,6 +193,15 @@ func (c *uiContext) updateOffscreen() {
|
||||
// scale. This is fine since ebiten.ScreenScale will be deprecated.
|
||||
}
|
||||
|
||||
func (c *uiContext) setClearingScreenSkipped(skipped bool) {
|
||||
c.m.Lock()
|
||||
defer c.m.Unlock()
|
||||
|
||||
if c.offscreen != nil {
|
||||
c.offscreen.mipmap.SetVolatile(!skipped)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *uiContext) setWindowResizable(resizable bool) {
|
||||
c.m.Lock()
|
||||
defer c.m.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user