check_gl: GLESv3 workaround for Mac OS X 10.7 35/20835/1
authorStanislav Vorobiov <s.vorobiov@samsung.com>
Mon, 12 May 2014 13:34:20 +0000 (17:34 +0400)
committerStanislav Vorobiov <s.vorobiov@samsung.com>
Tue, 13 May 2014 06:18:09 +0000 (10:18 +0400)
Mac OS X 10.7 supports OpenGL 3.2, however, it doesn't have
all the necessary functions implemented in order to implement
GLESv3 on target. This workaround checks for some mandatory
functions and if at least one of them is not present - we conclude
that GLESv3 is not supported

Change-Id: I855c5cfbb724b8f43ba00dbfa6f5c30431a91d4b
Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
tizen/src/check_gl_core.c

index b8422c59b75f0194cb7d4f9158dfdd5b2c9b2d02..6e48d66c8c967569175bd0089bdcd4ed12a2827c 100644 (file)
@@ -47,6 +47,16 @@ static const char *gl_version_str[gl_3_2 + 1] =
     "3.2"
 };
 
+static const char *gl_3_2_check_funcs[] =
+{
+    "glGenTransformFeedbacks",
+    "glBindTransformFeedback",
+    "glPauseTransformFeedback",
+    "glResumeTransformFeedback",
+    "glDeleteTransformFeedbacks",
+    "glVertexAttribDivisor"
+};
+
 void check_gl_log(gl_log_level level, const char *format, ...)
 {
     va_list args;
@@ -64,6 +74,7 @@ void check_gl_log(gl_log_level level, const char *format, ...)
 static const GLubyte *(GLAPIENTRY *get_string)(GLenum);
 static const GLubyte *(GLAPIENTRY *get_stringi)(GLenum, GLuint);
 static void (GLAPIENTRY *get_integerv)(GLenum, GLint*);
+static void (GLAPIENTRY *dummy)();
 
 static struct gl_context *check_gl_version(gl_version version)
 {
@@ -131,6 +142,7 @@ int check_gl(void)
     struct gl_context *ctx_3_1;
     struct gl_context *ctx_3_2;
     int have_es3 = 0;
+    int have_es3_compatibility = 0;
     int have_es1 = 0;
 
     if (!check_gl_init()) {
@@ -153,7 +165,25 @@ int check_gl(void)
     }
 
     have_es1 = (ctx_2 != NULL);
-    have_es3 = (ctx_3_2 != NULL);
+
+    if (ctx_3_2) {
+        unsigned int i;
+        int found_all = 1;
+
+        for (i = 0;
+             i < sizeof(gl_3_2_check_funcs)/sizeof(gl_3_2_check_funcs[0]);
+             ++i) {
+            if (!check_gl_procaddr((void**)&dummy, gl_3_2_check_funcs[i], 1) ||
+                !dummy) {
+                found_all = 0;
+                break;
+            }
+        }
+
+        if (found_all) {
+            have_es3 = 1;
+        }
+    }
 
     /*
      * Check if GL_ARB_ES3_compatibility is supported within
@@ -172,6 +202,7 @@ int check_gl(void)
 
             if (strcmp(tmp, "GL_ARB_ES3_compatibility") == 0) {
                 have_es3 = 1;
+                have_es3_compatibility = 1;
                 break;
             }
         }
@@ -183,11 +214,11 @@ int check_gl(void)
      * Check if OpenGL 2.1 contexts can be shared with OpenGL 3.x contexts
      */
 
-    if (ctx_2 && ((ctx_3_1 && have_es3) || ctx_3_2)) {
+    if (ctx_2 && have_es3) {
         struct gl_context *ctx = NULL;
 
-        ctx = check_gl_context_create(((ctx_3_1 && have_es3) ? ctx_3_1
-                                                             : ctx_3_2),
+        ctx = check_gl_context_create(((ctx_3_1 && have_es3_compatibility) ? ctx_3_1
+                                                                           : ctx_3_2),
                                       gl_2);
 
         if (ctx) {