RGBA和BGR的自动适配
parent
8f9a31dc78
commit
0e3f6f3b97
|
@ -32,6 +32,7 @@ void main(void) \
|
|||
gl_FragColor = vec4(rgb, 1); \
|
||||
}";
|
||||
// rgb片段着色器源码
|
||||
// 注意MEDIASUBTYPE_RGB32 是bgr的,所以需要再进行一次转换
|
||||
const char *fsrcrgb = "varying vec2 textureOut; \
|
||||
uniform sampler2D rgbdata; \
|
||||
void main() \
|
||||
|
@ -76,11 +77,12 @@ CPlayWidget::CPlayWidget(QWidget *parent):QOpenGLWidget(parent) {
|
|||
m_nVideoW = 0;
|
||||
mType = TYPE_YUV420P;
|
||||
connect(&this->tm,SIGNAL(timeout()),this,SLOT(OnUpdateFrame()));
|
||||
|
||||
//tm.start(1000);
|
||||
}
|
||||
|
||||
CPlayWidget::~CPlayWidget() {
|
||||
}
|
||||
|
||||
void CPlayWidget::PlayOneFrame() {//函数功能读取一张yuv图像数据进行显示,每单击一次,就显示一张图片
|
||||
if(NULL == m_pYuvFile)
|
||||
{
|
||||
|
@ -111,15 +113,13 @@ void CPlayWidget::PlayOneFrame() {//函数功能读取一张yuv图像数据进
|
|||
return;
|
||||
}
|
||||
|
||||
int CPlayWidget::SetDataType(CPlayWidget::IMG_TYPE type)
|
||||
{
|
||||
int CPlayWidget::SetDataType(CPlayWidget::IMG_TYPE type){
|
||||
this->mType = type;
|
||||
}
|
||||
|
||||
int CPlayWidget::OnCameraData(uint8_t *dat, uint32_t size)
|
||||
{
|
||||
memcpy(this->m_pBufRgb32,dat,size);
|
||||
qDebug()<<"camera receive data"<<size<<"\r\n";
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -284,10 +284,10 @@ void CPlayWidget::resizeGL(int w, int h)
|
|||
};
|
||||
//纹理矩阵
|
||||
static const GLfloat textureVertices[] = {
|
||||
0.0f, 1.0f,
|
||||
1.0f, 1.0f,
|
||||
0.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 1.0f,
|
||||
};
|
||||
//设置属性ATTRIB_VERTEX的顶点矩阵值以及格式
|
||||
glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, vertexVertices);
|
||||
|
@ -378,7 +378,7 @@ void CPlayWidget::resizeGL(int w, int h)
|
|||
m_nVideoW,
|
||||
m_nVideoH,
|
||||
0,
|
||||
GL_RGBA,
|
||||
GL_BGRA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
m_pBufRgb32);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>878</width>
|
||||
<height>732</height>
|
||||
<width>1208</width>
|
||||
<height>943</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -19,8 +19,8 @@
|
|||
<rect>
|
||||
<x>19</x>
|
||||
<y>20</y>
|
||||
<width>831</width>
|
||||
<height>630</height>
|
||||
<width>1171</width>
|
||||
<height>851</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -30,8 +30,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>878</width>
|
||||
<height>23</height>
|
||||
<width>1208</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in New Issue