0

我们有多年来一直使用 DX9 的 PC 代码,即我们调用 Direct3dCreate9 并从那里开始。它在安装了 DX9 DX10 和 DX11 的机器上运行良好。

我们想将此代码的大部分用于 windows phone 8.1 应用程序。我有一个使用 DX11 在模拟器上运行的示例项目,假设我们不需要任何 DX10 或 DX11 功能,那么让我们的 DX9 代码在手机上运行的最简单方法是什么。

我已包含 D3d9.h,但在 D3d11.lib 中找不到 Direct3dCreate9 调用。

那么,我们可以只使用 PC Direct X SDK(2009 年 8 月)中的 D3D9.lib 并链接到它吗?或者我们应该创建一个 DX11 对象,如果我们这样做了,我们可以在它上面使用 DX9 调用吗?还是会很痛!? 我对这里实际发生的事情感到有点困惑!

谢谢

肖恩

4

1 回答 1

1

您需要#include <d3d11_1.h>或者#include <d3d11_2.h>如果您的目标是 Windows Phone 8.1。

并将您的代码移植到 DirectX 11,调用是D3D11CreateDevice. 会很痛苦!

D3D_FEATURE_LEVEL featureLevels[] = 
{
    D3D_FEATURE_LEVEL_9_3
};

您仍将使用此功能级别。

// Create the Direct3D 11 API device object and a corresponding context.
ComPtr<ID3D11Device> device;
ComPtr<ID3D11DeviceContext> context;
DX::ThrowIfFailed(
    D3D11CreateDevice(
        nullptr, // Specify nullptr to use the default adapter.
        D3D_DRIVER_TYPE_HARDWARE,
        nullptr,
        creationFlags, // Set set debug and Direct2D compatibility flags.
        featureLevels, // List of feature levels this app can support.
        ARRAYSIZE(featureLevels),
        D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION.
        &device, // Returns the Direct3D device created.
        &m_featureLevel, // Returns feature level of device created.
        &context // Returns the device immediate context.
        )
    );


// Get the Direct3D 11.1 API device and context interfaces.
DX::ThrowIfFailed(
    device.As(&m_d3dDevice)
    );


DX::ThrowIfFailed(
    context.As(&m_d3dContext)
    );
于 2014-04-21T17:50:55.190 回答