Jump to content
  • Advertisement
Sign in to follow this  
Cypher19

Must....compile....SDK....example!!

This topic is 5470 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, so I'm trying to compile the ShadowMap example from the 2004 SDK, and here are the following errors I get from Visual C++ after getting extra stuff like the platform SDK:
Compiling...
ShadowMap.cpp

error C2664: 'D3DXCreateEffectFromFileA' : cannot convert parameter 2 from 'unsigned short [260]' to 'const char *'

error C2664: 'DXUTFindDXSDKMediaFileCch' : cannot convert parameter 3 from 'const char *' to 'const unsigned short *'

Error executing cl.exe.

ShadowMap.exe - 2 error(s), 0 warning(s)
The two errors come from these two lines: 1) V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect, NULL ) ); -note: str is a WCHAR of length MAX_PATH. 2) V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, g_aszMeshFile ) ); -note: g_aszMeshFile is an array of LPCTSTR's defined as such:
LPCTSTR g_aszMeshFile[] =
{
    "room.x",
    "airplane\\airplane 2.x",
    "misc\\car.x",
    "misc\\sphere.x",
    "UI\\arrow.x",
    "UI\\arrow.x",
    "UI\\arrow.x",
    "UI\\arrow.x",
    "UI\\arrow.x",
    "UI\\arrow.x",
    "UI\\arrow.x",
    "UI\\arrow.x",
    "ring.x",
    "ring.x",
};
Initially that chunk was giving me errors when the filenames all had 'L' in front before the quotes. The error was "error C2440: 'initializing' : cannot convert from 'unsigned short [7]' to 'const char *'" If anyone else has experienced this problem and/or knows how to fix it, can you please say how you did it?

Share this post


Link to post
Share on other sites
Advertisement
WCHAR is unsigned short. D3DXCreateEffectFromFile is a macro that maps to either the ANSI (D3DXCreateEffectFromFileA) or unicode (D3DXCreateEffectFromFileW) versions depending on the UNICODE preprocessor flag/define.
Seems like you don't have UNICODE defined project-wide?

The second error is because the function's expecting a unicode string, but you're giving it a character (char) string. g_aszMeshFile is of LPCTSTR which is 'const TCHAR*'

When UNICODE is not defined, TCHAR resolves to char, so LPCTSTR resolves to 'const char*'.

Share this post


Link to post
Share on other sites
So how do I define UNICODE? (btw, I had to create a default workspace because the sample didn't have one)

Nm, it's #define UNICODE isn't it?


Okay, now I've got a TON of new linker errors, mostly having to do with DXUT functions/classes. Does anyone know what libraries I need to include for them?

[Edited by - Cypher19 on September 28, 2004 4:46:30 PM]

Share this post


Link to post
Share on other sites
Hi.

First of all you can't define just UNICODE somewhere in your .h file. You have to add it to the preprocessor defines in you project-settings. should work better now. ;)

The 'L' macro before the quotes are correct. your array data type is wrong. In order to use eg. L"room.x" you have to declare the array as wchar_t.
The 'L' macro converts c-strings to wide-character-strings.

and third....i think the define is: _UNICODE

good luck.

- christoph -

Share this post


Link to post
Share on other sites
Quote:
You have to add it to the preprocessor defines in you project-settings

No. Go to the project settings and under the General settings change the 'Character Set' option to 'Use Unicode Character Set'.
Well, assuming that this setting does more than just define _UNICODE. If not, ignore me [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!