I am using a C++ graphics library which has functions void WaitForMouseDown() and void WaitForMouseUp(). The WaitForMouseDown function waits until the mouse button is pressed and then returns. WaitForMouseUp waits for the button to be released. There is another function in the library bool isMouseDown() which returns true if the mouse button is currently down.
Now, I have to start doing something in a loop when the user clicks the first time, and keep looping until user presses the mouse the second time.
I have tried the following approach, but for some reason the program crashes after the second click. Any ideas, what I am doing wrong?
int main(){ WaitForMouseUp(); while(!isMouseDown()){ //do something } return 0; }
do somethingpart itself that does the crashing rather than the mouse routines?do something, then it works fine. On the other hand, thedo somethingcode seems to run fine until user makes the second click.int main(){and notint main{?