Debian Codegraph @

tests/manual/examples/opengl/qopenglwindow/background_renderer.h

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4 #ifndef FRAGMENT_TOY_H
5 #define FRAGMENT_TOY_H
6
7 #include <QObject>
8 #include <QFile>
9 #include <QDateTime>
10 #if QT_CONFIG(filesystemwatcher)
11 #include <QFileSystemWatcher>
12 #endif
13 #include <QOpenGLVertexArrayObject>
14 #include <QOpenGLBuffer>
15 #include <QOpenGLShaderProgram>
16 #include <QOpenGLFunctions>
17
18 #include <memory>
19
20 class FragmentToy : public QObject, protected QOpenGLFunctions
21 {
22 Q_OBJECT
23 public:
24 explicit FragmentToy(const QString &fragmentSource, QObject *parent = nullptr);
25 ~FragmentToy();
26
27 void draw(const QSize &windowSize);
28
29 private:
30 void fileChanged(const QString &path);
31 bool m_recompile_shaders;
32 #if QT_CONFIG(filesystemwatcher)
33 QFileSystemWatcher m_watcher;
34 #endif
35 QString m_fragment_file;
36 QDateTime m_fragment_file_last_modified;
37
38 std::unique_ptr<QOpenGLShaderProgram> m_program;
39 std::unique_ptr<QOpenGLShader> m_vertex_shader;
40 std::unique_ptr<QOpenGLShader> m_fragment_shader;
41 QOpenGLVertexArrayObject m_vao;
42 QOpenGLBuffer m_vertex_buffer;
43 GLuint m_vertex_coord_pos;
44 };
45
46 #endif //FRAGMENT_TOY_H