• Advertisement

Archived

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

Directdraw and TextOut

This topic is 5906 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, Ive got a problem with using TextOut() function with direct draw. Im using it to display my credits screen. Im using a couple of font styles for redrawing it to the screen every time my game updates. The problem is that after some time the Font styles get displayed at their default font and size settings etc. This also causes my application to crash when exiting the credits screen. basically what im doing every update is ... getting the DC of the surface ... drawing the text and then Releasing the DC ... Does anyone know what the problem is here?? Or know of a better way to display Text on Screen... Thanks...

Share this post


Link to post
Share on other sites
Advertisement
You said you're using a couple of font styles... do you create the handles once, then draw all your frames using those initially created font handles.... or do you recreate the handles every "frame" as you're drawing your credits?

If you're recreating the fonts EVERY frame, then the problem is you aren't also destroying them at the end of the frame. If you continually create fonts without destroying them you'll get a SERIOUSLY nasty resource leak. When you run out of resources future calls that request resource creation will fail (which is why it starts drawing in the system font.. your font creation calls are failing).

Windows is horribly unstable after it runs out of resources... which also explains your crash.

So just destroy your font handles at the end of every frame and you'll be fine.



P.s.
I was very surprised to realize I knew the answer to your question


Edited by - Sorrow on February 22, 2002 12:33:16 AM

Share this post


Link to post
Share on other sites
wow thanks.. that solves everything

ye ive been setting font everyframe cause i was formating headings n stuff...

ive been tryin to figure out whats wrong for a while now
thanks heaps ...

Share this post


Link to post
Share on other sites
np Used to run into that with some of the GDI stuff I do at work when I forgot to release a single font or something... it''s a very distinctive kind of bug.

Share this post


Link to post
Share on other sites

  • Advertisement