aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-12-17 23:51:04 +0100
committeremersion <contact@emersion.fr>2017-12-17 23:51:04 +0100
commitb99d1f4fcca0f8d7b1d2042f51fdefcc73304e6f (patch)
treefab66d90e45cff436d123eab2f4475ed4f5bb7bc /render
parentbc5bdb7793d7737a42489ddb07b2fbb7f74a47f5 (diff)
Refactor wlr_egl_init to accept config_attribs
Diffstat (limited to 'render')
-rw-r--r--render/egl.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/render/egl.c b/render/egl.c
index e895df8d..fe20973c 100644
--- a/render/egl.c
+++ b/render/egl.c
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
@@ -47,7 +48,8 @@ const char *egl_error(void) {
}
}
-static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLint visual_id) {
+static bool egl_get_config(EGLDisplay disp, EGLint *attribs, EGLConfig *out,
+ EGLint visual_id) {
EGLint count = 0, matched = 0, ret;
ret = eglGetConfigs(disp, NULL, 0, &count);
@@ -58,7 +60,7 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLint visual_id) {
EGLConfig configs[count];
- ret = eglChooseConfig(disp, NULL, configs, count, &matched);
+ ret = eglChooseConfig(disp, attribs, configs, count, &matched);
if (ret == EGL_FALSE) {
wlr_log(L_ERROR, "eglChooseConfig failed");
return false;
@@ -71,7 +73,7 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLint visual_id) {
continue;
}
- if (visual == visual_id) {
+ if (!visual_id || visual == visual_id) {
*out = configs[i];
return true;
}
@@ -81,8 +83,8 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLint visual_id) {
return false;
}
-bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id,
- void *remote_display) {
+bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display,
+ EGLint *config_attribs, EGLint visual_id) {
if (!load_glapi()) {
return false;
}
@@ -92,7 +94,12 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id,
goto error;
}
- egl->display = eglGetPlatformDisplayEXT(platform, remote_display, NULL);
+ if (platform == EGL_PLATFORM_SURFACELESS_MESA) {
+ assert(remote_display == NULL);
+ egl->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ } else {
+ egl->display = eglGetPlatformDisplayEXT(platform, remote_display, NULL);
+ }
if (egl->display == EGL_NO_DISPLAY) {
wlr_log(L_ERROR, "Failed to create EGL display: %s", egl_error());
goto error;
@@ -104,7 +111,7 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id,
goto error;
}
- if (!egl_get_config(egl->display, &egl->config, visual_id)) {
+ if (!egl_get_config(egl->display, config_attribs, &egl->config, visual_id)) {
wlr_log(L_ERROR, "Failed to get EGL config");
goto error;
}