2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2014-03-20 11:58:22 +00:00
|
|
|
|
|
|
|
#ifndef FRAGMENT_TOY_H
|
|
|
|
#define FRAGMENT_TOY_H
|
|
|
|
|
2014-08-06 08:25:36 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QDateTime>
|
2018-09-26 06:56:36 +00:00
|
|
|
#if QT_CONFIG(filesystemwatcher)
|
2014-08-06 08:25:36 +00:00
|
|
|
#include <QFileSystemWatcher>
|
2018-09-26 06:56:36 +00:00
|
|
|
#endif
|
2014-08-06 08:25:36 +00:00
|
|
|
#include <QOpenGLVertexArrayObject>
|
|
|
|
#include <QOpenGLBuffer>
|
|
|
|
#include <QOpenGLShaderProgram>
|
|
|
|
#include <QOpenGLFunctions>
|
2014-03-20 11:58:22 +00:00
|
|
|
|
2019-05-14 18:42:01 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2014-03-20 11:58:22 +00:00
|
|
|
class FragmentToy : public QObject, protected QOpenGLFunctions
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-05-14 18:42:01 +00:00
|
|
|
explicit FragmentToy(const QString &fragmentSource, QObject *parent = nullptr);
|
|
|
|
~FragmentToy();
|
2014-03-20 11:58:22 +00:00
|
|
|
|
|
|
|
void draw(const QSize &windowSize);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void fileChanged(const QString &path);
|
|
|
|
bool m_recompile_shaders;
|
2018-09-26 06:56:36 +00:00
|
|
|
#if QT_CONFIG(filesystemwatcher)
|
2014-03-20 11:58:22 +00:00
|
|
|
QFileSystemWatcher m_watcher;
|
|
|
|
#endif
|
|
|
|
QString m_fragment_file;
|
|
|
|
QDateTime m_fragment_file_last_modified;
|
|
|
|
|
2019-05-14 18:42:01 +00:00
|
|
|
std::unique_ptr<QOpenGLShaderProgram> m_program;
|
|
|
|
std::unique_ptr<QOpenGLShader> m_vertex_shader;
|
|
|
|
std::unique_ptr<QOpenGLShader> m_fragment_shader;
|
2014-03-20 11:58:22 +00:00
|
|
|
QOpenGLVertexArrayObject m_vao;
|
|
|
|
QOpenGLBuffer m_vertex_buffer;
|
|
|
|
GLuint m_vertex_coord_pos;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //FRAGMENT_TOY_H
|