2022-05-10 12:06:48 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2012-06-05 13:21:55 +02:00
|
|
|
|
2023-01-30 14:32:42 +01:00
|
|
|
#ifndef OPENGLWINDOW_H
|
|
|
|
#define OPENGLWINDOW_H
|
|
|
|
|
2019-09-13 20:43:09 +02:00
|
|
|
#include <QWindow>
|
|
|
|
#include <QOpenGLFunctions>
|
2012-06-05 13:21:55 +02:00
|
|
|
|
2023-05-16 10:44:34 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QPainter)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QOpenGLContext)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QOpenGLPaintDevice)
|
2012-06-05 13:21:55 +02:00
|
|
|
|
|
|
|
//! [1]
|
|
|
|
class OpenGLWindow : public QWindow, protected QOpenGLFunctions
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-09-13 20:43:09 +02:00
|
|
|
explicit OpenGLWindow(QWindow *parent = nullptr);
|
2012-06-05 13:21:55 +02:00
|
|
|
~OpenGLWindow();
|
|
|
|
|
|
|
|
virtual void render(QPainter *painter);
|
|
|
|
virtual void render();
|
|
|
|
|
|
|
|
virtual void initialize();
|
|
|
|
|
|
|
|
void setAnimating(bool animating);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void renderLater();
|
|
|
|
void renderNow();
|
|
|
|
|
|
|
|
protected:
|
2016-06-15 10:12:35 +02:00
|
|
|
bool event(QEvent *event) override;
|
2012-06-05 13:21:55 +02:00
|
|
|
|
2016-06-15 10:12:35 +02:00
|
|
|
void exposeEvent(QExposeEvent *event) override;
|
2012-06-05 13:21:55 +02:00
|
|
|
|
|
|
|
private:
|
2019-09-13 20:43:09 +02:00
|
|
|
bool m_animating = false;
|
2012-06-05 13:21:55 +02:00
|
|
|
|
2019-09-13 20:43:09 +02:00
|
|
|
QOpenGLContext *m_context = nullptr;
|
|
|
|
QOpenGLPaintDevice *m_device = nullptr;
|
2012-06-05 13:21:55 +02:00
|
|
|
};
|
|
|
|
//! [1]
|
|
|
|
|
2023-01-30 14:32:42 +01:00
|
|
|
#endif // OPENGLWINDOW_H
|