Skip to content

Commit

Permalink
internal/ui: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Jul 29, 2023
1 parent 3869e2e commit d13bea2
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions internal/ui/ui_glfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ type userInterfaceImpl struct {
dropCallback glfw.DropCallback
framebufferSizeCallbackCh chan struct{}

glContextSetOnce sync.Once
darwinInitOnce sync.Once
bufferOnceSwappedOnce sync.Once

Expand Down Expand Up @@ -1046,6 +1045,13 @@ func (u *userInterfaceImpl) loopGame() error {
defer u.mainThread.Call(func() {
glfw.Terminate()
})

u.renderThread.Call(func() {
if u.graphicsDriver.IsGL() {
u.window.MakeContextCurrent()
}
})

for {
if err := u.updateGame(); err != nil {
return err
Expand Down Expand Up @@ -1079,14 +1085,6 @@ func (u *userInterfaceImpl) updateGame() error {
return err
}

u.glContextSetOnce.Do(func() {
u.renderThread.Call(func() {
if u.graphicsDriver.IsGL() {
u.window.MakeContextCurrent()
}
})
})

if err := u.context.updateFrame(u.graphicsDriver, outsideWidth, outsideHeight, deviceScaleFactor, u, func() {
// Call updateVsync even though fpsMode is not updated.
// When toggling to fullscreen, vsync state might be reset unexpectedly (#1787).
Expand Down

0 comments on commit d13bea2

Please sign in to comment.