OSDN Git Service

[added] Samsung GT-I5700 fix.
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sun, 12 Dec 2010 22:21:17 +0000 (22:21 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sun, 12 Dec 2010 22:21:17 +0000 (22:21 +0000)
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidGraphics.java
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLBaseSurfaceView.java
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceViewCupcake.java

index 7f2519e..4418f94 100644 (file)
@@ -24,7 +24,9 @@ import javax.microedition.khronos.egl.EGLDisplay;
 import android.app.Activity;\r
 import android.graphics.Bitmap;\r
 import android.graphics.BitmapFactory;\r
+import android.opengl.GLSurfaceView.EGLConfigChooser;\r
 import android.opengl.GLSurfaceView.Renderer;\r
+import android.os.Build;\r
 import android.util.DisplayMetrics;\r
 import android.view.Display;\r
 import android.view.View;\r
@@ -90,23 +92,49 @@ public final class AndroidGraphics implements Graphics, Renderer {
        }\r
 \r
        private View createGLSurfaceView(Activity activity, boolean useGL2) {\r
+               EGLConfigChooser configChooser = getEglConfigChooser();\r
+               \r
                if (useGL2 && checkGL20()) {\r
                        GLSurfaceView20 view = new GLSurfaceView20(activity);\r
                        view.setRenderer(this);\r
+                       if(configChooser != null)\r
+                               view.setEGLConfigChooser(configChooser);\r
                        return view;\r
                } else {\r
                        if (Integer.parseInt(android.os.Build.VERSION.SDK) <= 4) {\r
                                GLSurfaceViewCupcake view = new GLSurfaceViewCupcake(activity);\r
                                view.setRenderer(this);\r
+                               if(configChooser != null)\r
+                                       view.setEGLConfigChooser(configChooser);\r
                                return view;\r
                        } else {\r
                                android.opengl.GLSurfaceView view = new android.opengl.GLSurfaceView(\r
                                                activity);\r
                                view.setRenderer(this);\r
+                               if(configChooser != null)\r
+                                       view.setEGLConfigChooser(configChooser);\r
                                return view;\r
                        }\r
                }\r
-\r
+       }\r
+       \r
+       private EGLConfigChooser getEglConfigChooser() {\r
+               if(!Build.DEVICE.equalsIgnoreCase("GT-I7500"))\r
+                       return null;\r
+               else\r
+                       return new android.opengl.GLSurfaceView.EGLConfigChooser() {\r
+       \r
+                               public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {\r
+       \r
+                                       // Ensure that we get a 16bit depth-buffer. Otherwise, we'll fall\r
+                                       // back to Pixelflinger on some device (read: Samsung I7500)\r
+                                       int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };\r
+                                       EGLConfig[] configs = new EGLConfig[1];\r
+                                       int[] result = new int[1];\r
+                                       egl.eglChooseConfig(display, attributes, configs, 1, result);\r
+                                       return configs[0];\r
+                               }\r
+                       };\r
        }\r
 \r
        private void updatePpi() {\r
index a6ec52f..d034340 100644 (file)
@@ -503,24 +503,6 @@ public class GLBaseSurfaceView extends GLSurfaceView implements SurfaceHolder.Ca
                }\r
        }\r
 \r
-       /**\r
-        * An interface for choosing an EGLConfig configuration from a list of potential configurations.\r
-        * <p>\r
-        * This interface must be implemented by clients wishing to call\r
-        * {@link GLBaseSurfaceView#setEGLConfigChooser(EGLConfigChooser)}\r
-        */\r
-       public interface EGLConfigChooser {\r
-               /**\r
-                * Choose a configuration from the list. Implementors typically implement this method by calling\r
-                * {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the EGL specification available from The\r
-                * Khronos Group to learn how to call eglChooseConfig.\r
-                * @param egl the EGL10 for the current display.\r
-                * @param display the current display.\r
-                * @return the chosen configuration.\r
-                */\r
-               EGLConfig chooseConfig (EGL10 egl, EGLDisplay display);\r
-       }\r
-\r
        private static abstract class BaseConfigChooser implements EGLConfigChooser {\r
                public BaseConfigChooser (int[] configSpec) {\r
                        mConfigSpec = configSpec;\r
index 94ceca3..7ebd5c4 100644 (file)
@@ -27,6 +27,7 @@ import javax.microedition.khronos.opengles.GL;
 import javax.microedition.khronos.opengles.GL10;\r
 \r
 import android.content.Context;\r
+import android.opengl.GLSurfaceView.EGLConfigChooser;\r
 import android.opengl.GLSurfaceView.Renderer;\r
 import android.util.AttributeSet;\r
 import android.util.Log;\r
@@ -446,24 +447,6 @@ public class GLSurfaceViewCupcake extends SurfaceView implements SurfaceHolder.C
                GL wrap (GL gl);\r
        }\r
 \r
-       /**\r
-        * An interface for choosing an EGLConfig configuration from a list of potential configurations.\r
-        * <p>\r
-        * This interface must be implemented by clients wishing to call\r
-        * {@link GLSurfaceViewCupcake#setEGLConfigChooser(EGLConfigChooser)}\r
-        */\r
-       public interface EGLConfigChooser {\r
-               /**\r
-                * Choose a configuration from the list. Implementors typically implement this method by calling\r
-                * {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the EGL specification available from The\r
-                * Khronos Group to learn how to call eglChooseConfig.\r
-                * @param egl the EGL10 for the current display.\r
-                * @param display the current display.\r
-                * @return the chosen configuration.\r
-                */\r
-               EGLConfig chooseConfig (EGL10 egl, EGLDisplay display);\r
-       }\r
-\r
        private static abstract class BaseConfigChooser implements EGLConfigChooser {\r
                public BaseConfigChooser (int[] configSpec) {\r
                        mConfigSpec = configSpec;\r