Cleaned up OpenGL initialization a bit so we fail if we can't create a surface.
authorSam Lantinga <slouken@libsdl.org>
Sun, 04 Nov 2012 08:51:43 -0800
changeset 66453f83af6d119c
parent 6644 eacc8b228cef
child 6646 dd32cce44d3c
Cleaned up OpenGL initialization a bit so we fail if we can't create a surface.
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Sat Nov 03 22:46:03 2012 -0400
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sun Nov 04 08:51:43 2012 -0800
     1.3 @@ -268,10 +268,10 @@
     1.4  
     1.5      // EGL functions
     1.6      public static boolean initEGL(int majorVersion, int minorVersion) {
     1.7 -        if (SDLActivity.mEGLDisplay == null) {
     1.8 -            //Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion);
     1.9 +        try {
    1.10 +            if (SDLActivity.mEGLDisplay == null) {
    1.11 +                Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion);
    1.12  
    1.13 -            try {
    1.14                  EGL10 egl = (EGL10)EGLContext.getEGL();
    1.15  
    1.16                  EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    1.17 @@ -300,31 +300,20 @@
    1.18                  }
    1.19                  EGLConfig config = configs[0];
    1.20  
    1.21 -                /*int EGL_CONTEXT_CLIENT_VERSION=0x3098;
    1.22 -                int contextAttrs[] = new int[] { EGL_CONTEXT_CLIENT_VERSION, majorVersion, EGL10.EGL_NONE };
    1.23 -                EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, contextAttrs);
    1.24 -
    1.25 -                if (ctx == EGL10.EGL_NO_CONTEXT) {
    1.26 -                    Log.e("SDL", "Couldn't create context");
    1.27 -                    return false;
    1.28 -                }
    1.29 -                SDLActivity.mEGLContext = ctx;*/
    1.30                  SDLActivity.mEGLDisplay = dpy;
    1.31                  SDLActivity.mEGLConfig = config;
    1.32                  SDLActivity.mGLMajor = majorVersion;
    1.33                  SDLActivity.mGLMinor = minorVersion;
    1.34 +            }
    1.35 +            return SDLActivity.createEGLSurface();
    1.36  
    1.37 -                SDLActivity.createEGLSurface();
    1.38 -            } catch(Exception e) {
    1.39 -                Log.v("SDL", e + "");
    1.40 -                for (StackTraceElement s : e.getStackTrace()) {
    1.41 -                    Log.v("SDL", s.toString());
    1.42 -                }
    1.43 +        } catch(Exception e) {
    1.44 +            Log.v("SDL", e + "");
    1.45 +            for (StackTraceElement s : e.getStackTrace()) {
    1.46 +                Log.v("SDL", s.toString());
    1.47              }
    1.48 +            return false;
    1.49          }
    1.50 -        else SDLActivity.createEGLSurface();
    1.51 -
    1.52 -        return true;
    1.53      }
    1.54  
    1.55      public static boolean createEGLContext() {
    1.56 @@ -364,8 +353,10 @@
    1.57              }
    1.58              SDLActivity.mEGLSurface = surface;
    1.59              return true;
    1.60 +        } else {
    1.61 +            Log.e("SDL", "Surface creation failed, display = " + SDLActivity.mEGLDisplay + ", config = " + SDLActivity.mEGLConfig);
    1.62 +            return false;
    1.63          }
    1.64 -        return false;
    1.65      }
    1.66  
    1.67      // EGL buffer flip