FlorianGaillard
06-19-2009, 04:31 AM
Hi
I'm new in windows mobile programming. I'd like to use directX (direct3D) to display some basics 3D shapes on two forms. To do so, I use an object Device. I can display something on my main form, but when I try to do it on a second form, I get a NotAvailableException when I try to create a new device. I think I need to kill something before using a new device object but I don't know what to kill. I tried device = null, but it doesn't work. Here is the code:
private void InitializeGraphics()
{
try
{
// We don't want to run fullscreen
presentParams.Windowed = true;
// Discard the frames
presentParams.SwapEffect = SwapEffect.Copy;
// Turn on a Depth stencil
presentParams.EnableAutoDepthStencil = true;
// And the stencil format
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
//Create a device (bug here on the second attempt)
device = new Device(Manager.Adapters.Default.Adapter, DeviceType.Default, formToDisplay, CreateFlags.None, presentParams);
device.DeviceReset += new System.EventHandler(this.OnResetDevice);
this.OnCreateDevice(device, null);
this.OnResetDevice(device, null);
doDisplay = true;
}
catch (DirectXException)
{
//Catch any errors and return a failure
//doDisplay = false;
}
}
Thank you.
Florian.
I'm new in windows mobile programming. I'd like to use directX (direct3D) to display some basics 3D shapes on two forms. To do so, I use an object Device. I can display something on my main form, but when I try to do it on a second form, I get a NotAvailableException when I try to create a new device. I think I need to kill something before using a new device object but I don't know what to kill. I tried device = null, but it doesn't work. Here is the code:
private void InitializeGraphics()
{
try
{
// We don't want to run fullscreen
presentParams.Windowed = true;
// Discard the frames
presentParams.SwapEffect = SwapEffect.Copy;
// Turn on a Depth stencil
presentParams.EnableAutoDepthStencil = true;
// And the stencil format
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
//Create a device (bug here on the second attempt)
device = new Device(Manager.Adapters.Default.Adapter, DeviceType.Default, formToDisplay, CreateFlags.None, presentParams);
device.DeviceReset += new System.EventHandler(this.OnResetDevice);
this.OnCreateDevice(device, null);
this.OnResetDevice(device, null);
doDisplay = true;
}
catch (DirectXException)
{
//Catch any errors and return a failure
//doDisplay = false;
}
}
Thank you.
Florian.