- Edited
clarence112 It gets called whenever you or engine calls queue_redraw()
. So call it each time your code updates your custom widget parameters/appearance.
clarence112 It gets called whenever you or engine calls queue_redraw()
. So call it each time your code updates your custom widget parameters/appearance.
xyz I want it getting called every time the engine decides to draw a frame though. Any time any part of the screen changes whether my own code caused it or not.
clarence112 If the widget changes every frame, call queue_redraw()
from _process()
which runs once per frame.
xyz With low processor mode enabled _process can get called multiple times per frame as the main loop still runs regardless of whether another frame was rendered or not.
I'm trying to replicate this thing
clarence112 If you call queue_redraw()
from _process()
the redraw shouldn't happen more than once per frame, regardless of how many times per frame _process()
gets called.
xyz That forces new frames to be drawn constantly, which isn't what I want. It should only update in reaction to a frame being drawn. There can potentially be minutes between individual frames if nothing is happening.
clarence112 Frames are always pumped out at more or less constant rate in game engines. Not sure if low processor mode can affects this. You should run Godot's profiler and see what the gpu is doing. Canvas items with custom draws are composed in offscreen buffers. This happens when _draw()
is called. However actual blit of that offscreen buffer onto the main framebuffer will normally happen in accord with monitor refresh rate. So you can only minimize redraws of a canvas item into its offscreen buffer by triggering _draw()
only when item appearance changes, and your code always knows when that is.
Have you tried connecting to either one of these signals: https://docs.godotengine.org/en/stable/classes/class_renderingserver.html#signals? frame_pre_draw
should be what you need
LoipesMas Thank you! I guess I missed it when I looked through the rendering server documentation
clarence112 Marked the Best answer