Multiple Direct3D 9 devices and Alt-tabbing

824 views Asked by At

I have an application that creates a Direct3D 9 device in fullscreen mode and then starts presenting. At a later point, after having created the first device, I temporarily create a new Direct3D device in windowed mode (on the same thread but for a different window). I destroy this device immediately again, but somehow I'm then no longer able to Alt-tab out of the fullscreen application anymore. The application just stays on top rather than dropping to the background although it looks like the application is no longer in focus.

If I create my temporary device as D3DDEVTYPE_NULLREF, I'm suddenly able to Alt-tab out. Does anybody have an idea why that is, and if so, how I can create a second temporary device without messing up the existing device?

2

There are 2 answers

4
real4x On

When you create a D3D device you specify which window do bind it to (third parameter of CreateDevice call). I may suggest that destroying of second device takes out focus in a way which is unseen by the first device. Try explicitly returning the focus back to main window:

second_device->Release();
SetActiveWindow(hWnd);

Btw, if this is how you make parallel rendering consider using render targets or swap chains instead. DX9 docs say that switching between devices puts a significant penalty to performance.

1
Game_Overture On

Try resetting the first device after you create your second device. MSDN mentioned this is the proper way to initialize multiple devices. I can't find the article about it however :(

Although I've never needed to make a full screen and windowed device. I've only ever tried with two full-screen devices.