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 )

#ifndef TEXTURES_H_INCLUDED #define TEXTURES_H_INCLUDED #include "global.h" class Texture { private: // the opengl number of the texture GLuint tex; // the corner coords of the texture GLfloat minx, maxx; GLfloat miny, maxy; public: // create a new texture Texture(GLuint tex, GLfloat minx, GLfloat miny, GLfloat maxx, GLfloat maxy): tex(tex), minx(minx), miny(miny), maxx(maxx), maxy(maxy) {} // load a new texture Texture(const char *file); // destroy ~Texture(); // start using void Begin() { glBindTexture(GL_TEXTURE_2D, tex); glEnable(GL_TEXTURE_2D); } // stop using void End() { glDisable(GL_TEXTURE_2D); } // diamensions inline GLfloat maxX() { return maxx; } inline GLfloat minX() { return minx; } inline GLfloat maxY() { return maxy; } inline GLfloat minY() { return miny; } }; #endif