Directdraw and TextOut

Started by
2 comments, last by SoT 22 years, 1 month ago
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...
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
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 ...

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.

This topic is closed to new replies.

Advertisement