在DX11应用程序中使用DirectXHelper.h会导致找不到命名空间/类#' Visual Studio 2015中的错误

时间:2017-10-27 21:19:28

标签: c++ visual-studio-2015 directx

我正在尝试按照此处找到的DirectX 11教程:https://docs.microsoft.com/en-us/windows/uwp/gaming/setting-up-directx-resources

但是,我必须在线找到DirectXHelper.h。有几个不同的版本,但这是我发现的最小版本。

问题是,当我尝试使用它进行编译时,我会收到如下错误:

month

我不知道该做什么或我需要包括什么。当我搜索
时 Platform :: Exception :: CreateException(hr)我fidnit in C:\ PROGRAM FILES(X86)\ MICROSOFT VISUAL STUDIO 14.0 \ VC \ LIB \ STORE \ REFERENCES \ PLATFORM.WINMD

我不确定我应该如何引用它。

import org.apache.spark.sql.functions.{from_unixtime, unix_timestamp}

df.withColumn("month", from_unixtime(unix_timestamp($"orddate", "dd/MM/yy hh:mm"), "MMMMM")).show

+--------------+--------+
|       orddate|   month|
+--------------+--------+
|  12/1/10 9:37| January|
| 20/3/10 10:37|   March|
|  09/8/14 4:56|  August|
|30/12/11 12:13|December|
|  24/5/10 7:27|     May|
+--------------+--------+

注意:我尝试将其构建为Win32控制台应用程序和Win32应用程序,出现了同样的错误

1 个答案:

答案 0 :(得分:1)

该版本的ThrowIfFailed假设您正在使用C ++ / CX(a.k.a。/ZW)构建UWP应用程序。该教程假设您使用Windows 10上的UWP平台的DirectX 11 App模板作为起点。

你可以用C ++编写一个更通用的(使用/EHsc):

#include <exception>

namespace DX
{
    inline void ThrowIfFailed(HRESULT hr)
    {
        if (FAILED(hr))
        {
            // Set a breakpoint on this line to catch DirectX API errors
            throw std::exception();
        }
    }
}

有关此助手的更多信息,请参阅ThrowIfFailed

可以找到适用于Win32桌面应用的ReadDataAsync帮助程序版本here

只有UWP应用才需要

ConvertDipsToPixels

  

您应该查看支持Win32桌面应用,UWP应用,Windows phone 8.x和Xbox One XDK应用的 DirectX工具包 tutorials