Reputation: 11
I am working on a DirectX9 project, and it is time now to start doing sprites, and to do so, I need d3dx9.h included, so after a while of trying to get it linked properly, which itself was confusing because it found d3d9.h just fine and its in the same location as d3dx9, I assumed that I would just need to add it to additional libraries, and after a while it finally worked. However upon running the program I get an error, from d3dx9core.h:
C2061: syntax error: identifier 'TEXTMETRICA'
I cannot find any answers online, and cannot figure out what is causing this problem. The line of code is 330 of d3dx9core.h, STDMETHOD_(BOOL, GetTextMetricsA)(THIS_ TEXTMETRICA *pTextMetrics) PURE;
it comes with four errors, all pointing to this line. Any thoughts?
Upvotes: 1
Views: 678
Reputation: 41127
If you use the legacy DirectX SDK with VS 2015 or later, you need to make sure the DXSDK include/lib paths are after the standard Windows 8.1 SDK / Windows 10 SDK paths. This is because the legacy DirectX SDK has out-of-date copies of some Windows headers.
Details are covered at the bottom of Microsoft Docs.
DirectX 9 is very old, and really was only needed to target Windows XP. You should look at DirectX 11 instead, and in particular DirectX Tool Kit's
SpriteBatch
. See Living without D3DX.
UPDATE: If you still insist on using Direct3D 9, you can get the legacy D3DX9 helper library now from NuGet which you use with the Direct3D 9 headers in the modern Windows SDK. This is recommended over using the legacy DirectX SDK in any context, avoids known issues with the legacy DirectX SDK installer, removes the need to use the legacy DirectX End-User Runtime Redist, and updates the DLL to use SHA-256 instead of the deprecated SHA-1 codesigning. See this blog post.
Upvotes: 4