I’ve been using godot’s draw function to create what is essentially pie charts. The idea is that when I minimize the viewport on which they’re drawn, I’d screenshot it and use that as a thumbnail for the button that brings it back up.
You’re 100% correct. I don’t know why it was giving me issues on the main viewport before. You’ve helped me narrow down the issue and it seems to be that I’m using a subViewport.
If it helps, this is what my tree looks like with the subViewport highlighted. I was running the script from the subViewportContainer node that holds it and that gave me a blank screenshot. I’ve now tried to have it directly running from the subViewport instead but that also gives me a blank screenshot.
If I use get_viewport() as in your example, it uses the main viewport and that does screenshot the _draw function as well (along with everything else). So push comes to shove I can use that as a workaround.
I’d still like to figure out why it’s not working for the subViewport though.
Still can’t reproduce your issue! My tree now looks like this:
Control A
SubViewportContainer
SubViewport
Control B
I didn’t change any settings whatsoever. “Control B” has a script with just the _draw function I used above, whereas “Control A” only contains the _ready function now:
Works like a charm! The screenshot is smaller than before (since the default size for SubViewport is 512x512 pixels), but still contains the red circle.