Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast text rendering in OpenGL

Tags:

c++

opengl

glsl

I would like suggestions as to how to render text quickly in OpenGL.

Currently, I am reading a true type font and dynamically generating a texture containing all the ASCII characters, for each font used, for each font size used. Each texture is generated just once and kept for later use.

During the draw phase, I draw everything line by line.

I have a static array on memory, compute the kerning ect, modify the vertex positions and texture coordinates for the line. Then I bind the corresponding texture and render the line.

Unfortunately this seems to be very slow. Is there a better way?

like image 449
aCuria Avatar asked Jul 06 '12 08:07

aCuria


1 Answers

The best way IMO is to use distance fields. Will use less space, be fast, supports several nice text effects easily, and is pretty easy to implement ( especially since you've already seem to have the font -> texture parts ready ).

like image 146
Ylisar Avatar answered Sep 22 '22 12:09

Ylisar