Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
14
16
17class Q_OPENGLWIDGETS_EXPORT QOpenGLWidget : public QWidget
18{
20 Q_DECLARE_PRIVATE(QOpenGLWidget)
21
22public:
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());
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
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
86
87#endif // QOPENGLWIDGET_H
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtGui
Definition qimage.h:37
\inmodule QtGui
\inmodule QtOpenGLWidgets
void aboutToResize()
This signal is emitted when the widget's size is changed and therefore the framebuffer object is goin...
void aboutToCompose()
This signal is emitted when the widget's top-level window is about to begin composing the textures of...
void frameSwapped()
This signal is emitted after the widget's top-level window has finished composition and returned from...
void resized()
This signal is emitted right after the framebuffer object has been recreated due to resizing the widg...
\inmodule QtGui
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void paintGL() override
[2]
widget setFormat(format)
Combined button and popup list for selecting options.
static void * context
GLfloat GLfloat GLfloat w
[0]
GLfloat GLfloat f
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLfloat GLfloat p
[1]
#define GLuint
#define Q_ENUM(x)
#define Q_OBJECT
#define Q_SIGNALS