summaryrefslogtreecommitdiffstats
path: root/tests/manual/rhi/rhiwidgetproto/examplewidget.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/rhi/rhiwidgetproto/examplewidget.h')
-rw-r--r--tests/manual/rhi/rhiwidgetproto/examplewidget.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/manual/rhi/rhiwidgetproto/examplewidget.h b/tests/manual/rhi/rhiwidgetproto/examplewidget.h
new file mode 100644
index 0000000000..a17fe7bce1
--- /dev/null
+++ b/tests/manual/rhi/rhiwidgetproto/examplewidget.h
@@ -0,0 +1,66 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef EXAMPLEWIDGET_H
+#define EXAMPLEWIDGET_H
+
+#include "rhiwidget.h"
+#include <rhi/qrhi.h>
+
+class ExampleRhiWidget : public QRhiWidget
+{
+public:
+ ExampleRhiWidget(QWidget *parent = nullptr, Qt::WindowFlags f = {});
+
+ void initialize(QRhi *rhi, QRhiTexture *outputTexture) override;
+ void render(QRhiCommandBuffer *cb) override;
+
+ void setCubeTextureText(const QString &s)
+ {
+ if (itemData.cubeText == s)
+ return;
+ itemData.cubeText = s;
+ itemData.cubeTextDirty = true;
+ update();
+ }
+
+ void setCubeRotation(float r)
+ {
+ if (itemData.cubeRotation == r)
+ return;
+ itemData.cubeRotation = r;
+ itemData.cubeRotationDirty = true;
+ update();
+ }
+
+private:
+ QRhi *m_rhi = nullptr;
+ QRhiTexture *m_output = nullptr;
+ QScopedPointer<QRhiRenderBuffer> m_ds;
+ QScopedPointer<QRhiTextureRenderTarget> m_rt;
+ QScopedPointer<QRhiRenderPassDescriptor> m_rp;
+
+ struct {
+ QRhiResourceUpdateBatch *resourceUpdates = nullptr;
+ QScopedPointer<QRhiBuffer> vbuf;
+ QScopedPointer<QRhiBuffer> ubuf;
+ QScopedPointer<QRhiShaderResourceBindings> srb;
+ QScopedPointer<QRhiGraphicsPipeline> ps;
+ QScopedPointer<QRhiSampler> sampler;
+ QScopedPointer<QRhiTexture> cubeTex;
+ QMatrix4x4 mvp;
+ } scene;
+
+ void initScene();
+ void updateMvp();
+ void updateCubeTexture();
+
+ struct {
+ QString cubeText;
+ bool cubeTextDirty = false;
+ float cubeRotation = 0.0f;
+ bool cubeRotationDirty = false;
+ } itemData;
+};
+
+#endif