Game Development Reference
In-Depth Information
static {
System.loadLibrary("icosahedron");
}
@Override
public void onDrawFrame(GL10 arg0) {
// Log.d(TAG, "onDrawFrame");
int ticks = (int) System.currentTimeMillis();
drawFrame(ticks);
}
@Override
public void onSurfaceChanged(GL10 arg0, int w, int h) {
Log.d(TAG, "onSurfaceChanged w=" + w + " h=" + h);
initialize(w, h);
}
@Override
public void onSurfaceCreated(GL10 arg0, EGLConfig conf) {
Log.d(TAG, "onSurfaceCreated " + conf);
}
}
ViewRenderer also declares the native C++ methods that will be invoked to initialize the
scene, draw a frame, and set the rotation speed of the object. It also loads the native
C++ library libicosahedron.so , which contains the C++ implementations of these methods:
native static void initialize(int width, int height);
native static void drawFrame(int ticks);
native static void setRotationSpeed(int speed);
static {
System.loadLibrary("icosahedron");
}
Next comes the critical GL ES 3.1 configuration chooser.
OpenGL ES 3.1 Configuration Chooser
The configuration chooser is critical to selection of an EGLConfig that supports OpenGL ES 3.1.
ConfigChooser implements the Android interface GLSurfaceView.EGLConfigChooser and
must receive a configuration spec with the attribute EGL10.ELG_RENDERABLE_TYPE containing
the EGL_OPENGL_ES2_BIT flag. With this information, it queries the display for all available
configurations (see Listing 4-8).
// Get the number of minimally matching EGL configurations
int[] num_config = new int[1];
egl.eglChooseConfig(display, s_configAttribs2, null, 0, num_config);
 
Search WWH ::




Custom Search