diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-06-20 17:54:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-20 17:54:33 -0400 |
commit | 33f2c66fca6e8a628fe3f36d1abacf87226042de (patch) | |
tree | 1381f243d1bb9df41691e2b92593a8495bb80f37 /backend/egl.c | |
parent | 2f03ea0a6bea6c099f148eb745a725ca77813885 (diff) | |
parent | b9d36c8149536cff1aa229f59337dcfa2f70a37b (diff) |
Merge pull request #17 from nyorain/wayland-backend
Basic Wayland backend
Diffstat (limited to 'backend/egl.c')
-rw-r--r-- | backend/egl.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/backend/egl.c b/backend/egl.c index 2aac25b7..1ce2d8a7 100644 --- a/backend/egl.c +++ b/backend/egl.c @@ -6,7 +6,7 @@ #include "backend/egl.h" #include "common/log.h" -static const char *egl_error(void) { +const char *egl_error(void) { switch (eglGetError()) { case EGL_SUCCESS: return "Success"; @@ -68,11 +68,12 @@ static bool egl_exts() { return true; } -static bool egl_get_config(EGLDisplay disp, EGLConfig *out) { +static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLenum platform) { EGLint count = 0, matched = 0, ret; ret = eglGetConfigs(disp, NULL, 0, &count); if (ret == EGL_FALSE || count == 0) { + wlr_log(L_ERROR, "eglGetConfigs returned no configs"); return false; } @@ -80,12 +81,18 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out) { ret = eglChooseConfig(disp, NULL, configs, count, &matched); if (ret == EGL_FALSE) { + wlr_log(L_ERROR, "eglChooseConfig failed"); return false; } for (int i = 0; i < matched; ++i) { EGLint gbm_format; + if(platform == EGL_PLATFORM_WAYLAND_EXT) { + *out = configs[i]; + return true; + } + if (!eglGetConfigAttrib(disp, configs[i], EGL_NATIVE_VISUAL_ID, @@ -101,6 +108,7 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out) { } } + wlr_log(L_ERROR, "no valid egl config found"); return false; } @@ -109,7 +117,7 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *display) { if (!egl_exts()) { return false; } - + if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { wlr_log(L_ERROR, "Failed to bind to the OpenGL ES API: %s", egl_error()); goto error; @@ -127,7 +135,7 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *display) { goto error; } - if (!egl_get_config(egl->display, &egl->config)) { + if (!egl_get_config(egl->display, &egl->config, platform)) { wlr_log(L_ERROR, "Failed to get EGL config"); goto error; } @@ -163,7 +171,7 @@ void wlr_egl_free(struct wlr_egl *egl) { eglDestroyContext(egl->display, egl->context); eglTerminate(egl->display); eglReleaseThread(); - eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); } EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window) { |