mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
Stabilize FPS for JS
This commit is contained in:
parent
81ed2e3f18
commit
6efb806cc2
@ -21,7 +21,6 @@ import (
|
|||||||
"github.com/gopherjs/webgl"
|
"github.com/gopherjs/webgl"
|
||||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var canvas js.Object
|
var canvas js.Object
|
||||||
@ -32,7 +31,12 @@ func Use(f func(*opengl.Context)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DoEvents() {
|
func DoEvents() {
|
||||||
time.Sleep(0)
|
// TODO: requestAnimationFrame is not called when the window is not activated.
|
||||||
|
ch := make(chan struct{})
|
||||||
|
js.Global.Get("window").Call("requestAnimationFrame", func() {
|
||||||
|
close(ch)
|
||||||
|
})
|
||||||
|
<-ch
|
||||||
}
|
}
|
||||||
|
|
||||||
func Terminate() {
|
func Terminate() {
|
||||||
|
Loading…
Reference in New Issue
Block a user