#ifndef MYGLUTGUI_H
#define MYGLUTGUI_H

#include <cassert>
#include <string>
using namespace std;

#include <GL/glut.h>
#include <GL/gl.h>

#include <print.h>


/*!
  \brief OpenGL Glut window.

  The client derives this class and implements the graphics.
  The keyboard events are captured and handled
  by over riding keyboard.  The client is forced to define a
  display.

  The client is required to call globalSet(); in the derived 
  constructor to set the global gui pointer.  

  Since multiple menues are possible I did not set the global
  gui by default because then the order of constructors would 
  determine which menu was displayed - something that the client 
  will not want.
*/
class myglutgui
{
public:

  /** A global pointer. */
  static myglutgui* global;

  /** Sets this gui as the global gui. */
  void globalSet();

  /** Configure the window and graphics mode. */
  myglutgui
  (
    int & argc, 
    char** & argv,
    uintc mode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH,
    uintc x = 800,
    uintc y = 600,
    string const & title = ""
  );

  /** Destructor. */
  virtual ~myglutgui();

  /** Derived classes define display. */
  virtual void display()=0;

  /** Derived classes define keyboard. */
  virtual void keyboard(unsigned char key, int x, int y);

  /** Generally responsible for graphics initialization. 
      Not useful for classes with multiple initializations and
      hence this function is not abstract. */
  virtual void eval() {};

};

/** Forwards to myglutgui::global->keyboard. */
void myglutguikeyboard(unsigned char key, int x, int y);

/** Forwards to myglutgui::global->display. */
void myglutguidisplay();


#endif



