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

Godot Engine API for Dart and Flutter using "dart:ffi" #58

Closed
iapicca opened this issue Sep 10, 2019 · 16 comments
Closed

Godot Engine API for Dart and Flutter using "dart:ffi" #58

iapicca opened this issue Sep 10, 2019 · 16 comments

Comments

@iapicca
Copy link

iapicca commented Sep 10, 2019

As propsed to Dart
Dart 2.5 is introducing "Foreign Function Interface" (dart:ffi) that allows Dart-C interop.
Quoting the article in the link above:
"Dart enters the IEEE Spectrum programming language ratings as 16. It’s also 10 under trending, and 6 when filtering to languages for mobile (behind Java, C, C++, C#, and Swift).";
Flutter allows to build, with a single code base, mobile app for Android and iOS, PWA and soon desktop app for Windows, Linux and OSX.
Such an API would undoubtedly widen Godot adoption.

[edit] filling in template:

Describe the project you are working on:
I'm a Flutter developer and I'm working on a 2D game using flare
taking this as example

Describe how this feature / enhancement will help your project:
this feature would allow my creativity to express to a whole new level enabling the possibility of 3d rendering

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
it a technical proposal that doesn't impact a single feature, but the whole game complexity,
on the technical side what I picture is:
Flutter App => plugin (Godot Engine + Dart:ffi interface) => Flutter Widget Tree => Godot rendering inside a widget

Describe implementation detail for your proposal (in code), if possible:
please see the original post above

If this enhancement will not be used often, can it be worked around with a few lines of script?:
no, when available this enhancement will be used often and isn't possible for my knowledge to shrink it in few lines

Is there a reason why this should be core and not an add-on in the asset library?:
yes, it's a fully fledged feature, not an add-on

@clayjohn
Copy link
Member

Please update your post filling out the template properly or it will be closed in accordance with Rule 1. Rules can be found on the README on the main page of the repo https://github.com/godotengine/godot-proposals

@iapicca
Copy link
Author

iapicca commented Sep 11, 2019

Please update your post filling out the template properly or it will be closed in accordance with Rule 1. Rules can be found on the README on the main page of the repo https://github.com/godotengine/godot-proposals

I've update the original post, sorry I didn't read carefully the guidelines.

@groud
Copy link
Member

groud commented Sep 11, 2019

This was already proposed, and I still don't see any reason to implement that. The only argument I can find here is that it may bring some Flutter users to Godot, but we don't really care that much.

Flutter allows to build, with a single code base, mobile app for Android and iOS, PWA and soon desktop app for Windows, Linux and OSX.

Godot is already a multiplatform solution.

Describe how this feature / enhancement will help your project:
this feature would allow my creativity to express to a whole new level enabling the possibility of 3d rendering

That quite a vague use case... I don't see why your creativity would be limited with Godot, and Godot is already capable of 3D rendering.

@LikeLakers2
Copy link

LikeLakers2 commented Sep 11, 2019

Hi, I read through your edit.

First off, I get the impression that you've not tried Godot before. I want to point out that Godot is a maturing game engine all on its own (with facilities for game logic, rendering, UI, exporting to multiple platforms from a single codebase, etc.), and if you were to use Godot by itself, there's a good chance you could achieve nearly the same results without the needed complexity of having to manage Flutter + Dart + Flare + Godot + any other libraries or workarounds you'd need for your task.

Second off, what you are asking for is for bindings to be created so that Godot can use Flutter/Dart, and Flutter/Dart can use Godot. Unfortunately, bindings are not something that will usually be added to core (exceptions may apply, but I haven't seen any yet). There just isn't the demand for Flutter/Dart to be usable within Godot by default... so we don't really have any motivaton to create bindings for them, unfortunately.

That said, if you still want to use Godot as a 3D renderer for Flutter/Dart (as you seem to have said you want to), then by all means go ahead, as we don't want to stop you. We want to see cool games made! You will need to create bindings though, so that you can control Godot's VisualServer or scene tree from Dart. If you need help creating bindings (or anything else Godot-related), then please don't be afraid to ask on one of the community channels.

With all that said, this isn't a bad idea, having Godot be usable within Flutter/Dart and vice versa. But it's not something that I think we could do for you, as we just don't see the demand for it.

@iapicca
Copy link
Author

iapicca commented Sep 11, 2019

This was already proposed, and I still don't see any reason to implement that. The only argument I can find here is that it may bring some Flutter users to Godot, but we don't really care that much.

that's an honest answer, I respect that
too bad, I really feel that this could have been an opportunity for both

@girng
Copy link

girng commented Sep 16, 2019

Interesting, but why use Flare when you're already using Godot?

@iapicca
Copy link
Author

iapicca commented Sep 16, 2019

Interesting, but why use Flare when you're already using Godot?

flare is 2D there are no 3D engines for Dart that I'm aware of

@LikeLakers2
Copy link

LikeLakers2 commented Sep 16, 2019

@iapicca I think you misunderstood girng's question. Why are you using Dart, Flare, and Flutter when Godot already provides its own facilities for game logic, rendering, and UI components? Why use Dart, Flare, and Flutter when Godot more than likely can replace all three of those on its own?

@Sslaxx
Copy link

Sslaxx commented Sep 16, 2019

Would GDNative/NativeScript bindings for Dart be possible, or desirable?

@ElfEars
Copy link

ElfEars commented Sep 19, 2019

Imo: This is very much a "maybe in a few years if" case. (My estimate is about 5 or 6)

I don't want to speak for OP but I assume this is mostly for future compatibility with Google's Fuchsia project (A possible future replacement for android). Fuchsia only accepts flutter executables, ergo all applications must use it.

Opinions follow:
(I assume that dart is introducing C support because most people either use it or something that can be compiled to it, not dart itself. Gonna be honest in all my time as a developer I have only ever heard of it when researching the Fuchsia project. Several articles detail it's semi obscure history and are good reads for those interested.)

@iapicca
Copy link
Author

iapicca commented Sep 22, 2019

@LikeLakers2
the point is not to replace godot (or flutter),
if you want to go "full godot" you have no reason to use dart,
but...

Flutter gives an extremely good experience
in creating app for Android and iOS with a single code,
web and desktop (coming soon),
what flutter doesn't have is a 3D engine
(2D rendering is actually one of the selling point
of flutter, especially compared to React).

Imho the possibility to use Godot 's 3D engine in Flutter
would bring a lot of popularity to Godot itself
and since community is the flesh and blood of any
open source project I can only see this as a win win

@vnen
Copy link
Member

vnen commented Sep 23, 2019

I think the you are going the wrong way in this, honestly. You are saying "I'm using Flutter/Dart and want to bring in Godot 3D rendering". That is a task for Flutter, not for Godot. You can already do apps for Android, iOS, and desktop with Godot itself, bringing in Flutter is not a benefit in this regard.

For a proposal here, you should say "Bringing Flutter will make Godot better because it'll enable me to do X in my project, which wouldn't be possible without it". If you don't phrase it that way, it'll be hard for other people to see any benefit in this proposal.

@iapicca
Copy link
Author

iapicca commented Sep 28, 2019

I think the you are going the wrong way in this, honestly. You are saying "I'm using Flutter/Dart and want to bring in Godot 3D rendering". That is a task for Flutter, not for Godot. You can already do apps for Android, iOS, and desktop with Godot itself, bringing in Flutter is not a benefit in this regard.

For a proposal here, you should say "Bringing Flutter will make Godot better because it'll enable me to do X in my project, which wouldn't be possible without it". If you don't phrase it that way, it'll be hard for other people to see any benefit in this proposal.

it is possible, but I believe in open source
https://pub.dev/packages/flutter_unity_widget
also current solutions are based on "calling" the native code
which is greatly inefficient and now can be done differently
using dart:ffi

@aloisdeniel
Copy link

aloisdeniel commented May 14, 2020

While using Flutter doesn't make sense to me for the same reasons already exposed, I would love using Dart as a scripting language.

Simply because I use Dart on a day to day basis, and it is always simpler when you can keep your environment and tools (just like C# support).

@vnen
Copy link
Member

vnen commented May 14, 2020

Well, it's not feasible for Godot to support every possible programming language out there. We support a few officially (GDScript, C#, C/C++) and provide an interface for the community to add support for other languages (Rust, Nim, and Python are some examples available). If there's something missing in the interface that don't allow Dart to be done, we will highly consider adding that, but official support won't happen.

@mahdisml
Copy link

i started working on it :
https://github.com/mahdisml/DartGodot

@aaronfranke aaronfranke closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests