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

Adding a New Color Attribute

Now that we’ve updated our table structure by adding an additional point in the center of the table, we can now add a color attribute to each point. Let’s update the entire array of data as follows:

AirHockey2/src/com/airhockey/android/AirHockeyRenderer.java
 
float​​[]​ tableVerticesWithTriangles = {
 
// Order of coordinates: X, Y, R, G, B
 
 
// Triangle Fan
 
0f, 0f, 1f, 1f, 1f,
 
-0.5f, -0.5f, 0.7f, 0.7f, 0.7f,
 
0.5f, -0.5f, 0.7f, 0.7f, 0.7f,
 
0.5f, 0.5f, 0.7f, 0.7f, 0.7f,
 
-0.5f, 0.5f, 0.7f, 0.7f, 0.7f,
 
-0.5f, -0.5f, 0.7f, 0.7f, 0.7f,
 
 
// Line 1
 
-0.5f, 0f, 1f, 0f, 0f,
 
0.5f, 0f, 1f, 0f, 0f,
 
 
// Mallets
 
0f, -0.25f, 0f, 0f, 1f,
 
0f, 0.25f, 1f, 0f, 0f
 
};

As you can see, we’ve added three ...

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