Graphics Programs Reference
In-Depth Information
Note glDrawElements draws a sequence of primitives using a
vertex array and an additional (index) array with element indices for
this vertex array. This function helps remove redundant data from
the vertex array, and, as Chapter 5 shows, OpenGL ES may even
cache recently processed vertices/indices and reuse them without re-
sending them to the rendering pipeline.
Finally, replace the call to glDrawArrays with the line of code in Listing 4-8 .
Listing 4-8. GL RECTANGLE ELEMENTS/src/com/apress/android/glrect-
angleelements/GLES20Renderer.java
GLES20.glDrawElements(GLES20.GL_TRIANGLES, 6,
GLES20.GL_UNSIGNED_SHORT, _rectangleISB);
In Listing 4-8 , the arguments passed to glDrawElements are straightforward. The
GL_TRIANGLES argument specifies the mode (that is, the type of primitive), '6'
specifies the count of indices in the index array, GL_UNSIGNED_SHORT specifies
the data type of the index array, and the last argument specifies this index array as a
ShortBuffer . Please note that, in the output, as shown in Figure 4-3 , the rectangle
is blue in color, as the fragment color is explicitly set to blue— gl_FragColor =
vec4(0,0,1,1);
Now that you have a basic understanding of glDrawElements , you can start
learning about 3D-content authoring software—in this case, Blender. Using Blender,
we model 2D/3D objects, which can be parsed for vertex and index arrays for use
with glDrawElements .
Blender for Modeling
Blender is a powerful 3D application for modeling, animation, rendering, composit-
ing, video editing, and game creation. It is an open-source application and is avail-
able for the following OSes:
▪ Linux
 
 
Search WWH ::




Custom Search