Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibGodot with GDExtension #72883

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Faolan-Rad
Copy link
Contributor

LibGodot is a system to allows Godot to be compiled as a library and connected into it using GDExtensions by giving a function pointer to the entry point of a GDExtension implementation before starting Godot.

LibGodot adds language support for languages that have C support but can not becompiled into a shared library.

LibGodot allows the use of different C# runtimes allowing dotnetAOT compilation, C# android support, and C# web support.

LibGodot also allows Godot to be embedded in other applications like Blender.

@Faolan-Rad Faolan-Rad requested review from a team as code owners February 8, 2023 10:57
@lyuma
Copy link
Contributor

lyuma commented Feb 8, 2023

Related to #68153 - this provides a means of loading the Godot Engine from a standard .NET 6 android project

@Zireael07
Copy link
Contributor

Zireael07 commented Feb 8, 2023

Is this slated for 4.1 or 4.0?

@YuriSizov
Copy link
Contributor

@Zireael07 You can see the milestone :) Nothing of the sort is going into 4.0 at this point. We're done with features.

@Zireael07
Copy link
Contributor

Ah. Right. Mobile GitHub and my poor eyesight are to blame.

@Calinou
Copy link
Member

Calinou commented Feb 8, 2023

Does this address godotengine/godot-proposals#4773?

@Faolan-Rad
Copy link
Contributor Author

It does for the most part the thing it doesn't do is allow someone using the Library to manually tell Godot to update

core/libgodot/libgodot.cpp Outdated Show resolved Hide resolved
@fire
Copy link
Member

fire commented Feb 10, 2023

We discussed out-of-band how that @Faolan-Rad should tell us the story of his need for this feature and how this can benefit the wider community of C#, other languages and XR.

TL;DR: pending a new proposal.

@fire
Copy link
Member

fire commented Feb 12, 2023

The update problem was avoided by having the libgodot user make a gdextension and have it block in the gdextension class like the "_process" method.

Benefits

  1. Avoids stepping the MainLoop.
  2. Avoids handling synchronization when two different functions are called externally.

@neikeq
Copy link
Contributor

neikeq commented Feb 12, 2023

Regarding C#:

No work has started yet for porting to mobile, so I can't say what will be needed. If we can't find a better solution, we would have to go with a C# project as entry-point and Godot as a shared library. However, there's actually hope that .NET 8 or 9 could allow publishing mobile projects as libraries, which would simplify things for us.

@fire fire mentioned this pull request May 1, 2024
fire added a commit to V-Sekai/godot that referenced this pull request May 4, 2024
* Add a new GodotInstance GDCLASS that provides startup, shutdown and iteration commands
* Add a new GDExtension entry point that creates a new Godot instance and returns a GodotInstance object.
* This object can be used to control the GodotInstance.
* Allow specifying an external native rendering surface handle to render Godot into the UI of a host application.
  * It is also possible to embed multiple Godot windows into the UI of a host application.
  * Currently supported on MacOS and iOS

Sample Apps: https://github.com/migeran/libgodot_project

Developed by [Migeran](https://migeran.com)

Sponsors & Acknowledgements:

* Initial development sponsored by [Smirk Software](https://www.smirk.gg/)
* Rebasing to Godot 4.3 and further development sponsored by [Xibbon Inc.](https://xibbon.com)
* The GDExtension registration of the host process & build system changes were based
  on @Faolan-Rad's LibGodot PR: godotengine#72883

Co-Authored-By: Gabor Koncz <[email protected]>

Run pre-commit run -a

Fix error handling in window creation functions

Memdelete on a RefCounted object is not valid. Use unref.

Update Vulkan surface creation to use a method for getting the window handle.

Add native surface rendering support for iOS.

Add Vulkan rendering support in core driver types

Add rendering_native_surface_android include

Add rendering_native_surface_windows include

Update iOS rendering layer creation method to use a different cast

Run code formatting.

Switch memdelete to unref for RenderingNativeSurfaceWindows

Add include for rendering native surface on Windows

Update Vulkan and D3D12 rendering code for Windows

Refactor memory allocation functions to avoid compiler error.

Apply class reference.

Add support for D3D12 rendering context driver creation.

Update platform detection logic and handle selected platform based on SCons version

Make class registration for Wayland and X11 surfaces as internal classes.

Keep define for MemoryBarrier in rendering_device_driver_d3d12.h.

Change memory barrier struct names to MemoryAccessBarrier
fire added a commit to V-Sekai/godot that referenced this pull request May 10, 2024
* Add a new GodotInstance GDCLASS that provides startup, shutdown and iteration commands
* Add a new GDExtension entry point that creates a new Godot instance and returns a GodotInstance object.
* This object can be used to control the GodotInstance.
* Allow specifying an external native rendering surface handle to render Godot into the UI of a host application.
  * It is also possible to embed multiple Godot windows into the UI of a host application.
  * Currently supported on MacOS and iOS

Sample Apps: https://github.com/migeran/libgodot_project

Developed by [Migeran](https://migeran.com)

Sponsors & Acknowledgements:

* Initial development sponsored by [Smirk Software](https://www.smirk.gg/)
* Rebasing to Godot 4.3 and further development sponsored by [Xibbon Inc.](https://xibbon.com)
* The GDExtension registration of the host process & build system changes were based
  on @Faolan-Rad's LibGodot PR: godotengine#72883

Co-Authored-By: Gabor Koncz <[email protected]>
Co-Authored-By: K. S. Ernest (iFire) Lee <[email protected]>
kisg added a commit to migeran/godot that referenced this pull request Jun 10, 2024
* Based on top of the GDExtensionLoader PR: godotengine#91166
* Add a new GodotInstance GDCLASS that provides startup and iteration commands to control a Godot instance.
* Adds a libgodot_create_godot_instance entry point that creates a new Godot instance and returns a GodotInstance object.
* Adds a libgodot_destroy_godot_instance entry point that destroys the Godot instance.
* Allow specifying an external native rendering surface handle to render Godot into the UI of a host application.
  * It is also possible to embed multiple Godot windows into the UI of a host application.
  * Currently supported on MacOS and iOS

Sample Apps: https://github.com/migeran/libgodot_project

Developed by [Migeran](https://migeran.com)

Sponsors & Acknowledgements:

* Initial development sponsored by [Smirk Software](https://www.smirk.gg/)
* Rebasing to Godot 4.3 and further development sponsored by [Xibbon Inc.](https://xibbon.com)
* The GDExtension registration of the host process & build system changes were based
  on @Faolan-Rad's LibGodot PR: godotengine#72883

Co-Authored-By: Gabor Koncz <[email protected]>
kisg added a commit to migeran/godot that referenced this pull request Jul 4, 2024
* Based on top of the GDExtensionLoader PR: godotengine#91166
* Add a new GodotInstance GDCLASS that provides startup and iteration commands to control a Godot instance.
* Adds a libgodot_create_godot_instance entry point that creates a new Godot instance and returns a GodotInstance object.
* Adds a libgodot_destroy_godot_instance entry point that destroys the Godot instance.
* Allow specifying an external native rendering surface handle to render Godot into the UI of a host application.
  * It is also possible to embed multiple Godot windows into the UI of a host application.
  * Currently supported on MacOS and iOS

Sample Apps: https://github.com/migeran/libgodot_project

Developed by [Migeran](https://migeran.com)

Sponsors & Acknowledgements:

* Initial development sponsored by [Smirk Software](https://www.smirk.gg/)
* Rebasing to Godot 4.3 and further development sponsored by [Xibbon Inc.](https://xibbon.com)
* The GDExtension registration of the host process & build system changes were based
  on @Faolan-Rad's LibGodot PR: godotengine#72883

Co-Authored-By: Gabor Koncz <[email protected]>
@GeorgeS2019
Copy link

GeorgeS2019 commented Jul 12, 2024

@Faolan-Rad
@JiepengTan

Still on the TODO list:
#90510 (comment)

  • Windows build
  • Fix CI builds
  • Create a .NET/C# example using the new GDExtension-based .NET implementation.

[WIP] Windows platform: libgodot.dll

The libgodot.dll comes from

  • library_type=shared_library

scons platform=windows target=template_debug arch=x86_64 verbose=yes msvc=yes library_type=shared_library dev_build=yes debug_symbols=yes

bin\ godot.windows.template_debug.dev.x86_64.dll

scons platform=windows arch=x86_64 verbose=yes msvc=yes dev_build=yes debug_symbols=yes

bin\ godot.windows.editor.dev.x86_64.exe --dump-extension-api

With this, provide the json and the dll to the godot-dotnet project.

  1. bin\ extension_api.json
  2. bin\ godot.windows.template_debug.dev.x86_64.dll

The output will be c# wrappers for the godot.windows.template_debug.dev.x86_64.dll

Users can then write c# applications to embed godot as a library in .NET applications

Very similar to: LibGodotSharp

fire added a commit to V-Sekai/godot that referenced this pull request Sep 11, 2024
* Add a new GodotInstance GDCLASS that provides startup, shutdown and iteration commands
* Add a new GDExtension entry point that creates a new Godot instance and returns a GodotInstance object.
* This object can be used to control the GodotInstance.
* Allow specifying an external native rendering surface handle to render Godot into the UI of a host application.
  * It is also possible to embed multiple Godot windows into the UI of a host application.
  * Currently supported on MacOS and iOS
  * Currently supported on Windows

Sample Apps: https://github.com/migeran/libgodot_project

Developed by [Migeran](https://migeran.com)

Sponsors & Acknowledgements:

* Initial development sponsored by [Smirk Software](https://www.smirk.gg/)
* Rebasing to Godot 4.3 and further development sponsored by [Xibbon Inc.](https://xibbon.com)
* The GDExtension registration of the host process & build system changes were based
  on @Faolan-Rad's LibGodot PR: godotengine#72883

Co-Authored-By: Gabor Koncz <[email protected]>
Co-Authored-By: K. S. Ernest (iFire) Lee <[email protected]>
kisg added a commit to migeran/godot that referenced this pull request Oct 2, 2024
* Based on top of the GDExtensionLoader PR: godotengine#91166
* Add a new GodotInstance GDCLASS that provides startup and iteration commands to control a Godot instance.
* Adds a libgodot_create_godot_instance entry point that creates a new Godot instance and returns a GodotInstance object.
* Adds a libgodot_destroy_godot_instance entry point that destroys the Godot instance.
* Allow specifying an external native rendering surface handle to render Godot into the UI of a host application.
  * It is also possible to embed multiple Godot windows into the UI of a host application.
  * Currently supported on MacOS and iOS

Sample Apps: https://github.com/migeran/libgodot_project

Developed by [Migeran](https://migeran.com)

Sponsors & Acknowledgements:

* Initial development sponsored by [Smirk Software](https://www.smirk.gg/)
* Rebasing to Godot 4.3 and further development sponsored by [Xibbon Inc.](https://xibbon.com)
* The GDExtension registration of the host process & build system changes were based
  on @Faolan-Rad's LibGodot PR: godotengine#72883

Co-Authored-By: Gabor Koncz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.