Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Cleaned up OpenGL initialization a bit so we fail if we can't create …

…a surface.
  • Loading branch information
slouken committed Nov 4, 2012
1 parent e352c35 commit dfa933651f7827bf1674b83d857b254893d848e9
Showing with 13 additions and 22 deletions.
  1. +13 −22 android-project/src/org/libsdl/app/SDLActivity.java
@@ -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);
@@ -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() {
@@ -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

0 comments on commit dfa9336

Please sign in to comment.