How to control display per frame

Hello guys,

I’m reading source code of panda, but get confused, any body can help me?
the main_loop() only invokes do_frame, and do_frame only invoke _task_mgr.poll();

My question is: if APP does not setup any task, this main_loop() will do nothing? or is there an default task to draw models?
If so, where’s the ‘default drawing task’?

code below:

bool PandaFramework::
do_frame(Thread *current_thread) {
nassertr(_is_open, false);

_task_mgr.poll();

return !_exit_flag;
}

/**

  • Called to yield control to the panda framework. This function does not
  • return until set_exit_flag() has been called.
    */
    void PandaFramework::
    main_loop() {
    Thread *current_thread = Thread::get_current_thread();
    while (do_frame(current_thread)) {
    }
    }

@ayu3405
Hello. I am not an expert of Panda3D C++ internals, but I think it is task_igloop (pandaFramework.cxx:1400). It calls the render_frame method of the GraphicsEngine class that actually does rendering.

Thank you for hint.
So there’s task_igloop to draw scene, BTW, do you know whether this is a way to manually control/trigger render_frame?
It seems impossible, since task_igloop is registered when open window, the drawing is always automatically.

I only can think of two ways:

  1. Unregister task_igloop from the task manager, now you can control render manually.
  2. If you need Panda3D only for rendering, completely abandon PandaFramework class, open window, set a camera and call render_frame() only when you need.

But in case 2, if you need mouse and keyboard input, event handling, sound, physics, etc you will also have to set it up yourself, so approach 1 looks easier.

seems 1 is better, thank you for help.