gdx-dragome icon indicating copy to clipboard operation
gdx-dragome copied to clipboard

Missing Dragome features

Open czyzby opened this issue 8 years ago • 14 comments

In order to fully implement Dragome backend for LibGDX, we need to support some JS/Gradle related features:

  • [x] Gradle plugin. Example LibGDX project with Dragome backend included. #3
  • [x] requestAnimationFrame, cancelAnimationFrame support. We can use this polyfill to provide the same API for all browsers. #8
  • [x] Typed array wrappers. #4
  • [x] WebGL wrappers. #4
  • [x] Annotations support. https://github.com/dragome/dragome-sdk/issues/27
  • [x] A predictable way of replacing existing classes. https://github.com/dragome/dragome-sdk/issues/71
  • [x] Improved Document mapping. Missing addEventListener method.
  • [x] Touch events. https://github.com/dragome/dragome-sdk/issues/99

I think all of these should be somehow provided by Dragome modules/plugins, but we can implement them in gdx-dragome and transfer them to official repos when necessary.

czyzby avatar Mar 05 '16 14:03 czyzby

Official requestAnimationFrame does not return ID of the request, so I reimplemented it based on Window class in DragomeRenderer.

czyzby avatar Mar 05 '16 15:03 czyzby

requestAnimationFrame return ID is fixed wtih https://github.com/dragome/dragome-sdk/commit/9b00baf85979fce69caa355ef79f227f3952946a

fpetrola avatar Mar 05 '16 15:03 fpetrola

gdx-dragome project is on hold until the missing Dragome features are implemented.

czyzby avatar Mar 06 '16 17:03 czyzby

  • Annotations on methods are not implemented.
  • getResourceAsStream is not implemented. Image resources to a specified size could be converted to base64 and made available to the runtime just like client bundle of GWT.
  • Canvas image data manipulation and toDataURL methods are missing

ghost avatar Mar 06 '16 21:03 ghost

Initial support for annotations added: https://github.com/dragome/dragome-sdk/commit/a8c8a05038ce5f5806c19f0b440949eb066005c0 Now we can read annotations from classes, methods and method parameters. Tests for these new reflection features here: dragome/dragome-examples@d6794f2

fpetrola avatar Mar 14 '16 04:03 fpetrola

LibGDX reflection API also allows to read field annotations. I don't think it provides constructor annotations though.

Anyway, every platform allows to scan existing classes one way or the other. This allows frameworks like my Autumn to work. While not crucial, it would be nice if you could choose to generate meta-data storing all available classes, so you could easily scan them.

czyzby avatar Mar 14 '16 10:03 czyzby

Field annotations support added in: https://github.com/dragome/dragome-sdk/commit/f02ccf6bb5dcab4e61c58f341ff79f39b6058292

fpetrola avatar Mar 17 '16 21:03 fpetrola

Field reflection support including annotations tests: https://github.com/dragome/dragome-examples/commit/687e1e933db8816dd57a07ee5cb081e568c682f3?diff=unified#diff-0f897e29823e24d97bc52189f86de715

fpetrola avatar Mar 17 '16 22:03 fpetrola

That's great, I think that now reflection support is sufficient to run LibGDX without any additional fuss like the GWT reflection pool generator.

czyzby avatar Mar 18 '16 12:03 czyzby

Official bridge ready! Webgl and typedarrays bridges were implemented.

Both bridges were automatically created using w3c webidl files: webgl webidl typedarrays webidl

They were processed using https://github.com/esrille/esidl and the resulting interfaces were located inside dragome-w3c-standards module. Almost no code is required for implementing these bridges. Most changes were performed in DomHandlerDelegateStrategy which was updated to allow polymorphic getContext result in CanvasElement, as well to handle "set" and "get" methods as array access (array[index]).

Using this automatic approach, Dragome can create any kind of bridge just using WebIDL specifications to create interfaces directly, and performing a tiny setup for typing return values for certain js methods.

fpetrola avatar Mar 22 '16 07:03 fpetrola

I'm not sure how to use the Function interface when passing callbacks. Shouldn't classes like XMLHttpRequest have their own custom listeners for common callbacks like onreadystatechange? @fpetrola, see DragomeNet#sendHttpRequest method and check if this is the correct way of passing functions.

czyzby avatar Mar 22 '16 14:03 czyzby

Take a look at https://github.com/dragome/dragome-sdk/commit/08065f372d09f57472323a9994f380757bf580e8

I've changed idl to reflect eventhandler instead of function.

fpetrola avatar Mar 23 '16 04:03 fpetrola

Gradle support is working. I've moved standalone js generator to web module and I'm calling it from build.gradle:

task generateStandalone(type:JavaExec) {
   main = "com.dragome.web.helpers.serverside.StandaloneDragomeAppGenerator"
   classpath = sourceSets.main.runtimeClasspath
   args = [
   "./dist",
   "./webapp",
   "true",
   "true"
   ].toList()
}

fpetrola avatar Apr 03 '16 20:04 fpetrola

Let's keep this issue open until nearly 100% features from GWT are ported.

czyzby avatar Apr 22 '16 14:04 czyzby