// This mesh would be our goal.
ID3DXMesh *pMeshNew = NULL;
// This is just for creating font.
HDC hdc = CreateCompatibleDC( NULL );
HFONT hFont;
HFONT hFontOld;
hFont = CreateFont( 0, 0, 0, 0, bBold ? FW_BOLD : FW_NORMAL, bItalic, FALSE, FALSE,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE,
"Arial" );
hFontOld = (HFONT)SelectObject(hdc, hFont);
// CREATE 3D TEXT!
hr = D3DXCreateText( g_pDeviceD3D, hdc, szText, 0.001f, fDepth, &pMeshNew, NULL, NULL);
// And say goodbye to the font.
SelectObject(hdc, hFontOld);
DeleteObject( hFont );
DeleteDC( hdc );
Multiple lines with 3D text
Hi.
Normally, I prefer the hard, *doItYourself*, way, but the more I "need something for tomorrow", the more I resolve to external libraries, so here I am.[grin]
I wanted to render a 3D text. So I looked into DX SDK samples, and found one appropriate. It creates a ID3DXMesh interface, with drawable mesh with given text and font.
Cool.
Only that it apparently doesn't work with multi line text. It prints *squares* instead of '\n' or "\r\n".
What can I do?
~def
Quote:ID3DXFont::DrawText Method Documentation
DT_WORDBREAK
Breaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the pRect parameter. A carriage return/line feed sequence also breaks the line.
Try passing the DT_WORDBREAK flag along with the other format flags in the ID3DXFont::DrawText function calls.
i.e.
myFont->DrawText( NULL, "one\ntwo", -1, &rc, DT_WORDBREAK, someColor );
Sorry, I didn't notice you were working with 3D text.
In that case I don't know how to help you.
In that case I don't know how to help you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement