mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
d6439c9e6c
commit
d7ebc19d04
@ -45,12 +45,16 @@ const (
|
||||
|
||||
var vsyncEnabled int32 = 1
|
||||
|
||||
func SetVsyncEnabled(enabled bool) {
|
||||
func SetVsyncEnabled(enabled bool, graphicsDriver graphicsdriver.Graphics) {
|
||||
if enabled {
|
||||
atomic.StoreInt32(&vsyncEnabled, 1)
|
||||
} else {
|
||||
atomic.StoreInt32(&vsyncEnabled, 0)
|
||||
}
|
||||
|
||||
runOnRenderThread(func() {
|
||||
graphicsDriver.SetVsyncEnabled(enabled)
|
||||
}, true)
|
||||
}
|
||||
|
||||
// FlushCommands flushes the command queue and present the screen if needed.
|
||||
|
@ -81,6 +81,8 @@ type UserInterface struct {
|
||||
whiteImage *Image
|
||||
|
||||
mainThread thread.Thread
|
||||
|
||||
// TODO: Remove this (#2714).
|
||||
renderThread thread.Thread
|
||||
|
||||
userInterfaceImpl
|
||||
|
@ -1287,10 +1287,7 @@ func (u *UserInterface) setFPSMode(fpsMode FPSModeType) error {
|
||||
}
|
||||
|
||||
vsyncEnabled := u.fpsMode == FPSModeVsyncOn
|
||||
graphicscommand.SetVsyncEnabled(vsyncEnabled)
|
||||
u.renderThread.CallAsync(func() {
|
||||
u.graphicsDriver.SetVsyncEnabled(vsyncEnabled)
|
||||
})
|
||||
graphicscommand.SetVsyncEnabled(vsyncEnabled, u.graphicsDriver)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -1341,6 +1338,7 @@ func (u *UserInterface) update() (float64, float64, error) {
|
||||
|
||||
// Initialize vsync after SetMonitor is called. See the comment in updateVsync.
|
||||
// Calling this inside setWindowSize didn't work (#1363).
|
||||
// Also, setFPSMode has to be called after graphicscommand.SetRenderThread is called (#2714).
|
||||
if !u.fpsModeInited {
|
||||
if err := u.setFPSMode(u.fpsMode); err != nil {
|
||||
return 0, 0, err
|
||||
|
Loading…
Reference in New Issue
Block a user