| 1 |
// Copyright (C) 2018 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#ifndef TRIANGLERENDERER_H |
| 5 |
#define TRIANGLERENDERER_H |
| 6 |
|
| 7 |
#include <rhi/qrhi.h> |
| 8 |
|
| 9 |
class TriangleRenderer |
| 10 |
{ |
| 11 |
public: |
| 12 |
void setRhi(QRhi *r) { m_r = r; } |
| 13 |
void setSampleCount(int samples) { m_sampleCount = samples; } |
| 14 |
int sampleCount() const { return m_sampleCount; } |
| 15 |
void setTranslation(const QVector3D &v) { m_translation = v; } |
| 16 |
void setScale(float f) { m_scale = f; } |
| 17 |
void setDepthWrite(bool enable) { m_depthWrite = enable; } |
| 18 |
void setColorAttCount(int count) { m_colorAttCount = count; } |
| 19 |
QRhiGraphicsPipeline *pipeline() const { return m_ps; } |
| 20 |
void initResources(QRhiRenderPassDescriptor *rp); |
| 21 |
void releaseResources(); |
| 22 |
void resize(const QSize &pixelSize); |
| 23 |
void queueResourceUpdates(QRhiResourceUpdateBatch *resourceUpdates); |
| 24 |
void queueDraw(QRhiCommandBuffer *cb, const QSize &outputSizeInPixels); |
| 25 |
|
| 26 |
private: |
| 27 |
QRhi *m_r; |
| 28 |
|
| 29 |
QRhiBuffer *m_vbuf = nullptr; |
| 30 |
bool m_vbufReady = false; |
| 31 |
QRhiBuffer *m_ubuf = nullptr; |
| 32 |
QRhiShaderResourceBindings *m_srb = nullptr; |
| 33 |
QRhiGraphicsPipeline *m_ps = nullptr; |
| 34 |
|
| 35 |
QVector3D m_translation; |
| 36 |
float m_scale = 1; |
| 37 |
bool m_depthWrite = false; |
| 38 |
int m_colorAttCount = 1; |
| 39 |
QMatrix4x4 m_proj; |
| 40 |
float m_rotation = 0; |
| 41 |
float m_opacity = 1; |
| 42 |
int m_opacityDir = -1; |
| 43 |
int m_sampleCount = 1; // no MSAA by default |
| 44 |
}; |
| 45 |
|
| 46 |
#endif |