
Android Application Development Cookbook
By :

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.
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.
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...
Change the font size
Change margin width
Change background colour