// A simple program for generating a set of lines

// C includes
#include <math.h>

// C++ includes
#include <iostream>

#ifdef WIN32                     
using namespace std;
#include <process.h>
#include <string.h>
#endif

// The local includes
#include <GL/gl.h>
#include <GL/glut.h>

// function prototypes
void init(void);
void display(void);

// all this initialization can be used as is
int main(int argc, char *argv[]) {

  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  glutInitWindowSize(500, 500);
  glutInitWindowPosition(100, 100);
  glutCreateWindow(argv[0]);
  init(); 	// create image for display
  glutDisplayFunc(display);
  glutMainLoop();
  return(0);

}

// set up clear color and transforms for vertices
void init(void)	{
  glClearColor(0.5, 0.5, 0.5, 0.0);
  glShadeModel(GL_FLAT);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluOrtho2D(0.0, 500., 0., 500.);  // note: coordinates align with pixels
  glMatrixMode(GL_MODELVIEW);
  }

// draw a bunch of lines
void display(void)	{
  glClear(GL_COLOR_BUFFER_BIT);
  glBegin(GL_LINES);
    glColor3f(0.0, 0.0, 0.0);
    glVertex2i(0, 0);
    glVertex2i(400, 400);
    glColor3ub(255, 0, 0);  // we could do this with (1.0, 0., 0.) as well
    glVertex2i(0, 200);
    glVertex2i(400, 200);
    glColor3ub(0, 255, 0);
    glVertex2i(300, 0);
    glVertex2i(300, 400);
  glEnd();
  glFlush();	// force the results to display
  }

