Rendering multiple text lines

univrsal

Active Member
Hey there,

I'm working on a source type for obs and I'm looking for a way to display multiple lines of text in different positions.
Since obs already has a text source I'm trying to reuse it as a child source. Now the problem is that the text source
can only render one block of text, but I need it to display individual lines in different positions.

My first attempt was something like this:
C++:
obs_data_set_string(m_settings.settings, "text", "Line one");
obs_source_update(m_settings.source, m_settings.settings);
obs_source_video_render(m_settings.text_source);

/* To put them in the correct position I'd use gs_matrix_push(),
   gs_matrix_translate3f(...) and gs_matrix_pop()*/

obs_data_set_string(m_settings.settings, "text", "Line two");
obs_source_update(m_settings.source, m_settings.settings);
obs_source_video_render(m_settings.text_source);
Now that didn't really work. I got two blocks of text, but they both contain the same text. Looking into the source
code of obs-text.cpp, I found out that the text texture is only refreshed if the size changed or the texture is NULL,
but I couldn't find a way to force it to refresh the texture, which might be why both text blocks showed the same text.

The other approach I had in mind was to use a new text source for each text block, but I feel like that is overkill and
would waste a lot of memory. So I'd like to ask if there's a good way to draw multiple text blocks without using
multiple text sources or completely recreating the text rendering part.
 
Top