Added check for GLES2

This commit is contained in:
codeanticode
2012-01-30 21:03:40 +00:00
parent 5f29531a46
commit 22077aaa36
2 changed files with 17 additions and 5 deletions
@@ -29,6 +29,7 @@ import java.io.UnsupportedEncodingException;
import android.content.*;
import android.content.pm.ActivityInfo;
import android.content.pm.ConfigurationInfo;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.graphics.*;
@@ -44,6 +45,7 @@ import java.util.regex.*;
import java.util.zip.*;
import android.app.Activity;
import android.app.ActivityManager;
import android.net.Uri;
import android.text.format.Time;
import android.util.*;
@@ -784,6 +786,17 @@ public class PApplet extends Activity implements PConstants, Runnable {
public SketchSurfaceView3D(Context context, int wide, int high) {
super(context);
// Check if the system supports OpenGL ES 2.0.
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
if (!supportsEs2) {
throw new RuntimeException("GLES2 NOT SUPPORTED!!!");
}
surfaceHolder = getHolder();
// are these two needed?
surfaceHolder.addCallback(this);
+4 -5
View File
@@ -1620,13 +1620,13 @@ public class PGL {
* minimum size of 4 bits for red/green/blue, but will perform actual
* matching in chooseConfig() below.
*/
private int EGL_OPENGL_ES_BIT = 0x01; // EGL 1.x attribute value for
// private int EGL_OPENGL_ES_BIT = 0x01; // EGL 1.x attribute value for
// GL_RENDERABLE_TYPE.
// private int EGL_OPENGL_ES2_BIT = 0x04; // EGL 2.x attribute value for
private int EGL_OPENGL_ES2_BIT = 0x04; // EGL 2.x attribute value for
// GL_RENDERABLE_TYPE.
private int[] configAttribsGL = { EGL10.EGL_RED_SIZE, 4,
EGL10.EGL_GREEN_SIZE, 4, EGL10.EGL_BLUE_SIZE, 4,
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL10.EGL_NONE };
public AndroidConfigChooser(int r, int g, int b, int a, int d, int s) {
@@ -1667,8 +1667,7 @@ public class PGL {
return chooseBestConfig(egl, display, configs);
}
public EGLConfig chooseBestConfig(EGL10 egl, EGLDisplay display,
EGLConfig[] configs) {
public EGLConfig chooseBestConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
EGLConfig bestConfig = null;
float bestScore = 1000;