Rendering with the New Color Attribute
Now that we’ve added a color attribute to our data and we’ve updated the vertex and fragment shaders to use this attribute, the next steps are to remove the old code that passed in the color via a uniform and to tell OpenGL to read in colors as a vertex attribute.
Updating Constants
Let’s add the following constants to the top of AirHockeyRenderer:
AirHockey2/src/com/airhockey/android/AirHockeyRenderer.java | |
| private static final String A_COLOR = "a_Color"; |
| private static final int COLOR_COMPONENT_COUNT = 3; |
| private static final int STRIDE = |
| (POSITION_COMPONENT_COUNT + COLOR_COMPONENT_COUNT) * BYTES_PER_FLOAT; |
We’ll also need a new member variable:
AirHockey2/src/com/airhockey/android/AirHockeyRenderer.java ... |
Get OpenGL ES 2 for Android now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.