OpenGL Multiple fonts in OpenGL

This topic is 5200 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm using bitmap fonts, like the ones explained here: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=13, and I want to know if I can use multiple types of fonts. I tried using an array of HFONTs and I made a funtion that takes the HFONT and HDC and calls SelectObject(), and wglUseFontBitmaps(), but it doesn't seem to work. Any idea how to do this?

Share on other sites
Using NeHe's approach, the best thing to do would probably be to only load one font at a time, but make sure that the display lists you create do not overlap.

The thing to do would be to make the "GLuint base" into an array, "GLuint base[n]"

For example, the first wglUseFontBitmaps call might be:

base[0] = glGenLists(96);// ... font load ...wglUseFontBitmaps(hDC, 32, 96, base[0]);

and then

base[1] = glGenLists(96);// ... font load ...wglUseFontBitmaps(hDC, 32, 96, base[1]);

and so on. Don't forget to call glListBase each time you need to switch font, and also to glDeleteLists for all the font blocks.

By the way, if at any time you feel like upgrading your font system, it might be worth checking out freetype, or SDL_ttf if you move to SDL, and using textured quads for font rendering. It's much more efficient, and looks better too.

Share on other sites
Oh I get it, yeah I'm still learning OpenGL so I didn't know it worked like that. But yeah I'll check them out, see what works best, thanks.

Share on other sites
Note that glListBase will only affect calls to glCallLists, and not glCallList, glGenLists, and other functions related to display lists.

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 13
• 9
• 11
• 15