using mouse events to draw a line

I need to draw a line starting at right mouse down and ending at right mouse up. how can I do this?

You can use glutMouseFunc.

Originally posted by 1234:
I need to draw a line starting at right mouse down and ending at right mouse up. how can I do this?

yes, but how would I get the starting and the ending value into a glBegin(GL_LINES) function when I get one value from the mouse down and one value form the mouse up?

Have you ever thought about using variables?

int start_x, start_y; Mouse down store values here
int end_x, end_y; Mouse up store values here.

glBegin(GL_LINES);
glVertex2i( start_x, start_y);
glVertex2i( end_x, end_y );
glEnd();

Originally posted by 1234:
yes, but how would I get the starting and the ending value into a glBegin(GL_LINES) function when I get one value from the mouse down and one value form the mouse up?

ok i think i’ve got it now.

thanks