public Direct3D9Api(INativeWindow window) { MinZNear = 0.05f; IntPtr winHandle = window.WinHandle; d3d = Direct3D.Direct3DCreate9(Direct3D.SdkVersion); const int adapter = 0; // default adapter InitFields(); FindCompatibleFormat(adapter); PresentParameters args = GetPresentArgs(640, 480); try { device = Direct3D.CreateDevice(d3d, adapter, DeviceType.Hardware, winHandle, createFlags, &args); } catch (SharpDXException) { createFlags = CreateFlags.Mixed; try { device = Direct3D.CreateDevice(d3d, adapter, DeviceType.Hardware, winHandle, createFlags, &args); } catch (SharpDXException) { createFlags = CreateFlags.Software; device = Direct3D.CreateDevice(d3d, adapter, DeviceType.Hardware, winHandle, createFlags, &args); } } Capabilities caps; Device.GetCapabilities(device, &caps); MaxTexWidth = caps.MaxTextureWidth; MaxTexHeight = caps.MaxTextureHeight; CustomMipmapsLevels = true; SetDefaultRenderStates(); InitCommon(); }
/// <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(); }
/// <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(); }