3D Underwater World (using OpenGL and SDL)

Copyright Tristan Aubrey-Jones January 2008.

This is an example OpenGL SDL application which creates an animated 3D underwater world (screenshot), with "Thunderbird 4" with headlights moving on a spline path, a randomly generated sand terrain, sunken ship/submarine/treasure chest models, and swaying fish and seaweed. It is designed to demonstrate basic OpenGL features, and the structure is as follows:


home Home   up Up   ( Download )

#include "regulargrid.h" /* * TerrainGrid class * ---------------------- * Creates a random terrain using the * diamond-square fractal algorithm. * ------------------------- * Tristan Aubrey-Jones 18/12/2007 */ class TerrainGrid: public RegularGrid { private: // height (as normals created in advance to create in // the unit square) float height; // roughness constant float roughness; // the dimension exponent e, where dimensions = (2^e,2^e) int e; // performs the square step of the diamond-square algorithm void performSquareStep(int sqrSize, RegularGridVertex ran); // peforms the diamond step of the diamond-square algorithm void performDiamondStep(int sqrSize, RegularGridVertex ran); public: // constructor // res - resolution exponent // e.g. (1 gives 2x2, 8 gives 256x256) TerrainGrid(int res, float roughness, Vec3 v, Texture* tex): RegularGrid((2<