func Run(width, height int, scale float64, title string, g GraphicsContext) error { u := currentUI // GLContext must be created before setting the screen size, which requires // swapping buffers. var err error glContext, err = opengl.NewContext(currentUI.runOnMainThread) if err != nil { return err } if err := u.runOnMainThread(func() error { m := glfw.GetPrimaryMonitor() v := m.GetVideoMode() r, err := u.setScreenSize(width, height, scale) if err != nil { return err } if !r { return errors.New("ui: Fail to set the screen size") } u.window.SetTitle(title) u.window.Show() w, h := u.glfwSize() x := (v.Width - w) / 2 y := (v.Height - h) / 3 u.window.SetPos(x, y) return nil }); err != nil { return err } return u.loop(g) }
func Run(width, height int, scale float64, title string, g GraphicsContext) error { u := currentUI doc := js.Global.Get("document") doc.Set("title", title) u.setScreenSize(width, height, scale) canvas.Call("focus") var err error glContext, err = opengl.NewContext() if err != nil { return err } return u.loop(g) }
func Run(width, height int, scale float64, title string, g GraphicsContext) error { u := currentUI u.width = width u.height = height u.scale = scale // title is ignored? var err error glContext, err = opengl.NewContext() if err != nil { return err } for { if err := u.update(g); err != nil { return err } } }