summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libEGL_POWERVR/egl.c43
-rw-r--r--libEGL_POWERVR/egl.h12
2 files changed, 55 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);
}
diff --git a/libEGL_POWERVR/egl.h b/libEGL_POWERVR/egl.h
index d4e91c5..b8f5fd3 100644
--- a/libEGL_POWERVR/egl.h
+++ b/libEGL_POWERVR/egl.h
@@ -2,12 +2,24 @@
#define __PVREGL_H__
#include <stdint.h>
+#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
+#define EGL_FALSE 0
+#define EGL_TRUE 1
+
+#define EGL_SURFACE_TYPE 0x3033
+#define EGL_NONE 0x3038
+#define EGL_RENDERABLE_TYPE 0x3040
+#define EGL_RECORDABLE_ANDROID 0x3142
+
+#define EGL_PBUFFER_BIT 0x0001
+#define EGL_OPENGL_ES2_BIT 0x0004
+
typedef int32_t EGLint;
typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum;