Set up the OpenGL ES environment
Our first recipe will start by showing the steps to set up an activity to use an OpenGL GLSurfaceView
. Similar to the Canvas, the GLSurfaceView
is where your will perform your OpenGL drawing. As this is the starting point, the other recipes will refer to this recipe as the base step when they need a GLSurfaceView
created.
Getting ready
Create a new project in Android Studio and call it: SetupOpenGL
. Use the default Phone & Tablet options and select Empty Activity when prompted for Activity Type.
How to do it...
We'll start by indicating the application's use of OpenGL in the Android Manifest, and then we'll add the OpenGL classes to the activity. Here are the steps:
Open the Android Manifest and add the following XML:
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Open
MainActivity.java
and add the following global variables:private GLSurfaceView mGLSurfaceView;
Add the following inner class to the
MainActivity
class:class CustomGLSurfaceView...