aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/rendernode
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-06-26 15:08:47 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-07-01 14:20:49 +0200
commit08f9b552c3735e15f9bf58ab5908652b06e47e88 (patch)
treec36ba328ff34a49af32383dace76be6b4ccd2145 /tests/auto/quick/rendernode
parent8adc7bad2281596461cbf9557d2ca071113e095d (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 'tests/auto/quick/rendernode')
-rw-r--r--tests/auto/quick/rendernode/tst_rendernode.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp
index 98e31329a0..2397392419 100644
--- a/tests/auto/quick/rendernode/tst_rendernode.cpp
+++ b/tests/auto/quick/rendernode/tst_rendernode.cpp
@@ -44,6 +44,7 @@
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
#include <QtGui/qopenglcontext.h>
+#include <QtGui/qopenglfunctions.h>
#include <QtGui/qscreen.h>
#include <private/qsgrendernode_p.h>
@@ -86,8 +87,8 @@ public:
virtual void render(const RenderState &)
{
// If clip has been set, scissoring will make sure the right area is cleared.
- glClearColor(color.redF(), color.greenF(), color.blueF(), 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
+ QOpenGLContext::currentContext()->functions()->glClearColor(color.redF(), color.greenF(), color.blueF(), 1.0f);
+ QOpenGLContext::currentContext()->functions()->glClear(GL_COLOR_BUFFER_BIT);
}
QColor color;
@@ -129,9 +130,11 @@ private:
QColor m_color;
};
-class MessUpNode : public QSGRenderNode
+class MessUpNode : public QSGRenderNode, protected QOpenGLFunctions
{
public:
+ MessUpNode() : initialized(false) { }
+
virtual StateFlags changedStates()
{
return StateFlags(DepthState) | StencilState | ScissorState | ColorState | BlendState
@@ -140,17 +143,17 @@ public:
virtual void render(const RenderState &)
{
+ if (!initialized) {
+ initializeOpenGLFunctions();
+ initialized = true;
+ }
// Don't draw anything, just mess up the state
glViewport(10, 10, 10, 10);
glDisable(GL_SCISSOR_TEST);
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_EQUAL);
-#if defined(QT_OPENGL_ES)
glClearDepthf(1);
-#else
- glClearDepth(1);
-#endif
glClearStencil(42);
glClearColor(1.0f, 0.5f, 1.0f, 0.0f);
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@@ -163,6 +166,8 @@ public:
glFrontFace(frontFace == GL_CW ? GL_CCW : GL_CW);
glEnable(GL_CULL_FACE);
}
+
+ bool initialized;
};
class MessUpItem : public QQuickItem