Scaling

This is my first post here, so, hi to everybody!

Some while ago I playing with some Outline Fonts. But I experienced a very annoying problem to which maybe you have the answer. They’re being automatically re-scaled to match the viewport size. Even if I specify a certain height for the font, GL automatically increases the height when the viewport is increased.

Is it possible to use an Outline Font which WILL NOT be resized by Open GL when I resize the viewport? I am drawing in a window, this is why this is so important.

Thank you in advance.

Welcome to the forum :slight_smile:
I think you should be able to solve your problem by using:

glPushMatrix();
glLoadIdentity();
// do a new glTranslate, rotate, scale etc just for the font

//draw string
glPushMatrix();

If you need the font to stay fixed while changing window size, you could try using a bitmap font or Push - Clear - Draw string - Pop the PROJECTION matrix as well.
Hope I’ve helped :wink: cheers!

Thanks for your reply ::- ). In your code I see “glPushMatrix” twice. I guess you meant “glPopMatrix” the second time ::- ). Anyway. It doesn’t seem to be working. Here are my InitGL and Draw functions. These are the most important ones, the rest is pretty standard. This, by the way, is taken from a NEHE tutorial, lesson 14 from his website. The PrintGlText is made by him but all that is pretty standard. My problem is not drawing. My problem is perspective.

Thanks a lot for your help. Maybe we can shed some light in this matter. I am a begginer in OPEN GL but I did read some documentation about these functions. However, whatever I do, when I increase the OPEN GL viewport, the text’s height increases. Most annoying.

Here is how the font is declared (no matter what height I give it, it will still increase with the window, probably because it’s an outline font.)

  	font = CreateFont(	-12,							// Height Of Font
						0,								// Width Of Font
						0,								// Angle Of Escapement
						0,								// Orientation Angle
						FW_BOLD,						// 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
						"CopprplGoth Bd BT");				// Font Name
I don't want to use bitmap fonts since they are too rigid. Outline fonts rule, if only I could get them working right ::- D.

void InitGL ()
{	
	glShadeModel(GL_SMOOTH);
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);	
	glDepthFunc(GL_LEQUAL);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHTING);
	glEnable(GL_COLOR_MATERIAL);
	BuildGLFont();
}

void DrawGLScene ()
{
	glPushMatrix();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	glTranslatef(-1.8f,-0.3f,-1.7f);
	glRotatef(25.0f,1.0f,0.0f,0.0f);
 	PrintGLText("Testing.");
	glPopMatrix();
}

Thanks in advance for all your help!

Soooo… help? Anybody? ::- (

This is really simple. First you need to know in which coordinate range the wglUseFontOutlines maps the glyph’s vertices. The manual about wglUseFontOutlines says:
“The run of glyphs begins with the first glyph of the font of the specified device context. The em square size of the font, the notional grid size of the original font outline from which the font is fitted, is mapped to 1.0 in the x- and y-coordinates in the display lists. The extrusion parameter sets how much depth the font has in the z direction.”

So characters are in the range 0.0 to 1.0.
You never changed your projection or modelview matrices, which means you use the default identity matrices which is the same as doing

glMatrixMode(GL_PROJECTION)
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

Means add the above code in you init routine and nothing changes.
Then choose different glOrtho parameters in above code like
glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0);
and hey, the font is four times smaller.

You just need add a resize handler which changes the projection and glViewport according to your desired window size and that’s it.

Thank you very much for your answer Relic ::- D. How am I going to use glOrtho in conjuncture with the resizing of the window remains a mistery to me though.