Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Problem with texture mapped fonts

  1. #1
    Junior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Poland
    Posts
    196

    Problem with texture mapped fonts

    Hi,

    I have a problem with texture mapped fonts. I'm reading a font from file, the backgrund of texture font is black. I use BlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA). When I render a letter on a black background all is OK, but if I render a letter on some else surface which has else color I see the edges of letter which are used only for antyaliasing (I shouldn't see them). How to make font like in Quake 3 Arena that has one color and is correctly antyaliased (font color doesn't depends on colors behind the letter texture)? I have tested diffrent blending options but it gives nothing. The font file is OK. What should I do to make a font like in Quake3?
    I've checked NeHe's tutorial but there is else method than I want.

    thanks for help

  2. #2
    Email address no longer exists Frequent Contributor
    Join Date
    Dec 2002
    Location
    Espoo, Finland
    Posts
    599

    Re: Problem with texture mapped fonts

    Hi,

    First of all, your blending function is wrong, it should be GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA. Well maybe it's just a typo...

    To get the antialiased fonts right, your texture's color channel should be totally white. This way you can set the text color with glColor. You can antialias the alpha channel if you want.

    -Ilkka

  3. #3
    Junior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Poland
    Posts
    196

    Re: Problem with texture mapped fonts

    Hi,

    I've changed the second parameter to GL_ONE_MINUS_SRC_ALPHA but then I see a black color around a letter (all letter texture is opaque). But there is the second problem. When I set the blending to above letters are cutted a little from right side.
    Mark J. Kilgard writes about it in his tutorial "A Simple OpenGL-based API for Texture Mapped Text". He says that I should enable polygon offset by glEnable(GL_POLYGON_OFFSET) and then set glPolygonOffset(0.0, -3) but it doesn't work. Compilator doesn't know a constant called GL_POLYGON_OFFSET, is it a GL extension or what? How I have to fix it?

    And what is GL_ALPHA_TEST ?

    thanks

  4. #4
    Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    254

    Re: Problem with texture mapped fonts

    Hello glYaro,

    GL_ALPHA_TEST means:
    If enabled, do alpha testing. Also See glAlphaFunc .

  5. #5
    Email address no longer exists Frequent Contributor
    Join Date
    Dec 2002
    Location
    Espoo, Finland
    Posts
    599

    Re: Problem with texture mapped fonts

    I think it's GL_POLYGON_OFFSET_FILL. But I don't see why you would need it, unless you are drawing the text as a decal on existing geometry.

    Sounds to me like you don't have alpha channel, or your alpha is one all over the texture. The letters should be in the alpha channel, color channel should be completely white. Then it will work with that blending function.

    -Ilkka

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •