Graphics Programs Reference
In-Depth Information
GLES20.GL_DYNAMIC_DRAW);
}
Listing 6-14. TANK FENCE GAME 3/src/com/apress/android/tankfencegame3/
GLES20Renderer.java
GLES20.glUseProgram(_missilesProgram);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER,
_missilesBuffers[0]);
GLES20.glVertexAttribPointer(_missilesAPositionLocation,
3, GLES20.GL_FLOAT, false, 12, 0);
GLES20.glEnableVertexAttribArray(_missilesAPositionLocation);
GLES20.glUniformMatrix4fv(_missilesUVPLocation, 1,
false, _missilesVPMatrix, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER,
_missilesBuffers[1]);
GLES20.glDrawElements(GLES20.GL_POINTS,
GLES20Renderer._missiles.size(),
GLES20.GL_UNSIGNED_SHORT, 0);
In Listing 6-13 , GLES20.GL_DYNAMIC_DRAW is passed as an argument to
GLES20.glBufferData() because as I mentioned in the previous chapter,
GL_DYNAMIC_DRAW is used when the buffer object data will be specified re-
peatedly by the application. In the Tank Fence game, the _missiles Ar-
rayList will be repeatedly updated - therefore the corresponding buffers (array
and element buffers) use GL_DYNAMIC_DRAW .
Updating the Missiles ArrayList
I still haven't talked about how the fire button will be used to populate the _mis-
siles ArrayLis t . Before I do that, call the System.arraycopy() method
as shown in Listing 6-15 . And then, multiply _missilesMMatrix with
_tankCenter , where _tankCenter is initialized as -
private final float[] _tankCenter = new
 
 
Search WWH ::




Custom Search