| | |
Need to "pause" „while“ loop
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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++ ?
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++ ?
•
•
Join Date: Jun 2008
Posts: 9
Reputation:
Solved Threads: 2
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:
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.
One way of doing it, and this might not fit well into how your code is structured:
C++ Syntax (Toggle Plain Text)
while (1) { //drawing for the 3D app //when esc is pressed break; } 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 1:43 am.
The rendering loop is fully automatic, but I can do something like this:
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.
C++ Syntax (Toggle Plain Text)
// startup sequence // while loop while (true) { renderOneFrame(); if ( /* ESC pressed */ ) break; } if ( /* escaping main editor */ ) // clear sequence
•
•
Join Date: Jun 2008
Posts: 9
Reputation:
Solved Threads: 2
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.
![]() |
Similar Threads
- system("PAUSE") (C++)
Other Threads in the C++ Forum
- Previous Thread: operation overload
- Next Thread: NEED HELP PROGRAMMING! sorted arrays
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg simple sorting string strings temperature template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






