openglunderqml6 将初始化放在一个函数里,,
首先初始化操作,注意一定不能把gentexture写到循环里边,这样会导致gpu内存溢出(另外关于顶点的定义有时可以直接写在初始化的时候,有有时必须写到循环里)
void SquircleRenderer::Init_opengl()
{
initializeOpenGLFunctions();
if (!m_program) {
m_program = new QOpenGLShaderProgram();
m_program->addShaderFromSourceCode(QOpenGLShader::Vertex,
"attribute highp vec4 vertexIn;"
"attribute highp vec2 textureIn;"
"varying vec2 textureOut;"
"void main(void) {"
"gl_Position = vertexIn;"
"textureOut = textureIn;}");
m_program->addShaderFromSourceCode(QOpenGLShader::Fragment,
"varying vec2 textureOut;"
"uniform sampler2D tex_y;"
"uniform sampler2D tex_u;"
"uniform sampler2D tex_v;"