diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2012-05-17 09:23:10 -0700 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2012-05-17 11:41:09 -0700 |
commit | 78b0aac3df7c7966f511beb2629b5168ee30d37b (patch) | |
tree | e87fcf8e75e3790fbb6f161f85ccc9e07c3936c5 | |
parent | 17c99a5e3a8db6cbf38ce65c0a5a014f5be5b475 (diff) | |
download | waffle-78b0aac3df7c7966f511beb2629b5168ee30d37b.tar.gz |
egl: Check context attributes in egl_choose_config()
This is in preparation for creating EGL contexts of any flavor.
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r-- | src/waffle/egl/egl_no_native.c | 48 | ||||
-rw-r--r-- | src/waffle/egl/egl_no_native.h | 1 | ||||
-rw-r--r-- | src/waffle/wayland/wayland_config.c | 3 | ||||
-rw-r--r-- | src/waffle/x11_egl/xegl_config.c | 3 |
4 files changed, 53 insertions, 2 deletions
diff --git a/src/waffle/egl/egl_no_native.c b/src/waffle/egl/egl_no_native.c index 2efb684..583d218 100644 --- a/src/waffle/egl/egl_no_native.c +++ b/src/waffle/egl/egl_no_native.c @@ -72,14 +72,62 @@ egl_terminate(EGLDisplay dpy) return ok; } +/// @brief Check the `wcore_config_attrs.context_` attributes. +static bool +egl_config_check_context_attrs( + struct linux_platform *platform, + const struct wcore_config_attrs *attrs) +{ + int version = 10 * attrs->context_major_version + + attrs->context_minor_version; + + switch (attrs->context_api) { + case WAFFLE_CONTEXT_OPENGL: + if (version != 10) { + wcore_errorf(WAFFLE_UNSUPPORTED_ON_PLATFORM, + "on EGL, the requested version of OpenGL must be " + "the default value 1.0"); + return false; + } + if (!linux_platform_dl_can_open(platform, WAFFLE_DL_OPENGL)) { + wcore_errorf(WAFFLE_UNSUPPORTED_ON_PLATFORM, + "failed to open the OpenGL library"); + return false; + } + return true; + case WAFFLE_CONTEXT_OPENGL_ES1: + if (!linux_platform_dl_can_open(platform, WAFFLE_DL_OPENGL_ES1)) { + wcore_errorf(WAFFLE_UNSUPPORTED_ON_PLATFORM, + "failed to open the OpenGL ES1 library"); + return false; + } + return true; + case WAFFLE_CONTEXT_OPENGL_ES2: + if (!linux_platform_dl_can_open(platform, WAFFLE_DL_OPENGL_ES2)) { + wcore_errorf(WAFFLE_UNSUPPORTED_ON_PLATFORM, + "failed to open the OpenGL ES2 library"); + return false; + } + return true; + default: + wcore_error_internal("context_api has bad value %#x", + attrs->context_api); + return false; + } +} + EGLConfig egl_choose_config( + struct linux_platform *platform, EGLDisplay dpy, const struct wcore_config_attrs *attrs, int32_t waffle_gl_api) { bool ok = true; + if (!egl_config_check_context_attrs(platform, attrs)) + return false; + // WARNING: If you resize attrib_list, then update renderable_index. const int renderable_index = 19; diff --git a/src/waffle/egl/egl_no_native.h b/src/waffle/egl/egl_no_native.h index ddb7510..5f79daa 100644 --- a/src/waffle/egl/egl_no_native.h +++ b/src/waffle/egl/egl_no_native.h @@ -41,6 +41,7 @@ egl_terminate(EGLDisplay dpy); EGLConfig egl_choose_config( + struct linux_platform *platform, EGLDisplay dpy, const struct wcore_config_attrs *attrs, int32_t waffle_gl_api); diff --git a/src/waffle/wayland/wayland_config.c b/src/waffle/wayland/wayland_config.c index a706f6b..d6deef2 100644 --- a/src/waffle/wayland/wayland_config.c +++ b/src/waffle/wayland/wayland_config.c @@ -51,7 +51,8 @@ wayland_config_choose( if (!ok) goto error; - self->wl->egl_config = egl_choose_config(dpy->wl->egl_display, + self->wl->egl_config = egl_choose_config(platform->wl->linux_, + dpy->wl->egl_display, attrs, platform->wl->gl_api); if (!self->wl->egl_config) diff --git a/src/waffle/x11_egl/xegl_config.c b/src/waffle/x11_egl/xegl_config.c index 83d7d89..14bac8b 100644 --- a/src/waffle/x11_egl/xegl_config.c +++ b/src/waffle/x11_egl/xegl_config.c @@ -50,7 +50,8 @@ xegl_config_choose( ok &= egl_get_render_buffer_attrib(attrs, &self->xegl->egl_render_buffer); if (!ok) goto error; - self->xegl->egl_config = egl_choose_config(dpy->xegl->egl_display, + self->xegl->egl_config = egl_choose_config(platform->xegl->linux_, + dpy->xegl->egl_display, attrs, platform->xegl->gl_api); if (!self->xegl->egl_config) |