Original Post
This is a piece of code that extracts D3D materials. Something is wrong with the string conversions. "tempMaterials.pTextureFilename" is of type LPSTR So I'm trying to go from LPSTR to wstring to LPCTSTR This compiles, but I get an error when I run it: "Invalid null pointer" What's going on?
std::wstring StringToWString(const std::string& s)
{
std::wstring temp(s.length(),L' ');
std::copy(s.begin(), s.end(), temp.begin());
return temp;
}
//...
std::wstring strFileName;
for(DWORD i = 0; i < cMesh->numMat; i++)
{
strFileName = StringToWString(tempMaterials.pTextureFilename);
if(FAILED(D3DXCreateTextureFromFile(d3ddev, strFileName.c_str(), &cMesh->ppTexture)))
*(&cMesh->ppTexture) = NULL;
//...