mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ebiten: Rename SetClearingScreenSkipped/IsClearingScreenSkipped functions (#1317)
Fixes #1315
This commit is contained in:
parent
4f791a8e85
commit
65d5b64d29
@ -94,7 +94,7 @@ func (g *Game) Update(screen *ebiten.Image) error {
|
||||
}
|
||||
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyS) {
|
||||
ebiten.SetClearingScreenSkipped(!ebiten.IsClearingScreenSkipped())
|
||||
ebiten.SetScreenClearedEveryFrame(!ebiten.IsScreenClearedEveryFrame())
|
||||
}
|
||||
|
||||
g.count++
|
||||
|
@ -143,7 +143,7 @@ func (g *game) Update(screen *ebiten.Image) error {
|
||||
g.transparent = ebiten.IsScreenTransparent()
|
||||
floating := ebiten.IsWindowFloating()
|
||||
resizable := ebiten.IsWindowResizable()
|
||||
clearingScreenSkipped := ebiten.IsClearingScreenSkipped()
|
||||
screenCleared := ebiten.IsScreenClearedEveryFrame()
|
||||
|
||||
const d = 16
|
||||
toUpdateWindowSize := false
|
||||
@ -231,7 +231,7 @@ func (g *game) Update(screen *ebiten.Image) error {
|
||||
resizable = !resizable
|
||||
}
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyW) {
|
||||
clearingScreenSkipped = !clearingScreenSkipped
|
||||
screenCleared = !screenCleared
|
||||
}
|
||||
maximize := inpututil.IsKeyJustPressed(ebiten.KeyM)
|
||||
minimize := inpututil.IsKeyJustPressed(ebiten.KeyN)
|
||||
@ -258,7 +258,7 @@ func (g *game) Update(screen *ebiten.Image) error {
|
||||
ebiten.SetWindowDecorated(decorated)
|
||||
ebiten.SetWindowPosition(positionX, positionY)
|
||||
ebiten.SetWindowFloating(floating)
|
||||
ebiten.SetClearingScreenSkipped(clearingScreenSkipped)
|
||||
ebiten.SetScreenClearedEveryFrame(screenCleared)
|
||||
if maximize && ebiten.IsWindowResizable() {
|
||||
ebiten.MaximizeWindow()
|
||||
}
|
||||
|
22
run.go
22
run.go
@ -90,7 +90,7 @@ func CurrentFPS() float64 {
|
||||
|
||||
var (
|
||||
isDrawingSkipped = int32(0)
|
||||
isClearingScreenSkipped = int32(0)
|
||||
isScreenClearedEveryFrame = int32(1)
|
||||
currentMaxTPS = int32(DefaultTPS)
|
||||
)
|
||||
|
||||
@ -102,24 +102,24 @@ func setDrawingSkipped(skipped bool) {
|
||||
atomic.StoreInt32(&isDrawingSkipped, v)
|
||||
}
|
||||
|
||||
// SetClearingScreenSkipped enables or disables the clearing of the screen at the beginning of each frame.
|
||||
// SetScreenClearedEveryFrame enables or disables the clearing of the screen at the beginning of each frame.
|
||||
// The default value is false and the screen is cleared each frame by default.
|
||||
//
|
||||
// SetClearingScreenSkipped is concurrent-safe.
|
||||
func SetClearingScreenSkipped(skipped bool) {
|
||||
// SetScreenClearedEveryFrame is concurrent-safe.
|
||||
func SetScreenClearedEveryFrame(cleared bool) {
|
||||
v := int32(0)
|
||||
if skipped {
|
||||
if cleared {
|
||||
v = 1
|
||||
}
|
||||
atomic.StoreInt32(&isClearingScreenSkipped, v)
|
||||
theUIContext.setClearingScreenSkipped(skipped)
|
||||
atomic.StoreInt32(&isScreenClearedEveryFrame, v)
|
||||
theUIContext.setScreenClearedEveryFrame(cleared)
|
||||
}
|
||||
|
||||
// IsClearingScreenSkipped returns true if the frame isn't cleared at the beginning.
|
||||
// IsScreenClearedEveryFrame returns true if the frame isn't cleared at the beginning.
|
||||
//
|
||||
// IsClearingScreenSkipped is concurrent-safe.
|
||||
func IsClearingScreenSkipped() bool {
|
||||
return atomic.LoadInt32(&isClearingScreenSkipped) != 0
|
||||
// IsScreenClearedEveryFrame is concurrent-safe.
|
||||
func IsScreenClearedEveryFrame() bool {
|
||||
return atomic.LoadInt32(&isScreenClearedEveryFrame) != 0
|
||||
}
|
||||
|
||||
// IsDrawingSkipped returns true if rendering result is not adopted.
|
||||
|
10
uicontext.go
10
uicontext.go
@ -176,7 +176,7 @@ func (c *uiContext) updateOffscreen() {
|
||||
}
|
||||
if c.offscreen == nil {
|
||||
c.offscreen = newImage(sw, sh, FilterDefault)
|
||||
c.offscreen.mipmap.SetVolatile(!IsClearingScreenSkipped())
|
||||
c.offscreen.mipmap.SetVolatile(IsScreenClearedEveryFrame())
|
||||
}
|
||||
|
||||
// The window size is automatically adjusted when Run is used.
|
||||
@ -193,12 +193,12 @@ func (c *uiContext) updateOffscreen() {
|
||||
// scale. This is fine since ebiten.ScreenScale will be deprecated.
|
||||
}
|
||||
|
||||
func (c *uiContext) setClearingScreenSkipped(skipped bool) {
|
||||
func (c *uiContext) setScreenClearedEveryFrame(cleared bool) {
|
||||
c.m.Lock()
|
||||
defer c.m.Unlock()
|
||||
|
||||
if c.offscreen != nil {
|
||||
c.offscreen.mipmap.SetVolatile(!skipped)
|
||||
c.offscreen.mipmap.SetVolatile(cleared)
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ func (c *uiContext) update() error {
|
||||
|
||||
// Multiple successive Clear call should be integrated into one graphics command, then
|
||||
// calling Clear on every Update should not affect the performance.
|
||||
if !IsClearingScreenSkipped() {
|
||||
if IsScreenClearedEveryFrame() {
|
||||
c.offscreen.Clear()
|
||||
}
|
||||
if err := c.game.Update(c.offscreen); err != nil {
|
||||
@ -318,7 +318,7 @@ func (c *uiContext) draw() {
|
||||
}
|
||||
|
||||
if game, ok := c.game.(interface{ Draw(*Image) }); ok {
|
||||
if !IsClearingScreenSkipped() {
|
||||
if IsScreenClearedEveryFrame() {
|
||||
c.offscreen.Clear()
|
||||
}
|
||||
game.Draw(c.offscreen)
|
||||
|
Loading…
Reference in New Issue
Block a user