Game Development Reference
In-Depth Information
2.
We can specify multiple architectures to create a fat binary that will run on any of
them through the following command:
APP_ABI := armeabi armeabi-v7a x86 mips
There's more...
The main pitfall of the fat binaries is the resulting .apk size, as separate native code versions
are compiled for each of the speciied architectures. If your application heavily uses third-party
libraries, the package size can become an issue. Plan your deliverables wisely.
Basic rendering with OpenGL ES
Let us add some graphics to our sample Android application App2 . Here, we show how to
create an off-screen bitmap, and then copy it to the screen using the OpenGL ES Version 2 or
3 available on your Android device.
Refer to the App3 sample in the topic's downloadable code bundle for
the full source code.
Getting ready
We assume that the reader is somewhat familiar with OpenGL and the GL Shading Language
(GLSL). Refer to http://www.opengl.org/documentation for the desktop OpenGL, and
http://www.khronos.org/opengles for the mobile OpenGL ES documentation.
How to do it…
1.
We need to write a simple vertex and fragment GLSL shader that will render our
framebuffer on the screen using OpenGL ES. Let's put them directly into jni/
Wrappers.cpp as strings. The following code shows the vertex shader:
static const char g_vShaderStr[] =
"#version 100\n"
"precision highp float;\n"
"attribute vec3 vPosition;\n"
"attribute vec3 vCoords;\n"
"varying vec2 Coords;\n"
"void main()\n"
"{\n"
" Coords = vCoords.xy;\n"
" gl_Position = vec4( vPosition, 1.0 );\n"
"}\n";
 
Search WWH ::




Custom Search