Mac OS X: Can one process render to another process's window?

前提是你 提交于 2019-11-29 20:38:58

I was investigating a solution to this almost a year ago. I started a few threads on the apple mailing lists:

http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg08056.html

http://www.mail-archive.com/quartzcomposer-dev@lists.apple.com/msg01878.html

http://lists.apple.com/archives/mac-opengl/2008/May/msg00099.html

I had to revert to a solution which used CGWindowListCreateImage which took a screen grab of the opengl process window and convert it to a bitmap for display in the main process window. This is far from effeicient since pixel data is transfered from video ram to system ram.

I also tried a floating window solution. The opengl process window floated above the main process window and respond to mouse movements from the main window. But I had issues with dragging lag and window z order.

You would think NSWindowSharingReadWrite would do what you require, but doumentation/examples back then were practically non existent.

But maybe things have changed in the last year. Keep me posted if you find anything new !

Good luck

JC

fixermark

Here is the overall answer received from Apple's development team.

There is essentially no way to do this in MacOSX 10.5 and earlier that is as clean as attaching an OpenGL rendering context to another process's window. The hacks people have developed may be the best solutions in those cases.

The closest thing we have in MacOS 10.6 is the IOSurface system; using that in 10.6 seems to be the cleanest solution. If you want clicks in the rendered-to process to be intercepted by the rendering process, you'll have to bundle up the events yourself and pass them to the rendering process using whatever method you find most appropriate.

More information on IOSurface could be found in this StackOverflow entry

A window in one process can be written to by another process, seemingly if the NSWindowSharingType is set to NSWindowSharingReadWrite. That was added in Leopard. Note that I haven't used this myself, but I would say that it at least removes the "can't be done" obstacle for you ;-)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!