Text drawing

I planned to draw text using opengl and couldn't figure out how to get it to draw / assemble the actual string. If I wanted to draw “Hello World”, I can create a texture for each letter and draw them all, but I know that there should be an easier way to “pull out” the correct character set at a time, and then draw only once, I decided that I can get all the individual textures, add them to the vertex array, and then draw the vertex array with just one call to draw, but that seems inefficient. Any guides that cover this particular section?

+3
source share
2 answers

Assuming that you want only 2D letters to appear at a specific point in 3D space, the usual way to do this is the one you are describing. Well, actually, I would create one bitmap for the entire line, and then draw a bitmap into the scene. This is not very inefficient - in fact it is very effective, because you can cache the bitmap of the text and only need to be calculated once, and not every time the scene is drawn. This seems like a lot of code for something simple, but OpenGL often happens.

+2
source

I wrote an Android downloader and rendering for my Bitmap font generator (CBFG), which does what you are talking about.

Android- http://www.codehead.co.uk/cbfg/TexFont.java

http://www.codehead.co.uk/cbfg

, , , UV- .

, .

+2

Source: https://habr.com/ru/post/1785016/


All Articles