Lesson 13 - Bitmaped Fonts
I followed the lesson and I thought I put everything in correctly, but the text doesn''t appear on the screen. I put it all into one function to test but it still doesn''t work. Here is the code, what did I do wrong?
HFONT font;
mFont = glGenLists(96);
font = CreateFont(-24, // Height Of Font ( NEW )
0, // Width Of Font
0, // Angle Of Escapement
0, // Orientation Angle
FW_BOLD, // Font Weight
FALSE, // Italic
FALSE, // Underline
FALSE, // Strikeout
ANSI_CHARSET, // Character Set Identifier
OUT_TT_PRECIS, // Output Precision
CLIP_DEFAULT_PRECIS, // Clipping Precision
ANTIALIASED_QUALITY, // Output Quality
FF_DONTCARE|DEFAULT_PITCH, // Family And Pitch
"Courier New"); // Font Name
HFONT oldFont = (HFONT)SelectObject(mDeviceContext, font);
wglUseFontBitmaps(mDeviceContext, 32, 96, mFont);
SelectObject(mDeviceContext, oldFont);
DeleteObject(font);
glColor3f(0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity();
glTranslatef(0.0f,0.0f,-1.0f);
glColor3f(1.0f, 1.0f, 1.0f);
glRasterPos2f(-0.3f, 0.0f);
char text[] = "Test Message";
glPushAttrib(GL_LIST_BIT);
glListBase(mFont - 32);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();
SwapBuffers(mDeviceContext);
glDeleteLists(mFont, 96);
It looks like your deleting the font displaylists you created after rendering them once.
I am. This function was just a test so I could get all the relevant code in one function and post it here. In the normal code the lists don''t get deleted this way and the text still isn''t displayed.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement