在没有窗口的windows桌面上绘制OpenGL
我见过这样的事情,我想知道这是否可能,假设我运行我的应用程序 它会显示其下方的渲染结果。
所以基本上,在没有窗口的情况下在屏幕上渲染。
可能还是谎言?
注意:想要在 Windows 和 C++ 中执行此操作。
I've seen things like this and I was wondering if this was possible, say I run my application
and it will show the render on whatever is below it.
So basically, rendering on the screen without a window.
Possible or a lie?
Note: Want to do this on windows and in c++.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可以使用您的应用程序在其他应用程序的窗口上绘图。一旦你找到了你想要的窗口,你就拥有了它的 HWND,然后你就可以像使用你自己的窗口一样使用它来进行绘图。但由于该窗口不知道您已经执行了此操作,因此当它尝试重绘自身时,它可能会弄乱您在其上绘制的任何内容。
有一些非常复杂的方法可以解决这个问题,其中一些涉及使用窗口“挂钩”来拦截到该窗口的绘图消息,以便您知道它何时重绘,以便您也可以进行重绘。
另一种选择是在窗口上使用剪切区域。这可以让你给你的窗户一个不寻常的形状,并且让它后面的一切看起来仍然正确。
还有一些方法可以接管桌面背景窗口的绘制,并且您实际上可以运行一个在桌面背景上绘制动画和内容的应用程序(当桌面仍然可用时)。至少,在 XP 上这是可能的,不确定在 Vista/Win7 中是否有所改变。
不幸的是,所有这些选项都太复杂了,如果没有更多关于您想要做什么的信息,就无法深入了解。
It is possible to use your application to draw on other application's windows. Once you have found the window you want, you have it's HWND, you can then use it just like it was your own window for the purposes of drawing. But since that window doesn't know you have done this, it will probably mess up whatever you have drawn on it when it tries to redraw itself.
There are some very complicated ways of getting around this, some of them involve using windows "hooks" to intercept drawing messages to that window so you know when it has redrawn so that you can do your redrawing as well.
Another option is to use clipping regions on a window. This can allow you to give your window an unusual shape, and have everything behind it still look correct.
There are also ways to take over drawing of the desktop background window, and you can actually run an application that draws animations and stuff on the desktop background (while the desktop is still usable). At least, this was possible up through XP, not sure if it has changed in Vista/Win7.
Unfortunately, all of these options are too very complex to go in depth without more information on what you are trying to do.
您可以使用 GetDesktopWindow() 来获取桌面的
HWND
。但正如前面的答案所说(SoapBox),请小心,您可能会弄乱桌面,因为操作系统希望它拥有它。You can use GetDesktopWindow(), to get the
HWND
of the desktop. But as a previous answer says (SoapBox), be careful, you may mess up the desktop because the OS expects that it owns it.几年前我写了一个开源项目来在桌面后台实现这一点。它的名字叫Uberdash。如果遵循窗口层次结构,桌面只是某种“背景”容器中的窗口。然后是主容器和前容器。 Front 容器是窗口全屏显示或“始终位于顶部”的方式。您也许可以使用 Aero 合成来渲染前面容器中带有 alpha 的窗口,但您需要将事件传递到下部窗口。不会很漂亮。
此外,某些显卡中有一种称为覆盖/底层的技术。您过去可以直接渲染到叠加层。您的 GPU 会直接应用它,不会干扰主内存。因此,即使您进行了屏幕截图,您的覆盖层/底层也不会显示在屏幕截图中。不幸的是微软在 Vista 中禁止了这项技术......
I wrote an open source project a few years ago to achieve this on the desktop background. It's called Uberdash. If you follow the window hierarchy, the desktop is just a window in a sort of "background" container. Then there is a main container and a front container. The front container is how windows become full screen or "always on top." You may be able to use Aero composition to render a window with alpha in the front container, but you will need to pass events on to the lower windows. It won't be pretty.
Also, there's a technology in some video cards called overlays/underlays. You used to be able to render directly to an overlay. Your GPU would apply it directly, with no interference to main memory. So even if you took a screen capture, your overlay/underlay would not show up in the screen cap. Unfortunately MS banned that technology in Vista...