示例#1
0
        public Direct3DDevice9Ex CreateDeviceEx(uint Adapter, int DeviceType, IntPtr hFocusWindow, int BehaviorFlags,
                                                NativeStructs.D3DPRESENT_PARAMETERS pPresentationParameters, NativeStructs.D3DDISPLAYMODEEX pFullscreenDisplayMode)
        {
            ComInterface.IDirect3DDevice9Ex obj = null;
            int result = this.createDeviceEx(this.comObject, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, out obj);

            Marshal.ThrowExceptionForHR(result);

            return(new Direct3DDevice9Ex(obj));
        }
        private static Interop.Direct3DDevice9Ex CreateDevice(IntPtr handle)
        {
            const int D3D_SDK_VERSION = 32;

            using (var d3d9 = Interop.Direct3D9Ex.Create(D3D_SDK_VERSION))
            {
                var present = new Interop.NativeStructs.D3DPRESENT_PARAMETERS();
                present.Windowed             = 1;                           // TRUE
                present.SwapEffect           = 1;                           // D3DSWAPEFFECT_DISCARD
                present.hDeviceWindow        = handle;
                present.PresentationInterval = unchecked ((int)0x80000000); // D3DPRESENT_INTERVAL_IMMEDIATE;

                return(d3d9.CreateDeviceEx(
                           0,  // D3DADAPTER_DEFAULT
                           1,  // D3DDEVTYPE_HAL
                           handle,
                           70, // D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE
                           present,
                           null));
            }
        }