51 #include "../shared/examplefw.h"
56 static float vertexData[] =
58 -0.5f, 0.5f, 0.0f, 0.0f,
59 -0.5f, -0.5f, 0.0f, 1.0f,
60 0.5f, -0.5f, 1.0f, 1.0f,
61 0.5f, 0.5f, 1.0f, 0.0f
69 static float triangleData[] =
71 0.0f, 0.5f, 1.0f, 0.0f, 0.0f,
72 -0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
73 0.5f, -0.5f, 0.0f, 0.0f, 1.0f,
101 d.releasePool <<
d.vbuf;
105 d.releasePool <<
d.ibuf;
109 d.releasePool <<
d.ubuf;
113 d.releasePool <<
d.rb;
117 d.releasePool <<
d.tex;
128 d.releasePool <<
d.rt;
129 d.rtRp =
d.rt->newCompatibleRenderPassDescriptor();
130 d.releasePool <<
d.rtRp;
131 d.rt->setRenderPassDescriptor(
d.rtRp);
135 d.releasePool <<
d.triUbuf;
139 d.releasePool <<
d.triSrb;
140 d.triSrb->setBindings({
146 d.releasePool <<
d.triPs;
147 d.triPs->setSampleCount(4);
148 d.triPs->setShaderStages({
154 { 5 *
sizeof(float) }
160 d.triPs->setVertexInputLayout(inputLayout);
161 d.triPs->setShaderResourceBindings(
d.triSrb);
162 d.triPs->setRenderPassDescriptor(
d.rtRp);
167 d.releasePool <<
d.sampler;
171 d.releasePool <<
d.srb;
179 d.releasePool <<
d.ps;
180 d.ps->setShaderStages({
185 { 4 *
sizeof(float) }
191 d.ps->setVertexInputLayout(inputLayout);
192 d.ps->setShaderResourceBindings(
d.srb);
193 d.ps->setRenderPassDescriptor(
m_rp);
197 d.initialUpdates->uploadStaticBuffer(
d.vbuf, 0,
sizeof(vertexData), vertexData);
198 d.initialUpdates->uploadStaticBuffer(
d.vbuf,
sizeof(vertexData),
sizeof(triangleData), triangleData);
199 d.initialUpdates->uploadStaticBuffer(
d.ibuf, indexData);
202 d.triBaseMvp.perspective(45.0f,
d.rb->pixelSize().width() / float(
d.rb->pixelSize().height()), 0.01f, 1000.0f);
203 d.triBaseMvp.translate(0, 0, -2);
205 d.initialUpdates->updateDynamicBuffer(
d.triUbuf, 64, 4, &
opacity);
208 d.initialUpdates->updateDynamicBuffer(
d.ubuf, 64, 4, &flip);
214 d.releasePool.clear();
221 if (
d.initialUpdates) {
222 u->merge(
d.initialUpdates);
223 d.initialUpdates->release();
224 d.initialUpdates =
nullptr;
228 triMvp.
rotate(
d.triRot, 0, 1, 0);
230 u->updateDynamicBuffer(
d.triUbuf, 0, 64, triMvp.
constData());
236 u->updateDynamicBuffer(
d.ubuf, 0, 64, mvp.
constData());
241 cb->setGraphicsPipeline(
d.triPs);
242 cb->setViewport({ 0, 0, float(
d.rb->pixelSize().width()), float(
d.rb->pixelSize().height()) });
243 cb->setShaderResources();
245 cb->setVertexInput(0, 1, &vbufBinding);
250 const QSize outputSizeInPixels =
m_sc->currentPixelSize();
252 cb->setGraphicsPipeline(
d.ps);
253 cb->setViewport({ 0, 0, float(outputSizeInPixels.
width()), float(outputSizeInPixels.
height()) });
254 cb->setShaderResources();
255 vbufBinding.second = 0;
small capitals from c petite p scientific f u
static QColor fromRgbF(float r, float g, float b, float a=1.0)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
void rotate(float angle, const QVector3D &vector)
void scale(const QVector3D &vector)
const float * constData() const
void setResolveTexture(QRhiTexture *tex)
QPair< QRhiBuffer *, quint32 > VertexInput
QMatrix4x4 clipSpaceCorrMatrix() const
bool isYUpInFramebuffer() const
QRhiShaderResourceBindings * newShaderResourceBindings()
QRhiRenderBuffer * newRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount=1, QRhiRenderBuffer::Flags flags={}, QRhiTexture::Format backingFormatHint=QRhiTexture::UnknownFormat)
QRhiBuffer * newBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, int size)
QRhiSampler * newSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode addressU, QRhiSampler::AddressMode addressV, QRhiSampler::AddressMode addressW=QRhiSampler::Repeat)
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
QRhiGraphicsPipeline * newGraphicsPipeline()
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
static QRhiShaderResourceBinding sampledTexture(int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf)
void setColorAttachments(std::initializer_list< QRhiColorAttachment > list)
The QSize class defines the size of a two-dimensional object using integer point precision.
constexpr int height() const noexcept
constexpr int width() const noexcept
qreal opacity
The opacity of the window in the windowing system.
std::unique_ptr< QRhiSwapChain > m_sc
std::unique_ptr< QRhiRenderPassDescriptor > m_rp
virtual void customRender()
virtual void customInit()
qDeleteAll(list.begin(), list.end())
QShader getShader(const QString &name)
QRhiShaderResourceBindings * triSrb
QList< QRhiResource * > releasePool
QRhiTextureRenderTarget * rt
QRhiRenderPassDescriptor * rtRp
QRhiGraphicsPipeline * triPs
QRhiShaderResourceBindings * srb
QRhiGraphicsPipeline * ps
QRhiResourceUpdateBatch * initialUpdates
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)