Terrain

Let’s build some terrain

Drawing a few shapes is a good start, but what about a whole landscape? In these tutorials we’re going to build a terrain class, load a heightmap and get it on screen. Then we’ll add textures and look at a few ways to speed up the drawing.

Start with Terrain Class, or have a look at the tutorials below.

What we’ll build
A terrain class
Heightmaps and textures
Code
C++ and OpenGL
VBOs and level of detail
Before you start
OpenGL shapes and textures
Basic C++ classes
Class & height dataSurface & texturesBuffers & detail

Tutorials

We’ll start with the class and add to it as we go. Work through the tutorials in order so you’ve got the code we need for the next one.

  • 1. Terrain Class

    1. Terrain Class

    Terrain is one of those things that so far, hasn't been perfectly recreated in computer graphics. But it is almost there! Looking over a beautiful landscape can be one of the most amazing feelings in the ...

    Read tutorial →
  • 2. Terrain Loading

    2. Terrain Loading

    We have a basic class setup to hold our terrain, so now lets load in some data for us to display.

    Read tutorial →
  • 3. Terrain Rendering

    3. Terrain Rendering

    The moment we have been waiting for. Lets finally get something drawing out to our window. Even if it doesn't look like we would expect 🙂

    Read tutorial →
  • 4. Terrain Triangle Strips

    4. Terrain Triangle Strips

    We have a basic class setup to hold our terrain, so now lets load in some data for us to display.

    Read tutorial →
  • 5. Terrain Textures

    5. Terrain Textures

    Textures are going to be what make and break this terrain. A nice looking tutorial, and you will be seeing grass, mud, rocks and sand, but a bad texture and you will see just a bunch ...

    Read tutorial →
  • 6. Terrain Vertex Buffer Objects

    6. Terrain Vertex Buffer Objects

    Vertex Buffer Objects are used to store vertices, their indices and other information on the graphics card, for OpenGL to access directly. They are extremely fast and effecient, and are meant to supersede Display Lists. So ...

    Read tutorial →
  • 7. Terrain Level Of Detail

    7. Terrain Level Of Detail

    Level of Detail is a means of decreasing the polygon count of an object to gain a speed boost in your application. This is an extremely simple take on this, which simply draws every fourth vertex. ...

    Read tutorial →

Before you start

You should be comfortable drawing shapes and using textures in OpenGL, along with a bit of C++ class work. If you need a hand with the OpenGL side, have a look at the OpenGL 2 tutorials first.

More tutorials

Want to do more with lighting and textures? Try the GLSL tutorials. The OpenGL 4 tutorials also show how to draw using shaders and buffers.