windows 在两个应用程序之间共享 OpenGL 帧缓冲区/渲染缓冲区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6387049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Share OpenGL frame buffer / render buffer between two applications
提问by vrince
Let's say I have an application A
witch is responsible for painting stuff on screen via OpenGL
library. For tight integration purpose I would like to let this application A
do its job, but render in a FBO or directly in a render buffer and allow an application B
to have read-onlyaccess to this buffer to handle the display on screen (basically rendering it as a 2D texture).
假设我有一个应用程序A
女巫负责通过OpenGL
库在屏幕上绘制内容。对于紧密整合的目的,我想,让这个应用程序A
做它的工作,但呈现在FBO或直接在渲染缓冲器,并允许应用程序B
已只读到该缓冲区的访问来处理在屏幕上显示(基本上呈现它作为2D 纹理)。
It seems FBOs belongs to OpenGL contexts and contexts are not share-able between processes.I definitely understand that allowing several processes two mess with the same context is evil. But in my particular case I think it's reasonableto think it could be pretty safe.
似乎 FBO 属于 OpenGL 上下文,并且上下文不能在进程之间共享。我绝对理解允许多个进程在同一上下文中混为一谈是邪恶的。但在我的特殊情况下,我认为认为它可能非常安全是合理的。
NOTE:
笔记:
Application A
is a QApplication
and the application B
is a native win32
one
应用程序A
是一个QApplication
,应用程序B
是native win32
一个
EDIT:
编辑:
Render size is near full screen, I was thinking of a 2048x2048 32bits
buffer (I don't use the alpha channel for now but why not latter).
渲染大小接近全屏,我在考虑一个2048x2048 32bits
缓冲区(我现在不使用 alpha 通道,但为什么不使用后者)。
采纳答案by datenwolf
Framebuffer Objects can not be shared between OpenGL contexts, be it that they belong to the same process or not. But textures can be shared andtextures can be used as color buffer attachment to a framebuffer objects.
帧缓冲对象不能在 OpenGL 上下文之间共享,无论它们是否属于同一进程。但是纹理可以共享,纹理可以用作帧缓冲区对象的颜色缓冲区附件。
Sharing OpenGL contexts between processes it actually possible if the graphics system provides the API for this job. In the case of X11/GLX it is possible to share indirect rendering contexts between multiple processes. It may be possible in Windows by emplyoing a few really, really crude hacks. MacOS X, no idea how to do this.
如果图形系统为这项工作提供 API,那么在进程之间共享 OpenGL 上下文实际上是可能的。在 X11/GLX 的情况下,可以在多个进程之间共享间接渲染上下文。通过采用一些非常非常粗略的技巧,在 Windows 中是可能的。MacOS X,不知道如何做到这一点。
So what's probably the easiest to do is using a Pixel Buffer Object to gain performant access to the rendered picture. Then send it over to the other application through shared memory and upload it into a texture there (again through pixel buffer object).
因此,最简单的方法可能是使用像素缓冲区对象来获得对渲染图片的高性能访问。然后通过共享内存将其发送到其他应用程序并将其上传到那里的纹理中(再次通过像素缓冲区对象)。
回答by sarat
In my understanding, you won't be able to share the objects between the process under Windows, unless it's a kernel mode object. Even the shared textures and contexts can create performance hits also it has give you the additional responsibility of syncing the SwapBuffer() calls. Especially under windows platform the OpenGL implementation is notorious.
根据我的理解,您将无法在 Windows 下的进程之间共享对象,除非它是内核模式对象。即使共享的纹理和上下文也可以创建性能命中,它也赋予您同步 SwapBuffer() 调用的额外责任。特别是在 windows 平台下,OpenGL 实现是臭名昭著的。
In my opinion, you can relay on inter-process communication mechanisms like Events, mutex, window messages, pipes to sync the rendering. but just realize that there's a performance consideration on approaching in this way. Kernel mode objects are good but the transition to kernel each time has a cost of 100ms. Which is damns costly for a high performance rendering application. In my opinion you have to reconsider the multi-process rendering design.
在我看来,您可以通过事件、互斥、窗口消息、管道等进程间通信机制来同步渲染。但只要意识到以这种方式接近有一个性能考虑。内核模式对象很好,但每次转换到内核的成本为 100 毫秒。这对于高性能渲染应用程序来说是非常昂贵的。在我看来你必须重新考虑多进程渲染设计。