diff options
author | Frank Binns <frank.binns@imgtec.com> | 2012-06-29 14:06:27 +0100 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-06-29 12:25:53 -0400 |
commit | 43c2122af1caa750531f29bf734c03d1f50801d1 (patch) | |
tree | 57e7950f2d789910e5d90700ceb6372e922eff95 | |
parent | 7ba23583b237d4c07823006ef35dca434ebd5759 (diff) |
xeglgears: Make EGL_KHR_image usage portable
EGL extension functions don't have to be exported which means
xeglgears was failing to link against implementations that
support EGL_KHR_image but were not exporting its related functions.
This has been fixed by using eglGetProcAddress to get a function
pointer instead of using the functions prototype. This is portable.
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
-rw-r--r-- | src/egl/opengl/xeglgears.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/egl/opengl/xeglgears.c b/src/egl/opengl/xeglgears.c index 513c587f..866b89a8 100644 --- a/src/egl/opengl/xeglgears.c +++ b/src/egl/opengl/xeglgears.c @@ -51,6 +51,10 @@ static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_func; #endif +#ifdef EGL_KHR_image +static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR_func; +#endif + #define BENCHMARK @@ -405,6 +409,17 @@ egl_manager_new(EGLNativeDisplayType xdpy, const EGLint *attrib_list, eglGetProcAddress("glEGLImageTargetTexture2DOES"); #endif +#ifdef EGL_KHR_image + eglCreateImageKHR_func = (PFNEGLCREATEIMAGEKHRPROC) + eglGetProcAddress("eglCreateImageKHR"); + if (eglCreateImageKHR_func == NULL) { + printf("failed to get eglCreateImageKHR\n"); + eglTerminate(eman->dpy); + free(eman); + return NULL; + } +#endif + return eman; } @@ -850,10 +865,16 @@ main(int argc, char *argv[]) case GEARS_PIXMAP: case GEARS_PIXMAP_TEXTURE: ret = egl_manager_create_pixmap(eman, eman->xwin, EGL_TRUE, NULL); + +#ifdef EGL_KHR_image if (surface_type == GEARS_PIXMAP_TEXTURE) - eman->image = eglCreateImageKHR (eman->dpy, eman->ctx, - EGL_NATIVE_PIXMAP_KHR, - (EGLClientBuffer) eman->xpix, NULL); + eman->image = eglCreateImageKHR_func(eman->dpy, eman->ctx, + EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer) eman->xpix, NULL); +#else + fprintf(stderr, "EGL_KHR_image not found at compile time.\n"); +#endif + if (ret) ret = eglMakeCurrent(eman->dpy, eman->pix, eman->pix, eman->ctx); break; @@ -892,9 +913,13 @@ main(int argc, char *argv[]) GL_RENDERBUFFER_EXT, color_rb); - eman->image = eglCreateImageKHR(eman->dpy, eman->ctx, - EGL_GL_RENDERBUFFER_KHR, - (EGLClientBuffer) color_rb, NULL); +#ifdef EGL_KHR_image + eman->image = eglCreateImageKHR_func(eman->dpy, eman->ctx, + EGL_GL_RENDERBUFFER_KHR, + (EGLClientBuffer) color_rb, NULL); +#else + fprintf(stderr, "EGL_KHR_image not found at compile time.\n"); +#endif glGenRenderbuffers(1, &depth_rb); glBindRenderbuffer(GL_RENDERBUFFER_EXT, depth_rb); |