1+ package dev .abhishekbansal .nexrad ;
2+
3+ import android .app .Activity ;
4+ import android .app .ActivityManager ;
5+ import android .content .Context ;
6+ import android .content .pm .ConfigurationInfo ;
7+ import android .opengl .GLSurfaceView ;
8+ import android .os .Bundle ;
9+
10+
11+ public class LessonOneActivity extends Activity {
12+ /**
13+ * Hold a reference to our GLSurfaceView
14+ */
15+ private GLSurfaceView mGLSurfaceView ;
16+
17+ @ Override
18+ protected void onCreate (Bundle savedInstanceState ) {
19+ super .onCreate (savedInstanceState );
20+ setContentView (R .layout .lesson_one );
21+
22+ mGLSurfaceView = findViewById (R .id .gl_surface_view );
23+
24+ // Check if the system supports OpenGL ES 2.0.
25+ final ActivityManager activityManager = (ActivityManager ) getSystemService (Context .ACTIVITY_SERVICE );
26+ final ConfigurationInfo configurationInfo = activityManager .getDeviceConfigurationInfo ();
27+ final boolean supportsEs2 = configurationInfo .reqGlEsVersion >= 0x20000 ;
28+
29+ if (supportsEs2 ) {
30+ // Request an OpenGL ES 2.0 compatible context.
31+ mGLSurfaceView .setEGLContextClientVersion (2 );
32+
33+ // Set the renderer to our
34+ // demo renderer, defined below.
35+ final LessonOneRenderer renderer = new LessonOneRenderer ();
36+ mGLSurfaceView .setRenderer (renderer );
37+ } else {
38+ // This is where you could create an OpenGL ES 1.x compatible
39+ // renderer if you wanted to support both ES 1 and ES 2.
40+ return ;
41+ }
42+ }
43+
44+ @ Override
45+ protected void onResume () {
46+ // The activity must call the GL surface view's onResume() on activity onResume().
47+ super .onResume ();
48+ mGLSurfaceView .onResume ();
49+ }
50+
51+ @ Override
52+ protected void onPause () {
53+ // The activity must call the GL surface view's onPause() on activity onPause().
54+ super .onPause ();
55+ mGLSurfaceView .onPause ();
56+ }
57+ }
0 commit comments