if(FAILED(D3DXCreateFont(*(graphics->getDevice()),24,0,FW_NORMAL,1,false,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,ANTIALIASED_QUALITY,DEFAULT_PITCH|FF_DONTCARE,
"Arial",&g_font))) return false;
// Render function
g_font->DrawTextW(NULL, "Testing text", -1, &rText, DT_LEFT|DT_NOCLIP, 0x00000000);
D3DXCreateFont problem
Probably a simple problem I'm not seeing the solution to immediately.
I'm on a Drunken Hyena tutorial to get id3dxfont working. I followed the code on the tutorial and input the following:
Both lines there kick back the same error:
main.cpp(67) : error C2664: 'D3DXCreateFontW' : cannot convert parameter 11 from 'const char [6]' to 'LPCWSTR'
main.cpp(135) : error C2664: 'ID3DXFont::DrawTextW' : cannot convert parameter 2 from 'const char [13]' to 'LPCWSTR'
Anyone know what I can do with this?
You know that article does look interesting. I tried turning off the Unicode character set option, but that produces a huge problem for me. Why? About a good month's work of trial-and-error coding is built around that unicode option. Most of my code uses wchar_t, and to turn off the unicode option invalidates much of my code in the following way:
direct3d.cpp(52) : error C2664: 'D3DXGetImageInfoFromFileA' : cannot convert parameter 1 from 'wchar_t *' to 'LPCSTR'
So changing to a non-unicode character set is, unfortunately, not an option for me. (It's not just the one error, there are several occurences of this type of error)
I think I figured something out though. I don't know how it slipped by me, but I preceded my text inputs with an L, which fixed all my problems in the past:
This no longer produces errors, but now there's nothing being displayed on the screen. On breakpoint, the g_font object gives me no useful information, only several addresses but no readable values attached to anything.
Anyone see anything obviously wrong with this?
Edit: Strangely enough, while "DrawText" is not listed by intellisense, I can use that function as opposed to DrawTextW or DrawTextA. I edited the code in this post to reflect that.
[Edited by - pteri498 on March 25, 2006 7:36:30 AM]
direct3d.cpp(52) : error C2664: 'D3DXGetImageInfoFromFileA' : cannot convert parameter 1 from 'wchar_t *' to 'LPCSTR'
So changing to a non-unicode character set is, unfortunately, not an option for me. (It's not just the one error, there are several occurences of this type of error)
I think I figured something out though. I don't know how it slipped by me, but I preceded my text inputs with an L, which fixed all my problems in the past:
if(FAILED(D3DXCreateFont(*(graphics->getDevice()),24,0,FW_NORMAL,1,false,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,ANTIALIASED_QUALITY,DEFAULT_PITCH|FF_DONTCARE,L"Arial",&g_font))) return false; g_font->DrawText(NULL, textSample, -1, &rText, DT_LEFT|DT_NOCLIP, 0x00000000);
This no longer produces errors, but now there's nothing being displayed on the screen. On breakpoint, the g_font object gives me no useful information, only several addresses but no readable values attached to anything.
Anyone see anything obviously wrong with this?
Edit: Strangely enough, while "DrawText" is not listed by intellisense, I can use that function as opposed to DrawTextW or DrawTextA. I edited the code in this post to reflect that.
[Edited by - pteri498 on March 25, 2006 7:36:30 AM]
Make sure you put an 'L' before your strings, so that the compiler knows that they are wide character strings.
xyzzy
if(FAILED(D3DXCreateFont(*(graphics->getDevice()),24,0,FW_NORMAL,1,false,DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,ANTIALIASED_QUALITY,DEFAULT_PITCH|FF_DONTCARE, L"Arial",&g_font))) return false; // Render function g_font->DrawTextW(NULL, L"Testing text", -1, &rText, DT_LEFT|DT_NOCLIP, 0x00000000);
xyzzy
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement