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
qrhiwidget.h
Go to the documentation of this file.
1// Copyright (C) 2023 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 QRHIWIDGET_H
5#define QRHIWIDGET_H
6
7#include <QtWidgets/qwidget.h>
8
10
12class QRhi;
13class QRhiTexture;
17
18class Q_WIDGETS_EXPORT QRhiWidget : public QWidget
19{
21 Q_DECLARE_PRIVATE(QRhiWidget)
22 Q_PROPERTY(int sampleCount READ sampleCount WRITE setSampleCount NOTIFY sampleCountChanged)
23 Q_PROPERTY(TextureFormat colorBufferFormat READ colorBufferFormat WRITE setColorBufferFormat NOTIFY colorBufferFormatChanged)
24 Q_PROPERTY(QSize fixedColorBufferSize READ fixedColorBufferSize WRITE setFixedColorBufferSize NOTIFY fixedColorBufferSizeChanged)
25 Q_PROPERTY(bool mirrorVertically READ isMirrorVerticallyEnabled WRITE setMirrorVertically NOTIFY mirrorVerticallyChanged)
26 QDOC_PROPERTY(bool autoRenderTarget READ isAutoRenderTargetEnabled WRITE setAutoRenderTarget)
27
28public:
29 explicit QRhiWidget(QWidget *parent = nullptr, Qt::WindowFlags f = {});
30 ~QRhiWidget() override;
31
32 enum class Api {
33 Null,
34 OpenGL,
35 Metal,
36 Vulkan,
37 Direct3D11,
38 Direct3D12,
39 };
40 Q_ENUM(Api)
41
42 enum class TextureFormat {
43 RGBA8,
44 RGBA16F,
45 RGBA32F,
46 RGB10A2,
47 };
48 Q_ENUM(TextureFormat)
49
50 Api api() const;
51 void setApi(Api api);
52
53 bool isDebugLayerEnabled() const;
54 void setDebugLayerEnabled(bool enable);
55
56 int sampleCount() const;
57 void setSampleCount(int samples);
58
59 TextureFormat colorBufferFormat() const;
60 void setColorBufferFormat(TextureFormat format);
61
62 QSize fixedColorBufferSize() const;
63 void setFixedColorBufferSize(QSize pixelSize);
65
66 bool isMirrorVerticallyEnabled() const;
67 void setMirrorVertically(bool enabled);
68
69 QImage grabFramebuffer() const;
70
71protected:
72 bool isAutoRenderTargetEnabled() const;
73 void setAutoRenderTarget(bool enabled);
74
75 virtual void initialize(QRhiCommandBuffer *cb);
76 virtual void render(QRhiCommandBuffer *cb);
77 virtual void releaseResources();
78
79 QRhi *rhi() const;
80 QRhiTexture *colorTexture() const;
81 QRhiRenderBuffer *msaaColorBuffer() const;
82 QRhiTexture *resolveTexture() const;
83 QRhiRenderBuffer *depthStencilBuffer() const;
84 QRhiRenderTarget *renderTarget() const;
85
86 void resizeEvent(QResizeEvent *e) override;
87 void paintEvent(QPaintEvent *e) override;
88 bool event(QEvent *e) override;
89
95 void fixedColorBufferSizeChanged(const QSize &pixelSize);
97};
98
100
101#endif
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtGui
Definition qimage.h:37
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
\inmodule QtGui
Definition qrhi.h:1651
\inmodule QtGui
Definition qrhi.h:1094
\inmodule QtGui
Definition qrhi.h:1158
\inmodule QtGui
Definition qrhi.h:895
\inmodule QtWidgets
Definition qrhiwidget.h:19
void sampleCountChanged(int samples)
void renderFailed()
This signal is emitted whenever the widget is supposed to render to its backing texture (either due t...
void mirrorVerticallyChanged(bool enabled)
void fixedColorBufferSizeChanged(const QSize &pixelSize)
void colorBufferFormatChanged(TextureFormat format)
Api
Specifies the 3D API and QRhi backend to use.
Definition qrhiwidget.h:32
void frameSubmitted()
This signal is emitted after the widget's top-level window has finished composition and has \l{QRhi::...
TextureFormat
Specifies the format of the texture to which the QRhiWidget renders.
Definition qrhiwidget.h:42
void setFixedColorBufferSize(int w, int h)
Definition qrhiwidget.h:64
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
\inmodule QtCore
Definition qsize.h:25
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
Combined button and popup list for selecting options.
Definition qcompare.h:63
static bool initialize()
Definition qctf.cpp:94
GLsizei samples
GLfloat GLfloat GLfloat w
[0]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLboolean enable
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define QDOC_PROPERTY(text)
#define Q_SIGNALS
#define explicit
myWidget render(this)
QNetworkRequestFactory api
[0]