O'Reilly logo

OpenGL ES 2 for Android by Kevin Brothaler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Updating Shaders

We’ll also need to update our color shader. We defined our puck and mallet with a per-vertex position but not with a per-vertex color. Instead we’ll have to pass in the color as a uniform. The first thing we’ll do to make these changes is add a new constant to ShaderProgram:

AirHockeyWithImprovedMallets/src/com/airhockey/android/programs/ShaderProgram.java
 
protected​ ​static​ ​final​ ​String​ U_COLOR = ​"u_Color"​;

The next step is to update ColorShaderProgram. Go ahead and remove all references to aColorLocation, including getColorAttributeLocation, and then add the following uniform location definition:

AirHockeyWithImprovedMallets/src/com/airhockey/android/programs/ColorShaderProgram.java
 
private​ ​final​ ​int​ uColorLocation; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required