Game Development Reference
In-Depth Information
Invoking OpenGL ES 3.1 in Android
Before you jump into the Android project, there are three steps that you should keep in mind
when using OpenGL ES 3.1 in Android as opposed to old OpenGL ES versions.
1.
The surface view Java class must use a custom context factory to
enable 2.0 rendering.
2.
The surface view class must use a custom EGLConfigChooser to be able
to select an EGLConfig that supports 2.0. This is done by providing a
config specification to eglChooseConfig() that has the attribute
EGL10.ELG_RENDERABLE_TYPE containing the EGL_OPENGL_ES2_BIT flag set.
3.
The surface view class must select the surface's format, then choose an
EGLConfig that matches it exactly (with regards to red/green/blue/alpha
channels bit depths). Failure to do so will result in an EGL_BAD_MATCH error.
Project Icosahedron
Now you can put your skills to the test with a cool Android project to draw an icosahedron
using vertex and fragment shaders. The goals of the exercise are to
Demonstrate the use of vertex and fragment shaders using OpenGL
ES 3.1.
Demonstrate the use of hybrid activities (both Java and C++) to perform
the geometry rendering. The project launcher, surface, and rendering
thread will be created in Java. All OpenGL ES 3.1 rendering will be
performed in C++, using JNI to glue both parts together.
Demonstrate Android multi-touch functionality to manipulate the rotation
speed (using swipes) and the zooming (using pinching) of the shape.
But before you start, let's take a closer look at an icosahedron.
Reviewing the Shape
An icosahedron is a regular polyhedron with 20 identical equilateral triangular faces,
30 edges, and 12 vertices (see Figure 4-3 ).
 
Search WWH ::




Custom Search