Occluding Hidden Objects

We now have everything in place, so let’s run the app to see what happens. You might be surprised to find that the terrain doesn’t show up at all! Let’s take a look at onDrawFrame to see what might be going on:


We first draw the height map, but then we draw the skybox right after, obliterating everything that was there before. Switch the two draw calls so that the skybox is drawn first and the height map is drawn second, and see what happens.

The terrain should now show up, but you’ll likely see some strange artifacts, as seen in Figure 60, Terrain with strange artifacts. The reason ...

Get OpenGL ES 2 for Android now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.