I am writing an application for Mac OS - browser on WebKit to use for the some site on WebGL. All is ready, the application correctly displays normal HTML sites, but WebGL doesn't work. How can enable WebGL in my app?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- back button text does not change
- iOS (objective-c) compression_decode_buffer() retu
- how to find the index position of the ARRAY Where
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
Once you have a WebView, there is an undocumented method which can enable WebGL:
In this example I have protected it with
respondsToSelector:
to ensure the code will not abort if later versions remove this specific option.Note that I understand that an application containing code using undocumented interfaces may be rejected if submitted to Apple's Mac App Store.
Another option is to use a different embedded renderer which officially supports WebGL (where Apple's WebKit as demonstrated in Safari only has it as a developer option, presumably intended to be experimental). Since both Firefox and Chrome support WebGL, have a look at Gecko and Chromium Embedded Framework. (Note: I have not been able to confirm whether whether embedded Gecko supports WebGL.)
In Mavericks, this is the correct code.
You need to call performSelector otherwise you'll get a compile error.
I figured out how to do this without using an undocumented method. You need to set the user preference
WebKitWebGLEnabled
to@YES
for your app. To have the setting apply the first time the app is run, it needs to be set early, before theWebView
is initialized. In my case, theWebView
instance is loaded from the main nib file, so that's very early indeed. I added this code toSupporting Files/main.m
:Please note, since no undocumented method is called, I assume this code is within app store guidelines, but my app hasn't been reviewed yet!