I just started using GDI+ and there will be quite a few conversions.
The text I draw appears for a split second as a bunch of random symbols. I traced the problem down to the conversions.
Code updated at bottom
const wchar_t* convert::stringToWideChar(string String) {
wstring wideString;
for(int i = 0; i < String.length(); i++)
wideString += wchar_t( String[i] );
return wideString.c_str();
}
Used as:
testing = "Two Two";
const wchar_t* buf = convert::stringToWideChar(testing);
path.AddString(buf, wcslen(buf), &gFontFamily, FontStyleBold, 72, ptOrg, &strFormat);
The background is how the text is initially drawn. "Level 0" is what should be initially drawn. (In the screenshot the initial text is faded as should.)
Any ideas to do the conversion faster? (The strangest thing is it only happens with random specific strings, i.e. "Two" works, "Two Two", doesn't, "Two Too", does.
Updated
wstring convert::stringToWideChar(string String) {
wstring wideString;
for(int i = 0; i < String.length(); i++)
wideString += wchar_t(String[i] );
return wideString;
}
Used as:
const wchar_t* buf = convert::stringToWideChar("leveljjj").c_str();