Exercises

We covered quite a few new features in this chapter, so let’s take the time to explore them in more detail:

  • Read up about glCullFace and glFrontFace. Then, as an experiment, add a call to glFrontFace(GL_CW) in onSurfaceCreated.

  • Change the terrain fragment shader to render the terrain with the fragment depth as the color (Hint: You can use gl_FragCoord.z to get the current depth value in a range from 0 to 1; don’t forget that this value is nonlinear).

  • Add a texture to the height map. To make things more interesting, blend between two different textures, depending on the height.

  • Once you have that working, add a flat plane of water to cover up the bottom.

  • Change the height map implementation to use triangle strips and to degenerate triangles ...

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.