Jump to content

  • Log In with Google      Sign In   
  • Create Account

DirectX 9 multimonitor devices


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Erik Rufelt   Crossbones+   -  Reputation: 3632

Like
0Likes
Like

Posted 04 November 2005 - 03:55 AM

Hey, I'm trying to create two fullscreen devices, on two different monitors, with Direct3D 9. It works fine with windowed devices, I create the devices with different adapters and they draw fine on different monitors. Fullscreen works fine when I just use one device, but when creating two fullscreen devices I get D3DERR_DEVICELOST from the second CreateDevice. For testing I'm creating two windows, one on each screen, both covering the whole of their screens, with the WS_EX_TOPMOST style and no borders or anything. There's no visible difference between fullscreen and windowed mode now, so perhaps it doesn't matter if I tell D3D it's fullscreen or not, but I would like it to work. The only difference between "windowed" and "fullscreen" is that the 'Windowed' parameter of the D3DPRESENT_PARAMETERS is TRUE for window mode. when both devices have TRUE for windowed there's no problem. when I only use one device it works fine no matter if Windowed is TRUE or FALSE when I create the first device with Windowed TRUE it works fine to create the second with Windowed FALSE when I create the first device with Windowed FALSE I get an error no matter the Windowed mode of the second device
// This is reset before creating each device
d3dpp.Windowed = TRUE; // or FALSE for fullscreen
d3dpp.BackBufferWidth = SCREEN_WIDTH; // same on both monitors
d3dpp.BackBufferHeight = SCREEN_HEIGHT; // same on both monitors
d3dpp.hDeviceWindow = g_hWnd; // or g_hWnd2 which is located on the second monitor
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;

hResult = g_pD3D->CreateDevice(
0, // or 1 for the second monitor, this works fine
D3DDEVTYPE_HAL,
g_hWnd, // or g_hWnd2 on the second monitor
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp,
&g_pd3dDevice// or g_pd3dDevice2 for the second monitor
);

Is there something special I need to think about when setting up two fullscreen devices? Thanks, /Erik

Sponsor:

#2 Steven Hansen   Members   -  Reputation: 240

Like
0Likes
Like

Posted 04 November 2005 - 05:24 AM

Only one screen may be fullscreen - it has the focus. Sorry.

I do many multi-monitor apps, and this does seem to be an oversight with Windows developers! Argh. Anyway, windowed mode that fills the screen looks a lot like fullscreen, doesn't have the focus issues, and still runs reasonably fast - perhaps not HL2 fast, but fast enough for all the stuff I've done with it, including quite a bit of 3D advanced techniques.

Good luck.

#3 Erik Rufelt   Crossbones+   -  Reputation: 3632

Like
0Likes
Like

Posted 04 November 2005 - 09:17 AM

Thanks for the reply!

That kinda sucks. Still it seems strange..
This is how MSDN describes the hDeviceWindow parameter of the D3DPRESENT_PARAMETERS structure.
Quote:

hDeviceWindow
The device window determines the location and size of the back buffer on screen. This is used by Direct3D when the back buffer contents are copied to the front buffer during Present.
For a full-screen application, this is a handle to the top window (which is the focus window).

For applications that use multiple full-screen devices (such as a multimonitor system), exactly one device can use the focus window as the device window. All other devices must have unique device windows.

For a windowed-mode application, this handle will be the default target window for Present. If this handle is NULL, the focus window will be taken.
Note that no attempt is made by the runtime to reflect user changes in window size. The back buffer is not implicitly reset when this window is reset. However, the Present method does automatically track window position changes.


Clearly seems to say that there can be multiple fullscreen-devices..

/Erik

#4 deffer   Members   -  Reputation: 754

Like
0Likes
Like

Posted 04 November 2005 - 10:08 AM

I was recently having a similar problem.

Quote:
Original post by deffer
I was digging through DXSDK documentation and found out this:
Quote:
The concept of exclusive full-screen mode is retained in Microsoft DirectX 9.0, but it is kept entirely implicit in the IDirect3D9::CreateDevice and IDirect3DDevice9::Reset method calls. Whenever a device is successfully reset or created in full-screen operation, the Microsoft Direct3D object that created the device is marked as owning all adapters on that system. This state is known as exclusive mode, and at this point the Direct3D object owns exclusive mode. Exclusive mode means that devices created by any other Direct3D9 object can neither assume full-screen operation nor allocate video memory. In addition, when a Direct3D9 object assumes exclusive mode, all devices other than the device that went full-screen are placed into the lost state.

It's the most descriptive part I could find about the problem (not very descriptive, is it?[grin]


In the end I came to a conclusion that apparently it cannot be done with focus-switching feature.

#5 Erik Rufelt   Crossbones+   -  Reputation: 3632

Like
0Likes
Like

Posted 05 November 2005 - 09:26 AM

That same article (I think it was the same) says that there can be many fullscreen devices on different adapters, but that they need to use the same focus window.
It works using the same focus window, but I haven't been able to make the window cover both screens, seems like DX resets the window size or something.. which is bad if the user clicks the mouse outside of the focus window, and sometimes things behind the fullscreen app gets redrawn on top of it..
But perhaps there's a solution for that too =)

#6 Tim Cotter   Members   -  Reputation: 100

Like
0Likes
Like

Posted 31 January 2012 - 10:04 PM

yeah okay i know i'm replying to an old post. here's how i did it in win7:

create a focus window for both devices.
(optionally) create a device window for the first adapter.
create a device window for the second adapter.
create a direct3d9 context.
use this to create both devices.
create the first fullscreen device using the shared focus window and (optionally) the first device window.
create the second fullscreen device using the shared focus window and the second device window.
reset the first device.
the shared focus window is passed directly as a parameter to CreateDevice.
the device windows are passed in the presentation parameters structure.

all of the above must be done in the same thread as the GetMessage loop that handles messages for the above windows.

i like to use message only windows for fullscreen device windows.

i would suggest using directx 9ex instead of directx 9.
this way you can share resources between the two devices.

if the devices are created with the multi threaded flag then you can present to them from different threads.
in this case, the devices need to be "similar".
i don't know exactly how similar they have to be.
but using the same behavior flags and presentation parameters worked for me.
if the devices are not similar enough, you could get into a nasty deadlock situation where your presents happen at 0.5 fps.

CreateDevice and Reset tend to change the presentation parameters.
you might want to pass a copy instead of the master.

g'luck.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS