PDA

View Full Version : I am looking for redering text 2D



mairan21
01-18-2015, 03:46 AM
I am looking for redering text 2D in Opengl without shaders. Only needs to be cool.

Thanks.

Agent D
01-19-2015, 06:34 AM
If it has to be "without shaders", you are stuck with legacy OpenGL(R), either through compatibillity
profile that isn't supported everywhere, or by using a version no larger than 2.1.

Is there any reason why you want to use legacy GL?

I have no idea what your application is or what you define as cool text rendering, but here are
some possibilties:

Depending on how often the text changes, you can either use a fontmap (a texture image containing all
the glyphs you need) and stitch the text together from textured rectangles (one for each glyph), or you
have a bitmap containing the entire text string and you draw a single textured rectangle for the entire
text string.

You can generate font map either using some offline tool, or on the fly, using the FreeType library (especially
if you want to scale it up at some point).




Unfortionately, the only text rendering technique I think qualifies as cool uses shaders (which you don't want for some reason).
It stores the text characters in a single channel, 8 bit integer 2D texture. The texture is mapped onto a surface using nearest
neighbour filtering. The fragment shader uses the 8 bit integer value to compute an offset into a fontmap texture where all
characters have the same width and height, thus mapping stitching together the glyph images in the fragment shader.

mairan21
01-19-2015, 10:12 AM
Because I don't know how to make shaders.