Can I draw something on window, that does not belongs to me, using opengl?

久未见 提交于 2019-12-24 01:53:12

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/7566205/can-i-draw-something-on-window-that-does-not-belongs-to-me-using-opengl

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