I'm trying to create a piece of software. Low processor mode is enabled. I want to detect when a frame is about to be drawn in order to make sure some UI elements only update their appearance when needed.

For example: one of the elements I'm trying to make is a recreation of the editor's update spinner so I can make sure the other stuff I'm doing isn't causing extra frames to render, but I can't seem to find any kind of signal or anything that's called only just before a frame is about to start rendering.

    xyz

    _draw only gets called once when the scene starts, draws nothing (even though it works fine when it's changed to _process instead), and doesn't get called again even when other parts of the scene (both 2d and 3d) visibly change

    • xyz replied to this.

      update: fixed _draw not actually drawing anything by adding "propagate_notification(NOTIFICATION_DRAW)" but it still only gets called once

      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.

        • xyz replied to this.

          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

            • xyz replied to this.

              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.

                • xyz replied to this.

                  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.

                  LoipesMas Thank you! I guess I missed it when I looked through the rendering server documentation

                    clarence112 changed the title to [solved] How to detect screen refresh? .