#include <GL/glut.h> // this includes <GL/gl.h>
#include <stdio.h>


void display()
{
    // Tell OpenGL to clear the color buffer (there are other buffers also)
    // to the color specified by the command glClearColor()
    glClear(GL_COLOR_BUFFER_BIT) ;

    // empty the command buffer, causing all issued OpenGL commands to be executed
    // in this case, there are only two OpenGL commands that have been explicitly 
    // sent, glClearColor() and glClear()
    glFlush();

    // This is a glut convenience function which will print out an error message to the 
    // console, if an OpenGL or GLUT error occurs.
    glutReportErrors() ;
    return ;
}

int main(int argc, char **argv)
{
    // initialize GLUT
    // GLUT is NOT part of the OpenGL Standard
    // GLUT IS a window system independent toolkit which enables use to:
    // 1) Open up and configure an OpenGL window
    // 2) Receive events in a simple way from the window system
    glutInit( &argc, argv) ;

    // Ask GLUT to give a hint to the window system about the size of the window
    // we wish to create
    glutInitWindowSize(800,600) ;

    // Ask GLUT to create a window that uses direct RGB values for colors (rather than color indexing)
    // Ask GLUT to create a window that uses single buffering (more on this later)
    glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE) ;

    // Create the window with the title "example-00"
    glutCreateWindow("example-00") ;

    // Ask GLUT to call the function named 'display' when the contents of the window need to be drawn
    // The display function is where most of the action will take place
    glutDisplayFunc( display ) ;

    // This is the first OpenGL call we're seeing. This call specifies the RGBA color for
    // the background of the window. Values are specified in the range [0,1]. The value
    // 0,1,0,1 means 100% green and 100% alpha (completely opaque) Its safe to ignore the
    // alpha component in this program.
    // (GLUT specifies that we are allowed to change OpenGL state [though not draw] here)
    // TRY THIS: change the values here and make sure you see the contents of the window change
    glClearColor(0,1,0,1) ;

    // Enter the GLUT event loop. This program will never leave the event loop.
    glutMainLoop() ;

    return(0) ;
}