4#include <QtQuick/QQuickRhiItem>
16 QRhi *m_rhi =
nullptr;
17 std::unique_ptr<QRhiBuffer> m_vbuf;
18 std::unique_ptr<QRhiBuffer> m_ubuf;
19 std::unique_ptr<QRhiShaderResourceBindings> m_srb;
20 std::unique_ptr<QRhiGraphicsPipeline> m_pipeline;
34 float angle()
const {
return m_angle; }
62 if (
item->angle() != m_angle)
63 m_angle =
item->angle();
73 0.0f, 0.5f, 1.0f, 0.0f, 0.0f,
74 -0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
75 0.5f, -0.5f, 0.0f, 0.0f, 1.0f,
99 m_pipeline->setShaderStages({
105 { 5 *
sizeof(float) }
111 m_pipeline->setVertexInputLayout(inputLayout);
112 m_pipeline->setShaderResourceBindings(m_srb.get());
114 m_pipeline->create();
118 cb->resourceUpdate(resourceUpdates);
130 QMatrix4x4 modelViewProjection = m_viewProjection;
131 modelViewProjection.
rotate(m_angle, 0, 1, 0);
132 resourceUpdates->updateDynamicBuffer(m_ubuf.get(), 0, 64, modelViewProjection.constData());
135 cb->beginPass(
renderTarget(), clearColor, { 1.0f, 0 }, resourceUpdates);
137 cb->setGraphicsPipeline(m_pipeline.get());
140 cb->setShaderResources();
142 cb->setVertexInput(0, 1, &vbufBinding);
void render(QRhiCommandBuffer *cb) override
Called when the backing color buffer's contents needs updating.
void synchronize(QQuickRhiItem *item) override
This function is called on the render thread, if there is one, while the main/GUI thread is blocked.
void initialize(QRhiCommandBuffer *cb) override
Called when the item is initialized for the first time, when the associated texture's size,...
QQuickRhiItemRenderer * createRenderer() override
Reimplement this function to create and return a new instance of a QQuickRhiItemRenderer subclass.
The QColor class provides colors based on RGB, HSV or CMYK values.
static QColor fromRgbF(float r, float g, float b, float a=1.0)
Static convenience function that returns a QColor constructed from the RGB color values,...
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
void rotate(float angle, const QVector3D &vector)
Multiples this matrix by another that rotates coordinates through angle degrees about vector.
void perspective(float verticalAngle, float aspectRatio, float nearPlane, float farPlane)
Multiplies this matrix by another that applies a perspective projection.
void translate(const QVector3D &vector)
Multiplies this matrix by another that translates coordinates by the components of vector.
void update()
Schedules a call to updatePaintNode() for this item.
QRhiRenderTarget * renderTarget() const
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
virtual QSize pixelSize() const =0
QRhiRenderPassDescriptor * renderPassDescriptor() const
void uploadStaticBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Enqueues updating a region of a QRhiBuffer buf created with the type QRhiBuffer::Immutable or QRhiBuf...
static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf)
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
QRhiBuffer * newBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size)
QMatrix4x4 clipSpaceCorrMatrix() const
QRhiShaderResourceBindings * newShaderResourceBindings()
QRhiGraphicsPipeline * newGraphicsPipeline()
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
static QShader fromSerialized(const QByteArray &data)
Creates a new QShader instance from the given data.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
GLboolean GLboolean GLboolean GLboolean a
[7]
#define QML_NAMED_ELEMENT(NAME)
static float vertexData[]
static QShader getShader(const QString &name)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
QLatin1StringView QLatin1String