9 #include "watersurface.h"
11 const int LATTICE_SIZE = 10;
12 const double LATTICE_UNIT = 1;
15 WaterSurfacePtr surface;
16 std::unique_ptr<SeaView> seaView;
19 void glReshapeFunc(int width, int height);
20 void glMouseFunc(int button, int state, int x, int y);
21 void glMotionFunc(int x, int y);
23 int main(int argc, char** argv)
25 std::srand(std::time(0));
27 surface = std::make_shared<WaterSurface>(LATTICE_SIZE, LATTICE_UNIT);
28 sea = std::make_shared<Sea>(surface);
29 seaView = std::make_unique<SeaView>(LATTICE_SIZE * LATTICE_UNIT * 1.5,
32 glutInit(&argc, argv);
33 glutInitDisplayMode(GLUT_DOUBLE);
34 glutInitWindowSize(300, 300);
35 glutInitWindowPosition(100, 100);
36 glutCreateWindow("seamulator");
37 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
39 glutDisplayFunc(glDisplayFunc);
40 glutReshapeFunc(glReshapeFunc);
41 glutMouseFunc(glMouseFunc);
42 glutMotionFunc(glMotionFunc);
51 glClear(GL_COLOR_BUFFER_BIT);
61 void glReshapeFunc(int width, int height)
63 glMatrixMode(GL_PROJECTION);
65 gluPerspective(50.0, ((float)width/(float)height), 0, 1000.0);
66 glViewport(0, 0, width, height);
69 void glMouseFunc(int button, int state, int x, int y)
71 seaView->onMouseEvent(button, state, x, y);
74 void glMotionFunc(int x, int y)
76 seaView->onMouseMove(x, y);