Jump to content
  • Advertisement
Sign in to follow this  
hahaha

OpenGL Switching Bitmap Fonts

This topic is 4027 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

When my program initializes it creates two fonts using CreateFont from the win32 API. It uses opengl to create the display lists for each different font. ii have this function for drawing text:
void CFont::DrawBoldText(int x,int y,char *str)
{
     SelectObject(g_hDC,m_Bold);
     wglUseFontBitmaps(g_hDC,32,96,m_BoldBase);
     glRasterPos2i(x,y);
     glPushAttrib(GL_LIST_BIT);
       glListBase(m_BoldBase - 32);
       glCallLists((int)strlen(str),GL_UNSIGNED_BYTE,str);
     glPopAttrib();
}
void CFont::DrawText(int x,int y,char *str)
{
     SelectObject(g_hDC,m_Normal);
     wglUseFontBitmaps(g_hDC,32,96,m_NormalBase);
     glRasterPos2i(x,y);
     glPushAttrib(GL_LIST_BIT);
       glListBase(m_NormalBase - 32);
       glCallLists((int)strlen(str),GL_UNSIGNED_BYTE,str);
     glPopAttrib();
}

Calling SelectObject and wglUseFontBitmaps is very costly but if i dont do it the fonts dont change. I want to know what the proper way of switching between bitmap fonts is. And any ways that i can speed up my bitmap font drawing

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!