#### Archived

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

# Text Out

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

## Recommended Posts

Hi again! I want to display text for debugging purposes, so the speed doesnt matter and since im a newbie, i would like to keep it simple. This is what i use:
	PAINTSTRUCT ps;
HDC hdc;
hdc=GetDC(hWnd);
TCHAR cMessage[100];
lstrcpy( cMessage, _T("Arial") );
SetTextColor(hdc,RGB(0,0,0));
SetBkColor(hdc,RGB(255,255,255));

SetBkMode(hdc,TRANSPARENT);
hdc = BeginPaint (hWnd, &ps);

TextOut(hdc,400,300,cMessage,strlen(cMessage));
EndPaint( hWnd, &ps ); 
It works, but directx overwrites the text. How can i get it to stay on top? And is there a tutorial how to use the directx drawtext methods? Its hard to get started with it. Thank you!

##### Share on other sites
If you are using DX8, use the CD3DFont class found in the SDK.

The reason your code doesn''t work is that DX overrides the "normal" DC. I *strongly* urge you to use CD3DFont because the sooner you get into the mindset of not using GDI, the better.

##### Share on other sites
I would also like to know how to fix this problem, and i have no reference to CD3DFont in my libraries.

##### Share on other sites
G''day!

CD3DFont ships with the SDK, it''s part of the helper code they include. Technically it''s unsupported by Microsoft, but a lot of people use it without any issues. I can''t recall a single mention of a bug from anyone, so it''s pretty stable.

Another alternate is my text library. You have to create a bitmap font (there''s a link to a utility to do it for you) and it uses that rather than generating the font at run-time. It''s not feature-laden, but it looks good and it''s darn fast.
http://www.drunkenhyena.com/docs/dhFastFont.phtml

Stay Casual,

Ken
Drunken Hyena

##### Share on other sites
The problem is:
i know about CD3DFont but from the example text3d that is shipped with DX, its hard to learn.
im just too new at this to know why they used which specific command.
Did anyone of you use CD3dfont and can offer an example that implements it?
Thanks!

##### Share on other sites
G''day!

I don''t have any code examples for CD3DFont (because I haven''t used it yet). In the next couple of days I''ll have one on ID3DXFont up on my site. If you need something now check out my fast font library (URL listed in my last post). It has nice simple examples of how it works and it''s very easy to use.

Stay Casual,

Ken
Drunken Hyena

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 37
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631705
• Total Posts
3001826
×