Running Something Only After a New Frame Has Been Rendered

Simply put, is there a way to run a piece of code only after at least one new frame has been rendered?

To explain: For a project that I’m working on, I want to implement a very simple loading screen–no threading, just a static screen that’s shown until loading is finished.

However, past experience tells me that I can’t just attach a quad and then proceed with loading: the quad may well not be rendered until after the loading is done. And, if I recall correctly, even running the load after a very short “doMethodLater” may not be reliable.

So, what I want then is to put up my quad, wait until that has been rendered at least once, and only then proceed with the actual loading.

But I’m not sure of how to handle the “wait until rendered” part. Is there a way to detect that, or to get a callback on it happening…?

I think this is what you describe, but with synchronous loading, you can simply return True from the function.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import CallbackNode, NodePath
import time

class MyApp(ShowBase):

    def __init__(self):

        сall = CallbackNode('screen')

        object_geom = NodePath(сall)


    def draw(self, cbdata):

app = MyApp()

To make it work, just comment out object_geom.hide()

Ah, that does indeed seem to work! Thank you! :slight_smile: