52 #include <QtOpenGL/QOpenGLShader>
73 "attribute highp vec4 vertex;\n"
74 "uniform highp mat4 matrix;\n"
77 " gl_Position = matrix * vertex;\n"
80 "uniform mediump vec4 color;\n"
83 " gl_FragColor = color;\n"
88 int vertexLocation =
program.attributeLocation(
"vertex");
89 int matrixLocation =
program.uniformLocation(
"matrix");
90 int colorLocation =
program.uniformLocation(
"color");
94 static GLfloat const triangleVertices[] = {
105 program.enableAttributeArray(vertexLocation);
106 program.setAttributeArray(vertexLocation, triangleVertices, 3);
107 program.setUniformValue(matrixLocation, pmvMatrix);
110 glDrawArrays(GL_TRIANGLES, 0, 3);
112 program.disableAttributeArray(vertexLocation);
The QColor class provides colors based on RGB, HSV or CMYK values.
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
void ortho(const QRect &rect)
The QObject class is the base class of all Qt objects.
The QOpenGLShader class allows OpenGL shaders to be compiled.
The QOpenGLShaderProgram class allows OpenGL shader programs to be linked and used.
The QRectF class defines a finite rectangle in the plane using floating point precision.
The QString class provides a Unicode character string.
typedef GLfloat(GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC)(GLuint path