用glsl渲染rgb 测试ok
parent
d3aff4e773
commit
8f9a31dc78
|
@ -32,13 +32,11 @@ void main(void) \
|
||||||
gl_FragColor = vec4(rgb, 1); \
|
gl_FragColor = vec4(rgb, 1); \
|
||||||
}";
|
}";
|
||||||
// rgb片段着色器源码
|
// rgb片段着色器源码
|
||||||
const char *fsrcrgb = "in vec3 ourColor; \
|
const char *fsrcrgb = "varying vec2 textureOut; \
|
||||||
in vec2 TexCoord; \
|
|
||||||
uniform sampler2D rgbdata; \
|
uniform sampler2D rgbdata; \
|
||||||
uniform float mixValue; \
|
|
||||||
void main() \
|
void main() \
|
||||||
{ \
|
{ \
|
||||||
gl_FragColor = texture(rgbdata, TexCoord); \
|
gl_FragColor = texture(rgbdata, textureOut); \
|
||||||
}";
|
}";
|
||||||
|
|
||||||
void CPlayWidget::OnUpdateFrame() {
|
void CPlayWidget::OnUpdateFrame() {
|
||||||
|
@ -181,7 +179,6 @@ void CPlayWidget::initializeGL()
|
||||||
if(!bCompile)
|
if(!bCompile)
|
||||||
{
|
{
|
||||||
// todo 设置错误状态
|
// todo 设置错误状态
|
||||||
|
|
||||||
}
|
}
|
||||||
#define PROGRAM_VERTEX_ATTRIBUTE 0
|
#define PROGRAM_VERTEX_ATTRIBUTE 0
|
||||||
#define PROGRAM_TEXCOORD_ATTRIBUTE 1
|
#define PROGRAM_TEXCOORD_ATTRIBUTE 1
|
||||||
|
@ -315,7 +312,15 @@ void CPlayWidget::resizeGL(int w, int h)
|
||||||
//使用来自y数据生成纹理
|
//使用来自y数据生成纹理
|
||||||
glBindTexture(GL_TEXTURE_2D, id_y);
|
glBindTexture(GL_TEXTURE_2D, id_y);
|
||||||
//使用内存中m_pBufYuv420p数据创建真正的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_MAG_FILTER,GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_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);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
@ -323,7 +328,9 @@ void CPlayWidget::resizeGL(int w, int h)
|
||||||
//加载u数据纹理
|
//加载u数据纹理
|
||||||
glActiveTexture(GL_TEXTURE1);//激活纹理单元GL_TEXTURE1
|
glActiveTexture(GL_TEXTURE1);//激活纹理单元GL_TEXTURE1
|
||||||
glBindTexture(GL_TEXTURE_2D, id_u);
|
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,
|
m_nVideoH/2,
|
||||||
0,
|
0,
|
||||||
GL_RED,
|
GL_RED,
|
||||||
|
@ -365,7 +372,15 @@ void CPlayWidget::resizeGL(int w, int h)
|
||||||
//使用来自y数据生成纹理
|
//使用来自y数据生成纹理
|
||||||
glBindTexture(GL_TEXTURE_2D, id_rgb);
|
glBindTexture(GL_TEXTURE_2D, id_rgb);
|
||||||
//使用内存中m_pBufYuv420p数据创建真正的y数据纹理
|
//使用内存中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_MAG_FILTER,GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_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);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
|
|
@ -13,7 +13,7 @@ int main(int argc, char *argv[])
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
CPlayWidget gPlayer(nullptr);
|
CPlayWidget gPlayer(nullptr);
|
||||||
gPlayer.SetDataType(CPlayWidget::IMG_TYPE::TYPE_RGB32);
|
gPlayer.SetDataType(CPlayWidget::IMG_TYPE::TYPE_RGB32);
|
||||||
gPlayer.SetImgSize(1920,1080);
|
gPlayer.SetImgSize(640,480);
|
||||||
gPlayer.show();
|
gPlayer.show();
|
||||||
|
|
||||||
Camera *gCam = Camera::GetInstance();
|
Camera *gCam = Camera::GetInstance();
|
||||||
|
|
Loading…
Reference in New Issue