diff options
-rw-r--r-- | opengl/libs/EGL/egl.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp index de740a3..eeb587a 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.cpp @@ -42,6 +42,14 @@ #include "egl_impl.h" #include "Loader.h" +// Enable this define to allow querying vendor-specific GL extensions. This +// currently will only work correctly for implementations which have a single +// EGL backend; multiple EGL backends are not supported. +// There's also an extra subtlety with the EGLimage entry points in GL, which +// can't work properly if they're called directly (they have to go through +// a wrapper). +#define ENABLE_VENDOR_EXTENSIONS + #define MAKE_CONFIG(_impl, _index) ((EGLConfig)(((_impl)<<24) | (_index))) #define setError(_e, _r) setErrorEtc(__FUNCTION__, __LINE__, _e, _r) @@ -58,6 +66,11 @@ static char const * const gExtensionString = "EGL_KHR_image " "EGL_KHR_image_base " "EGL_KHR_image_pixmap " +#ifdef ENABLE_VENDOR_EXTENSIONS + "EGL_KHR_gl_texture_2D_image " + "EGL_KHR_gl_texture_cubemap_image " + "EGL_KHR_gl_renderbuffer_image " +#endif "EGL_ANDROID_image_native_buffer " "EGL_ANDROID_swap_rectangle " "EGL_ANDROID_get_render_buffer " @@ -1315,6 +1328,31 @@ EGLint eglGetError(void) return result; } +#ifdef ENABLE_VENDOR_EXTENSIONS +// Note: Similar implementations of this function also exist in gl2.cpp and +// gl.cpp, and are used by applications that call the exported entry points +// directly. +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); + +static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_impl = NULL; +static PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES_impl = NULL; + +static void glEGLImageTargetTexture2DOES_wrapper(GLenum target, GLeglImageOES image) +{ + GLeglImageOES implImage = + (GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image); + glEGLImageTargetTexture2DOES_impl(target, implImage); +} + +static void glEGLImageTargetRenderbufferStorageOES_wrapper(GLenum target, GLeglImageOES image) +{ + GLeglImageOES implImage = + (GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image); + glEGLImageTargetRenderbufferStorageOES_impl(target, implImage); +} +#endif + __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) { // eglGetProcAddress() could be the very first function called @@ -1330,6 +1368,30 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) addr = findProcAddress(procname, gExtentionMap, NELEM(gExtentionMap)); if (addr) return addr; +#ifdef ENABLE_VENDOR_EXTENSIONS + addr = 0; + for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) { + egl_connection_t* const cnx = &gEGLImpl[i]; + if (cnx->dso) { + if (cnx->egl.eglGetProcAddress) { + addr = cnx->egl.eglGetProcAddress(procname); + if (addr) { + if (!strcmp(procname, "glEGLImageTargetTexture2DOES")) { + glEGLImageTargetTexture2DOES_impl = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)addr; + return (__eglMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES_wrapper; + } + if (!strcmp(procname, "glEGLImageTargetRenderbufferStorageOES")) { + glEGLImageTargetRenderbufferStorageOES_impl = (PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)addr; + return (__eglMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES_wrapper; + } + + return addr; + } + } + } + } +#endif + return NULL; // TODO: finish implementation below addr = findProcAddress(procname, gGLExtentionMap, NELEM(gGLExtentionMap)); |