]> git.treefish.org Git - seamulator.git/blob - seamulator.cpp
15b731bcaf68b211411d5e58b3c8c9ca299d99e7
[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 glDisplayFunc()
15 {
16   glMatrixMode(GL_MODELVIEW);
17   glLoadIdentity();
18
19   glClear(GL_COLOR_BUFFER_BIT);
20
21   sea->update();
22   surface->draw();
23
24   glutSwapBuffers();
25
26   glutPostRedisplay();
27 }
28
29 void glReshapeFunc(int width, int height)
30 {
31   glMatrixMode(GL_PROJECTION);
32   glLoadIdentity();
33   gluPerspective(50.0, ((float)width/(float)height), 0, 1000.0);
34   glViewport(0, 0, width, height);
35   gluLookAt(0,-10,10, 0,0,0, 0,1,0);
36 }
37
38 int main(int argc, char** argv)
39 {
40   std::srand(std::time(0));
41
42   surface = std::make_shared<WaterSurface>(LATTICE_SIZE, LATTICE_UNIT);
43   sea = std::make_shared<Sea>(surface);
44
45   glutInit(&argc, argv);
46   glutInitDisplayMode(GLUT_DOUBLE);
47   glutInitWindowSize(300, 300);
48   glutInitWindowPosition(100, 100);
49   glutCreateWindow("seamulator");
50
51   glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
52
53   glutDisplayFunc(glDisplayFunc);
54   glutReshapeFunc(glReshapeFunc);
55
56   glutMainLoop();
57
58   return 0;
59 }