05fc3aef53
Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
// Copyright (C) 2021 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#ifndef EXAMPLEWIDGET_H
|
|
#define EXAMPLEWIDGET_H
|
|
|
|
#include "rhiwidget.h"
|
|
#include <QtGui/private/qrhi_p.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
|