mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Move vsync to ui.SwapBuffers on JavaScript version
This commit is contained in:
parent
94f1e7df64
commit
3588d0b485
@ -93,10 +93,6 @@ func vsync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*userInterface) doEvents() error {
|
func (*userInterface) doEvents() error {
|
||||||
vsync()
|
|
||||||
for !shown() {
|
|
||||||
vsync()
|
|
||||||
}
|
|
||||||
currentInput.UpdateGamepads()
|
currentInput.UpdateGamepads()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -110,7 +106,10 @@ func (*userInterface) isClosed() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*userInterface) swapBuffers() {
|
func (*userInterface) swapBuffers() {
|
||||||
// Do nothing.
|
vsync()
|
||||||
|
for !shown() {
|
||||||
|
vsync()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init() *opengl.Context {
|
func Init() *opengl.Context {
|
||||||
|
8
run.go
8
run.go
@ -109,8 +109,12 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
|
|||||||
c := float64(now-beforeForUpdate) * 60 / float64(time.Second)
|
c := float64(now-beforeForUpdate) * 60 / float64(time.Second)
|
||||||
runContext.isRunningSlowly = c >= 2.5
|
runContext.isRunningSlowly = c >= 2.5
|
||||||
for i := 0; i < int(c); i++ {
|
for i := 0; i < int(c); i++ {
|
||||||
// TODO: Input should be updated here,
|
if err := ui.DoEvents(); err != nil {
|
||||||
// but JavaScript version of ui.DoEvents does vsync.
|
return err
|
||||||
|
}
|
||||||
|
if ui.IsClosed() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if err := graphicsContext.update(f); err != nil {
|
if err := graphicsContext.update(f); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user