Browse Source

Fix red screen issue on affected Android devices models, e.g. S3.

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
75c1d9780c
1 changed files with 26 additions and 0 deletions
  1. 26 0
      Source/ThirdParty/SDL/src/video/android/SDL_androidvideo.c

+ 26 - 0
Source/ThirdParty/SDL/src/video/android/SDL_androidvideo.c

@@ -163,6 +163,32 @@ Android_VideoInit(_THIS)
     mode.h = Android_ScreenHeight;
     mode.refresh_rate = 0;
     mode.driverdata = NULL;
+
+    // Urho3D: merge patch found in https://bugzilla.libsdl.org/show_bug.cgi?id=2291 submitted by Thomas Faller
+    SDL_PixelFormat pixelFormat;
+    Uint32 mask;
+    int bitCount;
+
+    /* We need to set color sizes */
+    if(!SDL_InitFormat(&pixelFormat, mode.format)){
+        for(mask = pixelFormat.Rmask >> pixelFormat.Rshift,
+            bitCount = 0; mask > 0; mask >>= 1)
+            bitCount += 1;
+        SDL_GL_SetAttribute(SDL_GL_RED_SIZE, bitCount);
+        for(mask = pixelFormat.Gmask >> pixelFormat.Gshift,
+            bitCount = 0; mask > 0; mask >>= 1)
+            bitCount += 1;
+        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, bitCount);
+        for(mask = pixelFormat.Bmask >> pixelFormat.Bshift,
+            bitCount = 0; mask > 0; mask >>= 1)
+            bitCount += 1;
+        SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, bitCount);
+        for(mask = pixelFormat.Amask >> pixelFormat.Ashift,
+            bitCount = 0; mask > 0; mask >>= 1)
+            bitCount += 1;
+        SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, bitCount);
+    }
+
     if (SDL_AddBasicVideoDisplay(&mode) < 0) {
         return -1;
     }