Browse Source

Merge pull request #373 from dgough/master

Fixed EGL setup for Tegra 3 devices.
Darryl Gough 13 năm trước cách đây
mục cha
commit
2ef6add590
1 tập tin đã thay đổi với 13 bổ sung2 xóa
  1. 13 2
      gameplay/src/PlatformAndroid.cpp

+ 13 - 2
gameplay/src/PlatformAndroid.cpp

@@ -93,7 +93,7 @@ static EGLenum checkErrorEGL(const char* msg)
 static bool initEGL()
 static bool initEGL()
 {
 {
     // Hard-coded to 32-bit/OpenGL ES 2.0.
     // Hard-coded to 32-bit/OpenGL ES 2.0.
-    const EGLint eglConfigAttrs[] =
+    EGLint eglConfigAttrs[] =
     {
     {
         EGL_RED_SIZE,           8,
         EGL_RED_SIZE,           8,
         EGL_GREEN_SIZE,         8,
         EGL_GREEN_SIZE,         8,
@@ -135,11 +135,22 @@ static bool initEGL()
             goto error;
             goto error;
         }
         }
     
     
-        if (eglChooseConfig(__eglDisplay, eglConfigAttrs, &__eglConfig, 1, &eglConfigCount) != EGL_TRUE || eglConfigCount == 0)
+        if (eglChooseConfig(__eglDisplay, eglConfigAttrs, &__eglConfig, 1, &eglConfigCount) != EGL_TRUE)
         {
         {
             checkErrorEGL("eglChooseConfig");
             checkErrorEGL("eglChooseConfig");
             goto error;
             goto error;
         }
         }
+        
+        if (eglConfigCount == 0)
+        {
+            // try 16 bit depth buffer instead
+            eglConfigAttrs[9] = 16;
+            if (eglChooseConfig(__eglDisplay, eglConfigAttrs, &__eglConfig, 1, &eglConfigCount) != EGL_TRUE || eglConfigCount == 0)
+            {
+                checkErrorEGL("eglChooseConfig");
+                goto error;
+            }
+        }
     
     
         __eglContext = eglCreateContext(__eglDisplay, __eglConfig, EGL_NO_CONTEXT, eglContextAttrs);
         __eglContext = eglCreateContext(__eglDisplay, __eglConfig, EGL_NO_CONTEXT, eglContextAttrs);
         if (__eglContext == EGL_NO_CONTEXT)
         if (__eglContext == EGL_NO_CONTEXT)