Draw OpenGL on the windows desktop without a windo

2019-04-29 03:33发布

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++.

3条回答
smile是对你的礼貌
2楼-- · 2019-04-29 04:15

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.

查看更多
混吃等死
3楼-- · 2019-04-29 04:20

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...

查看更多
姐就是有狂的资本
4楼-- · 2019-04-29 04:33

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.

查看更多
登录 后发表回答