summaryrefslogtreecommitdiffstats
path: root/src/quick3d/quick3drender/items/quick3drendertargetoutput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick3d/quick3drender/items/quick3drendertargetoutput.cpp')
-rw-r--r--src/quick3d/quick3drender/items/quick3drendertargetoutput.cpp68
1 files changed, 32 insertions, 36 deletions
diff --git a/src/quick3d/quick3drender/items/quick3drendertargetoutput.cpp b/src/quick3d/quick3drender/items/quick3drendertargetoutput.cpp
index 5d35e7e00..810ded8b0 100644
--- a/src/quick3d/quick3drender/items/quick3drendertargetoutput.cpp
+++ b/src/quick3d/quick3drender/items/quick3drendertargetoutput.cpp
@@ -52,44 +52,40 @@ Quick3DRenderTargetOutput::Quick3DRenderTargetOutput(QObject * parent)
QQmlListProperty<QRenderTargetOutput> Quick3DRenderTargetOutput::qmlAttachments()
{
- return QQmlListProperty<QRenderTargetOutput>(this, 0,
- &Quick3DRenderTargetOutput::appendRenderAttachment,
- &Quick3DRenderTargetOutput::renderAttachmentCount,
- &Quick3DRenderTargetOutput::renderAttachmentAt,
- &Quick3DRenderTargetOutput::clearRenderAttachments);
-}
-
-void Quick3DRenderTargetOutput::appendRenderAttachment(QQmlListProperty<QRenderTargetOutput> *list, QRenderTargetOutput *output)
-{
- Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(list->object);
- if (rT)
- rT->parentRenderTarget()->addOutput(output);
-}
-
-QRenderTargetOutput *Quick3DRenderTargetOutput::renderAttachmentAt(QQmlListProperty<QRenderTargetOutput> *list, qsizetype index)
-{
- Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(list->object);
- if (rT)
- return rT->parentRenderTarget()->outputs().at(index);
- return nullptr;
-}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ using qt_size_type = qsizetype;
+#else
+ using qt_size_type = int;
+#endif
-qsizetype Quick3DRenderTargetOutput::renderAttachmentCount(QQmlListProperty<QRenderTargetOutput> *list)
-{
- Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(list->object);
- if (rT)
- return rT->parentRenderTarget()->outputs().count();
- return -1;
-}
+ using ListContentType = QRenderTargetOutput;
+ auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *output) {
+ Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(list->object);
+ if (rT)
+ rT->parentRenderTarget()->addOutput(output);
+ };
+ auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
+ Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(list->object);
+ if (rT)
+ return rT->parentRenderTarget()->outputs().count();
+ return 0;
+ };
+ auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
+ Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(list->object);
+ if (rT)
+ return rT->parentRenderTarget()->outputs().at(index);
+ return nullptr;
+ };
+ auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
+ Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(list->object);
+ if (rT) {
+ const auto outputs = rT->parentRenderTarget()->outputs();
+ for (QRenderTargetOutput *output : outputs)
+ rT->parentRenderTarget()->removeOutput(output);
+ }
+ };
-void Quick3DRenderTargetOutput::clearRenderAttachments(QQmlListProperty<QRenderTargetOutput> *list)
-{
- Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(list->object);
- if (rT) {
- const auto outputs = rT->parentRenderTarget()->outputs();
- for (QRenderTargetOutput *output : outputs)
- rT->parentRenderTarget()->removeOutput(output);
- }
+ return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
}
} // namespace Quick