#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;


#include <graphmisc.h>
#include <graphmisctest.h>
#include <print.h>
#include <zpr.h>

void graphmisctest::keyboard01
(
  unsigned char key, 
  int x, 
  int y
)
{
  switch (key)
  {
    case 27:
      exit(0);
      break;
  }
}

void graphmisctest::display01()
{ 
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  gobj::global->draw();


  glerrordisplay();
  
  glutSwapBuffers();
}


//<TODO> Review this test!!!
void graphmisctest::test001()
{
  double imax = 9;
  double dx = 1/(imax-1);

  colorfunction f;

  point3<double> w;
  double z;

  for ( unsigned int i=0; i<imax; ++i)
  {
    cout << i*dx << endl;
    z = i*dx;
    f(w,z);
    cout << w << endl;
  }

  cout << endl << endl << "Verifying Color function" << endl;
  double vz[9] = { 0.0, 0.125, 0.25, 0.375, 0.5, 0.625,0.75,0.875,1.0 }; 
  vector<double> v(vz,vz+9);
  for (unsigned int i=0; i<v.size(); ++i)
  {
    f(w,v[i]);
    cout << SHOW(v[i]) << " " << w << endl;
  }
}

void graphmisctest::test002(int argc, char** argv)
{
  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  glutInitWindowSize(800,600);
  glutCreateWindow("");
  glutDisplayFunc(display01);
  glutKeyboardFunc(keyboard01);

  OpenGLinitialisation();

  glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);
  glEnable(GL_NORMALIZE);

  xGraphics.set();

  gobjpush(new gobjglColor3ub(34,139,34));
  //gridsquare * gs = new gridsquare(1,0x0101,5,5,1.0,1.0);
  gridsquare * gs = new gridsquare(1,0xaaaa,5,5,1.0,1.0);
  
  gobjpush(gs);

  zpr zz;
  zz.update();
  glutMainLoop();
}





