1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QOPENGLWINDOW_H |
5 | #define QOPENGLWINDOW_H |
6 | |
7 | #include <QtOpenGL/qtopenglglobal.h> |
8 | |
9 | #ifndef QT_NO_OPENGL |
10 | |
11 | #include <QtGui/QPaintDeviceWindow> |
12 | #include <QtGui/QOpenGLContext> |
13 | #include <QtGui/QImage> |
14 | |
15 | QT_BEGIN_NAMESPACE |
16 | |
17 | class QOpenGLWindowPrivate; |
18 | |
19 | class Q_OPENGL_EXPORT QOpenGLWindow : public QPaintDeviceWindow |
20 | { |
21 | Q_OBJECT |
22 | Q_DECLARE_PRIVATE(QOpenGLWindow) |
23 | |
24 | public: |
25 | enum UpdateBehavior { |
26 | NoPartialUpdate, |
27 | PartialUpdateBlit, |
28 | PartialUpdateBlend |
29 | }; |
30 | |
31 | explicit QOpenGLWindow(UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = nullptr); |
32 | explicit QOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = nullptr); |
33 | ~QOpenGLWindow(); |
34 | |
35 | UpdateBehavior updateBehavior() const; |
36 | bool isValid() const; |
37 | |
38 | void makeCurrent(); |
39 | void doneCurrent(); |
40 | |
41 | QOpenGLContext *context() const; |
42 | QOpenGLContext *shareContext() const; |
43 | |
44 | GLuint defaultFramebufferObject() const; |
45 | |
46 | QImage grabFramebuffer(); |
47 | |
48 | Q_SIGNALS: |
49 | void frameSwapped(); |
50 | |
51 | protected: |
52 | virtual void initializeGL(); |
53 | virtual void resizeGL(int w, int h); |
54 | virtual void paintGL(); |
55 | virtual void paintUnderGL(); |
56 | virtual void paintOverGL(); |
57 | |
58 | void paintEvent(QPaintEvent *event) override; |
59 | void resizeEvent(QResizeEvent *event) override; |
60 | int metric(PaintDeviceMetric metric) const override; |
61 | QPaintDevice *redirected(QPoint *) const override; |
62 | |
63 | private: |
64 | Q_DISABLE_COPY(QOpenGLWindow) |
65 | }; |
66 | |
67 | QT_END_NAMESPACE |
68 | |
69 | #endif // QT_NO_OPENGL |
70 | |
71 | #endif |
72 |