Advertisement Jump to content


This topic is now archived and is closed to further replies.


GUI and DirectX

This topic is 5938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What''s the best way to implement transparency using DirectX in a window. What I''m going for is something akin to the Mac''s OS X shortcut bar at the bottom. I would like to render 3D objects inside of a window, but not have an ugly gray box behind it. I was thinking of using a square window without a frame, copy a bitmap of the background behind the window, and render it as a billboard in 3D space. However, depending on how much liberty the GDI will allow me to take, it could possibly be a processor-intensive hack. So, I guess my question is, "How do you render 3D objects on the desktop?" Paul Betts

Share this post

Link to post
Share on other sites
I can''t recall the name of the functions, but you can set Regions in your window. Anything in this region is opaque, outside is transparent. You set the region to be the shape of whatever you''re rendering, and the rest of the window will be transparent.

Windows2000 added some extras on to it, but I''ve never looked into it.

Doing a Google, or MSDN search on window regions and transparency will probably turn something up.

Stay Casual,

Drunken Hyena

Share this post

Link to post
Share on other sites
I think Ken''s talking about the SetWindowRgn function. You''ll need a function to get your HRGN though, out of a bitmap that has a fixed transparency color. I have some or you can just google for the function. There''s a good one at codeguru IIRC. Keep in mind that using SetWindowRgn for every render frame is likely to be slow (assuming your DX stuff is animated).

The 2K-added functions Ken''s talking about are probably AlphaBlend and TransparentBlt. They''re what is used in apps such as Glass2K. They are extremely slow though if you''re talking about decent sized windows.

You can also do as you say and blit the "desktop" to your DX rendering buffer. For that you can use PaintDesktop which will dump the desktop''s bitmap/tilemap/color/etc. to your chosen DC. I''ve had problems with this function when blitting to memory-based DCs on 98 second edition boxes, so what I have done in the past is to PaintDesktop to my window''s DC and then blit that DC to my memory DC. There are 2 problems with this approach however: the window must have a "desktop" Z order and other "desktop" images (icons and such) will be overdrawn, unless you create your own window in-between the desktop window and the listview window used to display the desktop icons (thinking only non-active desktop explorer here), which of course has its own set of problems .

There are other methods as well. I think I saw one approach a while back at flipcode where the guy just took over the desktop window drawing and then blit directly to it when needed. I can''t remember if he hooked the desktop proc or not but it definitely worked, although he was blitting to the entire screen instead of just a portion of it.

Anyway, hope all of this helps. I''m thinking of trying this myself soon. I''ve done it before using only GDI but I have some D3D-based stuff that I think would be cool sitting on the desktop.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!