From 75a51857e1cdf2caf579f1bbd908aefa045697a2 Mon Sep 17 00:00:00 2001 From: badlogicgames Date: Sun, 12 Dec 2010 22:21:17 +0000 Subject: [PATCH] [added] Samsung GT-I5700 fix. --- .../gdx/backends/android/AndroidGraphics.java | 30 +++++++++++++++++++++- .../android/surfaceview/GLBaseSurfaceView.java | 18 ------------- .../android/surfaceview/GLSurfaceViewCupcake.java | 19 +------------- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidGraphics.java b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidGraphics.java index 7f2519e0a..4418f9440 100644 --- a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidGraphics.java +++ b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidGraphics.java @@ -24,7 +24,9 @@ import javax.microedition.khronos.egl.EGLDisplay; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.opengl.GLSurfaceView.EGLConfigChooser; import android.opengl.GLSurfaceView.Renderer; +import android.os.Build; import android.util.DisplayMetrics; import android.view.Display; import android.view.View; @@ -90,23 +92,49 @@ public final class AndroidGraphics implements Graphics, Renderer { } private View createGLSurfaceView(Activity activity, boolean useGL2) { + EGLConfigChooser configChooser = getEglConfigChooser(); + if (useGL2 && checkGL20()) { GLSurfaceView20 view = new GLSurfaceView20(activity); view.setRenderer(this); + if(configChooser != null) + view.setEGLConfigChooser(configChooser); return view; } else { if (Integer.parseInt(android.os.Build.VERSION.SDK) <= 4) { GLSurfaceViewCupcake view = new GLSurfaceViewCupcake(activity); view.setRenderer(this); + if(configChooser != null) + view.setEGLConfigChooser(configChooser); return view; } else { android.opengl.GLSurfaceView view = new android.opengl.GLSurfaceView( activity); view.setRenderer(this); + if(configChooser != null) + view.setEGLConfigChooser(configChooser); return view; } } - + } + + private EGLConfigChooser getEglConfigChooser() { + if(!Build.DEVICE.equalsIgnoreCase("GT-I7500")) + return null; + else + return new android.opengl.GLSurfaceView.EGLConfigChooser() { + + public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { + + // Ensure that we get a 16bit depth-buffer. Otherwise, we'll fall + // back to Pixelflinger on some device (read: Samsung I7500) + int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE }; + EGLConfig[] configs = new EGLConfig[1]; + int[] result = new int[1]; + egl.eglChooseConfig(display, attributes, configs, 1, result); + return configs[0]; + } + }; } private void updatePpi() { diff --git a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLBaseSurfaceView.java b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLBaseSurfaceView.java index a6ec52faf..d034340a3 100644 --- a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLBaseSurfaceView.java +++ b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLBaseSurfaceView.java @@ -503,24 +503,6 @@ public class GLBaseSurfaceView extends GLSurfaceView implements SurfaceHolder.Ca } } - /** - * An interface for choosing an EGLConfig configuration from a list of potential configurations. - *

- * This interface must be implemented by clients wishing to call - * {@link GLBaseSurfaceView#setEGLConfigChooser(EGLConfigChooser)} - */ - public interface EGLConfigChooser { - /** - * Choose a configuration from the list. Implementors typically implement this method by calling - * {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the EGL specification available from The - * Khronos Group to learn how to call eglChooseConfig. - * @param egl the EGL10 for the current display. - * @param display the current display. - * @return the chosen configuration. - */ - EGLConfig chooseConfig (EGL10 egl, EGLDisplay display); - } - private static abstract class BaseConfigChooser implements EGLConfigChooser { public BaseConfigChooser (int[] configSpec) { mConfigSpec = configSpec; diff --git a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceViewCupcake.java b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceViewCupcake.java index 94ceca37e..7ebd5c4b1 100644 --- a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceViewCupcake.java +++ b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/surfaceview/GLSurfaceViewCupcake.java @@ -27,6 +27,7 @@ import javax.microedition.khronos.opengles.GL; import javax.microedition.khronos.opengles.GL10; import android.content.Context; +import android.opengl.GLSurfaceView.EGLConfigChooser; import android.opengl.GLSurfaceView.Renderer; import android.util.AttributeSet; import android.util.Log; @@ -446,24 +447,6 @@ public class GLSurfaceViewCupcake extends SurfaceView implements SurfaceHolder.C GL wrap (GL gl); } - /** - * An interface for choosing an EGLConfig configuration from a list of potential configurations. - *

- * This interface must be implemented by clients wishing to call - * {@link GLSurfaceViewCupcake#setEGLConfigChooser(EGLConfigChooser)} - */ - public interface EGLConfigChooser { - /** - * Choose a configuration from the list. Implementors typically implement this method by calling - * {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the EGL specification available from The - * Khronos Group to learn how to call eglChooseConfig. - * @param egl the EGL10 for the current display. - * @param display the current display. - * @return the chosen configuration. - */ - EGLConfig chooseConfig (EGL10 egl, EGLDisplay display); - } - private static abstract class BaseConfigChooser implements EGLConfigChooser { public BaseConfigChooser (int[] configSpec) { mConfigSpec = configSpec; -- 2.11.0