开发者

Can I draw something on window, that does not belongs to me, using 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. I'm using Qt if it helps.


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.

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.

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.


Qt has some NativeWindow hacks you can play with a bit.

On Windows you can use findWindowEx to get a HWND and interrogate its geometry, then position your own window on top of it.

You really shouldn't be able to interfere with another process's windows arbitrarily -- it's a security hazard.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜