diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-06-26 15:08:47 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-07-01 14:20:49 +0200 |
commit | 08f9b552c3735e15f9bf58ab5908652b06e47e88 (patch) | |
tree | c36ba328ff34a49af32383dace76be6b4ccd2145 /examples/quick/scenegraph | |
parent | 8adc7bad2281596461cbf9557d2ca071113e095d (diff) |
Avoid direct GL calls in Qt Quick examples and tests
Change-Id: I204a5513708aeff5cae00d06d4f0c27c20a13ace
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'examples/quick/scenegraph')
5 files changed, 11 insertions, 5 deletions
diff --git a/examples/quick/scenegraph/openglunderqml/squircle.cpp b/examples/quick/scenegraph/openglunderqml/squircle.cpp index 91d69c90a4..5be12e6b62 100644 --- a/examples/quick/scenegraph/openglunderqml/squircle.cpp +++ b/examples/quick/scenegraph/openglunderqml/squircle.cpp @@ -91,6 +91,8 @@ void Squircle::handleWindowChanged(QQuickWindow *win) void Squircle::paint() { if (!m_program) { + initializeOpenGLFunctions(); + m_program = new QOpenGLShaderProgram(); m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, "attribute highp vec4 vertices;" diff --git a/examples/quick/scenegraph/openglunderqml/squircle.h b/examples/quick/scenegraph/openglunderqml/squircle.h index 449e02bbf1..203a174f3c 100644 --- a/examples/quick/scenegraph/openglunderqml/squircle.h +++ b/examples/quick/scenegraph/openglunderqml/squircle.h @@ -44,9 +44,10 @@ #include <QtQuick/QQuickItem> #include <QtGui/QOpenGLShaderProgram> +#include <QtGui/QOpenGLFunctions> //! [1] -class Squircle : public QQuickItem +class Squircle : public QQuickItem, protected QOpenGLFunctions { Q_OBJECT diff --git a/examples/quick/scenegraph/shared/logorenderer.cpp b/examples/quick/scenegraph/shared/logorenderer.cpp index 4c5927b543..afe73155b5 100644 --- a/examples/quick/scenegraph/shared/logorenderer.cpp +++ b/examples/quick/scenegraph/shared/logorenderer.cpp @@ -66,6 +66,8 @@ void LogoRenderer::paintQtLogo() void LogoRenderer::initialize() { + initializeOpenGLFunctions(); + glClearColor(0.1f, 0.1f, 0.2f, 1.0f); QOpenGLShader *vshader1 = new QOpenGLShader(QOpenGLShader::Vertex, &program1); diff --git a/examples/quick/scenegraph/shared/logorenderer.h b/examples/quick/scenegraph/shared/logorenderer.h index 48fbf87203..abc95439f7 100644 --- a/examples/quick/scenegraph/shared/logorenderer.h +++ b/examples/quick/scenegraph/shared/logorenderer.h @@ -44,12 +44,13 @@ #include <QtGui/qvector3d.h> #include <QtGui/qmatrix4x4.h> #include <QtGui/qopenglshaderprogram.h> +#include <QtGui/qopenglfunctions.h> #include <QTime> #include <QVector> -class LogoRenderer { - +class LogoRenderer : protected QOpenGLFunctions +{ public: LogoRenderer(); ~LogoRenderer(); diff --git a/examples/quick/scenegraph/textureinthread/threadrenderer.cpp b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp index 7ae47108f1..270a7f4323 100644 --- a/examples/quick/scenegraph/textureinthread/threadrenderer.cpp +++ b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp @@ -93,14 +93,14 @@ public slots: } m_renderFbo->bind(); - glViewport(0, 0, m_size.width(), m_size.height()); + context->functions()->glViewport(0, 0, m_size.width(), m_size.height()); m_logoRenderer->render(); // We need to flush the contents to the FBO before posting // the texture to the other thread, otherwise, we might // get unexpected results. - glFlush(); + context->functions()->glFlush(); m_renderFbo->bindDefault(); qSwap(m_renderFbo, m_displayFbo); |