Lua: how do I make a custom Source that can display text in the scene?

I see lots of examples of scripts that use a Text(GDI+) scene to show text. But I already have to make a custom Source (see below) and it seems clumsy to have to add TWO sources to a scene just to show a little text. Can I do text output from my Source in Lua? I see the flag OBS_SOURCE_CUSTOM_DRAW, but aside from some functions talking about rendering "textures", I haven't found anything in the dox about rendering text.

Context: I am working on a modification to
https://obsproject.com/forum/threads/control-visca-over-ip-based-cameras.136462/

That project creates a custom Source which can be added to Scenes to control changes to camera presets.
If a scene selected into Preview wants to use a camera, it first looks at the Program scene.
If the camera isn't being used, then the camera preset can be changed.
If the camera IS being used, the preset is changed when the new scene transitions from Preview to Program

In the case where change of preset is postponed, I want to show a text overlay in the Preview on the order of "camera will change to closeup when scene transitions to Program"
 
I ended up adding a text(gdi+) source to the scenes, and showing and hiding it as the scenes enter Preview and Program.

Most of the work is triggered by OBS_FRONTEND_EVENT_SCENE_CHANGED and OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED events.
However, those events seem to fire AFTER the scene has already been rendered, so hiding the text source when the scene enters Program results in the text being shown in Program for a brief interval. I avoided that by handing the source_activate signal for the text source.

And learned that source_activate isn't generated for sources create with obs_source_create_private (the signal DOES occur for sources created with obs_source_create, or manually)
 
Back
Top