Skip to content

Commit 7efbff0

Browse files
committed
x/exp/shiny/driver/gldriver: allow ES2 on Linux and ES3 on Windows
The previous check for GL_ES_2_0 was compile-time, which makes no sense. The lack of support for OpenGL ES 2.0 contexts on Linux also makes no sense as gldriver supports OpenGL ES 2.0 on other platforms.
1 parent fa9d1d1 commit 7efbff0

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

shiny/driver/gldriver/egl.go

100755100644
File mode changed.

shiny/driver/gldriver/win32.go

100755100644
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func createEGLSurface(hwnd syscall.Handle, w *windowImpl) error {
329329
}
330330

331331
contextAttribs := [...]eglInt{
332-
_EGL_CONTEXT_CLIENT_VERSION, 2,
332+
_EGL_CONTEXT_CLIENT_VERSION, 3,
333333
_EGL_NONE,
334334
}
335335
context, _, _ := eglCreateContext.Call(
@@ -338,6 +338,19 @@ func createEGLSurface(hwnd syscall.Handle, w *windowImpl) error {
338338
_EGL_NO_CONTEXT,
339339
uintptr(unsafe.Pointer(&contextAttribs[0])),
340340
)
341+
if context == _EGL_NO_CONTEXT {
342+
// Try again with OpenGL ES 2.0.
343+
context2Attribs := [...]eglInt{
344+
_EGL_CONTEXT_CLIENT_VERSION, 2,
345+
_EGL_NONE,
346+
}
347+
context, _, _ = eglCreateContext.Call(
348+
display,
349+
uintptr(config),
350+
_EGL_NO_CONTEXT,
351+
uintptr(unsafe.Pointer(&context2Attribs[0])),
352+
)
353+
}
341354
if context == _EGL_NO_CONTEXT {
342355
return fmt.Errorf("eglCreateContext failed: %v", eglErr())
343356
}

shiny/driver/gldriver/x11.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ startDriver() {
126126
EGL_NONE
127127
};
128128
e_ctx = eglCreateContext(e_dpy, e_config, EGL_NO_CONTEXT, ctx_attribs);
129+
if (!e_ctx) {
130+
// Try again with OpenGL ES 2.0.
131+
static const EGLint ctx2_attribs[] = {
132+
EGL_CONTEXT_CLIENT_VERSION, 2,
133+
EGL_NONE
134+
};
135+
136+
e_ctx = eglCreateContext(e_dpy, e_config, EGL_NO_CONTEXT, ctx2_attribs);
137+
}
129138
if (!e_ctx) {
130139
fprintf(stderr, "eglCreateContext failed: %s\n", eglGetErrorStr());
131140
exit(1);

shiny/driver/gldriver/x11.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ type uiClosure struct {
130130
}
131131

132132
func main(f func(screen.Screen)) error {
133-
if gl.Version() == "GL_ES_2_0" {
134-
return errors.New("gldriver: ES 3 required on X11")
135-
}
136133
C.startDriver()
137134
glctx, worker = gl.NewContext()
138135

0 commit comments

Comments
 (0)