void OGLWidget::paintGL(){ qDebug()<<"paint"; if (!m_funcs) return; m_funcs->glClearColor(0.2f, 0.3f, 0.3f, 1.0f); m_funcs->glClear(GL_COLOR_BUFFER_BIT); m_program->bind(); //texture m_funcs->glActiveTexture(GL_TEXTURE0); m_funcs->glBindTexture(GL_TEXTURE_2D, m_texture); m_program->setUniformValue("ourTexture", 0); //transform m_program->setUniformValue("transform",figure->GetTransform()); QOpenGLVertexArrayObject::Binder vaoBinder(&m_vao); m_funcs->glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); if(countFigures>1)//отрисовываем еще одну фигуру { m_program->setUniformValue("transform",figure1->GetTransform()); m_funcs->glDrawElements(GL_TRIANGLES, 6*countFigures, GL_UNSIGNED_INT, 0); } m_program->release(); m_funcs->glBindTexture(GL_TEXTURE_2D, 0); m_vao.release();}
#version 330 corelayout (location = 0) in vec3 position;layout (location = 1) in vec2 texCoord;out vec2 TexCoord;uniform mat4 transform;void main(){ gl_Position =transform * vec4(position.x, position.y, position.z, 1.0); TexCoord=vec2(texCoord.x,1.0 - texCoord.y);}