Ejemplo n.º 1
0
        /// <summary>
        /// Tests if the D3D device has been lost and if it has
        /// it is retored. This happens on XP with things like
        /// resolution changes or pressing ctrl + alt + del.  With
        /// Vista, this will most likely never be called unless the
        /// video driver hangs or is changed.
        /// </summary>
        private void TestRestoreLostDevice()
        {
            if (m_device == null)
            {
                return;
            }

            /* This will throw an exception
             * if the device is lost */
            int hr = m_device.TestCooperativeLevel();

            /* Do nothing if S_OK */
            if (hr == 0)
            {
                return;
            }

            FreeSurfaces();

            while (hr != -2005530519)
            {
                Thread.Sleep(500);
                hr = m_device.TestCooperativeLevel();
            }

            CreateDevice();

            Thread.Sleep(500);

            IntPtr pDev = GetComPointer(m_device);

            /* Update with our new device */
            m_allocatorNotify.ChangeD3DDevice(pDev, GetAdapterMonitor(0));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tests if the D3D device has been lost and if it has
        /// it is retored. This happens on XP with things like
        /// resolution changes or pressing ctrl + alt + del.  With
        /// Vista, this will most likely never be called unless the
        /// video driver hangs or is changed.
        /// </summary>
        private void TestRestoreLostDevice()
        {
            if (m_device == null)
            {
                return;
            }

            /* This will throw an exception
             * if the device is lost */
            int hr = m_device.TestCooperativeLevel();

            /* Do nothing if S_OK */
            if (hr == 0)
            {
                return;
            }

            FreeSurfaces();
            CreateDevice();

            /* TODO: This is bad. FIX IT!
             * Figure out how to tell when the new
             * device is ready to use */
            Thread.Sleep(1500);

            IntPtr pDev = GetComPointer(m_device);

            /* Update with our new device */
            m_allocatorNotify.ChangeD3DDevice(pDev, GetAdapterMonitor(0));
        }