Switching Bitmap Fonts

Started by
0 comments, last by hahaha 16 years, 9 months ago
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
Advertisement
Anyone?

This topic is closed to new replies.

Advertisement