diff --git a/shiny/driver/gldriver/egl.go b/shiny/driver/gldriver/egl.go old mode 100755 new mode 100644 diff --git a/shiny/driver/gldriver/win32.go b/shiny/driver/gldriver/win32.go old mode 100755 new mode 100644 index 8ece242f5..a38cd0c6b --- a/shiny/driver/gldriver/win32.go +++ b/shiny/driver/gldriver/win32.go @@ -329,7 +329,7 @@ func createEGLSurface(hwnd syscall.Handle, w *windowImpl) error { } contextAttribs := [...]eglInt{ - _EGL_CONTEXT_CLIENT_VERSION, 2, + _EGL_CONTEXT_CLIENT_VERSION, 3, _EGL_NONE, } context, _, _ := eglCreateContext.Call( @@ -338,6 +338,19 @@ func createEGLSurface(hwnd syscall.Handle, w *windowImpl) error { _EGL_NO_CONTEXT, uintptr(unsafe.Pointer(&contextAttribs[0])), ) + if context == _EGL_NO_CONTEXT { + // Try again with OpenGL ES 2.0. + context2Attribs := [...]eglInt{ + _EGL_CONTEXT_CLIENT_VERSION, 2, + _EGL_NONE, + } + context, _, _ = eglCreateContext.Call( + display, + uintptr(config), + _EGL_NO_CONTEXT, + uintptr(unsafe.Pointer(&context2Attribs[0])), + ) + } if context == _EGL_NO_CONTEXT { return fmt.Errorf("eglCreateContext failed: %v", eglErr()) } diff --git a/shiny/driver/gldriver/x11.c b/shiny/driver/gldriver/x11.c index dff6d2d64..e7df29ec7 100644 --- a/shiny/driver/gldriver/x11.c +++ b/shiny/driver/gldriver/x11.c @@ -126,6 +126,15 @@ startDriver() { EGL_NONE }; e_ctx = eglCreateContext(e_dpy, e_config, EGL_NO_CONTEXT, ctx_attribs); + if (!e_ctx) { + // Try again with OpenGL ES 2.0. + static const EGLint ctx2_attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + + e_ctx = eglCreateContext(e_dpy, e_config, EGL_NO_CONTEXT, ctx2_attribs); + } if (!e_ctx) { fprintf(stderr, "eglCreateContext failed: %s\n", eglGetErrorStr()); exit(1); diff --git a/shiny/driver/gldriver/x11.go b/shiny/driver/gldriver/x11.go index 4847e85b2..9f50a4772 100644 --- a/shiny/driver/gldriver/x11.go +++ b/shiny/driver/gldriver/x11.go @@ -130,9 +130,6 @@ type uiClosure struct { } func main(f func(screen.Screen)) error { - if gl.Version() == "GL_ES_2_0" { - return errors.New("gldriver: ES 3 required on X11") - } C.startDriver() glctx, worker = gl.NewContext()