tags:

views:

78

answers:

2

I have an XNA application that renders onto a second monitor (adaptor 1), at regular intervals it takes a screenshot of itself and stores it as a Texture2D.

As this application launches it also shows a Windows Form with a panel. This panel is supposed to be drawn on by a seperate GraphicsDevice, and displays the Texture2D.

The problem I am having is that as I run this code in the Windows form to create the GraphicsDevice:

mainDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, panel1.Handle, pp);

I get a DeviceLostException. The standard advice in this case is to catch the exception, sleep the thread for a few seconds and retry, but this just puts me in an infinite loop.

I suspect this is because my XNA class is using the hardware at the same time and that I am thinking about this the wrong way. But I can't find any documentation on how I should be doing this correctly.

Any help would be much appreciated.

+1  A: 

I hope I'm wrong, because it would be pretty cool. But I don't believe that the XNA APIs allow you to render onto two separately monitors at once using dual graphics devices.

Joel Martinez
+1  A: 

GraphicsDevice is a physical device, not something attached to a window. If you have two physical devices, you can instantiate another GraphicsDevice using a different GraphicsAdapter (meaning not the default).

If you're not going to put much load on the device, or if one of them does not need a lot of hardware acceleration, you can create a software device instead. The capabilities may be similar, but it's going to be a lot slower.

Other than that, the only things I can think of are to see if XNA supports command buffers (which I'm not sure it does) and manage locking / unlocking the device yourself.

Jeff