从SwapChain

时间:2015-07-15 22:00:10

标签: c# wpf directx-11 slimdx

我有一个带有SlimDX控件的WPF应用程序(DirectX 11)。我在init上创建了一个SwapChain

var description = new SwapChainDescription()
{
 ModeDescription = new ModeDescription(WindowWidth, WindowHeight, new Rational(60, 1), Format.B8G8R8A8_UNorm)
 {
  ScanlineOrdering = DisplayModeScanlineOrdering.Unspecified,
  Scaling = DisplayModeScaling.Unspecified,
 },
 SampleDescription = new SampleDescription(1, 0),
 Usage = Usage.Shared | Usage.RenderTargetOutput | Usage.ShaderInput,
 BufferCount = 1,
 OutputHandle = D3DDeviceManager.SafeNativeMethods.GetDesktopWindow(),
 IsWindowed = true,
 SwapEffect = SwapEffect.Discard,
 Flags = SwapChainFlags.AllowModeSwitch,
};
SwapChain = new SwapChain(Device.Factory, Device, description);

注意,我设置了Shared标志。当我的窗口调整大小时,我想更新缓冲区大小并从SwapChain获取新的共享纹理。我是这样做的:

SwapChain.ResizeBuffers(1, WindowWidth, WindowHeight, Format.B8G8R8A8_UNorm, SwapChainFlags.None);
SharedTexture = SlimDX.Direct3D11.Resource.FromSwapChain<Texture2D>(SwapChain, 0);

但是生成的纹理将OptionFlags设置为None而不是Shared。这是为什么?难道我做错了什么?如果我从Texture2DDescription创建纹理,它可以正常工作。

0 个答案:

没有答案