DirectX, Text vs. Sprite

Started by
3 comments, last by Telastyn 19 years, 3 months ago
Quick question, I'm getting to the point in my 2D RPG Engine where I'm ready to design the 'usual' character status screen. My Player class has members that contain all of the character information. My first though was to simply add public methods to get these values and print them on screen using DrawText. However, in surfing for existing 2D art I've noticed that there are some games that have text (particularly numbers) on bmp sprites. Is it faster to render these bmp images than using the DrawText method? (Newby DirectX question, but that's why I'm in the beginner's forum). Thanks, Dave
Advertisement
Depends on your app. I prefer to draw text from sprites because that way I don't have to install a font in the target system for my game to work.

Also, sometimes we have fonts that should be rendered as sprites (textured fonts). The artists would kill me if I use plain fonts.

Luck!
Guimo

In my limited experience its a slight bit faster using a bitmapped font than using a truetype font. But whats more important than the speed it takes to render is what the different font types provide you with. Bitmapped fonts allow for ellaborately coloured and designed fonts to be creates pixel-perfectly by your artist at the expense of being able to (easilly) scale or recolor them. TT fonts allow you to manipulate the font more easilly at runtime through size, color, weight, etc. Your choice should really be based on what you are going to be doing to doing to your fonts.
I think using images is better than using TT fonts. I use a 64x64 block of a PNG file for each character, which gives you a lot of flexibility. You can use textured characters as you please, and add things like a drop shadow into the image. Make the characters white, and you can do things like:

-use additive blend to not draw the shadow (black is ignored)
-change the vertex colors to draw different colored characters
-scale and rotate characters with a lot of flexibility
-make your 'text' class an extension of whatever sprite class you use

A little more work than using system fonts but a lot more powerful in some ways. Note that I had to write a utility to measure the width of each character so the text class knows how to space the text (unless you use a fixed-width font, bleh.)
I use D3DXFont.

I don't know what's faster, and frankly, I don't care. I don't want to deal with writing my own font rendering system. I don't want to draw a few dozen characters. I don't want to deal with users who complain when I didn't draw the characters of their locale, or when my app breaks because the Font system chokes on unicode...

Load font, draw text. Done. Especially as a beginner, I've plenty of other things to worry about.

This topic is closed to new replies.

Advertisement