Drawing 2D Graphics and applying transforms with the OpenGL ES 1.x API
This recipe covers 2D drawing in OpenGL ES 1.x by example.
In order to draw 2D objects, we'll also describe the OpenGL rendering display through GLSurfaceView
, adding colors to them, and transformation.
Getting ready
Readers are recommended to read the introduction of this chapter, which is essential to understand some of the content in this recipe.
How to do it...
The following steps create our sample Android NDK project:
Create an Android application named
TwoDG1
. Set the package name ascookbook.chapter4.gl1x
. 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
TwoDG1
project in Eclipse, select Android Tools | Add Native Support.Add the following three Java files under the
cookbook.chapter4.gl1x
package:MyActivity.java
: It creates the activity of this project:import android.opengl.GLSurfaceView...