Jump to content
  • Advertisement
Sign in to follow this  
Ganoosh_

OpenGL Multiple fonts in OpenGL

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!