diff options
Diffstat (limited to 'libEGL_POWERVR/egl.c')
-rw-r--r-- | libEGL_POWERVR/egl.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libEGL_POWERVR/egl.c b/libEGL_POWERVR/egl.c index b5ebeca..78ee97d 100644 --- a/libEGL_POWERVR/egl.c +++ b/libEGL_POWERVR/egl.c @@ -37,6 +37,49 @@ EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) { + /* When the following conditions are met... + * 1. EGL_PBUFFER_BIT is set in EGL_SURFACE_TYPE + * 2. EGL_OPENGL_ES2_BIT is set in EGL_RENDERABLE_TYPE + * ...EGL_RECORDABLE_ANDROID is forced to EGL_FALSE. + * Why this happens is unknown, but the end result is no configs get returned. + * Code meeting the above conditions seems to work fine without EGL_RECORDABLE_ANDROID, + * so in this shim we'll drop it on their behalf so they actually get an EGLConfig. + */ + bool renderable_type_es2 = false, surface_type_pbuffer = false; + int i, j, attriblist_length = 0, recordable_attrib_pos = -1; + + while( attrib_list[attriblist_length++] != EGL_NONE ) + { + if( attrib_list[attriblist_length-1] == EGL_SURFACE_TYPE && (attrib_list[attriblist_length] & EGL_PBUFFER_BIT) != 0 ) + { + surface_type_pbuffer = true; + } + else if( attrib_list[attriblist_length-1] == EGL_RENDERABLE_TYPE && (attrib_list[attriblist_length] & EGL_OPENGL_ES2_BIT) != 0 ) + { + renderable_type_es2 = true; + } + else if( attrib_list[attriblist_length-1] == EGL_RECORDABLE_ANDROID && attrib_list[attriblist_length] == EGL_TRUE ) + { + recordable_attrib_pos = attriblist_length - 1; + } + ++attriblist_length; + } + + if( recordable_attrib_pos != -1 && surface_type_pbuffer && renderable_type_es2 ) + { + EGLint override_attrib_list[attriblist_length-2]; + + for( i = 0, j = 0; i < attriblist_length; ++i ) + { + if( i != recordable_attrib_pos && i != recordable_attrib_pos + 1 ) + { + override_attrib_list[j++] = attrib_list[i]; + } + } + + return IMGeglChooseConfig(dpy, override_attrib_list, configs, config_size, num_config); + } + return IMGeglChooseConfig(dpy, attrib_list, configs, config_size, num_config); } |