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

Creating a Projection Matrix in Our Code

We’re now ready to add a perspective projection to our code. Android’s Matrix class contains two methods for this, frustumM and perspectiveM. Unfortunately, frustumM has a bug that affects some types of projections,[32] and perspectiveM was only introduced in Android Ice Cream Sandwich and is not available on earlier versions of Android. We could simply target Ice Cream Sandwich and above, but then we’d be leaving out a large part of the market that still runs earlier versions of Android.

Instead, we can create our own method to implement the matrix as defined in the previous section. Open up the project we created back at the beginning of this chapter and add a new class called MatrixHelper to the package ...

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