Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed the issue that OpenGL could not be played #560

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions src/backends/mpv/mpv_glwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,18 @@ namespace dmr {
m_pFbo->release();
delete m_pFbo;
}
m_pFbo = new QOpenGLFramebufferObject(desiredSize);
// 创建 FBO 格式
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(0); // 禁用多重采样,避免与视频渲染冲突
format.setTextureTarget(GL_TEXTURE_2D);
format.setInternalTextureFormat(GL_RGBA8); // 使用 8 位 RGBA 格式
m_pFbo = new QOpenGLFramebufferObject(desiredSize, format);
// 检查 FBO 是否创建成功
if (!m_pFbo || !m_pFbo->isValid()) {
qWarning() << "Failed to create FBO with size:" << desiredSize;
return;
}
}

void MpvGLWidget::updateCornerMasks()
Expand Down Expand Up @@ -829,6 +840,17 @@ namespace dmr {
void MpvGLWidget::paintGL()
{
QOpenGLFunctions *pGLFunction = QOpenGLContext::currentContext()->functions();
if (!pGLFunction) {
qWarning() << "Failed to get OpenGL functions";
return;
}

// 检查纹理是否有效
if (m_pLightTex && !m_pLightTex->isCreated()) {
qWarning() << "Light texture not created";
return;
}

if (m_bPlaying) {

qreal dpr = qApp->devicePixelRatio();
Expand All @@ -848,8 +870,8 @@ namespace dmr {

m_renderContexRender(m_pRenderCtx, params);
} else {
pGLFunction->glEnable(GL_BLEND);
pGLFunction->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//pGLFunction->glEnable(GL_BLEND);
//pGLFunction->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

m_pFbo->bind();

Expand Down Expand Up @@ -913,7 +935,7 @@ namespace dmr {
}
}

pGLFunction->glDisable(GL_BLEND);
//pGLFunction->glDisable(GL_BLEND);
}
#ifdef __x86_64__
QWidget *topWidget = topLevelWidget();
Expand Down
4 changes: 2 additions & 2 deletions src/backends/mpv/mpv_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,10 @@ mpv_handle *MpvProxy::mpv_init()
qInfo() << "-------- __mips__hwdec____________";
m_sInitVo = "opengl-cb";
#else
my_set_property(pHandle, "vo", "libmpv,opengl-cb");
my_set_property(pHandle, "vo", "libmpv");
my_set_property(pHandle, "vd-lavc-dr", "no");
my_set_property(pHandle, "gpu-sw", "on");
m_sInitVo = "libmpv,opengl-cb";
m_sInitVo = "libmpv";
#endif
} else {
my_set_property(pHandle, "wid", m_pParentWidget->winId());
Expand Down
6 changes: 1 addition & 5 deletions src/libdmr/compositing_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ CompositingManager::CompositingManager()
}
if (_platform == Platform::Arm64 && isDriverLoaded)
m_bHasCard = true;
//TODO
_composited = false;
qInfo() << __func__ << "Composited is " << _composited;
return;
}
Expand Down Expand Up @@ -212,7 +210,7 @@ CompositingManager::CompositingManager()
file.close();

//TODO: 临时处理方案
_composited = false;
_composited = true;
#if defined (_MOVIE_USE_)
//TODO
// QGSettings gsettings("com.deepin.deepin-movie", "/com/deepin/deepin-movie/");
Expand Down Expand Up @@ -292,8 +290,6 @@ CompositingManager::CompositingManager()
{
_composited = true;
}
//TODO
_composited = false;
qInfo() << __func__ << "Composited is " << _composited;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libdmr/compositing_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CompositingManager: public QObject
bool composited() const
{
#if defined (_LIBDMR_)
return false;
return true;
#endif
return _composited;
}
Expand Down
Loading