Drawing polgons

I need to draw polygons using only the GLlines function (I can’t use the polygon function that is in the open GL library). I use the left button on the mouse to indicate the initial vertices and when I am done I use the right mouse to indicate this is the last vertex of my polygon. I was wondering what a sample code for the mouse function would look like for this.