/// <summary> /// レンダーターゲットを初期化します. /// </summary> private void InitializeTargets() { { // Direct3D レンダーターゲットの作成 var desc = new D3D.Texture2DDescription { Width = size.Width, Height = size.Height, MipLevels = 1, ArraySize = 1, Format = Format.B8G8R8A8_UNorm, SampleDescription = new SampleDescription(1, 0), Usage = D3D.ResourceUsage.Default, BindFlags = D3D.BindFlags.RenderTarget, CpuAccessFlags = D3D.CpuAccessFlags.None, OptionFlags = D3D.ResourceOptionFlags.GdiCompatible }; d3dRenderTarget = new D3D.Texture2D(deviceManager.Device, desc); } { // レンダーターゲットビューの作成 D3D.Texture2D target = D3DRenderTarget; var desc = new D3D.RenderTargetViewDescription { Format = target.Description.Format, Dimension = target.Description.SampleDescription.Count > 1 ? D3D.RenderTargetViewDimension.Texture2DMultisampled : D3D.RenderTargetViewDimension.Texture2D, MipSlice = 0 }; d3dRenderTargetView = new D3D.RenderTargetView(deviceManager.Device, target, desc); } // DXGIサーフェスの取得 dxgiSurface = d3dRenderTarget.AsSurface(); { // レンダーターゲットの作成 var properties = new D2D.RenderTargetProperties { Type = D2D.RenderTargetType.Default, PixelFormat = new D2D.PixelFormat(dxgiSurface.Description.Format, D2D.AlphaMode.Premultiplied), HorizontalDpi = 0, VerticalDpi = 0, Usage = D2D.RenderTargetUsage.GdiCompatible, MinimumFeatureLevel = D2D.FeatureLevel.Direct3D10 }; d2dRenderTarget = D2D.RenderTarget.FromDXGI(deviceManager.D2DFactory, dxgiSurface, properties); d2dGdiInteropRenderTarget = new D2D.GdiInteropRenderTarget(d2dRenderTarget); } if (TargetsInitialized != null) { TargetsInitialized(this, new EventArgs()); } }