Graphics Programs Reference
In-Depth Information
duplicated
ByteBuffer lineIBB =
ByteBuffer.allocateDirect(lineISA.length * 2);
lineIBB.order(ByteOrder.nativeOrder());
_lineISB = lineIBB.asShortBuffer();
_lineISB.put(lineISA);
_lineISB.position(0);
}
Finally, to render this wireframe rectangle, replace the call to
glDrawArrays
with
glDrawElements
using suitable arguments.
is '8', the
type
argument is
GL_UNSIGNED_SHORT
, and the last argument is the
ShortBuffer
.
Listing 4-6.
GL LINE ELEMENTS/src/com/apress/android/gllineelements/
GLES20Renderer.java
GLES20.glDrawElements(GLES20.GL_LINES, 8,
GLES20.GL_UNSIGNED_SHORT, _lineISB);
Rendering triangle primitives is left as an exercise for you; however, if you have
any confusion about this, go through the Renderer class inside the
GL TRIANGLE
ELEMENTS
application (
Chapter4/gltriangleelements.zip
). If you run
this application, you see output similar to
Figure 4-2
.
Search WWH ::

Custom Search