text vanishes

hello guys
i am presently working in an application where i am using multiple fonts to display text . i am using NEHE bitmap font building and printing basecode for my different fonts
the problem is that both the fonts are displaying on the screen alright but after two to three minutes of my applicatiuon run the text disappears but other drawing like trianles lines etc are ok . but the text vanishes . i used the following code
// Our Bitmap Font1
GLvoid BuildFont_1(GLvoid)
{
HFONT font; // Windows Font ID

base = glGenLists(96); // Storage For 96 Characters ( NEW )

font_size = -11;

font = CreateFont( font_size, // Height Of Font
0, // Width Of Font
0, // Angle Of Escapement
0, // Orientation Angle
FW_NORMAL, // 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
“Ariel”); // Font Name

SelectObject(hDC, font);

wglUseFontBitmaps(hDC, 32, 96, base); // Builds 96 Characters Starting At Character 32
}

// bitmap font 2
GLvoid BuildFont_2(GLvoid)
{
HFONT font; // Windows Font ID

base = glGenLists(96); // Storage For 96 Characters ( NEW )

font_size = -15;

font = CreateFont( font_size, // Height Of Font
0, // Width Of Font
0, // Angle Of Escapement
0, // Orientation Angle
FW_NORMAL, // 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

SelectObject(hDC, font);

wglUseFontBitmaps(hDC, 32, 96, base); // Builds 96 Characters Starting At Character 32
}

GLvoid KillFont(GLvoid) // Delete The Font
{
glDeleteLists(base, 96); // Delete All 96 Characters ( NEW )
}

GLvoid glPrint(const char *fmt, …) // Custom GL “Print” Routine
{
char text[256]; // Holds Our String
va_list ap;

if (fmt == NULL) // If There’s No Text
return;

va_start(ap, fmt); // Parses The String For Variables
vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers
va_end(ap);

glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits ( NEW )
glListBase(base - 32);

glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text ( NEW )
glPopAttrib(); // Pops The Display List Bits

}

i am calling the function buildfont_1 whenever i have to print using font1 before glprint function along with glRasterPos()and similarly i call buildfont_2 for font2
can any body help me out

thanks
kashif

Hi !

Do you mean that you call the buildfont functions many times ? if so, then that’s the problem, they genererate a number of display list data that you never erase as far as I can tell, so after a little while you will run out of memory.

You need to erase the old display lists first and you should only call the build functions when you have to.

Mikael

Why don’t you use 2 differents textures for your font ?

Texture1 and 2 and before drawing your text, just change the texture number ?

Not ?

hello mikael_aronsson
i read your reply but how can i erase my old display list and use new and then erase that and use previous one please provide me with some help .
how can i make a texture of different fonts
thaks