Skip to content
forked from bp74/StageXL

A fast and universal 2D rendering engine for HTML5 and Dart.

License

Notifications You must be signed in to change notification settings

nilsdoehring/StageXL

 
 

Repository files navigation

StageXL Flutter Proof of Concept (WIP)

What is this about?

There is community demand for a Flutter version of StageXL.

At the time of this writing, two rendering approaches seem eligible as replacements for the dart:html API, namely dart:ui Canvas (2D only) and the package flutter_web_gl, which provides native OpenGLES bindings for Android, iOS, macOS, and Windows (but not Flutter Web).

This project serves as a proof of concept.

What has been done

  • All references to dart:html have been removed – and because StageXL depends on it in a lot of places, it was necessary to refactor the whole package (i.e. we can't just add a Flutter renderer)
  • Canvas2D rendering: Most API calls replaced or substituted, but Graphics needs refactoring because in dart:ui Canvas, drawing and decorating are done within the same call, while StageXL's API uses two separate calls.
  • WebGL rendering: All API calls were refactored towards the slightly different FlutterWebGL APi.

What is working

  • Nothing as of now, but hey, at least the example does compile :-)

What is not working

  • Example: Getting a GLES error when initializing FlutterWebGL. Compare settings with flutter_web_gl's example.
  • GL: While the GL API is similar to dart:html's, it expects different data types and while conversion has been implemented, it has not been tested yet.
  • GL: Graphics/BitmapData/RenderTexture will probably need additional work
  • Canvas: Needs refactoring of Graphics operations because ui.Canvas expects styling info together with the draw call
  • Mouse and Touch events – a GestureDetector needs to get mapped to either Canvas or the Texture used by FlutterWebGL
  • Text – while basic text rendering should be possible to achieve with dart:ui's Paragraph, Flutter does not currently support control on glyph level.
  • Sound - basic sound functionality was implemented by using the soundpool package, but it is not possible to skip or play excerpts.
  • Video - while Flutter supports animated gif and webp, Flutter's support for 'real' Video is limited to exposing a Videoplayer widget, i.e. no way to get the contents
  • Lots of details, see TODOs in source

Does it make sense to port all of StageXL to Flutter?

Opinion: it should suffice to port the display list and graphics APIs and leave things like asset loading and resizing to Flutter. While some additional

StageXL resources

About

A fast and universal 2D rendering engine for HTML5 and Dart.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 99.2%
  • HTML 0.5%
  • Ruby 0.2%
  • CSS 0.1%
  • Swift 0.0%
  • Kotlin 0.0%