//display.h

#ifndef _DISPLAY_H_
#define _DISPLAY_H_

#include <iostream>
#include <math.h>
#include <X11/X.h>    // Basic X library
#include <GL/gl.h>
#include <GL/glut.h>
#include "../4d/4d.h"
using namespace std;

#define PI 3.141592


class Display
{
public:

  Display(GLdouble wxmin = 0.0, GLdouble wxmax = 1.0,
	  GLdouble wymin = 0.0, GLdouble wymax = 1.0,
	  GLdouble wzmin = 0.0, GLdouble wzmax = 1.0,
	  GLint vxmin=0, GLint vxmax=640,
	  GLint vymin=0, GLint vymax=480,
	  GLint vzmin=0, GLint vzmax=100,
  GLint width=640, GLint height=480);

  //selectors
  GLint height(void) const {return _height;}
  GLint width(void) const {return _width;}
      
  void initDisplay(int & argc, char ** argv);
      
  void reDisplay();

  
  //idle function for glui
  void myGlutIdle(void);

  //redisplay event handler
  void redisplay();
  
  //resize event handler
  void reShape(GLsizei x, GLsizei y);
  
  //mouse event handelers
  void myMouse(GLint button, GLint state, GLint x, GLint y);
  
  //timer event
  void timerEvent();

  //keyboard event handler
  void myKeyboard(unsigned char key, GLint x, GLint y);

  void myWADSKeyboard(unsigned char key, GLint x, GLint y);

  //button callback function
  void buttons(GLint button);

  //shape drawing functions

  //3d simplex in triangle strips
  void simplexTStrip();

  //3d simplex in GL_TRIANGLES
  void simplexTriangles();

  //3d simplex in polygons
  void simplexPolygons();

  //4d hypercube
  void drawWireHypercube(GLdouble c[16][5]);

private:
  GLint _width, _height;  //the height and width of the screen in pixels
  GLdouble _wxmin, _wxmax, _wymin, _wymax,
	       _wzmin, _wzmax;  //world coordinates
  GLdouble _eye[4], _look[4], _up[4];
  GLfloat _myLightPos[4];
  GLint _vxmin, _vxmax, _vymin, _vymax,
	    _vzmin, _vzmax;  //viewport coordinates
  GLdouble _theta[4];
  GLdouble _d[4];  //translation values.
  GLdouble _frustum[8]; //viewing volume sizes in glFrustum call order
  bool _freeLook; //true if free look is on (translation before rotation of eye coordinates)
				  //false if fixed look is on (rotation before translation of eye coordinates)	
};

#endif

