opengl, mouse, surfaces, break of for statement

Hi opengl people!!!
I wanted do ask a pair of things…

How can i break a “for” statement by click of the mouse using glut or opengl libraries?
i experienced that for this problem the only way is to wait until for finish and i dont know another way…i program in c and a little bit of c++ with visual studio 6

in my program i calculate some vertex and then i would like to make a surface with they but i would like to do it only one time… how could i do?
the number of point is at maximum 260000

thanks to all!!!

Post your code, so we can advise as to your solution.

From what I can tell maybe you need to break down you program into smaller routines.

void main(int argc,char * argv)
{

build_surface_data(); // build your surface and place in a varaible array or display list.
// then go into your main loop
glutMainLoop()
}

You also can replace the for loop, while loop

while( (mouse_click != TRUE) | | (count < target)
{

do stuff here until one of above is TRUE

}

Originally posted by courious:
[b]Hi opengl people!!!
I wanted do ask a pair of things…

How can i break a “for” statement by click of the mouse using glut or opengl libraries?
i experienced that for this problem the only way is to wait until for finish and i dont know another way…i program in c and a little bit of c++ with visual studio 6

in my program i calculate some vertex and then i would like to make a surface with they but i would like to do it only one time… how could i do?
the number of point is at maximum 260000

thanks to all!!![/b]

If I’ve needed to use a for loop and then needed to break out early I usually set the variable being tested to a higher value:

eg.

for (a=1;a<12;a++)
{
… do some stuff …
a = 13; // break out of for loop
}

But like has been previously suggested a while loop is probably better if one can be set up.

Tina

You can use the break command to break out of any loop.

If you’ve got a single-threaded app, your mouse event routine won’t get called right away if you’re already in the middle of another routine. You may have to use some API function similiar to GetAsyncKeyState for the mouse within the for loop.

[This message has been edited by Deiussum (edited 09-12-2002).]