forked from joejulian/gio
app/internal/window: fall back to OpenGL ES 2 if 3 is unavailable
Systems that only support ES 2 are unlikely to have the required extensions available. But we'll get a better exit error in that case. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -220,18 +220,25 @@ func createContext(disp _EGLNativeDisplayType) (*eglContext, error) {
|
|||||||
if eglCfg == nilEGLConfig {
|
if eglCfg == nilEGLConfig {
|
||||||
return nil, errors.New("eglChooseConfig returned 0 configs")
|
return nil, errors.New("eglChooseConfig returned 0 configs")
|
||||||
}
|
}
|
||||||
var eglCtx _EGLContext
|
visID, ret := eglGetConfigAttrib(eglDisp, eglCfg, _EGL_NATIVE_VISUAL_ID)
|
||||||
|
if !ret {
|
||||||
|
return nil, errors.New("newContext: eglGetConfigAttrib for _EGL_NATIVE_VISUAL_ID failed")
|
||||||
|
}
|
||||||
ctxAttribs := []_EGLint{
|
ctxAttribs := []_EGLint{
|
||||||
_EGL_CONTEXT_CLIENT_VERSION, 3,
|
_EGL_CONTEXT_CLIENT_VERSION, 3,
|
||||||
_EGL_NONE,
|
_EGL_NONE,
|
||||||
}
|
}
|
||||||
eglCtx = eglCreateContext(eglDisp, eglCfg, nilEGLContext, ctxAttribs)
|
eglCtx := eglCreateContext(eglDisp, eglCfg, nilEGLContext, ctxAttribs)
|
||||||
if eglCtx == nilEGLContext {
|
if eglCtx == nilEGLContext {
|
||||||
return nil, fmt.Errorf("eglCreateContext failed: 0x%x", eglGetError())
|
// Fall back to OpenGL ES 2 and rely on extensions.
|
||||||
}
|
ctxAttribs := []_EGLint{
|
||||||
visID, ret := eglGetConfigAttrib(eglDisp, eglCfg, _EGL_NATIVE_VISUAL_ID)
|
_EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
if !ret {
|
_EGL_NONE,
|
||||||
return nil, errors.New("newContext: eglGetConfigAttrib for _EGL_NATIVE_VISUAL_ID failed")
|
}
|
||||||
|
eglCtx = eglCreateContext(eglDisp, eglCfg, nilEGLContext, ctxAttribs)
|
||||||
|
if eglCtx == nil {
|
||||||
|
return nil, fmt.Errorf("eglCreateContext failed: 0x%x", eglGetError())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return &eglContext{
|
return &eglContext{
|
||||||
disp: eglDisp,
|
disp: eglDisp,
|
||||||
|
|||||||
Reference in New Issue
Block a user