Graphics Programs Reference
In-Depth Information
GLES20Renderer._buttonMissilePressed = true;
}
});
Now, turn your attention to the Renderer class (
TANK FENCE GAME 2/src/
com/apress/android/tankfencegame2/GLES20Renderer.java
).
Add the lines of code from
Listing 6-10
.
Because we are using point sprites to repres-
ent missiles, the
shader
code for a missile (
Listing 6-10
) just makes use of an attrib-
ute and a uniform variable.
Listing 6-10.
TANK FENCE GAME 3/src/com/apress/android/tankfencegame3/
GLES20Renderer.java
private final String _missilesVertexShaderCode =
"attribute vec3 aPosition; \n"
+ "uniform mat4 uVP; \n"
+ "void main() { \n"
+ " gl_PointSize = 15.0; \n"
+ " vec4 vertex =
vec4(aPosition[0],aPosition[1],aPosition[2],1.0); \n"
+ " gl_Position = uVP * vertex; \n"
+ "} \n";
private final String _missilesFragmentShaderCode =
"#ifdef GL_FRAGMENT_PRECISION_HIGH \n"
+ "precision highp float; \n"
+ "#else \n"
+ "precision mediump float; \n"
+ "#endif \n"
+ "void main() { \n"
+ " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); \n"
+ "} \n";
After this, add two static fields to this class, and initialize them as shown:
public static volatile boolean _buttonMissilePressed =
Search WWH ::
Custom Search