OSX Cocoa嵌入opengl视图里面webview [英] OSX Cocoa embed opengl view inside webview
问题描述
问题是webview和OpenGL视图之间的重叠。如果在webview顶部的OpenGL视图,webview UI(如:下拉框)可能切割的OpenGL视图。在OpenGL视图顶部的webview,所有的webview视图将阻止OpenGL视图。
有没有解决方案? (OpenGL和Webview)
WebKit有一个有趣的功能,您可以将网页视图与某些MIME类型关联到您自己的自定义NSView类。
在HTML网页视图中,您可以放置一个具有自定义mimetype的iframe(例如application / my-custom-view)。
之后,从你的本地应用程序,你可以调用:
[WebView registerViewClass: MyCustomView class] representationClass:[MyCustomRepresentation class] forMIMEType:@application / my-custom-view];
MyCustomRepresentation可以很轻量,我的Representation类不做任何事情,它只是定义了存根委托函数。
I am trying to build an MacOS app which create an OpenGL view and embed it to webview as it's element (using OpenGL instead of WebGL). The main goal is to use the web (html/javascript) as UI and draw the result with OpenGL view. (besides, the OpenGL view will also handle the user input)
The issue is the overlay between the webview and OpenGL view. If OpenGL view on top of webview, the webview UI (like: dropdown box) possible cut by the OpenGL view. The webview on top of OpenGL view, all of the webview view will block the OpenGL view.
Is there any solution to solve this? (OpenGL and Webview)
WebKit has an interesting functionality where you can associate webviews with certain MIME types to your own custom NSView classes.
In your HTML webview, you can put an iframe which has a custom mimetype (e.g. "application/my-custom-view").
After that, from your native app, you can call:
[WebView registerViewClass:[MyCustomView class] representationClass:[MyCustomRepresentation class] forMIMEType:@"application/my-custom-view"];
MyCustomRepresentation can be pretty lightweight, my Representation class doesn't do anything, it just defines stub delegate functions.
这篇关于OSX Cocoa嵌入opengl视图里面webview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!