SeaPtr sea;
 WaterSurfacePtr surface;
 
-void setupView()
+void glDisplayFunc()
 {
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  gluPerspective(50, (GLfloat)300 / (GLfloat)300, 0, 1000);
-  gluLookAt(0,-10,10, 0,0,0, 0,1,0);
-}
-
-void displayMe(void)
-{
-  setupView();
-
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
 
   glutPostRedisplay();
 }
 
+void glReshapeFunc(int width, int height)
+{
+  glMatrixMode(GL_PROJECTION);
+  glLoadIdentity();
+  gluPerspective(50.0, ((float)width/(float)height), 0, 1000.0);
+  glViewport(0, 0, width, height);
+  gluLookAt(0,-10,10, 0,0,0, 0,1,0);
+}
+
 int main(int argc, char** argv)
 {
   std::srand(std::time(0));
 
   glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 
-  glutDisplayFunc(displayMe);
+  glutDisplayFunc(glDisplayFunc);
+  glutReshapeFunc(glReshapeFunc);
 
   glutMainLoop();