Heightmaps and Vertex Buffer Objects in OpenGL

I took code from NeHe's Lesson 10 and Lesson 34 and combined them to create a program that lets you roam (float) around a world created through a bitmap file.

Lesson 10 was written in C using SDL under Linux. Lesson 34 was in C++ and used the GLX libraries instead of SDL.

I stuck with C and SDL, but brought the heightmap code and the vertex buffer object code from Lesson 34 into my solution.

Vertex buffer objects provide many of the benefits of Open GL vertex arrays and display lists, but are faster since the vertices are buffered in memory on the graphics card.

Using this simple demo, you can create custom worlds using a simple image editing program. Dark colors equate to low elevations; lighter colors are the opposite.

I found the blurring tool in Gimp to be useful in enhancing the realism of some of the scenery. I created a mountain by drawing concentric rings of color, getting lighter as they progressed inward. Without blurring to smooth the vertices between the two colors, you get a very table-like mountain, much like the jQuery logo.

To compile the code you'll need to be running Linux with SDL installed. Simply cd into the directory you unzipped the file and type make to build the myquake executable.

Pressing the up arrow moves you up, the left and right arrows rotate around. To move forward, press F, backwards press A, and to perform an incorrect strafe (I think it moves you up and down the x-axis no matter which way you're facing) press S or D.

Some sample renderings are shown below.

See more pictures here and download the source here.