Skip to content

Conversation

beicause
Copy link
Contributor

Closes #1299.
Adds on_main_loop_startup, on_main_loop_frame, on_main_loop_shutdown callbacks to ExtensionLibrary for Godot 4.5.

This PR needs rebase once we have api-4.5 feature.

@Bromeon Bromeon added feature Adds functionality to the library c: ffi Low-level components and interaction with GDExtension API labels Sep 16, 2025
@Bromeon Bromeon added this to the 0.4.x milestone Sep 16, 2025
@beicause beicause force-pushed the main-loop-callbacks branch from 66e5afc to 5daf025 Compare October 7, 2025 14:01
@beicause beicause marked this pull request as ready for review October 7, 2025 14:06
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1313

Copy link
Member

@Bromeon Bromeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

@beicause beicause force-pushed the main-loop-callbacks branch 2 times, most recently from 5cbea37 to a012d2f Compare October 7, 2025 15:21
Copy link
Member

@Bromeon Bromeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Some thoughts:

  • Godot uses "startup" and "shutdown", I think we should keep things consistent with the other godot-rust APIs and use "init" and "deinit" instead. Then we'd have on_level_init + on_main_loop_init, etc.
  • Is there a strict order between the levels and the main loop? If yes, should we (not in this PR, but a follow-up) consider representing MainLoop as its own InitLevel?

@beicause
Copy link
Contributor Author

beicause commented Oct 8, 2025

  • Godot uses "startup" and "shutdown", I think we should keep things consistent with the other godot-rust APIs and use "init" and "deinit" instead. Then we'd have on_level_init + on_main_loop_init, etc.
  • Is there a strict order between the levels and the main loop? If yes, should we (not in this PR, but a follow-up) consider representing MainLoop as its own InitLevel?

on_main_loop_init feels off, the startup is actually after the MainLoop/SceneTree is created. It is the final step of Main::start() and after all init levels (shutdown is the vice versa, before all init levels).

I think it's better to make them separate functions, keeping on_init_level lean so you're less likely to make mistakes in it.

@beicause beicause force-pushed the main-loop-callbacks branch from a012d2f to 663535e Compare October 8, 2025 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: ffi Low-level components and interaction with GDExtension API feature Adds functionality to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support registering main loop callback in Godot 4.5
3 participants