Question

I searched around a bit and couldn't find anything clear cut as to whether/how you can render true-type fonts using OpenGL (with SDL as the API if it makes any difference).

So I was wondering if anybody with experience knows the answer to if it is possible and how, or could point me to some other good source or explanation.

If it's not possible which I suspect is the case, any other suggestions would be greatly appreciated for working with fonts using OpenGL.

Was it helpful?

Solution

OpenGL itself deals only with points, lines and triangles. Anything going beyond that functionality must be implemented by the user. So no, there's no direct support for font rendering in OpenGL.

One can of course use OpenGL to rasterize glyphs, by various methods.

  • A very widespread method is texture mapped fonts, i.e. each (used) glyph of a font rendered into a texture atlat.
  • One can use OpenGL primitives to raster glyph curves, though this is a tricky subject.
  • Use shaders to implement vector textures
  • Use shaders to implement distance maps (distance maps are not unlike texture mapped font's but with a greatly reduced memory footprint).

OTHER TIPS

Look at this. Here is a more recent example of using FreeType with OpenGL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top