Graphics Programs Reference
In-Depth Information
false;
private static List<Missile> _missiles = new
ArrayList<Missile>(100);
Create and link a program for the missile shader code seen in Listing 6-10 , and get
the attribute and uniform locations:
_missilesAPositionLocation =
GLES20.glGetAttribLocation(_missilesProgram,
"aPosition");
_missilesUVPLocation =
GLES20.glGetUniformLocation(_missilesProgram, "uVP");
Create a field _missilesVPMatrix of type float[16] . In the onSur-
faceChanged() method, after combining the viewing and projection transform-
ations, copy the result into _missilesVPMatrix by calling the Sys-
tem.arraycopy() method - as shown in Listing 6-11 (here, the field _MVPMat-
rix is renamed to _planeVPMatrix as it will be used for VP transformation of
plane and enemy objects).
Listing 6-11. TANK FENCE GAME 3/src/com/apress/android/tankfencegame3/
GLES20Renderer.java
public void onSurfaceChanged(GL10 gl, int width, int
height) {
System.gc();
GLES20.glViewport(0, 0, width, height);
float ratio = (float) width / height;
float zNear = 0.1f;
float zFar = 1000;
float fov = 0.95f; // 0.2 to 1.0
float size = (float) (zNear * Math.tan(fov / 2));
Matrix.setLookAtM(_ViewMatrix, 0, 0, 0, 75, 0, 0, 0,
0, 1, 0);
 
 
Search WWH ::




Custom Search