Sign in to follow this  
Zanthos

Your text rendering method

Recommended Posts

Zanthos    300
What text rendering method do you use in your games? Is it home grown or taken from elsewhere? Have you been able to re-use it in another project without modification? Does it support any advanced text formatting methods like RTF/HTML? What API it it designed for? or does it support more than one?

Share this post


Link to post
Share on other sites
Mille    166
Well, I can say what we do :)

We have a bitmap for each font-type which contains all the chars. At load time the the bitmaps are read into memory. The tricky part is to load the chars into a displaylist (OpenGL) or vertex Buffer (DirectX/XBox), which depends on how the font bitmap is constructed.

Actually Nehe has a tutorial on how to do this, its lession-21 (which has a font .bmp file)

I'we implemented the main logic in a CText base class, and subclasses for each platform which handles the rendering.

good luck

Share this post


Link to post
Share on other sites
Endurion    5412
Mine is homegrown. I have two variations, one for 2d, one for 3d.

The base is pretty similar (building letters as images/sections of a texture). The text function simply displays a line of text.

I keep things like wrapping/formatting out of the text rendering, that's part of the GUI.

The 2d is built to work with GDI/DDraw (pointer to surface access), basically works with rectangular regions.

The old 3d version is built to work with Direct3d8, the new relies upon my abstract renderer interface, which has DX8 and DX9 plugins, and a very rudimentary OpenGL one (which i actually don't use).

I can reuse it in other projects without modification. This is, for basic text rendering. For special font effects like wavering i can still call single letter drawing functions. If it needs more than that i usually build specialized functions specific to a game/app.

Both use an abstract interface forcing them to provide TextLength/TextHeight functions (my GUI works with the font interface only, and needs those for aligning text).

Share this post


Link to post
Share on other sites
technobot    238
Grayscale texture that has all the chars + single quad per char in a set of display lists + blending/alpha-testing using the greyscale as alpha and luminance + external color setting (glSetColorxxx). Probably not the most efficient, but it works. We only have the texture font class atm, but we'll probably move the texture handling to a subclass at a later stage, and add other subclasses for different texture types (bitmap, 3D, color texture, and whatever else we'll need).

P.S.: We're targetting OpenGL only.

Share this post


Link to post
Share on other sites
Lithic    345
This is extremely interesting to me as I am currently looking for the best way to write a text engine in OpenGL. I want a methodology that supports standard font files for versatility, but also is cross-platform. This eliminates all Wgl stuff. Sdl also has no text functions. What would be the best solution for me?

My engine is C# Tao so I have an entirely different set of libraries at my disposal than most others posting here.

Share this post


Link to post
Share on other sites
Wyzfen    288
I use a bitmap with a regular grid of characters - and then seperate data for the kerning of the letters.
Rendered using quads and texture offsets (no texture swapping is good).
All provided by the Bitmap Font Builder :
http://www.lmnopc.com/bitmapfontbuilder/

Share this post


Link to post
Share on other sites
hplus0603    11356
I like text that is variable spaced, and nicely kerned, and that supports all the font options that my OS supports (in this case, Windows). Thus, I have a system which supports drawing text to offscreen surfaces, and another system which supports tieing surfaces to textures. I wrote it a few years ago, and just re-use it in each new setting.

Basically, it revolves around CreateDIBSection() and CreateCompatibleDC(), and the uses TexSubImage() on GL, and Lock() and memcpy() on Direct3D. If I'm to port to Linux, I'd have to re-implement the text-to-offscreen interface on top of something like FreeType, but that wouldn't be too hard (and a port is pretty far away, anyway).

Share this post


Link to post
Share on other sites
technobot    238
Quote:
Original post by Lithic
This is extremely interesting to me as I am currently looking for the best way to write a text engine in OpenGL. I want a methodology that supports standard font files for versatility, but also is cross-platform. This eliminates all Wgl stuff. Sdl also has no text functions. What would be the best solution for me?

My engine is C# Tao so I have an entirely different set of libraries at my disposal than most others posting here.

Since you want to support standard fonts, I think you may want to try a 3rd-party library. There a few mentioned in the Survey of OpenGL Font Technology, IIRC.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this