Sign in to follow this  
Florin Cazan

Problem with strings

Recommended Posts

Florin Cazan    144
if ( Materials[i].pTextureFilename != NULL ) { wchar_t strTexture[MAX_PATH]; StringCchCopyW( strTexture, MAX_PATH, L"Media\\" ); StringCchCatW( strTexture, MAX_PATH, (LPWSTR)Materials[i].pTextureFilename ); D3DXCreateTextureFromFileW( pd3dDevice, strTexture, &skyboxTex[i] ); } This is the code where I load the mesh textures from the "Media" directory. The problem is that I get this error: D3DX: Media\: The system cannot find the file specified. even though the path is correct and the files are all there. I've tried this code in ANSI mode and it worked, so it appears that when I make the conversion to LPWSTR something goes wrong. (Note: The project uses Unicode character set) What could I do to resolve this?

Share this post


Link to post
Share on other sites
CTar    1134
Quote:
What could I do to resolve this?

Figure out what is wrong...

What type is Materials[i].pTextureFilename? Is it char* or wchar_t*? It most likely is char*, and you try to convert to wchar_t* by using a cast. The cast will just change the type, not the actual binary data of the string.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this