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	( NEW )

}

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

thanks
kashif

Originally posted by kashif saeed:
i am call the function buildfont_1 whenever i have to print using font1 before any glprint function and similarly i call buildfont_2 for font2
can any body help me out

  1. What is it that makes this an advanced opengl post?

  2. Are you really creating your font each time you want to use it? At what point do you free the display lists created? I would suggest you look up glGetError() and use it. You will probably find you are running out of Display lists.

Bitmaps fonts will not display if the raster position is invalid (i.e. outside the viewport). If the text is even a single pixel outside the screen, the whole thing will not be drawn (there are ways to deal with this, however, I think the bitmap/rasterpos man pages explain it).

Originally posted by Adrian67:
[b]Bitmaps fonts will not display if the raster position is invalid (i.e. outside the viewport). If the text is even a single pixel outside the screen, the whole thing will not be drawn (there are ways to deal with this, however, I think the bitmap/rasterpos man pages explain it).

[/b]

The nehe code draws the text as a series of quads so this shouldn’t (won’t) be an issue.