Skip to main content
gamedev.net
🔒 Locked

unicode and strings

Started by jagguy2 Jan 12, 2008 at 4:40 AM 2 replies 850+ views
Original Post
jagguy2
jagguy2
D3DXCreateTextureFromFile( g_pd3dDevice, mtrls.pTextureFilename, //error cannot convert parameter 2 from 'LPSTR' to 'LPCWSTR' &tex); I tried wchar_t str[20],*str2; str2="L"+mtrls.pTextureFilename; How can i change the filename to unicode?
tompko
tompko
You'll want to look at wcstombs() and mbstowcs() which convert between multi-byte strings and wide character strings.
jagguy2
jagguy2



wcstombs(mtrls.pTextureFilename,str,20);
D3DXCreateTextureFromFile( g_pd3dDevice, str, &tex); //compiles but is this it? i get an x File with no materials so i dont know if this is correct



this is in a loop so is this a problem

const size_t length = 1 + strlen(mtrls.pTextureFilename);
LPWSTR wcsText = new WCHAR[length];
mbstowcs(wcsText, mtrls.pTextureFilename, length);

[Edited by - jagguy2 on January 12, 2008 6:26:51 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.