Jump to content
  • Advertisement
Sign in to follow this  
deffer

Multiple lines with 3D text

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
// 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 );

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

Share this post


Link to post
Share on other sites
Advertisement
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 );

Share this post


Link to post
Share on other sites
Sorry, I didn't notice you were working with 3D text.
In that case I don't know how to help you.

Share this post


Link to post
Share on other sites
Well, since I was out of any smart ideas, and I needed it for today, I built a mesh for each line, and kept them in a vector, then rendered all of them in a row, with proper vertical offset.

A bit wasteful, but gets the job done.
~def

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!