简体   繁体   English

在没有窗口的Windows桌面上绘制OpenGL

[英]Draw OpenGL on the windows desktop without a window

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++. 注意:想在Windows和c ++中执行此操作。

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. 一旦你找到了你想要的窗口,你就拥有它的HWND,然后就可以使用它就像你自己的窗口一样用于绘图。 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. 有一些非常复杂的解决方法,其中一些涉及使用Windows“钩子”拦截绘图消息到该窗口,所以你知道它何时重绘,以便你也可以进行重绘。

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. 至少,这可能通过XP,不确定它是否在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. 不幸的是,所有这些选项都非常复杂,无法深入了解您正在尝试做什么的更多信息。

You can use GetDesktopWindow() , to get the HWND of the desktop. 您可以使用GetDesktopWindow()来获取桌面的HWND But as a previous answer says (SoapBox), be careful, you may mess up the desktop because the OS expects that it owns it. 但正如之前的回答所说(SoapBox),要小心,你可能会搞砸桌面,因为操作系统希望它拥有它。

I wrote an open source project a few years ago to achieve this on the desktop background. 几年前我写了一个开源项目,以便在桌面背景上实现这一目标。 It's called Uberdash. 它被称为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. 您可以使用Aero合成在前端容器中渲染带有alpha的窗口,但是您需要将事件传递到下部窗口。 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. 您的GPU将直接应用它,不会干扰主存储器。 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... 不幸的是,MS禁止Vista中的技术...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM