Archived

This topic is now archived and is closed to further replies.

Saberman

thread or not?

Recommended Posts

Hallo, I''ve got a question and I hope someone could help me. A couple of days ago I posted a topic asking dome help about the little start-up console showed in games like quake3. (Not the in game console) Thanks to the help received I got convinced that that was just a standard window that was simulating a console. I managed to obtaing one identical. Now my doubt is the following, to put down some very rough pseudo-code, I have something like this : Program begin -> CreateConsole(and from this point I begin to send text the window dscribing various operations performed), -> various initializions(loading opengl32.dll...Creating main window(for rendering->initialing other Gl stuff ... finally main cycle(getting input..updating world...rendering...) So I have two windows, the console one and the one used for rendering(I think I could call it GLwindow...) Now how could I manage this situation? I mean should I begin a thread in WM_CREATE received by console wndproc and put all other stuff in that thread, or is this completely wrong? In the past I used system console(AllocConsole + _cprintf) for debugging so I never had two standard window in the same program but only the one I used to render. I hope someone could give me some hints about the way I should take Many thanks. Saberman.

Share this post


Link to post
Share on other sites
this is just my take on it but i''d do it as following:

- create the window for output giving it a winproc which has a custom msg handler
- create your opengl window
- kick a thread into life for handling all your main loop
- whenever you want to display some output in the other window send a windows message to it which matches your custom handler
- in the custom handler output what you send

the other idea is as above but instead of a custom window handler just use something like an stl list or vector (or some other non-sorting container) and from the main loop put strings in and in a thread for the other window pull the strings out and write them to the window.

Share this post


Link to post
Share on other sites
Thanks, it looks intersting.
As I mentioned I''m new enough to threads so when You say

: "kick a thread into life for handling all your main loop..."

I'' d like to ask You:


My doubt is the following :

if iI follow this order :

enter WinMain-->Create first window(to print out...)---> initialization + creation of Glwindow --->main_loop(...),

then if just before entering main_loop I send a WM_CLOSE to console window (in fact by this time all initialization stuff is done and eventual errors could be handled and displayed differently)Do I really need a thread?
(It''s likely to be a silly question but I''m trying to understand...)

Thanks.

Saberman





Share this post


Link to post
Share on other sites