Graphics Programs Reference
In-Depth Information
identical to the
GL CUBE
application). If you turn your attention to the per-vertex
position data (
Listing 3-28
)
specified in cubeVFA, you observe that it contains ver-
tices for six triangles (for an output similar to
Figure 3-22
)
—two triangles each for
back/front side and two for the top side of the incomplete cube shown in
Figure 3-22
.
Listing 3-28.
GL CULL FACE/src/com/apress/android/glcullface/GLES20Ren-
derer.java
float[ ] cubeVFA = {
0,0,-4,
0,2,-4,
2,2,-4, // back half
2,2,-4,
2,0,-4,
0,0,-4, // back half
2,2,-4,
0,2,-4,
0,2,-2, // top half
0,2,-2,
2,2,-2,
2,2,-4, // top half
2,2,-2,
0,2,-2,
0,0,-2, // front half
0,0,-2,
2,0,-2,
2,2,-2, // front half
};
Vertices for each of the triangles on the back side are arranged in a CW orientation,
whereas others are arranged in a CCW orientation. This is done intentionally to dis-
card triangles that have CW orientation (that is, a triangle whose vertices are ar-
ranged in a CW manner). To make the rendering pipeline aware of the culling state,
we proceed as shown in
Listing 3-29
.
Listing 3-29.
GL CULL FACE/src/com/apress/android/glcullface/GLES20Ren-
derer.java
Search WWH ::

Custom Search