Skip to main content
GameDev.net gamedev.net
🔒 Locked

Using TextOut with Direct X

Started by WhatsMyNameAgain Mar 2, 2000 at 8:54 PM 2 replies 500+ views
Original Post
WhatsMyNameAgain
WhatsMyNameAgain
I''m having some trouble with GDI and direct x. I use textout in my game to draw my text. I set up my HDC at startup, but all of the settings seem to be refreshed when I call my text function: void text(int x, int y, char txt[]) { lpddsback->GetDC(&textDC); TextOut(textDC, x, y, txt, strlen(txt)); lpddsback->ReleaseDC(textDC); } However, if I add the hdc setup code to the text function it works fine. How can I keep the setting for the HDC from getting reset?
Sparkle
Sparkle
Hi!

SaveDC() and RestoreDC() can save/restore the state of a DC, but I think you loose the state when you call ReleaseDC.
So my guess is you''ll have to set it up every time.

*Sparkle*

WhatsMyNameAgain
WhatsMyNameAgain
Isn''t that kind of inefecient? I would have to call 3 hdc setup functions every time I drew text.
Sparkle
Sparkle
Yes, it is inefficient.
The only solution I can think of is to draw all your text in the same function, thereby redusing the number of setups to one per frame.
I use TextOut() to draw text in DirectDraw too, so if anyone have a solution to this problem, please reveal your secrets

*Sparkle*

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.