Transparent backbuffer?

Started by
3 comments, last by r0dney 17 years, 6 months ago
I am currently using managed DirectX to render video and text to a windows form. I need to be able to render this content over existing non DirectX content on the same form. I think this would be possible if there is a way to make my main DirectX backbuffer surface transparent. Basically my surface covers the entire form, but I am only rendering to certain portions of it, and I would like to make the rest transparent so that I can see my other objects behind it. I have tried clearing my surface with an Alpha color, but this didn't work. Is this possible? If anyone can give me a pointer in the right direction I would greatly appreciate it. Thanks.
Advertisement
You can simpily create a windows controler( such as picture box ) on the main frame.And pass it's handle to the DirectX to create device.This is for c++, the same way as mdx I think!
I've seen numerous people ask about this sort of thing over the years and I've yet to see anyone actually succeed [oh]

The blending parts of Win32 are part of GDI/GDI+ as I understand it and given the low-level nature of Direct3D it doesn't tend to play nicely with GDI - it pretty much takes over the region and does the work itself. Thus enabling blending effects via GDI seem to get ignored.

As for having an entire back-buffer and only showing parts of it - again, don't think you'll achieve that. Even though you're not rendering to sections the presence of a Clear() means you *are* actually rendering to all of it (although, maybe scissor-rects or viewports might change this i]slightly). You can have an alpha channel in the backbuffer (if the hardware supports it), but that becomes more of a storage for D3DBLEND_DESTALPHA than for actual blending.

You might want to try and reverse the way you're approaching this. Instead of cutting out parts of the D3D render, add new bits to it. That is, use GDI (or whatever) to try and copy the graphical representation of the other controls on your form directly to the backbuffer. Effectively design your application to take over from Windows when it comes to compositing.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Is the content of the window you want your directx surface to be "above" static? If it is, you could hack it by first capturing the rectangle the surface will be above and then, every frame, render this texture into your frame buffer before anything else. Then, you'll need to render everything using either alphablending or alphatesting depending on your needs.

I guess this doesn't solve your problem as you probably want the content of the window underneath to be dynamic. Sorry, but as jollyjeffers mentions, I have yet to see a succesfull implementation of this sort of thing!

fb
Thanks for the replies. I do need the area of the windows form behind my DirectX surface to be active, so I can't use the approach of taking a screenshot to use as my background texture. I can just use a panel as the container for my DirectX area, but the problem is I need to render to more than one individual area of the screen at the same time, so just resizing and moving the panel won't fix my problem.

I do think I have come up with a workaround for this though. After some testing, I can "cut out" the areas I want visible using regions. I have made a panel the container for my DirectX device, and use regions to cut out the sections of the panel I want visible. This seems to work.

This topic is closed to new replies.

Advertisement