6 #include "watersurface.h"
8 const int LATTICE_SIZE = 10;
9 const int LATTICE_UNIT = 1;
12 WaterSurfacePtr surface;
14 void drawSingleTile(int x, int y)
16 glBegin(GL_TRIANGLES);
18 glVertex3f(x, y, surface->at(x, y).getHeight());
19 glVertex3f(x+1, y, surface->at(x+1, y).getHeight());
20 glVertex3f(x+1, y+1, surface->at(x+1, y+1).getHeight());
22 glVertex3f(x, y, surface->at(x, y).getHeight());
23 glVertex3f(x, y+1, surface->at(x, y+1).getHeight());
24 glVertex3f(x+1, y+1, surface->at(x+1, y+1).getHeight());
31 glMatrixMode(GL_PROJECTION); // Switch to the projection matrix so that we can manipulate how our scene is viewed
32 glLoadIdentity(); // Reset the projection matrix to the identity matrix so that we don't get any artifacts (cleaning up)
33 gluPerspective(50, (GLfloat)300 / (GLfloat)300, 0, 1000); // Set the Field of view angle (in degrees), the aspect ratio of our window, and the new and far planes
34 gluLookAt(0,-10,10, 0,0,0, 0,1,0);
35 glMatrixMode(GL_MODELVIEW);
38 glClear(GL_COLOR_BUFFER_BIT);
42 glScalef(LATTICE_UNIT, LATTICE_UNIT, 1.0f);
43 glTranslatef(-(float)(LATTICE_SIZE-1)/2, -(float)(LATTICE_SIZE-1)/2, 0);
44 for (int y = 0; y < LATTICE_SIZE-1; ++y) {
45 for (int x = 0; x < LATTICE_SIZE-1; ++x) {
55 int main(int argc, char** argv)
57 std::srand(std::time(0));
59 surface = std::make_shared<WaterSurface>(LATTICE_SIZE);
60 sea = std::make_shared<Sea>(surface);
62 glutInit(&argc, argv);
63 glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
64 glEnable(GL_DEPTH_TEST);
65 glutInitWindowSize(300, 300);
66 glutInitWindowPosition(100, 100);
67 glutCreateWindow("seamulator");
69 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
71 glutDisplayFunc(displayMe);