部署WebGL的应用程序作为原生的iOS或Android应用程序?应用程序、WebGL、Android、iOS

2023-09-04 23:46:56 作者:有梦才会去努力

有谁知道的一种方式,可以在其中部署WebGL的应用程序作为一个原生的iOS或Android应用程序?商用中间件是可以接受的,但一个开放的项目将是preferable。谢谢你。

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. Thanks.

推荐答案

进行了扩展,里斯的回答(这似乎是基于对的弥敦道德弗里斯工作),下面是code,我需要的的iOS 5.0 SDK中启用WebGL的:

As an extension to Joris' answer (which appears to be based on the work of Nathan de Vries), the following is the code I needed to enable WebGL within the iOS 5.0 SDK:

某处您的视图控制器实现的顶部附近:

Somewhere near the top of your view controller implementation:

@interface UIWebView()
- (void)_setWebGLEnabled:(BOOL)newValue;
@end

编程创建一个UIWebView并启用WebGL的:

Programmatically creating a UIWebView and enabling WebGL:

UIWebView *webDetailView = [[UIWebView alloc] initWithFrame:mainScreenFrame];

id webDocumentView = [webDetailView performSelector:@selector(_browserView)];
id backingWebView = [webDocumentView performSelector:@selector(webView)];
[backingWebView _setWebGLEnabled:YES];

我创建了一个示例应用程序演示WebGL的在iPhone / iPad的全屏的UIWebView运行,使用WebGL的暂存器网站 http://glsl.heroku.com 作为目标。警惕其中有些例子,将慢慢甚至是iPad 2的停顿,可能导致硬重启。表现似乎说明为什么WebGL是仍然在移动的WebKit官方不受支持的状态。

I created a sample application that demonstrates WebGL running in a iPhone / iPad fullscreen UIWebView, using the WebGL scratchpad site http://glsl.heroku.com as a destination. Be wary that some of those examples there will grind even an iPad 2 to a halt, potentially leading to a hard reboot. The performance there seems to indicate why WebGL is still in an officially unsupported state in mobile WebKit.

当然,作为已经指出,这不能保证工作在将来的iOS版本,并从App Store将获得你的申请被拒绝。这是只为爱好的工作和内部测试非常有用。

Of course, as has been stated, this is not guaranteed to work on future iOS versions and will get your application rejected from the App Store. This is only really useful for hobby work and internal testing.

的WebGL的例子对我的iPad 2上运行:

An example of WebGL running on my iPad 2: