PDA

View Full Version : using mouse events to draw a line



1234
10-03-2002, 06:13 AM
I need to draw a line starting at right mouse down and ending at right mouse up. how can I do this?

nexusone
10-03-2002, 06:15 AM
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?

1234
10-03-2002, 06:42 AM
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?

nexusone
10-03-2002, 07:32 AM
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?

1234
10-03-2002, 08:33 AM
ok i think i've got it now.

thanks