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
}\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
}\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
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
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