51 #include "../shared/examplefw.h"
73 static float quadVertexData[] =
75 -0.5f, 0.5f, 0.0f, 0.0f,
76 -0.5f, -0.5f, 0.0f, 1.0f,
77 0.5f, -0.5f, 1.0f, 1.0f,
78 0.5f, 0.5f, 1.0f, 0.0f
81 static quint16 quadIndexData[] =
105 qWarning(
"3D textures are not supported");
113 d.releasePool <<
d.tex;
122 p.drawText(10, 10,
"Slice 2:\nWhite text on blue background");
127 d.initialUpdates->uploadTexture(
d.tex, uploadSlice2);
131 p.begin(&imgYellowText);
133 p.drawText(10, 10,
"Slice 0: Yellow text on green background");
138 d.initialUpdates->uploadTexture(
d.tex, uploadSlice0);
145 d.releasePool <<
d.rt;
146 d.rtRp =
d.rt->newCompatibleRenderPassDescriptor();
147 d.releasePool <<
d.rtRp;
148 d.rt->setRenderPassDescriptor(
d.rtRp);
154 d.releasePool <<
d.vbuf;
158 d.releasePool <<
d.ibuf;
160 d.initialUpdates->uploadStaticBuffer(
d.vbuf, 0,
sizeof(quadVertexData), quadVertexData);
161 d.initialUpdates->uploadStaticBuffer(
d.ibuf, quadIndexData);
165 d.releasePool <<
d.ubuf;
171 d.initialUpdates->updateDynamicBuffer(
d.ubuf,
m_r->
ubufAligned(72) *
i + 64, 4, &flip);
178 d.releasePool <<
d.sampler;
182 d.releasePool <<
d.srb;
190 d.releasePool <<
d.ps;
191 d.ps->setShaderStages({
197 { 4 *
sizeof(float) }
203 d.ps->setVertexInputLayout(inputLayout);
204 d.ps->setShaderResourceBindings(
d.srb);
205 d.ps->setRenderPassDescriptor(
m_rp);
212 d.releasePool.clear();
219 if (
d.initialUpdates) {
220 u->merge(
d.initialUpdates);
221 d.initialUpdates->release();
222 d.initialUpdates =
nullptr;
244 d.slice1ClearColor.setX(
d.slice1ClearColor.x() + 0.01f);
245 if (
d.slice1ClearColor.x() > 1.0f)
246 d.slice1ClearColor.setX(0.0f);
253 u->generateMips(
d.tex);
255 const QSize outputSizeInPixels =
m_sc->currentPixelSize();
257 cb->setGraphicsPipeline(
d.ps);
259 cb->setShaderResources(
d.srb, 1, &dynOfs);
260 cb->setViewport({ 0, 0, float(outputSizeInPixels.
width()), float(outputSizeInPixels.
height()) });
266 cb->setShaderResources(
d.srb, 1, &dynOfs);
270 cb->setShaderResources(
d.srb, 1, &dynOfs);
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
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)
The QImage class provides a hardware-independent image representation that allows direct access to th...
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.
const float * constData() const
void translate(const QVector3D &vector)
The QPainter class performs low-level painting on widgets and other paint devices.
QPair< QRhiBuffer *, quint32 > VertexInput
QPair< int, quint32 > DynamicOffset
int ubufAligned(int v) const
bool isYUpInFramebuffer() const
bool isFeatureSupported(QRhi::Feature feature) const
QRhiShaderResourceBindings * newShaderResourceBindings()
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={})
@ ThreeDimensionalTextures
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
static QRhiShaderResourceBinding uniformBufferWithDynamicOffset(int binding, StageFlags stage, QRhiBuffer *buf, int size)
static QRhiShaderResourceBinding sampledTexture(int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
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
The QVector3D class represents a vector or vertex in 3D space.
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)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
QList< QRhiResource * > releasePool
QRhiTextureRenderTarget * rt
QRhiRenderPassDescriptor * rtRp
QVector3D slice1ClearColor
QRhiShaderResourceBindings * srb
QRhiGraphicsPipeline * ps
QRhiResourceUpdateBatch * initialUpdates