PDA

View Full Version : Handling Multiple Windows



Mukund
04-13-2010, 03:04 PM
Hello everyone.Im facing some problems wrt multiple windows.

This is what i intend to do:

I have one window in which certain rendering is taking place.
I have made this a slow process by giving delays in my program.

Now i have another window that says: "LOADING..PLEASE WAIT"..

Now i need something going on in my foreground window(the one that says "please wait").Also the rendering needs to be done in the background window.

So i need simultaneous operation of both windows.Is it possible?

Thanks in advance.

dorbie
04-13-2010, 04:41 PM
Yes it is possible, however you are not guaranteed that OpenGL will render to backbuffer memory for rendering underneath the hidden window on all platforms.

On some platforms there are ways to ensure you draw to the occluded backbuffer, but you could also render to an offscreen buffer rather than the window backbuffer.

You can certainly have one thread render to a progress dialog and another render to the backbuffer, or even schedule the context switches yourself from a single thread, or avoid context switches altogether (probably best and safest IMHO) by keeping the progress bar in some native format.

You could also draw to the backbuffer and render the progress to the frontbuffer occasionally using glFlush, and switch back to the backbuffer.... all in a single thread with no context switches but it would require testing and it would still impact performance. It would keep the code simple and avoid the whole occluded buffer rendering problems, but it hides a lot of crap the driver would be doing to make most of these schemes work.

Mukund
04-13-2010, 07:30 PM
Thanks Dorbie.
Well, i have never tried multithreaded programming.But have tried using multiple processes via forks on Linux.

Now im currently using Windows XP.
Is there any way in which i could do the same in Windows??

1)i mean can i create a child process and then exec() it like gow we can do in Linux based systems?? because learning about multithreading and then implementing it would be kind of hard.And this stuff is pretty urgent.

2)In the end,you mentioned about doing the same job using a single thread.I did not get you.

3)I tried using glutSetWindow() and alternate between the two windows.That did not work.

dorbie
04-16-2010, 04:13 PM
You can certainly multi-thread on windows. You can draw to separate windows from different threads and leave the driver to handle switches although I'd recommend avoiding touching OpenGL in the progress window if you use a window. The simplest way to do this is to launch a modeless dialog window. You still have the problem of actually getting rendering beneath the dialog, there's a way to do this, but I don't recall it off the top of my head. RTT & render to pbuffer certainly fit the bill but there may be a PFD or similar setting that makes it trivially enforceable. If it's a desktop setting of course you cannot rely on it on other systems.

The simplest way is to not use a separate window at all. You just draw the progress to the frontbuffer intermittently between backbuffer draw calls.