Game Development Reference
In-Depth Information
private void printConfigs(EGL10 egl, EGLDisplay display,
EGLConfig[] configs) {
int numConfigs = configs.length;
Log.w(TAG, String.format("%d configurations", numConfigs));
for (int i = 0; i < numConfigs; i++) {
Log.w(TAG, String.format("Configuration %d:\n", i));
printConfig(egl, display, configs[i]);
}
}
private void printConfig(EGL10 egl, EGLDisplay display, EGLConfig config) {
// code removed for simplicity
}
}
// Subclasses can adjust these values:
protected int mRedSize;
protected int mGreenSize;
protected int mBlueSize;
protected int mAlphaSize;
protected int mDepthSize;
protected int mStencilSize;
private int[] mValue = new int[1];
}
That takes care of the Java side of things; now let's shift gears to the C++ rendering.
Table 4-1 described the native side of the project (contained in the ico.cpp file), which is
the last piece of the puzzle. This file is in charge of the JNI function implementation; it also
contains the source of the shaders, plus scene initialization and rendering. Let's take a look.
Native Icosahedron
The Java native functions declared in ViewRenderer.java are implemented in C++ using the
syntax shown in Listing 4-9.
Listing 4-9. C++ Native Functions for the Project
// Java
static {
System.loadLibrary("icosahedron");
}
native static void initialize(int width, int height);
native static void drawFrame(int ticks);
native static void setRotationSpeed(int speed);
// C++
extern "C" {
JNIEXPORT void JNICALL Java_com_opengl_shader_ViewRenderer_initialize
(JNIEnv * env, jclass cls, jint w, jint h)
{
Init(w,h);
}
 
Search WWH ::




Custom Search