StageXL on Flutter – Prototype

73 views
Skip to first unread message

Nils Döhring

unread,
Sep 8, 2021, 10:57:02 AM9/8/21
to StageXL
Hi there,

after making myself a bit more familiar with Flutter over the past months, I've decided to just give it a shot and at least start to try and make StageXL work with Flutter.


Ideally, this would have been achieved by adding a third renderer to StageXL, but since StageXL heavily relies on dart:html and "HTML Elements" not just for rendering, I decided to take the machete approach by removing all imports of dart:html, and go on from there. 

What's been replaced so far:
- HTML Canvas / CanvasContext2D / GraphicsCanvas were replaced by dart:ui Canvas – there are limitations, and StageXL's "HTML Canvas Graphics API" needs refactoring of drawing and styling operations (ui:Canvas expects all Styling as a parameter of the draw calls)
- HTML WebGL was replaced with the flutter_web_gl package which exposes native OpenGLES bindings for Android, iOS, macOS and Windows, but not Flutter Web, obviously – also I am pretty sure that I introduced runtime bugs around data conversion
- StageXLs Sound API was implemented using the soundpool package, but there are a lot of limitations
- Mouse/Touch/Video APIs are commented out, for the moment

Does it work?
Of course not :-)
Canvas approach: while no code errors are reported, this appraoch will definitely not work at the moment (for the reasons stated above)
FlutterWebGL approach: while no code errors are reported, it seems that I made a configuration error, because FlutterWebGLs initialization fails (their sample project runs fine though). 

In the coming weeks, I won't find time to continue with this, which is why I thought to share the work in progress, now. Feel free to take this further!

By the way, I think a "real" implementation of StageXL for Flutter should probably be limited to making the display list and graphics API work with FlutterWebGL – most other functionality would be a mere wrapping of Flutter APIs, and would come with a lot of limitations (especially regarding Video and Sound).




linux...@gmail.com

unread,
Sep 8, 2021, 11:37:44 AM9/8/21
to StageXL
❤️❤️❤️

Bernhard Pichler

unread,
Sep 8, 2021, 12:57:13 PM9/8/21
to StageXL
Nils you are a hero :) this is awesome!
Reply all
Reply to author
Forward
0 new messages