@@ -29,21 +29,39 @@ public class BaseEGLConfigChooser implements EGLConfigChooser {
2929 private static final LogContext LCTX = LogManager .root ().lctx ("GLConfiguration" );
3030
3131 private final int mConfigSpec [] = new int [] { EGL10 .EGL_RED_SIZE , 5 , EGL10 .EGL_GREEN_SIZE , 6 , EGL10 .EGL_BLUE_SIZE ,
32- 5 , EGL10 .EGL_ALPHA_SIZE , 0 , EGL10 .EGL_STENCIL_SIZE , GLConfiguration . stencilRequired ? 1 : 0 , EGL10 .EGL_NONE };
32+ 5 , EGL10 .EGL_ALPHA_SIZE , 0 , EGL10 .EGL_STENCIL_SIZE , 1 , EGL10 .EGL_NONE };
3333
3434 private static final int [] ATTR_ID = { EGL10 .EGL_RED_SIZE , EGL10 .EGL_GREEN_SIZE , EGL10 .EGL_BLUE_SIZE ,
3535 EGL10 .EGL_ALPHA_SIZE , EGL10 .EGL_DEPTH_SIZE , EGL10 .EGL_STENCIL_SIZE , EGL10 .EGL_CONFIG_ID ,
3636 EGL10 .EGL_CONFIG_CAVEAT };
3737
3838 private static final String [] ATTR_NAME = { "R" , "G" , "B" , "A" , "D" , "S" , "ID" , "CAVEAT" };
3939
40+ private void setConfigValue (int key , int value ) {
41+ for (int i = 0 ; i < mConfigSpec .length ; i += 2 ) {
42+ if (mConfigSpec [i ] == key ) {
43+ mConfigSpec [i + 1 ] = value ;
44+ break ;
45+ }
46+ }
47+ }
48+
4049 @ Override
4150 public EGLConfig chooseConfig (final EGL10 egl , final EGLDisplay display ) {
4251 final int [] numConfig = new int [1 ];
4352 if (!egl .eglChooseConfig (display , mConfigSpec , null , 0 , numConfig )) {
4453 throw new RuntimeException ("eglChooseConfig failed" );
4554 }
4655
56+ if (numConfig [0 ] <= 0 ) {
57+ LCTX .i ("No configurations found. Trying EGL_STENCIL_SIZE 0" );
58+ setConfigValue (EGL10 .EGL_STENCIL_SIZE , 0 );
59+
60+ if (!egl .eglChooseConfig (display , mConfigSpec , null , 0 , numConfig )) {
61+ throw new RuntimeException ("eglChooseConfig failed" );
62+ }
63+ }
64+
4765 if (numConfig [0 ] <= 0 ) {
4866 throw new RuntimeException ("Your device cannot support required GLES configuration" );
4967 }
0 commit comments