Im having some probolems with C++ .. I’m trying to save a frame with the filename as timestamp but with no success, can anybody help me?
It saves properly if i use:
D3DXSaveTextureToFileW((LPCWSTR)"file.bmp",D3DXIFF_BMP,tex,NULL); or
D3DXSaveTextureToFileW(L"file.bmp", frameName,D3DXIFF_BMP,tex,NULL);
But if I try some more elaborated filename I get some issues, it compiles but doesn’t save the file …
I’m trying to use someting like
LPCWSTR frameName;
std::string s = std::string("file") + std::string(".bmp");
frameName = (LPCWSTR)s.c_str();
D3DXSaveTextureToFileW((LPCWSTR)frameName,D3DXIFF_BMP,tex,NULL);
Doesn’t save … And If I try something like I want to save the problem continues:
time_t seconds;
seconds = time (NULL);
time_t rawtime;
time ( &rawtime );
LPCWSTR frameName;
std::string s = std::string("file") + std::string(&rawtime);
frameName = (LPCWSTR)s.c_str();
D3DXSaveTextureToFileW((LPCWSTR)frameName,D3DXIFF_BMP,tex,NULL);
You cannot cast the result of
std::string::c_str()(aconst char*) to aLPCWSTR. Use astd::wstringstreamto construct the filename:If you want to store the result of
frameName.str()use astd::wstring.