Example Program: box.cc

The next code block is similar. The only difference is that the primitive drawn is a line loop and so only four vertices need to be specified - the last one is automatically connected to the first.

    glColor4fv( green );
    glBegin( GL_LINE_LOOP );
    glVertex2f( -0.5, -0.5 );
    glVertex2f(  0.5, -0.5 );
    glVertex2f(  0.5,  0.5 );
    glVertex2f( -0.5,  0.5 );
    glEnd();