コード例 #1
0
            //private Direct3DTexture9 GetSharedSurface(Direct3DDevice9 device)
            //{

            //    return device.CreateTexture(
            //        m_width,
            //        m_height,
            //        1,
            //        1,  //D3DUSAGE_RENDERTARGET
            //        Format,
            //        0  //D3DPOOL_DEFAULT
            //        );
            //}



            private static Direct3DDevice9Ex CreateDevice(IntPtr handle)
            {
                const int D3D_SDK_VERSION = 32;

                using (var d3d9 = Direct3D9Ex.Create(D3D_SDK_VERSION))
                {
                    var present = new NativeStructs.D3DPRESENT_PARAMETERS();

                    try
                    {
                        var wih = new System.Windows.Interop.WindowInteropHelper(App.Current.MainWindow);

                        if (wih.Handle != IntPtr.Zero)
                        {
                            handle = wih.Handle;
                        }
                    }
                    catch (Exception)
                    {
                    }

                    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));
                }
            }
コード例 #2
0
ファイル: D3D10Image.cs プロジェクト: wwkkww1983/Nutshell
        private static Direct3DDevice9Ex CreateDevice(IntPtr handle)
        {
            const int D3D_SDK_VERSION = 32;

            using (var d3d9 = Direct3D9Ex.Create(D3D_SDK_VERSION))
            {
                var present = new 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));
            }
        }