Hey guys,
I'm trying to get text to draw, but it won't. Here's how I set up the font:
HFONT oldFont;
HDC hdc;
int weight;
hdc = GRAPHICS.GetHDC();
m_base = glGenLists(96);
// Create the font
m_font = CreateFont(-size, 0, 0, 0, false, false, underline, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE|DEFAULT_PITCH, "Times New Roman");
oldFont = (HFONT)SelectObject(hdc, m_font);
wglUseFontBitmaps(hdc, 32, 96, m_base);
SelectObject(hdc, oldFont);
DeleteObject(m_font);
Here is how I render the text:
void TextManager::Render()
{
int numText = m_textList.size();
std::list<TextObject*>::iterator textBegin = m_textList.begin();
std::list<TextObject*>::iterator textEnd = m_textList.end();
Font* temp;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, GFX_DEFAULT_WINDOW_WIDTH, 0, GFX_DEFAULT_WINDOW_HEIGHT, 1.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
while(textBegin != textEnd)
{
// Only draw visible objects not marked
// for deletion
if(!(*textBegin)->m_visible)
{
++textBegin;
continue;
}
// Clear the modelview stack
glLoadIdentity();
// Set color and screen position
glColor4f((*textBegin)->m_color.x, (*textBegin)->m_color.y, (*textBegin)->m_color.z, (*textBegin)->m_color.w);
glTranslatef(0.0f, 0.0f, -1.0f);
glRasterPos2f((*textBegin)->m_pos.x, (*textBegin)->m_pos.y);
// Draw the text
glPushAttrib(GL_LIST_BIT);
temp = m_fontList[(*textBegin)->m_fontNum];
glListBase(temp->m_base - 32);
glCallLists(strlen((*textBegin)->m_text.c_str()), GL_UNSIGNED_BYTE, (*textBegin)->m_text.c_str());
glPopAttrib();
textBegin++;
}
glPopMatrix();
CAMERA.SetProjection();
CAMERA.SetModelView();
CheckGLError();
}
If anyone sees something wrong with this code, I would greatly appreciate some help.
Diginerd