uidriver/glfw: Set No-API when creating a hidden window first

GLFW tries to create an OpenGL context by default when creating a
window. This is not necessary when OpenGL is not used. This is an
optimization by skipping to create an OpenGL context if possible.

Fixes #1237
This commit is contained in:
Hajime Hoshi 2020-07-05 15:00:56 +09:00
parent 7873563667
commit f794fc8d66
2 changed files with 3 additions and 0 deletions

View File

@ -97,6 +97,7 @@ const (
CursorHidden = 0x00034002
CursorNormal = 0x00034001
NoAPI = 0
OpenGLAPI = 0x00030001
)
const (

View File

@ -129,6 +129,7 @@ func initialize() error {
return err
}
glfw.WindowHint(glfw.Visible, glfw.False)
glfw.WindowHint(glfw.ClientAPI, glfw.NoAPI)
// Create a window to set the initial monitor.
w, err := glfw.CreateWindow(16, 16, "", nil, nil)
@ -657,6 +658,7 @@ func (u *UserInterface) run(context driver.UIContext) error {
u.window = nil
if u.Graphics().IsGL() {
glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLAPI)
glfw.WindowHint(glfw.ContextVersionMajor, 2)
glfw.WindowHint(glfw.ContextVersionMinor, 1)
} else {