LPCTSTR operations/ convertion
how do I do this?...
Although my program uses directx, I think this is more of a windows question.
I'm making a mesh class to hold mesh, texture, and material data from a .x file.
One of the arguments for the directx function that loads the file, D3DXLoadMeshFromX, is a LPCTSTR representing the full path file to read from. (like L"C:/myModel.x")
In the process of loading the mesh, I also end up with a string representing the texture file name, in the form of a LPSTR, which was gotten from the .x file.
The problem is that the function that loads textures requires a LPCTSTR that represents the full path of the texture file. Passing the texture name as it is is legal (LPSTR is converted to LPCTSTR no problem), but it can't load the texture because it needs the full directory, not just the name. (It works if I manually alter the .x file so that the texture file name contains the full path, but I don't want to do this for every model I want to use)
So, essentially I have to lop off the .x file name, leaving the directory it is contained in, and tack on the texture file name, then send the result as a LPCTSTR to the directx function, D3DXCreateTextureFromFileA.
As far as I know, there are no functions that can easily manipulate LPCTSTR like find_last_of(char) of substr(int, int). I've tried converting to and from std::string and std::wstring but it doesn't work.
One more thing: this process must be done in 2 parts: 1: get the directory, and 2: add the texture file name, since I'll be using multiple texture file names, (gotten in a loop), but they are all in one directory.
So, any ideas?
How would I convert from LPCTSTR to std::string and back?