diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2012-05-17 09:37:59 -0700 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2012-05-17 11:41:09 -0700 |
commit | 65ec176e89a4f3b615ba102f1734449aa22eca3e (patch) | |
tree | 4d5ea32a67c3120a144372217be87299eba064d0 | |
parent | 78db2440dba63400f5ce6bef295f4f412005e788 (diff) | |
download | waffle-65ec176e89a4f3b615ba102f1734449aa22eca3e.tar.gz |
egl: Call eglBindAPI during context creation
Now we can create an EGL context of arbitrary flavor without
reinitializing Waffle.
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r-- | src/waffle/egl/egl_no_native.c | 20 | ||||
-rw-r--r-- | src/waffle/egl/egl_no_native.h | 3 | ||||
-rw-r--r-- | src/waffle/wayland/wayland_platform.c | 5 | ||||
-rw-r--r-- | src/waffle/x11_egl/xegl_platform.c | 5 |
4 files changed, 13 insertions, 20 deletions
diff --git a/src/waffle/egl/egl_no_native.c b/src/waffle/egl/egl_no_native.c index 1719cc0..4269737 100644 --- a/src/waffle/egl/egl_no_native.c +++ b/src/waffle/egl/egl_no_native.c @@ -197,21 +197,22 @@ egl_destroy_surface( return ok; } -bool -egl_bind_api(int32_t waffle_gl_api) +static bool +egl_bind_api(int32_t waffle_context_api) { bool ok = true; - switch (waffle_gl_api) { - case WAFFLE_OPENGL: + switch (waffle_context_api) { + case WAFFLE_CONTEXT_OPENGL: ok &= eglBindAPI(EGL_OPENGL_API); break; - case WAFFLE_OPENGL_ES1: - case WAFFLE_OPENGL_ES2: + case WAFFLE_CONTEXT_OPENGL_ES1: + case WAFFLE_CONTEXT_OPENGL_ES2: ok &= eglBindAPI(EGL_OPENGL_ES_API); break; default: - wcore_error_internal("gl_api has bad value 0x%x", waffle_gl_api); + wcore_error_internal("waffle_context_api has bad value #x%x", + waffle_context_api); return false; } @@ -227,6 +228,7 @@ egl_create_context( EGLContext share_context, int32_t waffle_context_api) { + bool ok = true; EGLint attrib_list[3]; switch (waffle_context_api) { @@ -249,6 +251,10 @@ egl_create_context( return EGL_NO_CONTEXT; } + ok = egl_bind_api(waffle_context_api); + if (!ok) + return false; + EGLContext ctx = eglCreateContext(dpy, config, share_context, attrib_list); if (!ctx) egl_get_error("eglCreateContext"); diff --git a/src/waffle/egl/egl_no_native.h b/src/waffle/egl/egl_no_native.h index d6f2b04..65a6b15 100644 --- a/src/waffle/egl/egl_no_native.h +++ b/src/waffle/egl/egl_no_native.h @@ -50,9 +50,6 @@ egl_destroy_surface( EGLDisplay dpy, EGLSurface surface); -bool -egl_bind_api(int32_t waffle_gl_api); - EGLContext egl_create_context( EGLDisplay dpy, diff --git a/src/waffle/wayland/wayland_platform.c b/src/waffle/wayland/wayland_platform.c index a2345e1..05dddb8 100644 --- a/src/waffle/wayland/wayland_platform.c +++ b/src/waffle/wayland/wayland_platform.c @@ -60,8 +60,6 @@ wayland_platform_create( int gl_api, const struct native_dispatch **dispatch) { - bool ok = true; - union native_platform *self; NATIVE_ALLOC(self, wl); if (!self) { @@ -85,9 +83,6 @@ wayland_platform_create( goto error; setenv("EGL_PLATFORM", "wayland", true); - ok &= egl_bind_api(gl_api); - if (!ok) - goto error; *dispatch = &wayland_dispatch; return self; diff --git a/src/waffle/x11_egl/xegl_platform.c b/src/waffle/x11_egl/xegl_platform.c index d206d04..2431de2 100644 --- a/src/waffle/x11_egl/xegl_platform.c +++ b/src/waffle/x11_egl/xegl_platform.c @@ -60,8 +60,6 @@ xegl_platform_create( int gl_api, const struct native_dispatch **dispatch) { - bool ok = true; - union native_platform *self; NATIVE_ALLOC(self, xegl); if (!self) { @@ -85,9 +83,6 @@ xegl_platform_create( goto error; setenv("EGL_PLATFORM", "x11", true); - ok &= egl_bind_api(gl_api); - if (!ok) - goto error; *dispatch = &xegl_dispatch; return self; |