From d41f959b960059dd05971af64eae0c3a1e9de3f0 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 4 May 2018 23:55:23 +0900 Subject: [PATCH] ui: Initialize GLFW before Run --- internal/ui/ui_glfw.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 55347d6cc..091e2bed5 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -66,11 +66,13 @@ var ( initCursorVisible: true, initWindowDecorated: true, } - currentUIInitialized = make(chan struct{}) ) func init() { runtime.LockOSThread() + if err := initialize(); err != nil { + panic(err) + } } func initialize() error { @@ -116,11 +118,6 @@ func initialize() error { func RunMainThreadLoop(ch <-chan error) error { // This must be called on the main thread. - if err := initialize(); err != nil { - return err - } - close(currentUIInitialized) - // TODO: Check this is done on the main thread. currentUI.setRunning(true) defer func() { @@ -445,8 +442,6 @@ func SetWindowDecorated(decorated bool) { } func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool) error { - <-currentUIInitialized - u := currentUI // GLContext must be created before setting the screen size, which requires // swapping buffers.