#include "../controller/callbacks/display.h"
#include "../controller/callbacks/keyboard.h"
#include "../controller/callbacks/mouse.h"
#include "../controller/callbacks/mouse_motion.h"
#include "../controller/callbacks/mouse_wheel.h"
#include "../controller/callbacks/reshape.h"
#include "../db/dbconnect.h"
#include "init.h"
#include "state0.h"
#include "view.h"
#include <GL/freeglut.h>
#include <GL/freeglut_ext.h>
#include <GL/glut.h>

void
view (void)
{
  // Connect to the database.
  dbconnect ();

  // GLUT Initialization
  glutInitWindowSize (500, 500);
  glutInitWindowPosition (100, 100);
  glutCreateWindow ("Protein Sequence Map - Flu");

  // GL Initialization
  glClearColor (CLEAR_COLOR);
  glColor3f (DRAW_COLOR);
  glEnable (GL_AUTO_NORMAL);
  glDisable (GL_DEPTH_TEST);
  glEnable (GL_MAP1_VERTEX_3);
  glShadeModel (GL_SMOOTH);

  /* Buffer objects to use. */
  glEnableClientState (GL_COLOR_ARRAY);
  glEnableClientState (GL_VERTEX_ARRAY);

  /* Enable Antialiasing as described in "Antialiasing"
     [Shreiner,247]. */
  glEnable (GL_LINE_SMOOTH);
  glEnable (GL_BLEND);
  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);

  // Initialize the model.
  init ();

  // Callbacks
  glutDisplayFunc (display);
  glutKeyboardFunc (keyboard);
  glutMouseFunc (mouse);
  glutMouseWheelFunc (mouse_wheel);
  glutMotionFunc (mouse_motion);
  glutReshapeFunc (reshape);

  return;
}