views:

328

answers:

1

I currently have an activex control that initiates a media (video/audio) framework another development group in my company developed and I am providing a window handle to that code. That handle is being used by their rendering plugin in the pipeline that uses Direct3d for rendering the video using that handle.

I have seperate LPDIRECT3D9EX and LPDIRECT3DDEVICE9EX pointers that I initialize in my activex control. I am trying to clear a backbuffer to transparent and then use directx drawing primatives to draw on that backbuffer producing a transparent window with my drawing primatives over the streaming video on the directx surface below.

It appears that clearing a device backbuffer with full alpha transparency is ignored by directx.

d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 1, 0 /*full alpha*/), 1.0f, 0);

I can see the object I draw but they are drawn on top of a backbuffer that has the RGB color specified without the alpha value. The project linked (http://www.codeproject.com/KB/directx/umvistad3d.aspx) to in the stackoverflow question below does what I want but requires vista's Desktop Window Manager and won't work for XP.

http://stackoverflow.com/questions/148275/how-do-i-draw-transparent-directx-content-in-a-transparent-window

  • I have tried with D3DRS_ALPHABLENDENABLE true with configured blend with no avail.
  • I have also tried to have pixels with full alpha values not rendered using D3DRS_ALPHATESTENABLE, D3DRS_ALPHAREF, and D3DRS_ALPHAFUNC setup but this doesn't work either.
  • I have tried using ColorFill with alpha after retrieving the backbuffer with GetBackBuffer but this doesn't work either. (again only RGB is used)
  • Finally I have tried creating a texture, selecting a surface, colorfilling that surface with a fully transparent alpha value, then loading that surface onto the backbuffer but only the RGB values appear to be used.

I have checked the capabilities using the DXCapsViewer.exe and the D3DFMT_A8R8G8B8 backbuffer format that I am using for the backbuffer is valid so it can't be that.

Has anyone gotten a transparent backbuffer in directx to work in XP?

+1  A: 

The problem is that your back buffer contains alpha values your front buffer, however ... does not. You will need to lock your back buffer and copy the pixels to the layered window DC. Do be warned though ... this WILL be slow.

Edit: In answer to your questions in the comment.

1) The point of alpha values in the back buffer is for alpha testing and blending
2) (See answer 1)
3) No I'm saying ignore the front buffer and get the back buffer.
4) What direct x object in use by the media frame work? There is no such thing. DirectShow != Direct3D whatever 99% of people seem to think ...

Goz
So when the backbuffer is swapped in as the front buffer the alpha values do nothing. What is the point of the alpha values for the back buffer? Is it just used in blending operations with primatives and textures applied to the backbuffer when alpha blend is enabled?So are you saying to use GetFrontBufferData mentioned on msdn as having the drawback of being "very slow, by design, and should not be used in any performance-critical path."? Is the only other alternative to get the directx device used by the media framework and use it for my draw primitives in my Beginscene/Endscene block?
flawlesslyfaulted
4) No, you misunderstand, the development group has developed their own media frame work and is not using DirectShow. As I stated in my question, I provide their framework with a window handle and they create a directx device pointer.3) What backbuffer? I have already tried getting and using my directx device's backbuffer as mentioned in my bullets. If I try to use the backbuffer the framework is using I will already have what I need and I will just inject my drawing anyway.Thanks for the information though... It corresponds to some of the things I read in different forums.
flawlesslyfaulted