Android examples for android.opengl:OpenGL
initialize OpenGL app
//package com.java2s; import android.app.ActivityManager; import android.content.Context; import android.content.pm.ConfigurationInfo; import android.opengl.GLSurfaceView; import android.opengl.GLSurfaceView.Renderer; import android.os.Build; public class Main { public static GLSurfaceView initGLapp(Context ctx, Renderer rnd) { GLSurfaceView glSurfaceView = new GLSurfaceView(ctx); final ActivityManager activityManager = (ActivityManager) ctx .getSystemService(Context.ACTIVITY_SERVICE); final ConfigurationInfo configurationInfo = activityManager .getDeviceConfigurationInfo(); final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000 || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && (Build.FINGERPRINT .startsWith("generic") || Build.FINGERPRINT.startsWith("unknown") || Build.MODEL.contains("google_sdk") || Build.MODEL.contains("Emulator") || Build.MODEL .contains("Android SDK built for x86"))); if (supportsEs2) { // Request an OpenGL ES 2.0 compatible context. glSurfaceView.setEGLContextClientVersion(2); glSurfaceView.setRenderer(rnd); return glSurfaceView; } else {/*from w w w . j av a 2s . c om*/ return null; } } }