Jump to content


OpenGL Font problems


  • You cannot reply to this topic
1 reply to this topic

#1 jedij

    New Member

  • Members
  • Pip
  • 8 posts

Posted 26 February 2009 - 09:50 PM

I'm using openGL to draw fonts to the screen. This is my font.cpp

GLFont::GLFont(HDC deviceContext, const char* name, int size, int weight, bool italic, bool underline, bool strikeout)
{
   m_deviceContext = deviceContext;
   HFONT	font;
   HFONT	oldfont;						
   m_baseList = glGenLists(96);					

   DWORD isItalic = FALSE;
   DWORD isUnderline = FALSE;
   DWORD isStrikeout = FALSE;

   if (italic) isItalic = TRUE;
   if (underline) isUnderline = TRUE;
   if (strikeout) isStrikeout = TRUE;

   font = CreateFont(-size,								       0,
		       0,						
		       0,								weight,					     
                          isItalic,					
                    isUnderline,
                    isStrikeout,	
              ANSI_CHARSET,					OUT_TT_PRECIS,					CLIP_DEFAULT_PRECIS,			ANTIALIASED_QUALITY,	
FF_DONTCARE|DEFAULT_PITCH,
                           name);					     
oldfont = (HFONT)SelectObject(deviceContext, font);
wglUseFontBitmaps(deviceContext, 32, 96, m_baseList);
SelectObject(deviceContext, oldfont);	
DeleteObject(font);						
}

GLFont::~GLFont()
{
   glDeleteLists(m_baseList, 96);					
}

void GLFont::print(const char* fmt, ...)
{
	char text[256];						
	va_list ap;						

	if (fmt == NULL)						
		return;						

	va_start(ap, fmt);						
	   vsprintf_s(text, 256, fmt, ap);				
	va_end(ap);						

	glPushAttrib(GL_LIST_BIT);					
	glListBase(m_baseList - 32);				
	glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);	
	glPopAttrib();	
}

my question is when i have underline = true. the whole word isnt underlined, but only the individual charachters are. Is tehre a way to have a continious underline?

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4969 posts
  • LocationBellevue, WA

Posted 26 February 2009 - 10:34 PM

Please use [code]...[/code] tags when posting code on the forums. Thanks!
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users