How to show font?

im doing a flight game but i cant display text/font on my screen, y??
i included 2 cpp and 2 header files.
i already defined glprint function, killfont, buildfont as well.
if anyone interrest with my problem u can post ur email then i’ll forward to u.
i need to pass this up to my college next month. someone plz help me. :frowning:

What kind of fonts? If you use texture fonts then:
Are you drawing your fonts in 2D (gluOrtho or glFrustum)? If so you should check that your vertices are located the right order clockwise or counter-clockwise (depends on your definition glFrontFace(…)). Check if the text/symbol is really on the screen. Check that you give right texture coordinates and the color is set to something visible (including transperency). The last thing - check if your “current texture” (glBindTexture(…)) is set to that font texture. I don’t use other font types, so i can’t help with them. The problem may also appear if you change to 2D mode, but forget to glLoadIdentity() viewport matrix. Could you post your CreateFont and Printf code so we could check and point you the mistake if it’s in them?

Hi, I have the same problem :frowning: , I have the code for those functions here:

 #include <windows.h>		// Header File For Windows
//#include <math.h>			// Header File For Windows Math Library
#include <stdio.h>			// Header File For Standard Input/Output
#include <stdarg.h>			// Header File For Variable Argument Routines
#include <gl\gl.h>			// Header File For The OpenGL32 Library
#include <gl\glu.h>			// Header File For The GLu32 Library
#include <gl\glaux.h>		// Header File For The Glaux Library

HDC			hDC=NULL;		// Private GDI Device Context
HGLRC		hRC=NULL;		// Permanent Rendering Context
HWND		hWnd=NULL;		// Holds Our Window Handle
HINSTANCE	hInstance;		// Holds The Instance Of The Application

GLuint	base;				// Base Display List For The Font Set

GLvoid BuildFont(GLvoid)								
	HFONT	font;										
	HFONT	oldfont;								

	base = glGenLists(96);						

	font = CreateFont(	-24,					
						"Courier New");	
    /*if (font) MessageBox(NULL,"font","Font",MB_OK);
    else MessageBox(NULL,"De fout zit bij font","Font",MB_OK);*/ //tested: juist!	

	oldfont = (HFONT)SelectObject(hDC, font);          
	wglUseFontBitmaps(hDC, 32, 96, base);			
	SelectObject(hDC, oldfont);						

GLvoid KillFont(GLvoid)									// Delete The Font List
	glDeleteLists(base, 96);							// Delete All 96 Characters

GLvoid glPrint(const char *fmt, ...)					// Custom GL "Print" Routine
	char		text[256];								// Holds Our String
	va_list		ap;										// Pointer To List Of Arguments

	if (fmt == NULL)									// If There's No Text
		return;											// Do Nothing

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

	glPushAttrib(GL_LIST_BIT);							// Pushes The Display List Bits
	glListBase(base - 32);								// Sets The Base Character to 32
	glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);	// Draws The Display List Text
	glPopAttrib();										// Pops The Display List Bits

Can anyone here help??? :confused:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.