【问题标题】:Using D3D9 code on Windows Phone 8.1在 Windows Phone 8.1 上使用 D3D9 代码
【发布时间】:2014-04-22 01:50:55
【问题描述】:

我们有多年来一直使用 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 调用吗? 还是会很痛! ?我对这里实际发生的事情感到有点困惑!

谢谢

肖恩

【问题讨论】:

    标签: windows directx windows-phone-8.1


    【解决方案1】:

    如果您面向 Windows Phone 8.1,则需要 #include <d3d11_1.h>#include <d3d11_2.h>

    并将您的代码移植到 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)
        );
    

    【讨论】:

    • 所以没有办法在 Windows Phone 8.1 上运行 DX9 代码?通过包含不同的库?
    • 是的,您只能在 Windows Phone 8.1 中包含 d3d11_2.h,它是 DirectX 11.2 库。
    猜你喜欢
    • 1970-01-01
    • 2015-02-13
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 2014-08-25
    • 1970-01-01
    • 1970-01-01
    • 2014-08-27
    相关资源
    最近更新 更多