0

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?

dreijer
  • 654
  • 8
  • 22

2 Answers2

0

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.

Game_Overture
  • 1,578
  • 3
  • 22
  • 34
  • Here is the MSDN article you referred to. Whether it would solve the submitter's problem is another matter! [Working with Multiple Monitor Systems (Direct3D 9)](https://msdn.microsoft.com/en-us/library/windows/desktop/bb206364(v=vs.85).aspx) – boblicious Feb 18 '16 at 11:30
0

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.

real4x
  • 1,433
  • 12
  • 11
  • I was thinking it might mess up the window styles on the fullscreen window somehow, too. I'll give the SetActiveWindow a go. And no, I don't use the second device for any rendering whatsoever. I just need the IDirect3DDevice9 (and its virtual table) for hooking purposes. – dreijer Jan 24 '12 at 13:38
  • It made no difference, sadly. – dreijer Jan 24 '12 at 14:05
  • Well, after some more reading about creation multiple devices there is another idea: second device sets a cooperative level incompatible with the first one. You may avoid this by either specifying D3DCREATE_NOWINDOWCHANGES in second device creation or explicit call to SetCooperativeLevel when second device is destroyed. – real4x Jan 24 '12 at 22:22
  • Thanks for doing some more reading on this, real4x. Setting D3DCREATE_NOWINDOWCHANGES didn't do anything, unfortunately, and SetCooperativeLevel() doesn't exist for Direct3D 9 (as far as I'm aware). I'm at a loss here. – dreijer Jan 26 '12 at 00:24