Inside my program I have a control node that is 300x300 pixels. I have a custom draw() function where the user can draw on the control node. I want to save the custom drawing on the control. Is there a way to access the drawing on the control? Is there a way to do this without using a separate viewport?
AFAIK it's not doable without a viewport, as viewports are Godot's only way to utilize custom render targets. Don't know if there will be more flexible ways to deal with render targets in version 4.
Haven't checked, but perhaps dealing with the visual server directly might allow for something?
You need a viewport to save. But you can use the default root viewport and just save a region.
Yeah, that's a possibility, if there's no overlapping elements.
I've skimmed through VisualServer reference but seems there's no additional functionality that could be useful here.
Thank you both for your input. Like you mentioned, the overlapping elements cause a problem if saving a region.
What's the problem of using a viewport? That is definitely the correct method.
Because the viewport has its own gui input, separate from the main program. If your app happens to have draggable windows like msgbox or file dialog, they get stuck while dragging over the viewport. There is a function "gui_disable_input" that must be tediously used after manually calculating if the window dialog is over the subviewport and isn't fulling reliable.