So far I have written a program that draws text to the screen and I am able to change the font type but I am unable to change the font size.

Here are the 3 main parts of my code that I think you need to see.

Font structure:

typedef struct Font
{
	const char* name;
	LONG height;
	GLuint base;
	GLYPHMETRICSFLOAT gmf[255];
};

Font creation and display functions:

void FONT::SetFont(const char* name, LONG height) //sets the font for the FontInstance
{
	HFONT hFont;
	LOGFONT logfont;
	logfont.lfHeight = -20; //this number does absolutely nothing
	logfont.lfWidth = 0;
	logfont.lfEscapement = 0;
	logfont.lfOrientation = 0;
	logfont.lfWeight = false;
	logfont.lfItalic = false;
	logfont.lfUnderline = false;
	logfont.lfStrikeOut = false;
	logfont.lfCharSet = ANSI_CHARSET;
	logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
	logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	logfont.lfQuality = ANTIALIASED_QUALITY;
	logfont.lfPitchAndFamily = DEFAULT_PITCH;
	strcpy(logfont.lfFaceName, name);

	hFont = CreateFontIndirect( &logfont );


	SelectObject( hDC, hFont );

	font.name = name;
	font.height = height;
	font.base = glGenLists(255);

	wglUseFontOutlines(hDC, 0, 255, font.base, 0.0f, 0.1f, WGL_FONT_POLYGONS, font.gmf);

	DeleteObject( hFont );
}

void FONT::DrawFunc()
{
	glPushMatrix();
		glColor3fv(color);
		glPushMatrix();
			glTranslatef(0, 0, 0);

			glListBase(font.base);
			glCallLists( strlen(text), GL_UNSIGNED_BYTE, text );
		glPopMatrix();
	glPopMatrix();
}

Also if this is a really poor way of printing text to the screen feel free to add what you think is a better way.

I have looked at doing raster drawing but since this is for drawing text on a user interface I would like to stick with the OpenGL unit system for drawing objects and text.

I can post up more code if needed.

Have you tried to create font directly from CreateFont() instead of using CreateFontIndirect()? Also, why this

hFont = CreateFontIndirect( &logfont );

becomes

font.name = name;

Either way it stores a font to hFont.

font.name = name; just stores the name for later so I know what font it is.

I'm pretty sure it has something to do with using display lists but I have no clue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.