summaryrefslogtreecommitdiffstats
path: root/tests/manual/examples/opengl/qopenglwindow/background_renderer.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/examples/opengl/qopenglwindow/background_renderer.h')
-rw-r--r--tests/manual/examples/opengl/qopenglwindow/background_renderer.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/manual/examples/opengl/qopenglwindow/background_renderer.h b/tests/manual/examples/opengl/qopenglwindow/background_renderer.h
new file mode 100644
index 0000000000..76c0bec6a8
--- /dev/null
+++ b/tests/manual/examples/opengl/qopenglwindow/background_renderer.h
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef FRAGMENT_TOY_H
+#define FRAGMENT_TOY_H
+
+#include <QObject>
+#include <QFile>
+#include <QDateTime>
+#if QT_CONFIG(filesystemwatcher)
+#include <QFileSystemWatcher>
+#endif
+#include <QOpenGLVertexArrayObject>
+#include <QOpenGLBuffer>
+#include <QOpenGLShaderProgram>
+#include <QOpenGLFunctions>
+
+#include <memory>
+
+class FragmentToy : public QObject, protected QOpenGLFunctions
+{
+ Q_OBJECT
+public:
+ explicit FragmentToy(const QString &fragmentSource, QObject *parent = nullptr);
+ ~FragmentToy();
+
+ void draw(const QSize &windowSize);
+
+private:
+ void fileChanged(const QString &path);
+ bool m_recompile_shaders;
+#if QT_CONFIG(filesystemwatcher)
+ QFileSystemWatcher m_watcher;
+#endif
+ QString m_fragment_file;
+ QDateTime m_fragment_file_last_modified;
+
+ std::unique_ptr<QOpenGLShaderProgram> m_program;
+ std::unique_ptr<QOpenGLShader> m_vertex_shader;
+ std::unique_ptr<QOpenGLShader> m_fragment_shader;
+ QOpenGLVertexArrayObject m_vao;
+ QOpenGLBuffer m_vertex_buffer;
+ GLuint m_vertex_coord_pos;
+};
+
+#endif //FRAGMENT_TOY_H