Sign in to follow this  
VanKurt

D3D + Invisible window

Recommended Posts

VanKurt    133
Hi guys! I'm using DX9 and Vista. Is there any way to render with Direct3D to a invisible window? The effect I want to achive is that you can only see what I render, but NOT the window itself. This should be used to create a little creature walking around on your desktop/applications and doing funny stuff ;-) I have a little D3D experience but don't know much about Windows and its internal mechanics...but I'm sure there is a way!!! Thanks for any hint!!!

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Integrating D3D with the desktop has been tried by many people (or at least they've asked!) yet few if any ever report success. Maybe the new graphics architecture in Vista will make it easier, but I suspect not.

A borderless window should be possible with regular Win32 calls, but getting any sort of transparency (for a non-rectangular sprite) would probably be pushing it too far as that's mixing GDI+/Win32/D3D which generally don't have (easy) access to eachothers resources.

Do let us know if you find anything that works though [smile]

Jack

Share this post


Link to post
Share on other sites
NightCabbage    100
I've got an idea for how this might work...

It's possible to have a transparent window, right?

The problem is trying to put a rendered image from DX onto it.

(unless I'm barking up the wrong tree)

So couldn't you just do a render to texture, and then grab the texture data, and write that on the window using a normal technique?

Share this post


Link to post
Share on other sites
VanKurt    133
Sounds nice... anyone with more KnowHow than me here who could comment on this?



(I think its strange that this topic is so badly documented on the internet...)

Share this post


Link to post
Share on other sites
Nik02    4348
This is definitely possible. Firstly, you create a window with WS_EX_LAYERED style flag, and create your device on that.

Now, instead of clearing and presenting to the default frame buffer (steps that would make your window a solid colored rectangle), you need to create an extra render target and render to that. In addition to the ordinary color channels, the render target should have an alpha channel since you want the opacity of the result to be variable.

After rendering your image, lock the bytes and copy them to a GDI bitmap with alpha channel allocated (see Layered Windows topic and its children topics on MSDN).

Finally, you can update your layered window with the aforementioned GDI bitmap which now contains the rendered image with alpha transparency.

The performance of all this varies considerably between different video hardware. Some cards do not allow render targets to be locked and read from at all. Some graphics drivers insist on clearing the window bound to D3D even though you don't explicitly want it, ruining the internal alpha channel of that window's bitmap and thus ruining the effect. For these reasons, I would not recommend using D3D with variable-opacity windows, at least in commercial projects.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this