How to save the previous LINE?

Hi,

In my program I am trying to draw a square, rectangle etc using my drawLine method. But I am loosing the previous line when I click on my left buttown to draw second line to complete the sqaure.

Can you please help me on how to save the previous line?

//FUNCTION TO DRAW A LINE
void drawLine(int x1, int y1, int x2 , int y2)
{
glColor3f(r,g,b);
glBegin(GL_LINES);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
glEnd();

}

// SELECTING MOUSE MOTION
void choose_mouse_motion(int x, int y)
{
int z;

if(mouse_track)
{
    z = wh-y;
	currentX = x;
	currentY = z;
} 
glutPostRedisplay();

}

You don’t “save” it. OpenG works by redrawing the screen (in most cases, anyway). So you will need to store the coordinates of your line, say, in a list and redraw them all each frame.