Deploy WebGL applications as native iOS or Android applications?

后端 未结 8 747
既然无缘
既然无缘 2021-01-30 04:21

Does anyone know of a way in which you can deploy a WebGL app as a native iOS or Android app? Commercial middleware is acceptable, although an open project would be preferable.

8条回答
  •  感动是毒
    2021-01-30 04:33

    As the iOS version of WebKit doesn't support WebGL natively, I think you have two options:

    • Implement the WebGL API in the JavaScript context of a WebView yourself by forwarding calls to the native OpenGL via iframe RPC or so. There isn't a clean way of calling (Objective-)C functions from JavaScript on iOS, unfortunately. Performance could be a problem.

    • AOT-Compile or interpret the JavaScript in a third-party runtime, then implement WebGL from there. JIT compilers are disallowed on iOS, so something like V8 won't work. Appcelerator Titanium statically compiles JavaScript as far as I know, and also has an interpreter. You could use that, but you'd still need to implement the WebGL glue yourself.

    I'm not aware of any existing WebGL bridges for iOS, so I think you will need to either write it yourself or get someone to do it for you. One problem that might not be possible to overcome is if you use anything other than WebGL to display stuff - e.g. HTML, 2D , etc. Combining WebView display with an OpenGL framebuffer is going to be rather tricky.

    I don't know much about Android, but considering the rules are more relaxed there, it might be possible to embed a WebGL-compatible browser there.

提交回复
热议问题