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:

Heightmap/src/com/particles/android/ParticlesRenderer.java
 
glClear(GL_COLOR_BUFFER_BIT);
 
drawHeightmap();
 
drawSkybox();
 
drawParticles();

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 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.