mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
internal/atlas: bug fix: inFrame was not correctly updated
Updates #2814
This commit is contained in:
parent
7d517bfb63
commit
7a921e03da
@ -742,7 +742,7 @@ func (i *Image) DumpScreenshot(graphicsDriver graphicsdriver.Graphics, path stri
|
||||
defer backendsM.Unlock()
|
||||
|
||||
if !inFrame {
|
||||
panic("atlas: ReadPixels must be called in between BeginFrame and EndFrame")
|
||||
panic("atlas: DumpScreenshots must be called in between BeginFrame and EndFrame")
|
||||
}
|
||||
|
||||
return i.backend.restorable.Dump(graphicsDriver, path, blackbg, image.Rect(0, 0, i.width, i.height))
|
||||
@ -752,9 +752,13 @@ func EndFrame(graphicsDriver graphicsdriver.Graphics, swapBuffersForGL func()) e
|
||||
backendsM.Lock()
|
||||
defer backendsM.Unlock()
|
||||
defer func() {
|
||||
inFrame = true
|
||||
inFrame = false
|
||||
}()
|
||||
|
||||
if !inFrame {
|
||||
panic("atlas: inFrame must be true in EndFrame")
|
||||
}
|
||||
|
||||
if err := restorable.EndFrame(graphicsDriver, swapBuffersForGL); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -780,6 +784,11 @@ func floorPowerOf2(x int) int {
|
||||
func BeginFrame(graphicsDriver graphicsdriver.Graphics) error {
|
||||
backendsM.Lock()
|
||||
defer backendsM.Unlock()
|
||||
|
||||
if inFrame {
|
||||
panic("atlas: inFrame must be false in BeginFrame")
|
||||
}
|
||||
|
||||
inFrame = true
|
||||
|
||||
var err error
|
||||
@ -821,5 +830,10 @@ func BeginFrame(graphicsDriver graphicsdriver.Graphics) error {
|
||||
func DumpImages(graphicsDriver graphicsdriver.Graphics, dir string) (string, error) {
|
||||
backendsM.Lock()
|
||||
defer backendsM.Unlock()
|
||||
|
||||
if !inFrame {
|
||||
panic("atlas: DumpImages must be called in between BeginFrame and EndFrame")
|
||||
}
|
||||
|
||||
return restorable.DumpImages(graphicsDriver, dir)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user