Caps caps = Manager.GetDeviceCaps(0, DeviceType.Hardware); if (caps.DeviceCaps.SupportsHardwareTransformAndLight) device3D = new Device(0, DeviceType.Hardware, ctrl, CreateFlags.HardwareVertexProcessing, presentParams); else device3D = new Device(0, DeviceType.Hardware, ctrl, CreateFlags.SoftwareVertexProcessing, presentParams);
if (caps.MaxActiveLights < 2) ErrorManage("Votre carte ne supporte pas assez de lumires..."); if (caps.MaxTextureBlendStages < 2) ErrorManage("Votre carte ne supporte pas le multitexturing..."); if (caps.RasterCaps.SupportsAnisotropy) ErrorManage("Votre carte ne supporte pas le filtrage anisotropique...");
private static DepthFormat GetDepthFormat(Format backbufferFormat) { if (Manager.CheckDepthStencilMatch(0, DeviceType.Hardware, Manager.Adapters[0].CurrentDisplayMode.Format, backbufferFormat, DepthFormat.D24X8)) return DepthFormat.D24S8; return DepthFormat.D15S1; } private static Format GetBackBufferFormat() { if (Manager.CheckDeviceType(0, DeviceType.Hardware, Manager.Adapters[0].CurrentDisplayMode.Format, Format.X8R8G8B8, true)) return Format.X8R8G8B8; if (Manager.CheckDeviceType(0, DeviceType.Hardware, Manager.Adapters[0].CurrentDisplayMode.Format, Format.R5G6B5, true)) return Format.R5G6B5; return Format.Unknown; } public static void InitDXM(Control ctrl) { try { PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; presentParams.BackBufferFormat = GetBackBufferFormat(); presentParams.AutoDepthStencilFormat = GetDepthFormat(presentParams.BackBufferFormat); presentParams.EnableAutoDepthStencil = true; presentParams.BackBufferCount = 2;