This has got to be the stupidest OpenGL trick ever. Imagine passing a C-style string directly into a POINTS draw call. No quads, no vertex positions, no texture coordinates; just raw ASCII. For example:
This is legal. It’s important to use the IPointer suffix for glVertexAttrib, otherwise GL will try to normalize your values instead of passing them straight through.
I did something similar to render text on my Toon shading demo:
The vertex shader simply passes gl_VertexID and the character to the geometry shader:
Most of the logic lives in the geometry shader; it expands the points into quads and computes the correct texture coordinates. It assumes you’re using a monospace font arranged into an atlas with 16 rows and 16 columns. The first character in the atlas is a space character (ASCII code 32).
I think something similar could be done to support non-monospace fonts, although it would be less simple. The string would need to live in random access memory (eg, a uniform array) instead of a vertex buffer.
OpenGL Demo
I posted the demo code for the Toon-shaded knot with text overlay on github: