4ian / GDevelop

🎮 Open-source, cross-platform 2D/3D/multiplayer game engine designed for everyone.
https://gdevelop.io
Other
10.9k stars 854 forks source link

C++ exporting to very low-end MCU devices #938

Closed haviital closed 5 years ago

haviital commented 5 years ago

Hi,

I just found this tool, GDevelop, and it looks really promising! I have not had time to dig in the source codes yet, but I decided to ask a question first.

So, do you think it is possible to make GDevelop to export the project for a limited HW devices (as a native C++ code)? I mean MCU based devices with just few hundred KB (!) of ROM and even less RAM? My aim is to use only a limited set of the GDevelop features ("GDevelop Micro") to make it possible to use it in MCU based devices. So I most probably would need a fork GDevelop sources in GitHub. I realize that it would mean rewriting most of the runner classes due the memory and cpu restrictions, but I still think it could be worth it, because the editor is so good.

Before going too far, I would like to know if you see any fundamental problems in that?

Thanks!

4ian commented 5 years ago

Hey,

Any initiative like this could be interesting, though I think it's a "niche" as it's the first time I hear about these devices :) So maybe GDevelop is not the ideal tool? If you're interested, the work would consist in possibly adapting GDCpp (the native game engine) so that GDevelop 5 can export native games (for now, GDevelop 5 is based on JS games only (GDJS folder)). It would require quite a few changes, so maybe another idea would be to start a lightweight alternative to GDCpp and GDJS game engines.

It will be quite a lot of time to invest to plug the editor to a new GDxxx platform though, so I would advocate for trying to find a ready made game engine for these devices (or even better, a popular game engine) and then constructing this new GDxxx based upon this game engine. (For example, GDCpp was based on SFML, and GDJS is based on Pixi.js).

Happy to answer if you have more questions! I'll close the thread as I keep issues for bugs. :)

haviital commented 5 years ago

Thanks for a quick response!

Here is a link to one of this kind of device: www.pokitto.com

I have read somewhere that GDevelop 4 could export native C++. Would it be a good idea to use that as a base for "GDevelop Micro"?

We have been discussing porting SFML to Pokitto already, so that might be a good starting point.

4ian commented 5 years ago

I have read somewhere that GDevelop 4 could export native C++. Would it be a good idea to use that as a base for "GDevelop Micro"?

It's still in the codebase, it's the "GDCpp" folder I was speaking about. It's not used in GD5 but was used in GD4.

We have been discussing porting SFML to Pokitto already, so that might be a good starting point.

That's an option indeed. I'm a bit afraid of the porting/cross platform capabilities of SFML though, the iOS and Android port took a very long time to be available - and not sure they are battle-tested. Something to keep in mind, SFML is very good quality but I've been a bit disappointed by this portability issue - not sure if there is something better but still.

haviital commented 5 years ago

In that case, it might be easiest first try to make a minimal implementation over GD4, as GDCpp is used there. I am not sure if I will just use Pokitto's own API in modified GDCpp. Depends what kind of services the very minimal game requires from the C++ API.

How is a specific game defined for GDCpp? Is that some kind of resource file that GDCpp will read and run (binary, xml, etc.). Of course the needed images etc. are binary, but I mean the game logic, game objects, etc.

haviital commented 5 years ago

Tested a minimal (just show one tiny bimap) native Windows game on GD4:

Btw: what would be a good forum for this discussion?

haviital commented 5 years ago

Ok, slowly getting hold of how gd is working in some respects:

Some notes about my plans for Pokitto port:

4ian commented 5 years ago

Apologies for not answering before.

  • The codebase is huge

Yes :)

  • Gd serializes the game data to a combined binary and xml file, gam.egd
  • There looks to be some kind of encrypting used in the gam.egd

Yes, for now you could ignore this, but if you want to take a writing/reading to this file is done in DatFile.cpp

  • Serialization is used both to save and load the project in the editor and for reading the game scene and resources when starting an exported stanalone game binary

Yes :)

haviital commented 5 years ago

I am going to continue with this project soon. I am interested if GD will prove to be useful for MCU level device.

4ian commented 5 years ago

You might be interested in the way the experimental Android export for SFML was done by the way. See AndroidExporter.cpp.

I believe GDCpp could also be adapted to work with WebAssembly in the future, exporting lightweight and ultra performant games.

haviital commented 5 years ago

Thanks for the info.

Btw. Is there any other forum to discuss these things? It could be that many people do not find this discussion.