diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-11-05 00:25:12 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-11-05 06:46:05 (GMT) |
commit | b91f1a2f749586014e8b28c6766015ff6ba62ee7 (patch) | |
tree | b7c4eebcd52754645f463b363a425ce163f643a9 /doc/src/snippets | |
parent | 23572588c4b0c759c14a6c1687e5bd86461e31e8 (diff) | |
download | Qt-b91f1a2f749586014e8b28c6766015ff6ba62ee7.zip Qt-b91f1a2f749586014e8b28c6766015ff6ba62ee7.tar.gz Qt-b91f1a2f749586014e8b28c6766015ff6ba62ee7.tar.bz2 |
Modify QGLShader and QGLShaderProgram in response to API review
Reviewed-by: Sarah Smith
Diffstat (limited to 'doc/src/snippets')
-rw-r--r-- | doc/src/snippets/code/src_opengl_qglshaderprogram.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp b/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp index 2997297..9a15f19 100644 --- a/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp +++ b/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp @@ -40,32 +40,32 @@ ****************************************************************************/ //! [0] -QGLShader shader(QGLShader::VertexShader); -shader.compile(code); +QGLShader shader(QGLShader::Vertex); +shader.compileSourceCode(code); QGLShaderProgram program(context); program.addShader(shader); program.link(); -program.enable(); +program.bind(); //! [0] //! [1] -program.addShader(QGLShader::VertexShader, +program.addShaderFromSourceCode(QGLShader::Vertex, "attribute highp vec4 vertex;\n" "attribute mediump mat4 matrix;\n" "void main(void)\n" "{\n" " gl_Position = matrix * vertex;\n" "}"); -program.addShader(QGLShader::FragmentShader, +program.addShaderFromSourceCode(QGLShader::Fragment, "uniform mediump vec4 color;\n" "void main(void)\n" "{\n" " gl_FragColor = color;\n" "}"); program.link(); -program.enable(); +program.bind(); int vertexLocation = program.attributeLocation("vertex"); int matrixLocation = program.attributeLocation("matrix"); @@ -84,9 +84,12 @@ QColor color(0, 255, 0, 255); QMatrix4x4 pmvMatrix; pmvMatrix.ortho(rect()); +program.enableAttributeArray(vertexLocation); program.setAttributeArray(vertexLocation, triangleVertices, 3); program.setUniformValue(matrixLocation, pmvMatrix); program.setUniformValue(colorLocation, color); glDrawArrays(GL_TRIANGLES, 0, 3); + +program.disableAttributeArray(vertexLocation); //! [2] |