Exemple #1
0
        //-----------------------------------------------------------------------------
        // Static functions
        //-----------------------------------------------------------------------------

        //-----------------------------------------------------------------------------
        // FindAdapter
        //
        // Given a handle to a monitor, returns the ordinal number that D3D uses to
        // identify the adapter.
        //-----------------------------------------------------------------------------

        protected static void FindAdapter(IDirect3D9 pD3D9, IntPtr hMonitor, out int puAdapterID)
        {
            int cAdapters = 0;

            puAdapterID = -1;

            cAdapters = pD3D9.GetAdapterCount();
            for (int i = 0; i < cAdapters; i++)
            {
                IntPtr hMonitorTmp = pD3D9.GetAdapterMonitor(i);

                if (hMonitorTmp == IntPtr.Zero)
                {
                    break;
                }
                if (hMonitorTmp == hMonitor)
                {
                    puAdapterID = i;
                    break;
                }
            }

            if (puAdapterID == -1)
            {
                throw new COMException("D3DPresentEngine::FindAdapter", (int)HResult.E_FAIL);
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a new VMR9 custom allocator to use with Direct3D
        /// </summary>
        public Vmr9Allocator()
        {
            /* Use the 9Ex for Vista */
            if (IsVistaOrBetter)
            {
                Direct3D.Direct3DCreate9Ex(D3D_SDK_VERSION, out m_d3dEx);
            }
            else /* For XP */
            {
                m_d3d = Direct3D.Direct3DCreate9(D3D_SDK_VERSION);
            }

            CreateDevice();
        }
        static Vmr9Allocator()
        {
            m_hWnd = GetDesktopWindow();

            /* Use the 9Ex for Vista */
            if (IsVistaOrBetter)
            {
                Direct3D.Direct3DCreate9Ex(D3D_SDK_VERSION, out m_d3dEx);
            }
            else /* For XP */
            {
                m_d3d = Direct3D.Direct3DCreate9(D3D_SDK_VERSION);
            }

            CreateDevice();
        }
Exemple #4
0
        /// <summary>
        /// Creates a new VMR9 custom allocator to use with Direct3D
        /// </summary>
        public Vmr9Allocator()
        {
            /* Use the 9Ex for Vista */
            int hr = 0;

            if (IsVistaOrBetter)
            {
                hr = Direct3D.Direct3DCreate9Ex(D3D_SDK_VERSION, out m_d3dEx);
            }
            else /* For XP */
            {
                m_d3d = Direct3D.Direct3DCreate9(D3D_SDK_VERSION);
            }

            if (m_d3dEx == null && m_d3d == null)
            {
                string hrStr = hr == 0 ? "" : $"({hr:X})";
                throw new WPFMediaKitException($"Could not create IDirect3D9 {hrStr}. " + VMR9_ERROR);
            }

            CreateDevice();
        }
Exemple #5
0
        /// <summary>
        /// Part of the dispose pattern
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            //if (m_disposed) return;

            if (disposing)
            {
                InvokeNewSurfaceEvent(IntPtr.Zero);
                /* Pass a dummy cookie to TerminateDevice */
                TerminateDevice(IntPtr.Zero);

                if (m_allocatorNotify != null)
                {
                    Marshal.FinalReleaseComObject(m_allocatorNotify);
                    m_allocatorNotify = null;
                }

                if (m_d3d != null)
                {
                    Marshal.FinalReleaseComObject(m_d3d);
                    m_d3d = null;
                }

                if (m_d3dEx != null)
                {
                    Marshal.FinalReleaseComObject(m_d3dEx);
                    m_d3dEx = null;
                }

                if (m_device != null)
                {
                    Marshal.FinalReleaseComObject(m_device);
                    m_device = null;
                }
            }

            m_disposed = true;
        }
Exemple #6
0
        //-----------------------------------------------------------------------------
        // Static functions
        //-----------------------------------------------------------------------------
        //-----------------------------------------------------------------------------
        // FindAdapter
        //
        // Given a handle to a monitor, returns the ordinal number that D3D uses to
        // identify the adapter.
        //-----------------------------------------------------------------------------
        protected static void FindAdapter(IDirect3D9 pD3D9, IntPtr hMonitor, out int puAdapterID)
        {
            int cAdapters = 0;
            puAdapterID = -1;

            cAdapters = pD3D9.GetAdapterCount();
            for (int i = 0; i < cAdapters; i++)
            {
                IntPtr hMonitorTmp = pD3D9.GetAdapterMonitor(i);

                if (hMonitorTmp == IntPtr.Zero)
                {
                    break;
                }
                if (hMonitorTmp == hMonitor)
                {
                    puAdapterID = i;
                    break;
                }
            }

            if (puAdapterID == -1)
            {
                throw new COMException("D3DPresentEngine::FindAdapter", E_Fail);
            }
        }
        /// <summary>
        /// Part of the dispose pattern
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            //if (m_disposed) return;

            if (disposing)
            {
                InvokeNewSurfaceEvent(IntPtr.Zero);
                /* Pass a dummy cookie to TerminateDevice */
                TerminateDevice(IntPtr.Zero);
               
                if (m_allocatorNotify != null)
                {
                    Marshal.FinalReleaseComObject(m_allocatorNotify);
                    m_allocatorNotify = null;
                }

                if (m_d3d != null)
                {
                    Marshal.FinalReleaseComObject(m_d3d);
                    m_d3d = null;
                }

                if (m_d3dEx != null)
                {
                    Marshal.FinalReleaseComObject(m_d3dEx);
                    m_d3dEx = null;
                }

                if (m_device != null)
                {
                    Marshal.FinalReleaseComObject(m_device);
                    m_device = null;
                }
            }

            m_disposed = true;
        }
        /// <summary>
        /// Creates a new VMR9 custom allocator to use with Direct3D
        /// </summary>
        public Vmr9Allocator()
        {
            /* Use the 9Ex for Vista */
            if (IsVistaOrBetter)
                Direct3D.Direct3DCreate9Ex(D3D_SDK_VERSION, out m_d3dEx);
            else /* For XP */
                m_d3d = Direct3D.Direct3DCreate9(D3D_SDK_VERSION);

            CreateDevice();
        }
        static Vmr9Allocator()
        {
            m_hWnd = GetDesktopWindow();

            /* Use the 9Ex for Vista */
            if (IsVistaOrBetter)
                Direct3D.Direct3DCreate9Ex(D3D_SDK_VERSION, out m_d3dEx);
            else /* For XP */
                m_d3d = Direct3D.Direct3DCreate9(D3D_SDK_VERSION);

            CreateDevice();
        }
Exemple #10
0
 private Direct3D9(IDirect3D9 d3d9interface)
 {
     _ID3d9 = d3d9interface;
 }