package edu.cs4730.opengl3ex2; import android.app.Activity; import android.app.ActivityManager; import android.content.Context; import android.content.pm.ConfigurationInfo; import android.os.Bundle; import android.util.Log; /* * simple example where the GLSurfaceView is an extended class and the bulk * of the code is in there and the render of course. * * Note, there is no xml layout for this example. It's all done in onCreate, myGlSurfaceView and the render. * * The render is from http://www.learnopengles.com/android-lesson-one-getting-started/ with GLES 3.0 mods. */ public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if ( detectOpenGLES30() ) { //so we know it a opengl 3.0 and use our extended GLsurfaceview. setContentView(new myGlSurfaceView(this)); } else { // This is where you could create an OpenGL ES 2.0 and/or 1.x compatible // renderer if you wanted to support both ES 1 and ES 2. Log.e("HelloTriangle", "OpenGL ES 3.0 not supported on device. Exiting..."); finish(); } } private boolean detectOpenGLES30() { ActivityManager am = ( ActivityManager ) getSystemService ( Context.ACTIVITY_SERVICE ); ConfigurationInfo info = am.getDeviceConfigurationInfo(); return ( info.reqGlEsVersion >= 0x30000 ); } }