Archived

This topic is now archived and is closed to further replies.

CD3DFont problems

This topic is 5502 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

Has anyone used CD3DFont? I tried to use it last night after following the tutorial in the SDK, but I''m not doing something right. As far as I can tell, I need to: in my init: cFontBig = new CD3DFont( _T("Arial"), 24, D3DFONT_BOLD );cFontBig->InitDeviceObjects( pD3DDev );cFontBig->RestoreDeviceObjects(); Then in my render loop (condensed): pD3DDev->BeginScene();cFontBig->DrawText( 350, 250, D3DCOLOR_ARGB( 255, 0, 0, 127), _T("Level 1: Ready") );pD3DDev->EndScene(); Since I have a vertex buffer for my graphics, and cD3DFont creates one as well, how do I account for that? Right now, every other letter is showing and the ones that aren''t are blocks. Then when my game leaves that game state to go to start, it locks. Anyone know how to use CD3DFont properly, and how bad does it slow down a scene? Much greatness is achieved thru perseverance and faith.

Share this post


Link to post
Share on other sites
quote:
Original post by Paladin__
Anyone know how to use CD3DFont properly


look at any sdk sample.
quote:

and how bad does it slow down a scene?


not bad for something that''s free and readable.

Share this post


Link to post
Share on other sites
give this a try


    
HFONT font_handle;
LPD3DXFONT mpFont;


//setup

font_handle = CreateFont(18, 0,0,0, FW_NORMAL, FALSE, FALSE,0,0, ANSI_CHARSET, 0,0,0,0, "Westminster");
D3DXCreateFont(g_pDevice, font_handle, &mpFont);



//drawing

RECT rect;
rect.left = x;
rect.top = y;
rect.right = 0;
rect.bottom = 0;

mpFont->Begin();
mpFont->DrawTextA(buffer, -1, &rect, DT_CALCRECT, 0);
mpFont->DrawTextA(buffer, -1, &rect, DT_LEFT, D3DCOLOR_XRGB(255, 255, 255));
mpFont->End();



hope this helps

"Sweetie! Get Mommy's bazooka!"

[edited by - Mister Stewart on November 21, 2002 10:43:47 AM]

Share this post


Link to post
Share on other sites
I have always heard that LPD3DXFONT is pretty slow. I do want to know specifics, because I do not know for sure. I thought CD3DFont is faster. Is that true?

Much greatness is achieved thru perseverance and faith.

Share this post


Link to post
Share on other sites
CD3DFont does not use GDI, while LPD3DXFONT does. Thus why CD3DFont is MUCH faster than LPD3DXFONT. Note that this does come with a downside, artifacts are present when you use a large font with CD3D. Not also that CD3D does not support strikethrough (and I believe a few other styles. I''m pretty sure italic fonts are supported. perhaps not.)

¬_¬

Share this post


Link to post
Share on other sites
Ahh ok. I have some theories on my problem with CD3DFont, but I can''t try them until tonight. I''ve noticed it does change my VB to the font VB, but I guess I need to set my VB back each frame to render my graphics. I''ll see when I get home.

I do want to learn CD3DFont, but with the SDK, the classes bounce all over the place and I''m stepping thru to find all the steps needed to create a font.

Much greatness is achieved thru perseverance and faith.

Share this post


Link to post
Share on other sites