0
\$\begingroup\$

I am rendering text using the FreeType library allong with OpenGL, but say I want to render a long line of text, as seen in the following image:

enter image description here

The text continues on the same line until it goes off screen. In the above image, you can see that the window can fit the word "Test" 11 times, but the 12th goes of screen, so in a perfect world I would just be able to put \n (new line command in most systems) after the 11th word and the 12th would be rendered on a new line under the original. However, the command \n does not work the same in FreeType as it does for std::cout and printf.

Therefore my question is this - How could I render the text of one TextRenderer object on multiple lines, the same way the \n command works for single std::cout and printf calls? (I don't want to create a new object for each line of text, I can already do it this way but it seems wasteful) Maybe there is a way for FreeType to know it is at the edge of a window and if so render the next characters appropriately?

\$\endgroup\$
3
  • \$\begingroup\$ freetype only provides you with required information to render glyphs, everything else you code yourself \$\endgroup\$ Commented Mar 20, 2020 at 7:06
  • \$\begingroup\$ @Ocelot fair enough, I was just checking I diden't miss something. \$\endgroup\$ Commented Mar 20, 2020 at 22:23
  • \$\begingroup\$ You can always batch the text lines together in a buffer and then execute 1 draw call (instead of 1 draw call per text line), for efficient rendering. Whether the extra work is needed depends on the amount of text that's supposed to be rendered of course. If only a few lines of text will be rendered at a time, you probably won't have to worry about performance. \$\endgroup\$ Commented Mar 23, 2020 at 10:01

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.