Need to "pause" „while“ loop

Reply

Join Date: Jan 2008
Posts: 54
Reputation: Thew is an unknown quantity at this point 
Solved Threads: 0
Thew's Avatar
Thew Thew is offline Offline
Junior Poster in Training

Need to "pause" „while“ loop

 
0
  #1
Jun 14th, 2008
Hello,
I need help in my application development.
I'm actualy working on editor for simple 3D App, and I need to add window for rendering 3D content into the editor. But as many of you know, 3D apps have the while loop keep rendering. So if I create main editor window and the the 3D content window, how can I set up the 3D App so everytime ESC is pressed, the mouse and control will be given to main editor window. I thought about some thread, but then I need to "pause" it everytime ESC is pressed. Is any way how to pause the thread in C++ ?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 16,588
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1614
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Need to "pause" „while“ loop

 
0
  #2
Jun 14th, 2008
MS-Windows: Sleep(milliseconds) -- *nix: usleep(milliseconds).
The most important thing in the Olympic Games is not to win but to take part, just as the most important thing in life is not the triumph but the struggle. The essential thing is not to have conquered but to have fought well.
-Pierre de Coubertin, The Olympic Creed Inspired by Bishop Ethelbert
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 47
Reputation: Cybulski is an unknown quantity at this point 
Solved Threads: 3
Cybulski's Avatar
Cybulski Cybulski is offline Offline
C++ wannabe

Re: Need to "pause" „while“ loop

 
0
  #3
Jun 14th, 2008
I'm quite sure he asked how to test keypress in while but I have no idea how to do it while( now)
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 9
Reputation: TacklesMcCaw is an unknown quantity at this point 
Solved Threads: 2
TacklesMcCaw TacklesMcCaw is offline Offline
Newbie Poster

Re: Need to "pause" „while“ loop

 
0
  #4
Jun 15th, 2008
It depends what kind of graphics library you are using. I personally have only ever used openGL on because that is portable, but it seems like you aren't using that, or are not using a standard graphics library at all, not that I know all that much about them.

One way of doing it, and this might not fit well into how your code is structured:

  1. while (1) {
  2. //drawing for the 3D app
  3.  
  4. //when esc is pressed
  5. break;
  6. }
  7. return;

Where return conceivably brings you back to the section of the code that handles the editor. The assumption I'm making is that you can call at will the function that does the 3D rendering loop, but that may be a bad assumption without knowing the code. I would put the 3D rendering commands into a separate function that you can call from the main app, so that you can return to it at your leisure.
Last edited by TacklesMcCaw; Jun 15th, 2008 at 12:43 am.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 54
Reputation: Thew is an unknown quantity at this point 
Solved Threads: 0
Thew's Avatar
Thew Thew is offline Offline
Junior Poster in Training

Re: Need to "pause" „while“ loop

 
0
  #5
Jun 15th, 2008
The rendering loop is fully automatic, but I can do something like this:
  1. // startup sequence
  2.  
  3. // while loop
  4. while (true)
  5. {
  6. renderOneFrame();
  7. if ( /* ESC pressed */ )
  8. break;
  9. }
  10.  
  11. if ( /* escaping main editor */ )
  12. // clear sequence
so eveytime the ESC is pressed in 3D Window, rendering process will be broken, but one thing that I still don't know is, how can I after the rendering loop broke bring mouse to the main editor Window, I think to focus the Window, so the 3D Window will be inactive until I click it.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 9
Reputation: TacklesMcCaw is an unknown quantity at this point 
Solved Threads: 2
TacklesMcCaw TacklesMcCaw is offline Offline
Newbie Poster

Re: Need to "pause" „while“ loop

 
0
  #6
Jun 15th, 2008
Well that depends on what you're using to do all this windowing and graphics work. I happen to only use OpenGL/glut which is windowing system agnostic, which means its not always possible to fully control where the mouse is displayed, but whatever your using (I'm assuming something MS related, which I don't have any experience with) might be able to physically move the cursor. As far as making the editor the main window that should be easy as long as whatever API you're using has something akin to glutSetWindow(int) where int is a window ID. Like I said, I don't know other API's very well, but I do know that it is possible to do this, you just need to know what you're using well enough.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 1346 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC