WebPreferences *p = [webView preferences];
if ([p respondsToSelector:@selector(setWebGLEnabled:)]) {
[p setWebGLEnabled:YES];
}
Thanks

Code: Select all
ImportC ""
sel_registerName(str.p-ascii)
EndImport
If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com")
pref = CocoaMessage(0, GadgetID(0), "preferences")
If CocoaMessage(0, pref, "respondsToSelector:", sel_registerName("setWebGLEnabled:"))
CocoaMessage(0, pref, "setWebGLEnabled:", #YES)
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Code: Select all
Once you have a WebView, there is an undocumented method which can enable WebGL:
WebPreferences *p = [webView preferences];
if ([p respondsToSelector:@selector(setWebGLEnabled:)]) {
[p setWebGLEnabled:YES];
}
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.