View Full Version : Scaling
09-11-2005, 03:30 AM
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 :)
I think you should be able to solve your problem by using:
// do a new glTranslate, rotate, scale etc just for the font
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 ;) cheers!
09-15-2005, 11:26 AM
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 ()
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
void DrawGLScene ()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}Thanks in advance for all your help!
09-21-2005, 09:38 AM
Soooo... help? Anybody? ::- (
09-22-2005, 01:55 AM
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
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0)
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.
09-28-2005, 07:51 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.