【问题标题】:Can Direct2D actually work with a direct3D 11 device?Direct2D 真的可以与 direct3D 11 设备一起使用吗?
【发布时间】:2015-10-30 07:03:42
【问题描述】:

我在互联网上听说 Direct2D 只能用于 Direct3D 10.1 设备。但我决定用 D2D 进行试验,看看这是否真的如此。一旦我完成了所有的实验......我得出了一个令人怀疑的结论,即 Direct2d 实际上可以使用 direct3d 11 设备。

无论如何,这是我用来试验的代码。我尝试使用 direct3d 11 设备创建一个 DXGI 表面(指向 D3D11 2D 纹理)。

            /* SharedTextureDesc object contains description of a 2D texture*/

D3D11device->CreateTexture2D(&SharedTextureDesc, NULL, &SharedTexture);

SharedTexture->QueryInterface(__uuidof(IDXGIResource), (void**)&SharedResource);

SharedResource->GetSharedHandle(&SharedHandle);

D3D11device->OpenSharedResource(SharedHandle, __uuidof(IDXGISurface1), (void**)&SharedSurface); 

上面的代码只是显示我使用 direct3d 11 设备创建了一个 DXGI 表面。下面,我使用 DXGI 表面为 Direct2D 创建渲染目标。

/* RenderTargetProperties contains the description for render target */

D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory), (void**) &D2DFactory);

D2DFactory->CreateDxgiSurfaceRenderTarget(SharedSurface, &RenderTargetProperties, &RenderTargetD2D)

Direct2d 的渲染目标似乎可以工作,我可以使用它在我的游戏中实际渲染文本。方法CreateDxgiSurfaceRenderTarget() 甚至返回了一个S_OK,告诉我它成功了。

但我唯一的问题是……direct2d 的渲染目标是否仍然可以正常工作?还是 Direct2D 根本不能与 Direct3D 11 设备一起使用?

【问题讨论】:

    标签: c++ direct2d direct3d11


    【解决方案1】:

    DirectX 11.1 系统上的 Direct2D 可以与 Direct3D 11 设备一起使用。 DirectX 11.1 包含在 Windows 8 或更高版本中,并通过KB2670838在 Windows 7 SP1 上得到部分支持

    对于 DirectX 11.0 系统(即带有 KB971644 的 Windows Vista SP2、Windows 7 RTM 或未安装 KB2670838 的 Windows 7 SP1),您必须使用 DXGI 表面共享,这样 Direct2D 才能在 Direct3D 10.1 设备上运行并且您“共享”使用 Direct3D 11 设备的结果。

    请参阅MSDNDirectX 11.1 and Windows 7DirectX 11.1 and Windows 7 Update

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-21
      • 2020-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多