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 4 of 4

Thread: Text drawing in GL 4.3

  1. #1
    Intern Contributor
    Join Date
    Sep 2012
    Posts
    76

    Text drawing in GL 4.3

    Greetings:
    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.
    http://en.wikibooks.org/wiki/OpenGL_...t_Rendering_01

    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,
    Sam

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    474
    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
    Posts
    76
    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
    Location
    Australia
    Posts
    1,106
    If you just want something quick try this
    http://github.prideout.net/strings-i...ertex-buffers/

Posting Permissions

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