Resetting d3device error


  • Is there any procedure before and after resetting the directX device ?
    I want to make the toggle fullscreen function , but when I restart the device , there are errors (sometime the error is unknown , sometime it throws DeviceLost Exception).
    I can start the directX device at the beginning , but if i change the presentationParams and reset the device , it occur error. My code is like this :

    void initdevice(bool fullscreen) {
     PresentParameters d3dpp = new PresentParameters();
     d3dpp.DeviceWindow = form1;
     d3dpp.BackBufferWidth = 800;
     d3dpp.BackBufferHeight = 600;
     if (fullscreen) {
      d3dpp.Windowed = false;
     } else {
      form1.ClientSize = new Size(800, 600);
      d3dpp.Windowed = true;

     if (device != null) {
     } else {
      device = new Device(Manager.Adapters[0].Adapter, DeviceType.Hardware, form1, CreateFlags.HardwareVertexProcessing, d3dpp);

    Is there any procedure that I missed ? or the window form's problem ? or reset method is wrong ?
    I see some of the programmer simply dispose old device and create a new device instead of using reset(d3dpp) , which method is better ?

    Also I've a question about threading.
    If a thread is suspended, and the program is going to be disposed. How to terminate the suspended thread ?
    When I try to use thread.Abort() to terminate it , it seems no effect ( I see it still 'isAlive' in the watch ) .
    If I first resume the thread then abort it , it seems a fool method , and it may not work all the time.
    I use another thread to do rendering. So sometimes if the render is suspended, and to program is going to be disposed , it crush (maybe the D3Device is disposed , but the render thread fail to terminate.)

    Saturday, April 02, 2005 5:36 PM


  • Sces -
    Similar to the response to your last post, you should try the managed Directx newsgroup -- they probably have more expertise in this area.

    Karen Liu
    Visual C#
    Wednesday, April 06, 2005 7:47 PM

All replies