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

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

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