aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/scenegraph
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-03-25 14:17:26 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-27 16:54:15 +0100
commitd453b38415adcaef814ec54c3419673d2dbf4ce7 (patch)
tree868397d8cc2205760d8ca6c31e4545a2c3d0c3a1 /examples/quick/scenegraph
parent476ebf976f3010f3593cec34e5d9b31335ad72a4 (diff)
Fix reading of shader sources in scene graph example
Task-number: QTBUG-33080 Change-Id: I9219233ab7c7fbe89c0a9f1453d7c6aeeca498a1 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'examples/quick/scenegraph')
-rw-r--r--examples/quick/scenegraph/graph/linenode.cpp22
-rw-r--r--examples/quick/scenegraph/graph/noisynode.cpp15
-rw-r--r--examples/quick/scenegraph/graph/noisynode.h3
3 files changed, 8 insertions, 32 deletions
diff --git a/examples/quick/scenegraph/graph/linenode.cpp b/examples/quick/scenegraph/graph/linenode.cpp
index 015aa4f0ee..0c63129ea8 100644
--- a/examples/quick/scenegraph/graph/linenode.cpp
+++ b/examples/quick/scenegraph/graph/linenode.cpp
@@ -40,8 +40,6 @@
#include "linenode.h"
-#include <QtCore/QResource>
-
#include <QtGui/QColor>
#include <QtQuick/QSGSimpleMaterial>
@@ -58,14 +56,10 @@ class LineShader : public QSGSimpleMaterialShader<LineMaterial>
QSG_DECLARE_SIMPLE_SHADER(LineShader, LineMaterial)
public:
- LineShader()
- : vsh(readResource(":/scenegraph/graph/shaders/line.vsh")),
- fsh(readResource(":/scenegraph/graph/shaders/line.fsh"))
- {}
-
- const char *vertexShader() const { return vsh.constData(); }
-
- const char *fragmentShader() const { return fsh.constData(); }
+ LineShader() {
+ setShaderSourceFile(QOpenGLShader::Vertex, ":/scenegraph/graph/shaders/line.vsh");
+ setShaderSourceFile(QOpenGLShader::Fragment, ":/scenegraph/graph/shaders/line.fsh");
+ }
QList<QByteArray> attributes() const { return QList<QByteArray>() << "pos" << "t"; }
@@ -81,15 +75,7 @@ public:
id_color = program()->uniformLocation("color");
}
- static QByteArray readResource(const char *path) {
- QResource r(path);
- Q_ASSERT(r.isValid());
- return QByteArray((const char *)r.data(), r.size());
- }
-
private:
- QByteArray vsh;
- QByteArray fsh;
int id_color;
int id_spread;
int id_size;
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp
index 1fc87a2b97..7b2a843409 100644
--- a/examples/quick/scenegraph/graph/noisynode.cpp
+++ b/examples/quick/scenegraph/graph/noisynode.cpp
@@ -40,8 +40,6 @@
#include "noisynode.h"
-#include <QtCore/QResource>
-
#include <QtQuick/QSGSimpleMaterialShader>
#include <QtQuick/QSGTexture>
#include <QtQuick/QQuickWindow>
@@ -63,16 +61,9 @@ class NoisyShader : public QSGSimpleMaterialShader<NoisyMaterial>
QSG_DECLARE_SIMPLE_SHADER(NoisyShader, NoisyMaterial)
public:
- const char *vertexShader() const {
- QResource r(":/scenegraph/graph/shaders/noisy.vsh");
- Q_ASSERT(r.isValid());
- return (const char *) r.data();
- }
-
- const char *fragmentShader() const {
- QResource r(":/scenegraph/graph/shaders/noisy.fsh");
- Q_ASSERT(r.isValid());
- return (const char *) r.data();
+ NoisyShader() {
+ setShaderSourceFile(QOpenGLShader::Vertex, ":/scenegraph/graph/shaders/noisy.vsh");
+ setShaderSourceFile(QOpenGLShader::Fragment, ":/scenegraph/graph/shaders/noisy.fsh");
}
QList<QByteArray> attributes() const { return QList<QByteArray>() << "aVertex" << "aTexCoord"; }
diff --git a/examples/quick/scenegraph/graph/noisynode.h b/examples/quick/scenegraph/graph/noisynode.h
index b5a291330f..348efc66d2 100644
--- a/examples/quick/scenegraph/graph/noisynode.h
+++ b/examples/quick/scenegraph/graph/noisynode.h
@@ -42,8 +42,7 @@
#define NOISYNODE_H
#include <QSGGeometryNode>
-
-class QQuickWindow;
+#include <QQuickWindow>
class NoisyNode : public QSGGeometryNode
{