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,
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).
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.