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
        //-----------------------------------------------------------------------------
        // 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);
            }
        }