我可以使用opengl在不属于我的窗口上绘制东西吗? [英] Can I draw something on window, that does not belongs to me, using opengl?
问题描述
我听说您可以钩住窗口句柄并将此窗口用作OpenGL画布.我知道如何钩住窗户,但找不到在窗户上画画的方法.
I heard you can hook window handle and use this window as OpenGL canvas. I know how to hook windows, but I can't find how can I draw on this window.
PS.如果有帮助,我正在使用Qt.
PS. I'm using Qt if it helps.
推荐答案
OpenGL上下文一次只能在一个线程中使用,并且绑定到进程.因此,所需的是创建一个外部进程资源的OpenGL上下文.
OpenGL contexts are only usable in one thread at a time and are bound to processes. So what that required was creating a OpenGL context of a foreign process' resource.
在Windows上使用一些非常古怪的黑客手段,至少在WinXP中才有可能实现(我不了解Vista或7);这通常包括共享过程内存的大部分.
On Windows using some very quircky hacks this was possible in at least WinXP (I don't know about Vista or 7); this usually includes making large portions of the process memory shared.
在X11/GLX上,通过将上下文创建为间接渲染上下文要容易得多(不幸的是,出于某些阴暗的借口,OpenGL-3没有完整的间接GLX规范);间接上下文可以从多个进程访问.
On X11/GLX it's a lot easier by creating the context as indirect rendering context (unfortunately OpenGL-3 has not complete indirect GLX specification, for some shady excuses of reasons); indirect contexts can be accessed from multiple processes.
在任何情况下,两个过程都必须配合才能完成这项工作.
In any case both processes must cooperate to make this work.
这篇关于我可以使用opengl在不属于我的窗口上绘制东西吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!