Skip to content

Commit

Permalink
uidriver/glfw: Bug fix: Need to call updateVsync after setWindowSize
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Sep 22, 2020
1 parent 26768aa commit 7386fa3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions internal/uidriver/glfw/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,17 @@ func (u *UserInterface) update() error {
u.setInitFullscreen(false)
}

// Initialize vsync after SetMonitor is called. See the comment in updateVsync.
// Calling this inside setWindowSize didn't work (#1363).
_ = u.t.Call(func() error {
if !u.vsyncInited {
u.vsync = u.isInitVsyncEnabled()
u.updateVsync()
u.vsyncInited = true
}
return nil
})

// This call is needed for initialization.
u.updateSize()

Expand Down Expand Up @@ -1046,13 +1057,6 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
u.windowWidth = width
u.windowHeight = height

if !u.vsyncInited {
// Initialize vsync after SetMonitor is called. See the comment in updateVsync.
u.vsync = u.isInitVsyncEnabled()
u.updateVsync()
u.vsyncInited = true
}

u.toChangeSize = true
return nil
})
Expand Down

0 comments on commit 7386fa3

Please sign in to comment.