日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

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

發(fā)布時(shí)間:2024/1/8 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Qt WA_TranslucentBackground 导致视频渲染不了的问题 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

使用QT5.7 + VS2015做的試驗(yàn),視頻渲染使用D3D9。發(fā)現(xiàn)的規(guī)律是:

頂層窗口(指父窗口為NULL的窗口)如果設(shè)置了

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

那么不管是用該頂層窗口本身的窗口句柄,還是使用子窗口的句柄作為D3D的渲染窗口,都渲染不出來(lái)。如果頂層窗口沒(méi)有同時(shí)設(shè)置以上的屬性/標(biāo)志,子窗口不管設(shè)置還是沒(méi)有設(shè)置以上兩個(gè)屬性/標(biāo)志,視頻都可以渲染出來(lái)。

調(diào)試了下,D3D的初始化、渲染接口都能成功執(zhí)行,找了不少論壇,后來(lái)在一個(gè)頁(yè)面上看到有類似的說(shuō)明:

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也是一樣的原理,直接訪問(wèn)顯卡,所以D3D在這種情況下不能渲染視頻,估計(jì)也是這個(gè)原因,它里面還提到了對(duì)于這個(gè)問(wèn)題Qt做不了什么,因?yàn)檫@需要窗口管理器那邊來(lái)解決這個(gè)問(wèn)題。

我又嘗試了使用Dib來(lái)貼圖,仍然失敗。看來(lái)目前還未有解決辦法。

總結(jié)

以上是生活随笔為你收集整理的Qt WA_TranslucentBackground 导致视频渲染不了的问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。