Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Cleaned up OpenGL initialization a bit so we fail if we can't create …
Browse files Browse the repository at this point in the history
…a surface.
  • Loading branch information
slouken committed Nov 4, 2012
1 parent e352c35 commit dfa9336
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions android-project/src/org/libsdl/app/SDLActivity.java
Expand Up @@ -268,10 +268,10 @@ public static void showTextInput(int x, int y, int w, int h) {

// EGL functions
public static boolean initEGL(int majorVersion, int minorVersion) {
if (SDLActivity.mEGLDisplay == null) {
//Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion);
try {
if (SDLActivity.mEGLDisplay == null) {
Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion);

try {
EGL10 egl = (EGL10)EGLContext.getEGL();

EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
Expand Down Expand Up @@ -300,31 +300,20 @@ public static boolean initEGL(int majorVersion, int minorVersion) {
}
EGLConfig config = configs[0];

/*int EGL_CONTEXT_CLIENT_VERSION=0x3098;
int contextAttrs[] = new int[] { EGL_CONTEXT_CLIENT_VERSION, majorVersion, EGL10.EGL_NONE };
EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, contextAttrs);
if (ctx == EGL10.EGL_NO_CONTEXT) {
Log.e("SDL", "Couldn't create context");
return false;
}
SDLActivity.mEGLContext = ctx;*/
SDLActivity.mEGLDisplay = dpy;
SDLActivity.mEGLConfig = config;
SDLActivity.mGLMajor = majorVersion;
SDLActivity.mGLMinor = minorVersion;
}
return SDLActivity.createEGLSurface();

SDLActivity.createEGLSurface();
} catch(Exception e) {
Log.v("SDL", e + "");
for (StackTraceElement s : e.getStackTrace()) {
Log.v("SDL", s.toString());
}
} catch(Exception e) {
Log.v("SDL", e + "");
for (StackTraceElement s : e.getStackTrace()) {
Log.v("SDL", s.toString());
}
return false;
}
else SDLActivity.createEGLSurface();

return true;
}

public static boolean createEGLContext() {
Expand Down Expand Up @@ -364,8 +353,10 @@ public static boolean createEGLSurface() {
}
SDLActivity.mEGLSurface = surface;
return true;
} else {
Log.e("SDL", "Surface creation failed, display = " + SDLActivity.mEGLDisplay + ", config = " + SDLActivity.mEGLConfig);
return false;
}
return false;
}

// EGL buffer flip
Expand Down

0 comments on commit dfa9336

Please sign in to comment.