From 8f9a31dc78724f12e7ae361addb56875c06cda30 Mon Sep 17 00:00:00 2001 From: a7458969 <290198252@qq.com> Date: Tue, 26 May 2020 09:06:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8glsl=E6=B8=B2=E6=9F=93rgb=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95ok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/qt_gl_render/yuvgl/cplaywidget.cpp | 31 +++++++++++++++++------ client/qt_gl_render/yuvgl/main.cpp | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/client/qt_gl_render/yuvgl/cplaywidget.cpp b/client/qt_gl_render/yuvgl/cplaywidget.cpp index bd9f811..ef8b237 100644 --- a/client/qt_gl_render/yuvgl/cplaywidget.cpp +++ b/client/qt_gl_render/yuvgl/cplaywidget.cpp @@ -32,13 +32,11 @@ void main(void) \ gl_FragColor = vec4(rgb, 1); \ }"; // rgb片段着色器源码 -const char *fsrcrgb = "in vec3 ourColor; \ - in vec2 TexCoord; \ +const char *fsrcrgb = "varying vec2 textureOut; \ uniform sampler2D rgbdata; \ - uniform float mixValue; \ void main() \ { \ - gl_FragColor = texture(rgbdata, TexCoord); \ + gl_FragColor = texture(rgbdata, textureOut); \ }"; void CPlayWidget::OnUpdateFrame() { @@ -181,7 +179,6 @@ void CPlayWidget::initializeGL() if(!bCompile) { // todo 设置错误状态 - } #define PROGRAM_VERTEX_ATTRIBUTE 0 #define PROGRAM_TEXCOORD_ATTRIBUTE 1 @@ -315,7 +312,15 @@ void CPlayWidget::resizeGL(int w, int h) //使用来自y数据生成纹理 glBindTexture(GL_TEXTURE_2D, id_y); //使用内存中m_pBufYuv420p数据创建真正的y数据纹理 - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_nVideoW, m_nVideoH, 0, GL_RED, GL_UNSIGNED_BYTE, m_pBufYuv420p); + glTexImage2D(GL_TEXTURE_2D, + 0, + GL_RED, + m_nVideoW, + m_nVideoH, + 0, + GL_RED, + GL_UNSIGNED_BYTE, + m_pBufYuv420p); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -323,7 +328,9 @@ void CPlayWidget::resizeGL(int w, int h) //加载u数据纹理 glActiveTexture(GL_TEXTURE1);//激活纹理单元GL_TEXTURE1 glBindTexture(GL_TEXTURE_2D, id_u); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_nVideoW/2, + glTexImage2D(GL_TEXTURE_2D, + 0, GL_RED, + m_nVideoW/2, m_nVideoH/2, 0, GL_RED, @@ -365,7 +372,15 @@ void CPlayWidget::resizeGL(int w, int h) //使用来自y数据生成纹理 glBindTexture(GL_TEXTURE_2D, id_rgb); //使用内存中m_pBufYuv420p数据创建真正的y数据纹理 - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_nVideoW, m_nVideoH, 0, GL_RGB, GL_UNSIGNED_BYTE, m_pBufRgb32); + glTexImage2D(GL_TEXTURE_2D, + 0, + GL_RGBA, + m_nVideoW, + m_nVideoH, + 0, + GL_RGBA, + GL_UNSIGNED_BYTE, + m_pBufRgb32); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); diff --git a/client/qt_gl_render/yuvgl/main.cpp b/client/qt_gl_render/yuvgl/main.cpp index 7d12ce9..bd20a1b 100644 --- a/client/qt_gl_render/yuvgl/main.cpp +++ b/client/qt_gl_render/yuvgl/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); CPlayWidget gPlayer(nullptr); gPlayer.SetDataType(CPlayWidget::IMG_TYPE::TYPE_RGB32); - gPlayer.SetImgSize(1920,1080); + gPlayer.SetImgSize(640,480); gPlayer.show(); Camera *gCam = Camera::GetInstance();