Results 1 to 10 of 11

Thread: Text rendering in OpenGL

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Thank you for the replies!

    I might consider using bitmp fonts for beginning. I don't have yet experience with that, but as far as I image, I should render a character map (atlas) at runtime, using the OS's built in text rendering functions. The character map would be a single channel texture (alpha map). Then each quad's tex-coordinates should map an exact character from the texture. Then I can combine the character alpha map with a custom texture or color to fill the character in the fragment shader. Would that work? How do you do it in your implementations?

    But wouldn't be a problem for the mipmapping if I use a single texture for font atlas? Is it a better solution to store each character in different texture?

    About the 3d text geometry, since I target for multiplatform code, I am unable to use the windows api for text geometry. My only idea for now is to find and download a 3d font model set (I guess there should be any) or try to create in Blender, so I can load it from it's file and have each character as a tri model group and then use them to render the text.
    Last edited by Anton; 07-11-2014 at 09:52 PM.

  2. #2
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    If you're looking for 2d fonts, I would personally have to point out that ZenGL (by Andru) renders some quite pretty fonts. Basically, you feed it a font from your system (via ttf or whatever you prefer) and give it the characters you want. From this, it generate .zfi file which stores the information for how to render the font, and some .tga images which contain the visual information. Then all you need do is simply combine the two which in hindsight is reasonably easy to do. If you want a reference implementation, one can see some code for it here: https://sourceforge.net/p/prometheus...ee/PM_Font.pas
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  3. #3
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    I would suggest FreeType it is a portable font engine that would allow to use most fonts. I use it to create bitmap fonts but with some work I think you could pull the information you need to do full 3D. http://sourceforge.net/projects/freetype/

  4. #4
    Quote Originally Posted by Anton View Post
    I don't have yet experience with that, but as far as I image, I should render a character map (atlas) at runtime, using the OS's built in text rendering functions. The character map would be a single channel texture (alpha map). Then each quad's tex-coordinates should map an exact character from the texture. Then I can combine the character alpha map with a custom texture or color to fill the character in the fragment shader. Would that work? How do you do it in your implementations?
    No. You can pre-generate a texture, and save the character pixel widths in file. Texture is usually a 24-bit RGBA image. You can even pre-generate one and then add effects in photoshop/gimp.

    Quote Originally Posted by Anton View Post
    But wouldn't be a problem for the mipmapping if I use a single texture for font atlas? Is it a better solution to store each character in different texture?
    Mipmapping is done per texture basis, fonts shouldn't need any. Mipmapping technique is used to smoothen repeating textures like terrain that fade into distance. Font neither repeats nor has varying depth. And true, you don't want to include fonts in global single texture. You can't mipmap a texture atlas either, it will simply mess up clamping.

Bookmarks

Posting Permissions

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