mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 18:52:44 +01:00
internal/glfw: bug fix: limit the DWM swap interval to Vista and 7
This change applies the bug fix at glfw/glfw#1072. Updates #2961
This commit is contained in:
parent
d5f15f9354
commit
86e0bcc264
@ -261,23 +261,18 @@ func makeContextCurrentWGL(window *Window) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func swapBuffersWGL(window *Window) error {
|
func swapBuffersWGL(window *Window) error {
|
||||||
if window.monitor == nil && winver.IsWindowsVistaOrGreater() {
|
if window.monitor == nil {
|
||||||
// DWM Composition is always enabled on Win8+
|
// HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7
|
||||||
enabled := winver.IsWindows8OrGreater()
|
if !winver.IsWindows8OrGreater() && winver.IsWindowsVistaOrGreater() {
|
||||||
|
enabled, err := _DwmIsCompositionEnabled()
|
||||||
if !enabled {
|
|
||||||
var err error
|
|
||||||
enabled, err = _DwmIsCompositionEnabled()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
if enabled {
|
||||||
|
for i := 0; i < window.context.platform.interval; i++ {
|
||||||
// HACK: Use DwmFlush when desktop composition is enabled
|
// Ignore an error from DWM functions as they might not be implemented e.g. on Proton (#2113).
|
||||||
if enabled {
|
_ = _DwmFlush()
|
||||||
for i := 0; i < window.context.platform.interval; i++ {
|
}
|
||||||
// Ignore an error from DWM functions as they might not be implemented e.g. on Proton (#2113).
|
|
||||||
_ = _DwmFlush()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,22 +292,18 @@ func swapIntervalWGL(interval int) error {
|
|||||||
|
|
||||||
window.context.platform.interval = interval
|
window.context.platform.interval = interval
|
||||||
|
|
||||||
if window.monitor == nil && winver.IsWindowsVistaOrGreater() {
|
if window.monitor == nil {
|
||||||
// DWM Composition is always enabled on Win8+
|
// HACK: Disable WGL swap interval when desktop composition is enabled on Windows
|
||||||
enabled := winver.IsWindows8OrGreater()
|
// Vista and 7 to avoid interfering with DWM vsync
|
||||||
|
if !winver.IsWindows8OrGreater() && winver.IsWindowsVistaOrGreater() {
|
||||||
if !enabled {
|
enabled, err := _DwmIsCompositionEnabled()
|
||||||
e, err := _DwmIsCompositionEnabled()
|
|
||||||
// Ignore an error from DWM functions as they might not be implemented e.g. on Proton (#2113).
|
// Ignore an error from DWM functions as they might not be implemented e.g. on Proton (#2113).
|
||||||
if err == nil {
|
if err == nil {
|
||||||
enabled = e
|
enabled = false
|
||||||
|
}
|
||||||
|
if enabled {
|
||||||
|
interval = 0
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// HACK: Disable WGL swap interval when desktop composition is enabled to
|
|
||||||
// avoid interfering with DWM vsync
|
|
||||||
if enabled {
|
|
||||||
interval = 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user