Displaying graphics with EGL
Besides the GLSurfaceView
display mechanism we
described in the previous recipe, it is also possible to display OpenGL graphics using EGL.
Getting ready
Readers are recommended to read the Drawing 3D Graphics and Lighting up the Scene with OpenGL ES 1.x API recipe before going through this one.
How to do it...
The following steps describe how to create an Android project that demonstrates the usage of EGL:
Create an Android application named
EGLDemo
. Set the package name ascookbook.chapter4.egl
. Please refer to the Loading native libraries and registering native methods recipe in Chapter 2, Java Native Interface, if you want more detailed instructions.Right-click on the project
EGLDemo
, select Android Tools | Add Native Support.Add two Java files, namely
EGLDemoActivity.java
andMySurfaceView.java
.EGLDemoActivity.java
setsContentView
as an instance ofMySurfaceView
, and starts and stops rendering at the Android activity callback functions:… … public void onCreate...