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
|
var vsyncEnabled int32 = 1
|
||||||
|
|
||||||
func SetVsyncEnabled(enabled bool) {
|
func SetVsyncEnabled(enabled bool, graphicsDriver graphicsdriver.Graphics) {
|
||||||
if enabled {
|
if enabled {
|
||||||
atomic.StoreInt32(&vsyncEnabled, 1)
|
atomic.StoreInt32(&vsyncEnabled, 1)
|
||||||
} else {
|
} else {
|
||||||
atomic.StoreInt32(&vsyncEnabled, 0)
|
atomic.StoreInt32(&vsyncEnabled, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runOnRenderThread(func() {
|
||||||
|
graphicsDriver.SetVsyncEnabled(enabled)
|
||||||
|
}, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlushCommands flushes the command queue and present the screen if needed.
|
// FlushCommands flushes the command queue and present the screen if needed.
|
||||||
|
@ -80,7 +80,9 @@ type UserInterface struct {
|
|||||||
|
|
||||||
whiteImage *Image
|
whiteImage *Image
|
||||||
|
|
||||||
mainThread thread.Thread
|
mainThread thread.Thread
|
||||||
|
|
||||||
|
// TODO: Remove this (#2714).
|
||||||
renderThread thread.Thread
|
renderThread thread.Thread
|
||||||
|
|
||||||
userInterfaceImpl
|
userInterfaceImpl
|
||||||
|
@ -1287,10 +1287,7 @@ func (u *UserInterface) setFPSMode(fpsMode FPSModeType) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vsyncEnabled := u.fpsMode == FPSModeVsyncOn
|
vsyncEnabled := u.fpsMode == FPSModeVsyncOn
|
||||||
graphicscommand.SetVsyncEnabled(vsyncEnabled)
|
graphicscommand.SetVsyncEnabled(vsyncEnabled, u.graphicsDriver)
|
||||||
u.renderThread.CallAsync(func() {
|
|
||||||
u.graphicsDriver.SetVsyncEnabled(vsyncEnabled)
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1341,6 +1338,7 @@ func (u *UserInterface) update() (float64, float64, error) {
|
|||||||
|
|
||||||
// Initialize vsync after SetMonitor is called. See the comment in updateVsync.
|
// Initialize vsync after SetMonitor is called. See the comment in updateVsync.
|
||||||
// Calling this inside setWindowSize didn't work (#1363).
|
// Calling this inside setWindowSize didn't work (#1363).
|
||||||
|
// Also, setFPSMode has to be called after graphicscommand.SetRenderThread is called (#2714).
|
||||||
if !u.fpsModeInited {
|
if !u.fpsModeInited {
|
||||||
if err := u.setFPSMode(u.fpsMode); err != nil {
|
if err := u.setFPSMode(u.fpsMode); err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
|
Loading…
Reference in New Issue
Block a user