Originally Posted by
Codeplug
Some things to note:
TCHAR resolves to either a "char" or a "wchar_t" depending on if UNICODE is defined or not (in VS project properties, "Use Unicode Character Set" will enable UNICODE).
LPCTSTR - the "T" in the middle stands for TCHAR, so this is a "const TCHAR*" - which in turn is either "const char*" or "const wchar_t*".
LPSTR = char*
LPCSTR = const char*
LPWSTR = wchar_t*
LPCWSTR = const wchar_t*
LPTSTR = LPSTR or LPWSTR
LPCTSTR = LPCSTR or LPCWSTR
Of the two API's mentioned, there are two versions of each:
D3DXLoadMeshFromXA or D3DXLoadMeshFromXW
D3DXCreateTextureFromFileA or D3DXCreateTextureFromFileW
If you don't call the "A" or "W" version explicit, then the UNICODE setting will determine which version is called.
So if you just want to deal in char strings, then just use char string and call the "A" functions explicitly.
Or just use wchar_t strings and call the "W" functions explicitly.
Or just use TCHAR strings and call leave off the "A" or "W" from the function call. I don't recommend using TCHAR's myself, but you have to understand what they are since the Win32 API uses them.
gg
I want to use plain old std::string with regular single byte ascii chars.
should this work?
Code:
string file="C:/models/mymodel.x";
D3DXLoadMeshFromXA(file.c_str());//other args not shown
//do some string manipulation to get the full path texture file name
LPSTR pTextureFilename="mymodel.bmp";//this is actually gotten from a directx function
string directory=file.substr(0,file.find_last_of('/'))+"/";
string strTexture=directory+pTextureFilename;
D3DXCreateTextureFromFileA(strTexture.c_str());//other args not shown
The above compiled fine and seemed to work. I put breakpoints where it loads the mesh and file and all the strings were correct and the correct data was loaded into the mesh, texture, and materials.
However, I then get a completely new error. (which i'll make a new post for in a minute. Has to do with _BLOCK_TYPE_IS_VALID ASSERTE failure because a destructor is being called on an uninitialized object during array initialization.)