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;

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 ); = 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()
			glTranslatef(0, 0, 0);

			glCallLists( strlen(text), GL_UNSIGNED_BYTE, text );

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 = name;

Edited 6 Years Ago by Taywin: n/a

Either way it stores a font to hFont. = 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.

This article has been dead for over six months. Start a new discussion instead.