]> git.treefish.org Git - seamulator.git/blob - seamulator.cpp
Added unit length getter
[seamulator.git] / seamulator.cpp
1 #include <ctime>
2
3 #include <GL/glut.h>
4
5 #include "sea.h"
6 #include "watersurface.h"
7
8 const int LATTICE_SIZE = 10;
9 const double LATTICE_UNIT = 1;
10
11 SeaPtr sea;
12 WaterSurfacePtr surface;
13
14 void setupView()
15 {
16   glMatrixMode(GL_PROJECTION);
17   glLoadIdentity();
18   gluPerspective(50, (GLfloat)300 / (GLfloat)300, 0, 1000);
19   gluLookAt(0,-10,10, 0,0,0, 0,1,0);
20 }
21
22 void displayMe(void)
23 {
24   setupView();
25
26   glMatrixMode(GL_MODELVIEW);
27   glLoadIdentity();
28
29   glClear(GL_COLOR_BUFFER_BIT);
30
31   sea->update();
32   surface->draw();
33
34   glutSwapBuffers();
35
36   glutPostRedisplay();
37 }
38
39 int main(int argc, char** argv)
40 {
41   std::srand(std::time(0));
42
43   surface = std::make_shared<WaterSurface>(LATTICE_SIZE, LATTICE_UNIT);
44   sea = std::make_shared<Sea>(surface);
45
46   glutInit(&argc, argv);
47   glutInitDisplayMode(GLUT_DOUBLE);
48   glutInitWindowSize(300, 300);
49   glutInitWindowPosition(100, 100);
50   glutCreateWindow("seamulator");
51
52   glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
53
54   glutDisplayFunc(displayMe);
55
56   glutMainLoop();
57
58   return 0;
59 }