Graphics Programs Reference
In-Depth Information
float rectangleVFA[] = {
0, 0, 0,
0, 0.5f, 0,
0.75f, 0.5f, 0,
0.75f, 0.5f, 0, // duplication
0.75f, 0, 0,
0, 0, 0,
// duplication
};
To avoid this redundancy, use glDrawElements and provide a float array con-
sisting of unique vertices of the object, as well as another ( short ) array consisting
of element indices to access vertices (from the float array) representing primit-
ive(s).
Note Meshes are primary shapes, such as triangles, used to repres-
ent real world objects in modeling softwares similar to Blender. The
following section, “Blender for Modeling,” discusses them.
GL POINT ELEMENTS Application
Without modifying the output of the GL POINT ADVANCED application, as shown
in Figure 3-10 ( Chapter3/glpointadvanced.zip ), you can replace the call
to glDrawArrays with glDrawElements . Please note that the shader code re-
mains the same. In the Renderer class of the GL POINT ADVANCED application,
turn your attention to the initShapes method. Much as we create a
FloatBuffer for the vertex array ( Listing 4-2 ), we create a ShortBuffer for
the index array ( Listing 4-3 ).
Listing 4-2. GL POINT ADVANCED/src/com/apress/android/glpointadvanced/
GLES20Renderer.java
private void initShapes() {
float[] pointVFA = {
0.1f,0.1f,0.0f, // first quadrant
-0.1f,0.1f,0.0f, // second quadrant
-0.1f,-0.1f,0.0f, // third quadrant
 
 
 
Search WWH ::




Custom Search