| 1 |
// Copyright (C) 2018 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#ifndef TRIANGLEONCUBERENDERER_H |
| 5 |
#define TRIANGLEONCUBERENDERER_H |
| 6 |
|
| 7 |
#include "trianglerenderer.h" |
| 8 |
|
| 9 |
class TriangleOnCubeRenderer |
| 10 |
{ |
| 11 |
public: |
| 12 |
void setRhi(QRhi *r) { m_r = r; } |
| 13 |
void setSampleCount(int samples) { m_sampleCount = samples; } |
| 14 |
void setTranslation(const QVector3D &v) { m_translation = v; } |
| 15 |
void initResources(QRhiRenderPassDescriptor *rp); |
| 16 |
void releaseResources(); |
| 17 |
void resize(const QSize &pixelSize); |
| 18 |
void queueResourceUpdates(QRhiResourceUpdateBatch *resourceUpdates); |
| 19 |
void queueOffscreenPass(QRhiCommandBuffer *cb); |
| 20 |
void queueDraw(QRhiCommandBuffer *cb, const QSize &outputSizeInPixels); |
| 21 |
|
| 22 |
private: |
| 23 |
QRhi *m_r; |
| 24 |
|
| 25 |
QRhiBuffer *m_vbuf = nullptr; |
| 26 |
bool m_vbufReady = false; |
| 27 |
QRhiBuffer *m_ubuf = nullptr; |
| 28 |
QRhiTexture *m_tex = nullptr; |
| 29 |
QRhiRenderBuffer *m_ds = nullptr; |
| 30 |
QRhiTexture *m_tex2 = nullptr; |
| 31 |
QRhiTexture *m_depthTex = nullptr; |
| 32 |
QRhiSampler *m_sampler = nullptr; |
| 33 |
QRhiTextureRenderTarget *m_rt = nullptr; |
| 34 |
QRhiRenderPassDescriptor *m_rp = nullptr; |
| 35 |
QRhiShaderResourceBindings *m_srb = nullptr; |
| 36 |
QRhiGraphicsPipeline *m_ps = nullptr; |
| 37 |
|
| 38 |
QVector3D m_translation; |
| 39 |
QMatrix4x4 m_proj; |
| 40 |
float m_rotation = 0; |
| 41 |
int m_sampleCount = 1; // no MSAA by default |
| 42 |
|
| 43 |
TriangleRenderer m_offscreenTriangle; |
| 44 |
|
| 45 |
QImage m_image; |
| 46 |
}; |
| 47 |
|
| 48 |
#endif |