mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 12:08:58 +01:00
parent
17dc972b7a
commit
662a22461d
22
uicontext.go
22
uicontext.go
@ -229,14 +229,23 @@ func (c *uiContext) offsets() (float64, float64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *uiContext) Update(afterFrameUpdate func()) error {
|
func (c *uiContext) Update(afterFrameUpdate func()) error {
|
||||||
updateCount := clock.Update(MaxTPS())
|
|
||||||
|
|
||||||
// TODO: If updateCount is 0 and vsync is disabled, swapping buffers can be skipped.
|
// TODO: If updateCount is 0 and vsync is disabled, swapping buffers can be skipped.
|
||||||
|
|
||||||
if err := buffered.BeginFrame(); err != nil {
|
if err := buffered.BeginFrame(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := c.update(afterFrameUpdate); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := buffered.EndFrame(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *uiContext) update(afterFrameUpdate func()) error {
|
||||||
|
updateCount := clock.Update(MaxTPS())
|
||||||
for i := 0; i < updateCount; i++ {
|
for i := 0; i < updateCount; i++ {
|
||||||
c.updateOffscreen()
|
c.updateOffscreen()
|
||||||
|
|
||||||
@ -255,6 +264,11 @@ func (c *uiContext) Update(afterFrameUpdate func()) error {
|
|||||||
afterFrameUpdate()
|
afterFrameUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// c.screen might be nil when updateCount is 0 in the initial state (#1039).
|
||||||
|
if c.screen == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// This clear is needed for fullscreen mode or some mobile platforms (#622).
|
// This clear is needed for fullscreen mode or some mobile platforms (#622).
|
||||||
c.screen.Clear()
|
c.screen.Clear()
|
||||||
|
|
||||||
@ -285,10 +299,6 @@ func (c *uiContext) Update(afterFrameUpdate func()) error {
|
|||||||
op.Filter = FilterLinear
|
op.Filter = FilterLinear
|
||||||
}
|
}
|
||||||
_ = c.screen.DrawImage(c.offscreen, op)
|
_ = c.screen.DrawImage(c.offscreen, op)
|
||||||
|
|
||||||
if err := buffered.EndFrame(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user