/* Luo Li
   Super Comp Program 2
*/

/*sample GL.cpp*/

#include <stdio.h>
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "glaux.h"

static void Init (void)
{

  glClearColor(1.0, 1.0, 1.0, 1.0);
  glShadeModel( GL_FLAT  );

}

static void Reshape (int width, int height )
{
  glViewport( 0, 0, (GLint)width, (GLint)height);
  glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
  glOrtho( -0.0, 4.0, 0.0, 1.0, -1.0, 1.0);
  glMatrixMode(GL_MODELVIEW);
}
static void key_up()
{
  cout<<"AUX_UP\n";
}
static void key_down()
{
  cout<<"AUX_DOWN\n";
}
static void key_esc()
{
 auxQuit();
}
void DrawMyStuff()
{
 float i,j;
 double p,x,xtemp;
 glColor3f( 0.5, 0.5, 1.0 );
 glBegin( GL_POINTS );
 for (p=0; p<4; p+=.001)
 {
  x= .5;
  xtemp=x;
  for (int i=0; i<50; i++) 
   {
       xtemp=p*xtemp*(1-xtemp);
       glVertex3f(p,xtemp,0.0);
   }
 }
 glEnd();
 
}

static void display()
{
 glClear ( GL_COLOR_BUFFER_BIT);
 DrawMyStuff();
 glFlush();
 auxSwapBuffers();
}

int main (int argc, char **argv)
{ 
 auxInitDisplayMode( AUX_RGBA);
 auxInitPosition( 50, 50, 800, 200);
 if (auxInitWindow("Luo' Box")==GL_FALSE)
   { 
     auxQuit();
   }
 
 Init();

 auxExposeFunc(Reshape);
 auxReshapeFunc(Reshape);
 auxKeyFunc( AUX_UP, key_up);
 auxKeyFunc( AUX_DOWN, key_down);
 auxMainLoop( display);

 return 0;

}

    
