thread or not?

Started by
2 comments, last by Saberman 20 years, 5 months ago
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.
Gaxx
Advertisement
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.
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





Gaxx
Your console could simply be a modeless dialog box. That way the threading is handled implicitly by the OS, rather than you having to mess about with it yourself.

This topic is closed to new replies.

Advertisement