Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Text drawing in GL 4.3

  1. #1
    Intern Contributor
    Join Date
    Sep 2012

    Text drawing in GL 4.3

    What's the best way to draw text in GL 4.3 core? I searched the forum but couldn't find a good answer. The wiki below seems a bit dated too.

    I don't need anything fancy - basically, need to label stuff and output messages. Something almost as convenient as glutStrokeCharacter would be great.

    Thanks for suggestions,

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Quote Originally Posted by sam_thedancer View Post
    What's the best way to draw text in GL 4.3 core?
    For efficiency, you want to use as few draw calls as possible, i.e. one per line or block of text rather than one per glyph. The easiest way is to just render it as a mesh, i.e. two triangles for each glyph.

    You can reduce the memory required by using a geometry shader which takes GL_POINTS with the character code and position as attributes and generates a pair of triangles using metrics stored in a texture.

    If you're using a monospaced font, you can use gl_VertexID to generate the X offset. For a proportional font, each glyph has to be placed explicitly (the concurrent nature of GLSL means that you can't calculate the offset based upon that for the previous character).

  3. #3
    Intern Contributor
    Join Date
    Sep 2012
    Thanks, GClements.
    But I was wondering if there's library or such that I can just plug in. I really don't want to spend time making glyphs myself as the text is just incidental to my program.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    If you just want something quick try this

Posting Permissions

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