Font Engine
I just got done reading "Creating a font engine" on gamedev, and it mentions that there are faster ways to output text to a screen than using a Device Context (dc) and TextOut(). What are some other methods?
Thanks everyone,
Fungame
One way to do it is to blit the text (character by character) from DirectDraw a surface(s) using BltFast. All you need as a bitmap with all the characters you need in, then just clip out the right character and blit it, then go on with the next one.
Read my post ''Make this function faster!'' from earlier today. It''s about blitting text the good way, the non-GDI way, the helluva fast way! I posted my source code. Take a look at it.
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
February 07, 2000 12:30 PM
The best way is to read in the metrics of a True type font and blit is dynamically. The pre-generated font tables result in unrealistic looking text. ( I guess they are ok if you want all your fonts to line up perfectly like a text edtiory, but this looks bad for most applications). The best implementation I''ve found of this is in the Nuke library for directx. Source is available and easy to rip out.
Personaly I didn''t like the way the article went about creating a font engine. It''s too reliant on the person your giving your game to having the propper font in order to work. The best way I''ve seen is to create a bitmap with all characters you might need into it. You then take the bitmap and chop it up into blocks and blit them onto the screen just like a sprite. Your WriteOutText function would simply interperate your string of characters or numbers in to the appropriate coords for each letter in the bitmap file. Psudo code would look similar to this:
WriteOutText(string, xscreen, yscreen)
{
Open Bitmap
loop through the character array of the string
{
if letter = "a" then goto 0,0 in the bitmap file and
blit to xscreen, yscreen
}
Close Bitmap
}
WriteOutText(string, xscreen, yscreen)
{
Open Bitmap
loop through the character array of the string
{
if letter = "a" then goto 0,0 in the bitmap file and
blit to xscreen, yscreen
}
Close Bitmap
}
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement