简体   繁体   English

如何在没有Vista桌面窗口管理器的情况下在DirectX 9中获得完全透明的后缓冲

[英]How to get a fully transparent backbuffer in directx 9 without vista Desktop Window Manager

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. 我目前有一个Activex控件,用于启动媒体(视频/音频)框架,该框架由我公司的另一个开发小组开发,并且正在提供该代码的窗口句柄。 That handle is being used by their rendering plugin in the pipeline that uses Direct3d for rendering the video using that handle. 他们的渲染插件正在使用Direct3d通过该手柄渲染视频的管道中的渲染插件使用该手柄。

I have seperate LPDIRECT3D9EX and LPDIRECT3DDEVICE9EX pointers that I initialize in my activex control. 我在ActiveX控件中初始化了单独的LPDIRECT3D9EX和LPDIRECT3DDEVICE9EX指针。 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. 我正在尝试将后备缓冲区清除为透明,然后使用DirectX绘图基元在该后缓冲区上绘制,从而在我的DirectX曲面上的流式视频上生成一个透明窗口,其中包含我的绘图基元。

It appears that clearing a device backbuffer with full alpha transparency is ignored by directx. 看来用DirectX清除具有完全Alpha透明度的设备后备缓冲区。

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. 我可以看到我绘制的对象,但是它们绘制在具有指定的RGB颜色而没有alpha值的后缓冲之上。 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. 在下面的stackoverflow问题中链接到的项目( http://www.codeproject.com/KB/directx/umvistad3d.aspx )可以满足我的要求,但是需要Vista的Desktop Window Manager,并且不适用于XP。

How do I draw transparent DirectX content in a transparent window? 如何在透明窗口中绘制透明DirectX内容?

  • I have tried with D3DRS_ALPHABLENDENABLE true with configured blend with no avail. 我尝试将D3DRS_ALPHABLENDENABLE true与已配置的Blend混合使用,但无济于事。
  • 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. 我也尝试过使用D3DRS_ALPHATESTENABLE,D3DRS_ALPHAREF和D3DRS_ALPHAFUNC设置无法渲染具有完整alpha值的像素,但这也不起作用。
  • I have tried using ColorFill with alpha after retrieving the backbuffer with GetBackBuffer but this doesn't work either. 我尝试用GetBackBuffer检索后缓冲后将ColorFill与alpha配合使用,但这也不起作用。 (again only RGB is used) (再次仅使用RGB)
  • 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. 最终,我尝试了创建纹理,选择表面,使用完全透明的alpha值对该表面进行颜色填充,然后将该表面加载到后缓冲上,但是似乎只使用了RGB值。

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. 我已经使用DXCapsViewer.exe和D3DFMT_A8R8G8B8后备缓冲区格式检查了功能,我使用的后备缓冲区格式是有效的,因此不是那样。

Has anyone gotten a transparent backbuffer in directx to work in XP? 有没有人在DirectX中获得透明的后备缓冲区以在XP中工作?

The problem is that your back buffer contains alpha values your front buffer, however ... does not. 问题是您的后缓冲区包含前缓冲区的alpha值,但是...不。 You will need to lock your back buffer and copy the pixels to the layered window DC. 您将需要锁定后台缓冲区,并将像素复制到分层窗口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 1)后缓冲区中的Alpha值点用于Alpha测试和混合
2) (See answer 1) 2)(请参阅答案1)
3) No I'm saying ignore the front buffer and get the back buffer. 3)不,我是说忽略前缓冲区并获取后缓冲区。
4) What direct x object in use by the media frame work? 4)媒体框架使用的直接x对象是什么? There is no such thing. 哪有这回事。 DirectShow != Direct3D whatever 99% of people seem to think ... DirectShow!= Direct3D,无论99%的人似乎认为...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM