#### Archived

This topic is now archived and is closed to further replies.

# Bitmap Fonts Not Showing Up...

## Recommended Posts

OK, I am redoing one of my first games (originally done on an Atari400 in BASIC with no graphics) in OpenGL since I have a good bit of knowledge of GL, and since I want to add multiplayer. However, to test the MP connection to the server I am writing on my Debian Linux box, I figured I''d use a bitmap font to see the messages comming and going between the two to make sure it works right. The first step is to just display a simple text message in the upper-left screen. I make the font, but it won''t display. Here''s the code used.
void KillGLFont()
{
glDeleteLists(WinData.FontBase, 256);
return;
}

void BuildGLFont()
{
HFONT Font, OldFont;

WinData.FontBase = glGenLists(256);
Font = CreateFont(-24, 0, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, "Times New Roman");
OldFont = (HFONT)SelectObject(WinData.DeviceContext, Font);
wglUseFontBitmaps(WinData.DeviceContext, 0, 256, WinData.FontBase);
SelectObject(WinData.DeviceContext, OldFont);
DeleteObject(Font);

return;
}

void GLPrint(char *GLTextFMT, ...)
{
char GLTextBuffer[1024];
va_list GLTextArgs;

if(GLTextFMT == NULL)
{
ErrorLog("OpenGL.cpp: GLPrintf() recieved a NULL string.");
return;
}

if(strlen(GLTextFMT) > 896)
{
ErrorLog("OpenGL.cpp: Attempted to display a string longer than 896 characters.");
return;
}

memset(GLTextBuffer, ''\0'', sizeof(GLTextBuffer));
va_start(GLTextArgs, GLTextFMT);
vsprintf(GLTextBuffer, GLTextFMT, GLTextArgs);
va_end(GLTextArgs);

glTranslatef(0.000, 0.000, 1.000);
glRasterPos2f(-0.500, -0.400);
glColor3f(1.0, 1.0, 0.0);
glPushAttrib(GL_LIST_BIT);
glListBase(WinData.FontBase);
glCallLists(strlen(GLTextBuffer), GL_UNSIGNED_BYTE, GLTextBuffer);
glPopAttrib();
glTranslatef(0.000, 0.000, -1.000);

return;
}

WinData.FontBase is an "unsigned int", and the code spawns no errors or warnings. Granted, this is a very simple method, but I need the text. Should I be somehow making polygons to map the text onto? Here''s how I call it in my ain loop right now.
//Deep within the main loop

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLPrint("AoY Online Client v%s", VERSION);
SwapBuffers(WinData.DeviceContext);
//And yes, this is temporary code

//while I test the font


I am running Windoze XP Home, with all the latest patches and such. If it matters, none of my applications will go fullscreen in Windows XP. They work fine on 98SE on my P2/233 and P3/866, but on WinXP on this box, it just seems to change the screen resolution and stretch (not maximize) the GL app window to the extents of the monitor. It won''t hide the mouse either, and I can drag the GL app window around and actually see my desktop and such. Also, when I exit the main loop in XP, the last line of code before "return Message.wParam;" logs that the GL window was destroyed OK, and I get that line of code in the log, but then it throws an error! I can''t figre it out to save my life. I can post the window creation and destruction code if you guys think it''s my problem. Thanks for the help!

##### Share on other sites
JoeDeuter    122
Hi

glTranslatef(0.000, 0.000, 1.000);

That would put the font out of view wouldn''t it?

glTranslatef(0.000, 0.000, -1.000);

IE; 1 unit into the screen, thatway the font is guarenteed 1 GL unit infront of your eyeball :-)

Joe

##### Share on other sites
I thought the thing was, the farther form your high, the numbers increased. And behind the eye was negative. I''ll try it. Give me a sec.

Yeah that fixed it. Thanks for the help with the font. Now I still have two major problems on XP. The app will NOT go fullscreen, even though it returns CDS_DISPCHANGESUCCESSFUL and changes to 800x600 res. Also, when I quit, I added a log line above "return Message.wParam;" and it logs it. For some reason, returning to the system spawns an error, even though the window has been closed! What the HECK is wrong with XP?? It runs FINE on 95, 98SE, and ME. This is really ticking me off because MS gets paid millions each year and they can''t make a f*&^)(*& OS that runs right YET.

-The Great Sephiroth