Fonts in Warcraft3. How they keep them the same size on different resolutions?

Started by
9 comments, last by owl 19 years, 10 months ago
And how would you go to render fonts like they do on the heros description and hit point that apear on the screen while you play, all this in openGL. I render my fonts with the Freetype lib in ortho mode, but I think ortho would be a bitch in order to make the text be in a certain/moving area of a 3D rendered scene... I'm using ortho mode because is the only way I can make the font be rendered with the appropiate size (in pixels). Besides, in Warcraft3's menu, when you change the resolution, the fonts in the buttons and everything else remain with the same size, no matter what resolution you pick. I'm blank. I don't know how to do it. help? Thanks EDIT: I know Warcraft3 runs with DirectX. [edited by - owl on June 4, 2004 2:44:31 AM]
[size="2"]I like the Walrus best.
Advertisement
We have that in Eternal Lands too (but for us it is a little easier, given the fact we have an Ortho perspective (but we do have to adjust the text size for zoom in and out). Our client is OpenSource, so you can look on how we do it (I didn''t write that specific code, and I am too lazy to check the math behind it, but feel free to look).
I have not player war craft, but does the font size stay the same in pixel size or in proportion to the screen size?

If you want your text to stay in same pixel size regardless of your resolution (that is, when in higher resolution, the text will look smaller on screen), then use your window size as the bounds you set with the glOrtho.

For example:
int iWidth = pEngine->GetWindowWidth();
int iHeight = pEngine->GetWindowHeight();
glOrtho( 0, iWidth, 0, iHeight, -1, 1 );


In the other case pick fixed width or height (say width=640), and scale the other dimension depending the window aspect ratio. Then feed that dimension to the glOrtho.

For example:
int iWidth = pEngine->GetWindowWidth();
int iHeight = pEngine->GetWindowWidth();
float fW = 640.0f;
float fH = fW / (float)iWidth * (float)iHeight;
glOrtho( 0, fW, 0, fH, -1, 1 );
I think they rendered it as textured quad. But I don''t know how they make it still look good even in different resolutions.
you may set the ortho mode as:
glOrtho( 0, 1, 0, 1, -1, 1 );

and when rendering fonts (as a texture on a quad) you can use for example:

glVertex2f(0.00f , 0.00f);
glVertex2f(0.10f , 0.00f);
...

in every resolution the size of the 2D object will be same just like you wanted.




What we do in life, echoes in eternity!
What we do in life, echoes in eternity!
quote:Original post by alnite
I think they rendered it as textured quad. But I don''t know how they make it still look good even in different resolutions.


by making the default resolution insanly high. Make a font bitmap set like 64 pixels high. THen on higher resolutions you always size it smaller, and it still looks nice

--------------------------------------------------------
Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.
My guess is that they use orthogonal projection with "resolution" set to 1024x768, and when they draw menu and fonts, they just assume that screen is 1024x768. That would explane, why fonts look crappy when resolution is smaller than 1024x768, but of course I''m not exactly sure what ortho resolution they are using.
Thank you everyone!

quote:Original post by emreture
you may set the ortho mode as:
glOrtho( 0, 1, 0, 1, -1, 1 );

and when rendering fonts (as a texture on a quad) you can use for example:

glVertex2f(0.00f , 0.00f);
glVertex2f(0.10f , 0.00f);
...

in every resolution the size of the 2D object will be same just like you wanted.


That''s what I''m thinking, but how would you do to make some text match the position of an object that was positioned using another cartesian space?

Anyway I''m afraid that the scaled font may look quite crappy... Maybe making the bitmap font insanely high as vampire says could work...
[size="2"]I like the Walrus best.
any ideas?
[size="2"]I like the Walrus best.
Just draw the text in the perspective mode, above the actor''s head. Of course, rotate it so it faces the camera.
Calculate the distance from camera to actor, and modify the text size accordingly.

This topic is closed to new replies.

Advertisement