Game Development Reference
In-Depth Information
drawFrame();
return 1;
}
Native Cube
Native cube ( cube.c ) is the last file in the lot (see Listing 5-15). This file is a carbon copy of Cube.java . It
defines the vertices, colors, and indices of the cube, and draws it in the same way as its Java counterpart.
Listing 5-15. Native Implementation of Cube.java
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <GLES/gl.h>
#define FIXED_ONE 0x10000
#define one 1.0f
typedef unsigned char byte;
extern void jni_printf(char *format, ...);
// Cube vertices
static GLfloat vertices[24] = {
-one, -one, -one,
one, -one, -one,
one, one, -one,
-one, one, -one,
-one, -one, one,
one, -one, one,
one, one, one,
-one, one, one,
};
// Colors
static GLfloat colors[] = {
0, 0, 0, one,
one, 0, 0, one,
one, one, 0, one,
0, one, 0, one,
0, 0, one, one,
one, 0, one, one,
one, one, one, one,
0, one, one, one,
};
static byte indices[] = {
0, 4, 5, 0, 5, 1,
1, 5, 6, 1, 6, 2,
Search WWH ::




Custom Search