OSX Cocoa嵌入opengl视图里面webview [英] OSX Cocoa embed opengl view inside webview

查看:380
本文介绍了OSX Cocoa嵌入opengl视图里面webview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图构建一个MacOS应用程序创建一个OpenGL视图,并将其嵌入到webview的元素(使用OpenGL而不是WebGL)。主要目标是使用web(html / javascript)作为UI,并使用OpenGL视图绘制结果。 (此外,OpenGL视图也将处理用户输入)



问题是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]; 

请参阅 https://developer.apple.com/library /mac/documentation/Cocoa/Reference/Webkit/Classes/WebView_Class/Reference/Reference.html#//apple_ref/occ/clm/WebView/registerViewClass:representationClass:forMIMEType



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"];

See https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Webkit/Classes/WebView_Class/Reference/Reference.html#//apple_ref/occ/clm/WebView/registerViewClass:representationClass:forMIMEType:

MyCustomRepresentation can be pretty lightweight, my Representation class doesn't do anything, it just defines stub delegate functions.

这篇关于OSX Cocoa嵌入opengl视图里面webview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆