Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qopenglwidget.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QOPENGLWIDGET_H
6#define QOPENGLWIDGET_H
7
8#include <QtOpenGLWidgets/qtopenglwidgetsglobal.h>
9
10#include <QtWidgets/QWidget>
11#include <QtGui/QSurfaceFormat>
12#include <QtGui/qopengl.h>
13
14QT_BEGIN_NAMESPACE
15
16class QOpenGLWidgetPrivate;
17
18class Q_OPENGLWIDGETS_EXPORT QOpenGLWidget : public QWidget
19{
20 Q_OBJECT
21 Q_DECLARE_PRIVATE(QOpenGLWidget)
22
23public:
24 enum UpdateBehavior {
25 NoPartialUpdate,
26 PartialUpdate
27 };
28 Q_ENUM(UpdateBehavior)
29
30 enum TargetBuffer : uint8_t {
31 LeftBuffer = 0, // Default
32 RightBuffer // Only used when QSurfaceFormat::StereoBuffers is enabled
33 };
34 Q_ENUM(TargetBuffer)
35
36 explicit QOpenGLWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
37 ~QOpenGLWidget();
38
39 void setUpdateBehavior(UpdateBehavior updateBehavior);
40 UpdateBehavior updateBehavior() const;
41
42 void setFormat(const QSurfaceFormat &format);
43 QSurfaceFormat format() const;
44
45 GLenum textureFormat() const;
46 void setTextureFormat(GLenum texFormat);
47
48 bool isValid() const;
49
50 void makeCurrent();
51 void makeCurrent(TargetBuffer targetBuffer);
52 void doneCurrent();
53
54 QOpenGLContext *context() const;
55 GLuint defaultFramebufferObject() const;
56 GLuint defaultFramebufferObject(TargetBuffer targetBuffer) const;
57
58 QImage grabFramebuffer();
59 QImage grabFramebuffer(TargetBuffer targetBuffer);
60
61 TargetBuffer currentTargetBuffer() const;
62
63Q_SIGNALS:
64 void aboutToCompose();
65 void frameSwapped();
66 void aboutToResize();
67 void resized();
68
69protected:
70 virtual void initializeGL();
71 virtual void resizeGL(int w, int h);
72 virtual void paintGL();
73
74 void paintEvent(QPaintEvent *e) override;
75 void resizeEvent(QResizeEvent *e) override;
76 bool event(QEvent *e) override;
77
78 int metric(QPaintDevice::PaintDeviceMetric metric) const override;
79 QPaintDevice *redirected(QPoint *p) const override;
80 QPaintEngine *paintEngine() const override;
81
82private:
83 Q_DISABLE_COPY(QOpenGLWidget)
84};
85
86QT_END_NAMESPACE
87
88#endif // QOPENGLWIDGET_H
QOpenGLWidgetPaintDevicePrivate(QOpenGLWidget *widget)
QOpenGLWidgetPaintDevice(QOpenGLWidget *widget)
void ensureActiveTarget() override
This virtual method is provided as a callback to allow re-binding a target frame buffer object or con...
void endBackingStorePainting() override
void beginCompose() override
QOpenGLFramebufferObject * resolvedFbos[2]
QPlatformTextureList::Flags textureListFlags() override
bool setCurrentTargetBuffer(QOpenGLWidget::TargetBuffer targetBuffer)
static constexpr GLenum gl_color_attachment0
static constexpr GLenum gl_depth_attachment
void initializeViewportFramebuffer() override
QWidgetPrivate::TextureData texture() const override
QOpenGLContext * context
static constexpr GLenum gl_depth_stencil_attachment
static constexpr GLenum gl_stencil_attachment
void beginBackingStorePainting() override
void endCompose() override
QPlatformBackingStoreRhiConfig rhiConfig() const override
QOpenGLPaintDevice * paintDevice
QImage grabFramebuffer(QOpenGLWidget::TargetBuffer targetBuffer)
QImage grabFramebuffer() override
void resolveSamplesForBuffer(QOpenGLWidget::TargetBuffer targetBuffer)
QSurfaceFormat requestedFormat
void resolveSamples() override
bool isStereoEnabled() override
void resizeViewportFramebuffer() override
QOffscreenSurface * surface
QRhiTexture * wrapperTextures[2]
bool toggleStereoTargetBuffer() override
QOpenGLFramebufferObject * fbos[2]
\inmodule QtOpenGLWidgets
Combined button and popup list for selecting options.
#define GL_SRGB_ALPHA
Definition qopenglext.h:864
#define GL_SRGB8_ALPHA8
Definition qopenglext.h:865
#define GL_SRGB
Definition qopenglext.h:862
#define GL_SRGB8
Definition qopenglext.h:863