PDA

View Full Version : windows & dx


lennard
05-05-2007, 10:00 PM
Has anyone created multiple windows, each with their own displayed DX surface? Can't tell if this is possible from the doc's.

PeterM
05-06-2007, 02:12 AM
Yes, that should work fine.

lennard
05-06-2007, 10:24 AM
Hi Peter, have you actually accomplished this?

The part that is throwing me is that when you create the DD object (always described as singular) you bind it directly to a window:

ddrval = DirectDrawCreate( NULL, &lpDD, NULL );

ddrval = lpDD->SetCooperativeLevel( hwnd, DDSCL_NORMAL );

and I can't find documentation anywhere that says that multiple DD objects is an OK thing. Additionally, I know I have potential issues with each surface being lost if there are many windows but I'm not sure, in practice, if that is an issue on modern machines.

PeterM
05-06-2007, 10:34 AM
I've created an app with multiple windows and DD objects before and didn't have any problems.

The only bummer is that you won't be able to share source surfaces for blitting between the windows since they will have been created by different DirectDraw objects.

Maybe there's a way around this, but I didn't experiment with it.

Donavon Keithley
05-06-2007, 12:08 PM
The DirectDraw object essentially represents the video device, so unless you're targeting multiple devices (e.g., multimon), I would use just one.

To render to multiple windows, you can create a clipper for each one, or use IDirectDrawClipper:SetHWnd to switch between windows.

FWIW, the window that SetCooperativeLevel takes is only needed for exclusive mode. DD resizes it to fill the screen. It also hooks into the message queue to detect, for example, when another window becomes active so that it can minimize the window and relinquish control of the device. I'm not 100% sure, but I think it's ignored for DDSCL_NORMAL.

HTH (and it's been a looong time since I've programmed DD, so I hope I'm remembering this right...).