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

Introducing Triangle Fans

With a new point in the middle of the table, we’ll end up with four triangles instead of two. We’ll center the new point at (0, 0). Let’s open up AirHockeyRenderer in the new project that we created at the beginning of this chapter and update the triangles as follows:

AirHockey2/src/com/airhockey/android/AirHockeyRenderer.java
 
// Triangle Fan
 
0, 0,
 
-0.5f, -0.5f,
 
0.5f, -0.5f,
 
0.5f, 0.5f,
 
-0.5f, 0.5f,
 
-0.5f, -0.5f,

The first question you might be asking is, “Why did we only define six points? Don’t we need to define three vertices per triangle?” While it’s true that we need three vertices per triangle, we can sometimes reuse the same vertex in more than one triangle. Let’s take a look at our new structure again, ...

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