Graphics Programs Reference
In-Depth Information
to
the
uniform
6-19
)
by
calling
the
method
GLES20.glUniformMatrix4fv()
.
Listing 6-18.
TANK FENCE GAME 4/src/com/apress/android/tankfencegame4/
GLES20Renderer.java
private void renderEnemies(float[] enemiesMMatrix) {
GLES20.glUseProgram(_enemyProgram);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER,
_enemyBuffers[0]);
GLES20.glVertexAttribPointer(_enemyAPositionLocation,
3, GLES20.GL_FLOAT, false, 12, 0);
GLES20.glEnableVertexAttribArray(_enemyAPositionLocation);
GLES20.glUniformMatrix4fv(_enemiesUMLocation, 1,
false, enemiesMMatrix, 0);
GLES20.glUniformMatrix4fv(_enemiesUVPLocation, 1,
false, _enemiesVPMatrix, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER,
_enemyBuffers[1]);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, 24,
GLES20.GL_UNSIGNED_SHORT, 0);
}
Finally, to transform the vertex positions this matrix is combined with the view-pro-
jection matrix, as shown in
Listing 6-19
. Please note that the
_enemiesVPMatrix
Matrix.multiplyMM(_planeVPMatrix, 0,
_ProjectionMatrix, 0, _ViewMatrix, 0);
System.arraycopy(_planeVPMatrix, 0, _enemiesVPMatrix,
0, 16);
Listing 6-19.
TANK FENCE GAME 4/src/com/apress/android/tankfencegame4/
GLES20Renderer.java
Search WWH ::
Custom Search