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
4#ifndef QOPENGLWIDGET_H
5#define QOPENGLWIDGET_H
6
7#include <QtOpenGLWidgets/qtopenglwidgetsglobal.h>
8
9#include <QtWidgets/QWidget>
10#include <QtGui/QSurfaceFormat>
11#include <QtGui/qopengl.h>
12
13QT_BEGIN_NAMESPACE
14
15class QOpenGLWidgetPrivate;
16
17class Q_OPENGLWIDGETS_EXPORT QOpenGLWidget : public QWidget
18{
19 Q_OBJECT
20 Q_DECLARE_PRIVATE(QOpenGLWidget)
21
22public:
23 enum UpdateBehavior {
24 NoPartialUpdate,
25 PartialUpdate
26 };
27 Q_ENUM(UpdateBehavior)
28
29 enum TargetBuffer : uint8_t {
30 LeftBuffer = 0, // Default
31 RightBuffer // Only used when QSurfaceFormat::StereoBuffers is enabled
32 };
33 Q_ENUM(TargetBuffer)
34
35 explicit QOpenGLWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
36 ~QOpenGLWidget();
37
38 void setUpdateBehavior(UpdateBehavior updateBehavior);
39 UpdateBehavior updateBehavior() const;
40
41 void setFormat(const QSurfaceFormat &format);
42 QSurfaceFormat format() const;
43
44 GLenum textureFormat() const;
45 void setTextureFormat(GLenum texFormat);
46
47 bool isValid() const;
48
49 void makeCurrent();
50 void makeCurrent(TargetBuffer targetBuffer);
51 void doneCurrent();
52
53 QOpenGLContext *context() const;
54 GLuint defaultFramebufferObject() const;
55 GLuint defaultFramebufferObject(TargetBuffer targetBuffer) const;
56
57 QImage grabFramebuffer();
58 QImage grabFramebuffer(TargetBuffer targetBuffer);
59
60 TargetBuffer currentTargetBuffer() const;
61
62Q_SIGNALS:
63 void aboutToCompose();
64 void frameSwapped();
65 void aboutToResize();
66 void resized();
67
68protected:
69 virtual void initializeGL();
70 virtual void resizeGL(int w, int h);
71 virtual void paintGL();
72
73 void paintEvent(QPaintEvent *e) override;
74 void resizeEvent(QResizeEvent *e) override;
75 bool event(QEvent *e) override;
76
77 int metric(QPaintDevice::PaintDeviceMetric metric) const override;
78 QPaintDevice *redirected(QPoint *p) const override;
79 QPaintEngine *paintEngine() const override;
80
81private:
82 Q_DISABLE_COPY(QOpenGLWidget)
83};
84
85QT_END_NAMESPACE
86
87#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