Sign in to follow this  

Anti-aliasing bitmap fonts

This topic is 3314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm using bitmap fonts for the moment (created with CreateFont and wglUseFontBitmaps, -not- font textures), and I'm wondering if there's a way to anti-alias those fonts. I've tried to use WGL_ARB_multisample, but for some reason that doesn't work with bitmap fonts. Lines, points and polygons are all anti-aliased, but my bitmap fonts aren't. Could there be a problem in my code, or is it normal that bitmap fonts aren't anti-aliased? [EDIT] In CreateFont, I use ANTIALIASED_QUALITY as the output quality, but that didn't have any effect either.

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
WGL_ARB_multisample? I don't see how it is possible for AA to not work because this is full scene AA (EVEYTHING IS effected)


Well, WGL_ARB_multisample will definitely not work for this. Sure it is on everything, but regular AA only changes the edges of primitives, and the letters themselves are not constructed by primitives (but rather constructed IN primitives).

I have never used CreateFont and wglUseFontBitmaps, as generally I just use DirectX and assorted functions. From what I have just read, however, it seems like you are doing a bitmap operation directly to the frame buffer (as opposed to converting it to a texture which is then rendered to the frame buffer as a quad). If the former is true, then what you are looking for is not anti-aliasing. If the latter, then this should help:

I think you usually do this by using transparency super-sampling (although this is sometimes slow), which is a feature on many cards, or by using transparency multi-sampling with alpha blending enabled. The super-sampling technique gets very accurate results with a minor performance hit while the multi-sampling with alpha blending gets a little bit fuzzy on the edges but a very small performance hit. Both of these are featured in a sample in the Nvidia SDK 9.5 (although they do not use it on text, and it is done in DX, which is OK because there are always ways to get the same flag on OpenGL).

Share this post


Link to post
Share on other sites
Quote:
Original post by generaleskimo
Quote:
Original post by V-man
WGL_ARB_multisample? I don't see how it is possible for AA to not work because this is full scene AA (EVEYTHING IS effected)


Well, WGL_ARB_multisample will definitely not work for this. Sure it is on everything, but regular AA only changes the edges of primitives, and the letters themselves are not constructed by primitives (but rather constructed IN primitives).


No, it doesn't just effect edges of polygons. It effects every pixel.
Perhaps the user is not noticing it. Perhaps he wants a stronger AA applied.

Share this post


Link to post
Share on other sites
Quote:
No, it doesn't just effect edges of polygons. It effects every pixel.

That's what I was thinking too. Here is a screenshot: http://bayimg.com/HaLpmAaBO. As you can see: the line is anti-alised, the text isn't.

Setting the output quality to PROOF_QUALITY doesn't work, and creating the font with 2x the original size and using glScalef doesn't anti-alias the font.

It doesn't seem that I can get it to work with the WIN32 font functions. I'm going to use FreeType, which makes anti-aliased letters by building textures while wglUseFontBitmaps only builds black&white bitmaps.

Share this post


Link to post
Share on other sites
Quote:
Original post by beun
Setting the output quality to PROOF_QUALITY doesn't work, and creating the font with 2x the original size and using glScalef doesn't anti-alias the font.


Lol, I didn't say glScalef will anti-alias your fonts. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by beun
Quote:
No, it doesn't just effect edges of polygons. It effects every pixel.

That's what I was thinking too. Here is a screenshot: http://bayimg.com/HaLpmAaBO. As you can see: the line is anti-alised, the text isn't.

Setting the output quality to PROOF_QUALITY doesn't work, and creating the font with 2x the original size and using glScalef doesn't anti-alias the font.

It doesn't seem that I can get it to work with the WIN32 font functions. I'm going to use FreeType, which makes anti-aliased letters by building textures while wglUseFontBitmaps only builds black&white bitmaps.


Well, if you put that text onto a texture of the same resolution, where the background is black with an alpha of 0, and then use linear magnification filtering (not sure what the flag is in openGL) along with alpha blending, then it should blend the edges with texture filtering. Thats how I solve these sorts of things.


Quote:
Original post by V-man
No, it doesn't just effect edges of polygons. It effects every pixel.
Perhaps the user is not noticing it. Perhaps he wants a stronger AA applied.


In a more general sense of the word you would be correct. However, this kind of anti-aliasing doesn't function that way (it might act differently if it used the very slow full-screen super-sampling anti-aliasing technique). This is because it is assuming that it is only sampling one surface (therefore 100% coverage, and no need to run the fragment shader/pixel pipeline twice). All MSAA works like this, and the result is that the only pixels that are affected are the ones at polygon boundaries (you can find a very good explanation about why here). Instead, it is just sampling the texture once with "point" filtering enabled, so you end up with squares. However, using linear filtering will mean that We'll end up with fuzzy boundaries instead of blocky boundaries, if I'm not mistaken.

Now, anyone know the command to use linear filtering instead of point filtering in OpenGL? I only know how to do it in HLSL with Direct3D and in Nvidia CG. Can't be that hard, though.

Share this post


Link to post
Share on other sites

This topic is 3314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this