Open linkerlin opened 9 months ago
Can you explain how you envision this integration working?
It's already possible to compile GDExtension's made with godot-cpp to WASM and load them in the web build of Godot. I don't personally know how to do it, but I'd imagine it'd be possible to link such a GDExtension with other WASM packages. So, for that, I don't think you'd need any changes to Godot itself.
Or, are you imagining using WASM on non-web platforms? I suspect it'd be possible to make a GDExtension WASM binding (similar to how we have C++, Rust, Python, Lua, Java/Kotlin/JVM, etc bindings) that would allow doing this as well, again without needing changes to Godot itself.
I think exposing the gdextension API over Javascript would be the easiest short term solution.
Can someone provide a sample of:
Compiling GDExtension's made with godot-cpp to WASM and load them in the web build of Godot?
Describe the project you are working on
A 2D education software with Godot.
Describe the problem or limitation you are having in your project
The problem I am encountering with my project is that I would like to extend GDExtension using a WebAssembly package compiled from Java/TeaVM. Currently, there is limited or no support for integrating WebAssembly modules within the GDExtension framework of the Godot Engine. This limitation hinders the ability to use Java or other JVM-based languages, through TeaVM compilation, to script game logic or extend the engine's capabilities. My objective is to leverage the strengths of Java and the existing ecosystem of tools and libraries it offers by compiling it into WebAssembly, which can then be executed within the context of Godot's game engine. The lack of this integration is a significant bottleneck for my project, as it restricts the choice of programming languages and the potential for performance optimization and cross-platform compatibility that WebAssembly could offer.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The feature enhancement I am proposing is the integration of full WebAssembly support within the GDExtension framework of the Godot Engine. This enhancement would allow developers to compile code from languages such as Java into WebAssembly modules using tools like TeaVM, and then load and execute these modules as part of their Godot projects.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I am writing to propose an enhancement to the Godot Engine's GDExtension system that I believe could significantly broaden the engine's scripting capabilities and developer reach. My proposal is for the engine to include comprehensive support for WebAssembly (WASM) within the GDExtension framework. Feature Description: The main objective of this feature request is to enable full compatibility with WebAssembly in GDExtensions. This integration would allow developers to leverage a wide array of existing open-source toolchains, enabling support for a diverse set of programming languages that can compile to WebAssembly. These languages include, but are not limited to, Java, Groovy, Kotlin, Lua, JavaScript, and TypeScript. Justification and Benefits: Expanded Scripting Language Options: By supporting WebAssembly in GDExtensions, Godot Engine would instantly become more flexible and powerful, allowing developers to write game logic in their preferred programming language, which could then be compiled to WASM and run within the engine. This feature aligns with Godot's commitment to being an inclusive and versatile game development tool. Performance: WebAssembly is designed to enable near-native performance for web applications, which is a significant advantage for games developed in Godot Engine that target web platforms. WASM's binary format allows for faster parsing, execution, and can potentially lead to performance improvements in games. Community Growth: Supporting more languages can attract a broader developer community to Godot Engine. Many developers who are proficient in languages like Java or Kotlin may find this feature particularly appealing, thereby increasing the user base and contributions to the engine. Interoperability: Through WebAssembly, GDExtension can tap into a vast ecosystem of libraries and tools that have been built for these languages, thus enabling more complex and diverse game functionalities. Implementation Considerations: The GDExtension system would need to interface with the WebAssembly binary module, allowing the execution of WASM-compiled scripts. Ensure memory safety and sandboxing models of WebAssembly are well integrated to maintain the security and stability of the engine. Provide detailed documentation and examples to help developers get started with WASM in Godot, including setting up their toolchains for various languages. Consider the feasibility of debugging tools that can work seamlessly with WebAssembly within the Godot editor. I hope the team finds this proposal valuable and worth considering for a future release. The addition of WebAssembly support would undoubtedly set Godot Engine apart in the realm of open-source game development platforms. Thank you for your time and consideration. Best regards,
If this enhancement will not be used often, can it be worked around with a few lines of script?
The enhancement to add full WebAssembly support within the GDExtension framework in Godot is not something that can be worked around with just a few lines of script due to the complex nature of the integration required. The implementation of such support would involve significant changes to the engine's core to handle WebAssembly modules, including memory management, interfacing with Godot's scene and resource systems, and exposing Godot's APIs to the WebAssembly modules.
Is there a reason why this should be core and not an add-on in the asset library?
Deep Integration Required: WebAssembly support is not a simple plug-in feature but rather requires deep integration with the Godot Engine's core. This includes the need for a runtime environment that can load, execute, and interface with WebAssembly modules, manage memory safely, and interact with Godot's existing systems and APIs