/**
 * keyboard_ctrl is registered as a GLUT callback.
 * It is responsible for catching when special keys are pressed.
 *
 * @param key The key pressed.
 * @param x The x coordinate of the mouse when the key was pressed.
 * @param y The y coordinate of the mouse when the key was pressed.
 */
void keyboard_ctrl( int key, int x, int y ) {

  Scene *theScene = Engine::instance()->rootScene();
  Cameras *camList = Engine::instance()->cams();
  
  switch ( key ) {
  //Cycle between active Objects ...
  case GLUT_KEY_LEFT:
    theScene->prev();
    break;
  case GLUT_KEY_RIGHT:
    theScene->next();
    break;

    //Change the Draw Mode ...
  case GLUT_KEY_F1:
    theScene->active()->Mode( GL_POINTS );
    break;
  case GLUT_KEY_F2:
    theScene->active()->Mode( GL_LINE_STRIP );
    break;
  case GLUT_KEY_F3:
    theScene->active()->Mode( GL_TRIANGLE_STRIP );
    break;
  case GLUT_KEY_F4:
    theScene->active()->Mode( GL_TRIANGLES );
    break;
  }

  // If there are no Cameras, don't muck around with this section.
  if ( camList->numCameras() < 1 ) return;

  switch ( key ) {
  case GLUT_KEY_PAGE_UP:
    camList->prev();
    break;

  case GLUT_KEY_PAGE_DOWN:
    camList->next();
    break;
  }
}