Qt WA_TranslucentBackground 导致视频渲染不了的问题

11 篇文章 0 订阅

使用QT5.7 + VS2015做的试验,视频渲染使用D3D9。发现的规律是:

顶层窗口(指父窗口为NULL的窗口)如果设置了

	this->setWindowFlags( Qt::FramelessWindowHint);
	this->setAttribute(Qt::WA_TranslucentBackground,true);

那么不管是用该顶层窗口本身的窗口句柄,还是使用子窗口的句柄作为D3D的渲染窗口,都渲染不出来。如果顶层窗口没有同时设置以上的属性/标志,子窗口不管设置还是没有设置以上两个属性/标志,视频都可以渲染出来。

调试了下,D3D的初始化、渲染接口都能成功执行,找了不少论坛,后来在一个页面上看到有类似的说明:

OpenGL_and_translucent_background_do_not_work_together_due_to_a_limitation

里面提到:

Due to a limitation in window managers, it is not possible to combine OpenGL with a translucent background window (set with WA_TranslucentBackground). The reason for this is because OpenGL is rendered directly onto the screen and the compositor used to enable the translucent background cannot ensure that the OpenGL is rendered correctly.

There is nothing that can be done in Qt to fix this as it needs to be done on the side of the window manager.

To work around this issue you can either just use Qt to render everything and not OpenGL, or you can render the OpenGL into a pixmap and draw that onto your widget instead.

大意是OpenGL是直接渲染在屏幕的,而透明背景的compositor不能保证OpenGL可以正确地渲染,我想D3D也是一样的原理,直接访问显卡,所以D3D在这种情况下不能渲染视频,估计也是这个原因,它里面还提到了对于这个问题Qt做不了什么,因为这需要窗口管理器那边来解决这个问题。

我又尝试了使用Dib来贴图,仍然失败。看来目前还未有解决办法。

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值