9 #include "watersurface.h"
11 const int LATTICE_SIZE{128};
12 const double LATTICE_EXTEND{10};
13 const int INIT_WINDOW_POS_X{50};
14 const int INIT_WINDOW_POS_Y{50};
15 const int INIT_WINDOW_WIDTH{800};
16 const int INIT_WINDOW_HEIGHT{600};
17 const double INIT_VIEW_DISTANCE{LATTICE_EXTEND * 1.5};
18 const double INIT_VIEW_AZIMUTH{0};
19 const double INIT_VIEW_ALTITUDE{M_PI / 4};
20 const char WINDOW_TITLE[]{"seamulator"};
23 WaterSurfacePtr surface;
24 std::unique_ptr<SeaView> seaView;
27 void glReshapeFunc(int width, int height);
28 void glMouseFunc(int button, int state, int x, int y);
29 void glMotionFunc(int x, int y);
31 int main(int argc, char** argv)
33 std::srand(std::time(0));
35 surface = std::make_shared<WaterSurface>(LATTICE_SIZE, LATTICE_EXTEND);
36 sea = std::make_shared<Sea>(surface);
37 seaView = std::make_unique<SeaView>(INIT_VIEW_DISTANCE, INIT_VIEW_AZIMUTH,
40 glutInit(&argc, argv);
41 glutInitDisplayMode(GLUT_DOUBLE);
42 glutInitWindowSize(INIT_WINDOW_WIDTH, INIT_WINDOW_HEIGHT);
43 glutInitWindowPosition(INIT_WINDOW_POS_X, INIT_WINDOW_POS_Y);
44 glutCreateWindow(WINDOW_TITLE);
45 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
47 glutDisplayFunc(glDisplayFunc);
48 glutReshapeFunc(glReshapeFunc);
49 glutMouseFunc(glMouseFunc);
50 glutMotionFunc(glMotionFunc);
59 glClear(GL_COLOR_BUFFER_BIT);
69 void glReshapeFunc(int width, int height)
71 glMatrixMode(GL_PROJECTION);
73 gluPerspective(50.0, ((float)width/(float)height), 0, 1000.0);
74 glViewport(0, 0, width, height);
77 void glMouseFunc(int button, int state, int x, int y)
79 seaView->onMouseEvent(button, state, x, y);
82 void glMotionFunc(int x, int y)
84 seaView->onMouseMove(x, y);