mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Initialize GLContext at Start
This commit is contained in:
parent
5a3ea34cfc
commit
121063ee2b
@ -46,14 +46,6 @@ func CurrentUI() UserInterface {
|
||||
var glContext *opengl.Context
|
||||
|
||||
func GLContext() *opengl.Context {
|
||||
if glContext != nil {
|
||||
return glContext
|
||||
}
|
||||
var err error
|
||||
glContext, err = opengl.NewContext(currentUI.runOnMainThread)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return glContext
|
||||
}
|
||||
|
||||
@ -145,6 +137,13 @@ func (u *userInterface) ScreenScale() float64 {
|
||||
}
|
||||
|
||||
func (u *userInterface) Start(width, height int, scale float64, title string) error {
|
||||
// GLContext must be created before setting the screen size, which requres
|
||||
// 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()
|
||||
|
@ -139,14 +139,6 @@ func touchEventToTouches(e *js.Object) []touch {
|
||||
var glContext *opengl.Context
|
||||
|
||||
func GLContext() *opengl.Context {
|
||||
if glContext != nil {
|
||||
return glContext
|
||||
}
|
||||
var err error
|
||||
glContext, err = opengl.NewContext()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return glContext
|
||||
}
|
||||
|
||||
@ -301,6 +293,11 @@ func (u *userInterface) Start(width, height int, scale float64, title string) er
|
||||
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 nil
|
||||
}
|
||||
|
||||
|
@ -27,14 +27,6 @@ import (
|
||||
var glContext *opengl.Context
|
||||
|
||||
func GLContext() *opengl.Context {
|
||||
if glContext != nil {
|
||||
return glContext
|
||||
}
|
||||
var err error
|
||||
glContext, err = opengl.NewContext()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return glContext
|
||||
}
|
||||
|
||||
@ -83,6 +75,11 @@ func (u *userInterface) Start(width, height int, scale float64, title string) er
|
||||
u.height = height
|
||||
u.scale = scale
|
||||
// title is ignored?
|
||||
var err error
|
||||
glContext, err = opengl.NewContext()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user