PDA

View Full Version : opengl, mouse, surfaces, break of for statement



courious
09-11-2002, 12:46 PM
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!!!

nexusone
09-11-2002, 01:41 PM
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) &#0124; &#0124; (count < target)
{

do stuff here until one of above is TRUE

}



Originally posted by courious:
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!!!

tinak
09-12-2002, 02:55 AM
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

Deiussum
09-12-2002, 04:27 AM
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).]