未解析的外部符号D3DXSaveSurfaceToFileW

问题描述 投票:0回答:2

我是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);

这些是我的标题:

#include <D3dx9tex.h>

#include "pch.h"
#include "Game.h"


extern void ExitGame();

using namespace DirectX; using namespace DirectX::SimpleMath;

using Microsoft::WRL::ComPtr;

我不断收到错误IDirect3DSurface9:未声明的标识符以及D3DXSaveSurfaceToFile。有谁知道问题是什么?

错误消息:link to error msgs screeenshot

更新:我将缺少的标题添加到Game.h文件中,未声明的标识符错误现在消失了,但现在我收到一个新错误:未解析的外部符号D3DXSaveSurfaceToFileW。

Screenshot to error

c++ directx
2个回答
1
投票

D3DXSaveSurfaceToFileW是已弃用的D3DX9帮助程序库中的实用程序函数。它根本不是Direct3D的一部分,而且是一个可选的并排组件,只能在传统的DirectX SDK中提供。

如上所述,您需要链接d3dx9.lib并安装旧版DirectX SDK并正确设置include / lib路径以使用旧版DirectX SDK。值得注意的是,如果您使用的是使用Windows 8.x或Windows 10 SDK的VS 2012或更高版本,则include / lib路径顺序会有很大差异。传统的DirectX SDK标头很大程度上已经过时了。

请参阅MSDNWhere is the DirectX SDK (2015 Edition)?The Zombie DirectX SDKLiving without D3DX

如果您不熟悉DirectX,请不要使用传统的Direct3D 9。使用DirectX 11.有关起点,请参阅DirectX Tool Kit tutorials


© www.soinside.com 2019 - 2024. All rights reserved.