blob: 94a50a6d9b4c46bf012ddebd8c182486046bb740 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef TESTRHIITEM_H
#define TESTRHIITEM_H
#include "rhiitem.h"
class TestRenderer : public RhiItemRenderer
{
public:
void initialize(QRhi *rhi, QRhiTexture *outputTexture) override;
void synchronize(RhiItem *item) override;
void render(QRhiCommandBuffer *cb) override;
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> tex;
QMatrix4x4 mvp;
} scene;
struct {
QColor color;
} itemData;
void initScene();
void updateTexture();
};
class TestRhiItem : public RhiItem
{
Q_OBJECT
QML_NAMED_ELEMENT(TestRhiItem)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
public:
RhiItemRenderer *createRenderer() override { return new TestRenderer; }
QColor color() const { return m_color; }
void setColor(QColor c);
signals:
void colorChanged();
private:
QColor m_color;
};
#endif
|