/// <summary> /// デバイスの初期化処理 /// </summary> /// <param name="control">適用するコントロールへの参照</param> public void Load(bool needDX11 = false, DeviceCreationFlags dx11flag = DeviceCreationFlags.None, SlimDX.Direct3D10.DeviceCreationFlags dx10flag_for2DDraw = SlimDX.Direct3D10.DeviceCreationFlags.BgraSupport) { ApplyDebugFlags(ref dx11flag, ref dx10flag_for2DDraw); Factory = new Factory1(); CurrentAdapter = Factory.GetAdapter1(0); //スワップチェーンの初期化 try { Device = new Device(CurrentAdapter, dx11flag, new[] { FeatureLevel.Level_11_0 }); } catch (Direct3D11Exception) { if (needDX11) { throw new NotSupportedException("DX11がサポートされていません。DX10.1で初期化するにはLoadの第一引数needDraw=falseとして下さい。"); } try { Device = new Device(CurrentAdapter, dx11flag, new[] { FeatureLevel.Level_10_0 }); } catch (Direct3D11Exception) { throw new NotSupportedException("DX11,DX10.1での初期化を試みましたが、両方ともサポートされていません。"); } } DeviceFeatureLevel = Device.FeatureLevel; Context = Device.ImmediateContext; SampleDescription sampleDesc = new SampleDescription(1, 0); #if VSG_DEBUG #else Device10 = new Device1(CurrentAdapter, DriverType.Hardware, dx10flag_for2DDraw, SlimDX.Direct3D10_1.FeatureLevel.Level_9_3); #endif MMEEffectManager.IniatializeMMEEffectManager(this); }
/// <summary> /// Device initialization /// </summary> /// <param name="control">A reference to the controls applied</param> public void Load(bool needDX11 = false, DeviceCreationFlags dx11flag = DeviceCreationFlags.None, SlimDX.Direct3D10.DeviceCreationFlags dx10flag_for2DDraw = SlimDX.Direct3D10.DeviceCreationFlags.BgraSupport) { ApplyDebugFlags(ref dx11flag, ref dx10flag_for2DDraw); this.Factory = new Factory1(); this.CurrentAdapter = this.Factory.GetAdapter1(0); //Initialization of the swap chain try { this.Device = new Device(this.CurrentAdapter, dx11flag, new[] { FeatureLevel.Level_11_0 }); } catch (Direct3D11Exception) { if (needDX11) { throw new NotSupportedException("DX11 is not supported. To initialize in DX10.1 should be the first argument needDraw = false of Load."); } try { this.Device = new Device(this.CurrentAdapter, dx11flag, new[] { FeatureLevel.Level_10_0 }); } catch (Direct3D11Exception) { throw new NotSupportedException("DX11,DX10.1 An attempt was made to initialization in, but both are not supported."); } } this.DeviceFeatureLevel = this.Device.FeatureLevel; this.Context = this.Device.ImmediateContext; SampleDescription sampleDesc = new SampleDescription(1, 0); #if VSG_DEBUG #else this.Device10 = new Device1(this.CurrentAdapter, DriverType.Hardware, dx10flag_for2DDraw, SlimDX.Direct3D10_1.FeatureLevel.Level_9_3); #endif MMEEffectManager.IniatializeMMEEffectManager(this); }
private void ApplyDebugFlags(ref DeviceCreationFlags dx11flag, ref SlimDX.Direct3D10.DeviceCreationFlags dx10flag_for2DDraw) { Debug.Print("デバイスはデバッグモードで作成されました。"); //dx11flag = dx11flag | DeviceCreationFlags.Debug; dx10flag_for2DDraw = dx10flag_for2DDraw | SlimDX.Direct3D10.DeviceCreationFlags.BgraSupport; }
private void ApplyDebugFlags(ref DeviceCreationFlags dx11flag, ref SlimDX.Direct3D10.DeviceCreationFlags dx10flag_for2DDraw) { Debug.Print("The device was created in debug mode."); //dx11flag = dx11flag | DeviceCreationFlags.Debug; dx10flag_for2DDraw = dx10flag_for2DDraw | SlimDX.Direct3D10.DeviceCreationFlags.BgraSupport; }