Graphics Programs Reference
In-Depth Information
the
ShortBuffer
(corresponding to the
element array buffer object
), if you as-
signed it as the current buffer object, as shown in
Listing 5-2
.
So, in place of
FloatBuffer
or
ShortBuffer
, argument “0” is passed when calling
glVer-
texAttribPointer
or
glDrawElements
.
Listing 5-2.
TANK FENCE 1/src/com/apress/android/tankfence1/GLES20Ren-
derer.java
GLES20.glUseProgram(_tankProgram);
GLES20.glUniformMatrix4fv(_tankUMVPLocation, 1, false,
_MVPMatrix, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER,
_tankBuffers[0]);
GLES20.glVertexAttribPointer(_tankAPositionLocation,
3, GLES20.GL_FLOAT, false, 12, 0);
GLES20.glEnableVertexAttribArray(_tankAPositionLocation);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER,
_tankBuffers[1]);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, 84,
GLES20.GL_UNSIGNED_SHORT, 0);
To understand this better, import the archive file
Chapter5/tankfence1.zip
.
This loads the
TANK FENCE 1
application into your Eclipse workspace. You will
also find other similar applications in the source code -
TANK FENCE 2
and
TANK
FENCE 3
. These three applications will help you move in a stepwise manner to
use buffer objects for the plane, enemy, and player (game objects in the
Tank
Fence
game). The outputs of these applications are similar to the
TANK FENCE
ELEMENTS *
series of applications. The only difference between these applications
is the use of buffer objects.
Using Color Masks
Before moving further, I will also talk about using color masks in ES 2.0. Color
masks allow you to enable or disable writes to specific components (red, green, blue,
and alpha) in the color buffer.
Search WWH ::
Custom Search