未解析的外部符号 D3DXSaveSurfaceToFileW
unresolved external symbol D3DXSaveSurfaceToFileW
我是 DirectX 新手。我有这个代码:
IDirect3DSurface9* pSurface;
m_swapChain->GetBuffer(0, __uuidof(pSurface), reinterpret_cast<void**>(&pSurface));
char text[] = "Desktop.bmp";
wchar_t wtext[20];
mbstowcs(wtext, text, strlen(text) + 1);//Plus null
LPWSTR ptr = wtext;
D3DXSaveSurfaceToFile(ptr, D3DXIFF_PNG,pSurface,NULL,NULL);
这些是我收录的 headers:
#include <D3dx9tex.h>
#include "pch.h"
#include "Game.h"
extern void ExitGame();
using namespace DirectX; using namespace DirectX::SimpleMath;
using Microsoft::WRL::ComPtr;
我不断收到错误 IDirect3DSurface9: undeclared identifier 以及 D3DXSaveSurfaceToFile。有谁知道问题出在哪里?
错误消息:
link to error msgs screeenshot
更新:
我将缺少的 headers 添加到 Game.h 文件,未声明的标识符错误现在消失了,但现在我收到一个新错误:未解析的外部符号 D3DXSaveSurfaceToFileW。
Screenshot to error
使用这个 link 解决了错误。
https://www.gamedev.net/forums/topic/580434-d3dxsavesurfacetofile-error-1120/
D3DXSaveSurfaceToFileW
是已弃用的 D3DX9 帮助程序库中的一个实用函数。它实际上根本不是 Direct3D 的一部分,而是一个可选的 side-by-side 组件,仅在旧版 DirectX SDK 中提供。
如前所述,您需要 link 和 d3dx9.lib
AND 安装旧版 DirectX SDK AND正确设置 include/lib 路径以使用旧版 DirectX SDK。值得注意的是,如果您使用的是使用 Windows 8.x 或 Windows 10 SDK 的 VS 2012 或更高版本,则 include/lib 路径顺序会完全不同。旧版 DirectX SDK headers 主要是 out-of-date。
见MSDN, Where is the DirectX SDK (2015 Edition)?, The Zombie DirectX SDK, and Living without D3DX。
If you are new to DirectX, don't bother with legacy Direct3D 9. Use DirectX 11. For a starting point, see the DirectX Tool Kit tutorials
我是 DirectX 新手。我有这个代码:
IDirect3DSurface9* pSurface;
m_swapChain->GetBuffer(0, __uuidof(pSurface), reinterpret_cast<void**>(&pSurface));
char text[] = "Desktop.bmp";
wchar_t wtext[20];
mbstowcs(wtext, text, strlen(text) + 1);//Plus null
LPWSTR ptr = wtext;
D3DXSaveSurfaceToFile(ptr, D3DXIFF_PNG,pSurface,NULL,NULL);
这些是我收录的 headers:
#include <D3dx9tex.h>
#include "pch.h"
#include "Game.h"
extern void ExitGame();
using namespace DirectX; using namespace DirectX::SimpleMath;
using Microsoft::WRL::ComPtr;
我不断收到错误 IDirect3DSurface9: undeclared identifier 以及 D3DXSaveSurfaceToFile。有谁知道问题出在哪里?
错误消息: link to error msgs screeenshot
更新: 我将缺少的 headers 添加到 Game.h 文件,未声明的标识符错误现在消失了,但现在我收到一个新错误:未解析的外部符号 D3DXSaveSurfaceToFileW。
Screenshot to error
使用这个 link 解决了错误。
https://www.gamedev.net/forums/topic/580434-d3dxsavesurfacetofile-error-1120/
D3DXSaveSurfaceToFileW
是已弃用的 D3DX9 帮助程序库中的一个实用函数。它实际上根本不是 Direct3D 的一部分,而是一个可选的 side-by-side 组件,仅在旧版 DirectX SDK 中提供。
如前所述,您需要 link 和 d3dx9.lib
AND 安装旧版 DirectX SDK AND正确设置 include/lib 路径以使用旧版 DirectX SDK。值得注意的是,如果您使用的是使用 Windows 8.x 或 Windows 10 SDK 的 VS 2012 或更高版本,则 include/lib 路径顺序会完全不同。旧版 DirectX SDK headers 主要是 out-of-date。
见MSDN, Where is the DirectX SDK (2015 Edition)?, The Zombie DirectX SDK, and Living without D3DX。
If you are new to DirectX, don't bother with legacy Direct3D 9. Use DirectX 11. For a starting point, see the DirectX Tool Kit tutorials