Last active
December 7, 2018 02:40
-
-
Save baobao/4ff4be53b57320080943c70fb25b4a58 to your computer and use it in GitHub Desktop.
デバイスとSwapChainを作成のみの部分コード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// デバイスとSwapChainを作成 | |
/// </summary> | |
static public SlimDX.Result CreateDeviceWithSwapChain( | |
Form form, | |
out SlimDX.Direct3D11.Device device, | |
out SwapChain swapChain | |
) | |
{ | |
return Device.CreateWithSwapChain( | |
// Direct3Dの機能を持つデバイス(GPU)を使用する | |
DriverType.Hardware, | |
// デバイスに特別なふるまいをさせるときは設定するが、基本はNone | |
DeviceCreationFlags.None, | |
// SwapChainの詳細設定 | |
new SwapChainDescription() | |
{ | |
// 2:ダブルバッファでティアリングを回避 | |
BufferCount = 2, | |
// 表示するウィンドウ | |
OutputHandle = form.Handle, | |
// falseにするとフルスクリーン | |
IsWindowed = true, | |
// SwapChainのマルチサンプル方法設定 | |
SampleDescription = new SampleDescription() | |
{ | |
Count = 1, | |
Quality = 0 | |
}, | |
// ウィンドウの大きさやリフレッシュレートに関する設定 | |
ModeDescription = new ModeDescription() | |
{ | |
// ウィンドウの幅 | |
Width = form.ClientSize.Width, | |
// ウィンドウの高さ | |
Height = form.ClientSize.Height, | |
// リフレッシュレート60Hz | |
RefreshRate = new SlimDX.Rational(60, 1), | |
// ウィンドウのフォーマット | |
// https://msdn.microsoft.com/ja-jp/library/ee416140(v=vs.85).aspx | |
Format = Format.R8G8B8A8_UNorm | |
}, | |
// 描画対象の使用方法 | |
// ウィンドウにただ表示するだけなので、RenderTargetOutputをセット | |
Usage = Usage.RenderTargetOutput | |
}, | |
out device, | |
out swapChain | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment