Click to See Complete Forum and Search --> : Troubles using directX in windows mobile 6


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.

mbldev
06-28-2009, 07:12 PM
When you open your second form it cannot see your variables. You need to run debug and step through your code. Check the scoping on your variables and objects.

FlorianGaillard
07-03-2009, 11:58 AM
Thanks.

Actually, it was the device.dispose() method that I forgot to invoke.

Florian.