const char *rcvsrc = "#version 330 core\n \
layout(location = 0) in vec3 aPos;\n \
uniform vec2 offtP; \
void main(){\n \
gl_Position = vec4(aPos.x + offtP.x, aPos.y + offtP.y, aPos.z, 1.0f);\n \
}\n ";
const char *rcfsrc = "#version 330 core\n \
out vec4 FragColor;\n \
void main(){\n \
FragColor = vec4(1.0f, 0.0f, 0.0f, 1.0f);\n \
}\n ";
videoProgram.addCacheableShaderFromSourceCode(QOpenGLShader::Vertex,vsrc); videoProgram.addCacheableShaderFromSourceCode(QOpenGLShader::Fragment,fsrc); videoProgram.link();
rcProgram.addShaderFromSourceCode(QOpenGLShader::Vertex,rcvsrc);断的成语
rcProgram.addShaderFromSourceCode(QOpenGLShader::Fragment,rcfsrc);
rcProgram.link();
{
QOpenGLVertexArrayObject::Binder vaoBind(&rcvao);
GLfloat rcPoints[]{
0.25f, 0.25f, 0.0f, // top right
0.25f, -0.25f, 0.0f, // bottom right
-0.25f, -0.25f, 0.0f, // bottom left
-0.25f, 0.25f, 0.0f, // top left
};
rcvbo.bind();
rcvbo.allocate(rcPoints, sizeof(rcPoints));
int attr = -1;
attr = rcProgram.attributeLocation("aPos");
rcProgram.tAttributeBuffer(attr, GL_FLOAT, 0, 3, sizeof(GLfloat) * 3);
}
{
QOpenGLVertexArrayObject::Binder vaoBind(&vao);
GLfloat points[]{
-1.0f, 1.0f,
1.0f, 1.0f,
1.0f, -1.0f,
-1.0f, -1.0f,
0.0f,0.0f,
1.0f,0.0f,
动作的词语1.0f,1.0f,
高中音乐教材0.0f,1.0f
};
vbo.bind();
vbo.allocate(points,sizeof(points));
m_pTextureY = std::make_unique<QOpenGLTexture>(QOpenGLTexture::Target2D); m_pTextureU = std::make_unique<QOpenGLTexture>(QOpenGLTexture::Target2D); m_pTextureV = std::make_unique<QOpenGLTexture>(QOpenGLTexture::Target2D); m_pTextureY->create();
m_pTextureU->create();
m_pTextureV->create();
int attr = -1;
attr = videoProgram.attributeLocation("vertexIn");
videoProgram.tAttributeBuffer(attr, GL_FLOAT, 0, 2, 2*sizeof(GLfloat));
attr = videoProgram.attributeLocation("textureIn");
videoProgram.tAttributeBuffer(attr, GL_FLOAT, 2 * 4 * sizeof(GLfloat),2,2*sizeof(GLfloat));
}
}
void RenderWidget::render(uchar *yuvPtr, int w, int h)
教师节庆祝活动{
m_nCount++;
// glDisable(GL_DEPTH_TEST);玉米虾仁
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
if(nullptr == yuvPtr || 0 >= w || 0 >= h){
return;
}
videoProgram.bind();
举世混浊
{
拼魔方的教程
QOpenGLVertexArrayObject::Binder vaoBind(&vao);
//Y
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, m_pTextureY->textureId());
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w, h, 0, GL_RED,GL_UNSIGNED_BYTE, yuvPtr);
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);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//U
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_pTextureU->textureId());
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w >> 1, h >> 1, 0, GL_RED,GL_UNSIGNED_BYTE, yuvPtr + w * h);
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);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//V
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_pTextureV->textureId());
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w >> 1, h >> 1, 0, GL_RED, GL_UNSIGNED_BYTE, yuvPtr + w * h * 5 / 4); glTexParameteri(GL_TEXTURE_2D,GL_TEXTU
RE_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);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
三年级寓言故事
videoProgram.tUniformValue("tex_y",2);
videoProgram.tUniformValue("tex_u",1);
videoProgram.tUniformValue("tex_v",0);
glDrawArrays(GL_QUADS, 0, 4);
}
rcProgram.bind();
{
QOpenGLVertexArrayObject::Binder rcvaoBind(&rcvao);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
float offt = sin(m_nCount * 0.1f);
rcProgram.tUniformValue("offtP", QVector2D(offt, 0.7f));
glDrawArrays(GL_QUADS, 0, 4);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}