| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #include "qnodraw.h" |
| 41 | |
| 42 | QT_BEGIN_NAMESPACE |
| 43 | |
| 44 | namespace Qt3DRender { |
| 45 | |
| 46 | /*! |
| 47 | \class Qt3DRender::QNoDraw |
| 48 | \inmodule Qt3DRender |
| 49 | |
| 50 | \brief When a Qt3DRender::QNoDraw node is present in a FrameGraph branch, this |
| 51 | prevents the renderer from rendering any primitive. |
| 52 | |
| 53 | Qt3DRender::QNoDraw should be used when the FrameGraph needs to set up some render |
| 54 | states or clear some buffers without requiring any mesh to be drawn. It has |
| 55 | the same effect as having a Qt3DRender::QRenderPassFilter that matches none of |
| 56 | available Qt3DRender::QRenderPass instances of the scene without the overhead cost |
| 57 | of actually performing the filtering. |
| 58 | |
| 59 | When disabled, a Qt3DRender::QNoDraw node won't prevent the scene from |
| 60 | being rendered. Toggling the enabled property is therefore a way to make a |
| 61 | Qt3DRender::QNoDraw active or inactive. |
| 62 | |
| 63 | Qt3DRender::QNoDraw is usually used as a child of a |
| 64 | Qt3DRendeR::QClearBuffers node to prevent from drawing the scene when there |
| 65 | are multiple render passes. |
| 66 | |
| 67 | \code |
| 68 | Qt3DRender::QViewport *viewport = new Qt3DRender::QViewport(); |
| 69 | Qt3DRender::QCameraSelector *cameraSelector = new Qt3DRender::QCameraSelector(viewport); |
| 70 | |
| 71 | Qt3DRender::QClearBuffers *clearBuffers = new Qt3DRender::QClearBuffers(cameraSelector); |
| 72 | clearBuffers->setBuffers(Qt3DRender::QClearBuffers::ColorDepthBuffer); |
| 73 | |
| 74 | Qt3DRender::QNoDraw *noDraw = new Qt3DRender::QNoDraw(clearBuffers); |
| 75 | |
| 76 | Qt3DRender::QRenderPassFilter *mainPass = new Qt3DRender::QRenderPassFilter(cameraSelector); |
| 77 | .... |
| 78 | Qt3DRender::QRenderPassFilter *previewPass = new Qt3DRender::QRenderPassFilter(cameraSelector); |
| 79 | .... |
| 80 | \endcode |
| 81 | |
| 82 | \since 5.5 |
| 83 | */ |
| 84 | |
| 85 | /*! |
| 86 | \qmltype NoDraw |
| 87 | \instantiates Qt3DRender::QNoDraw |
| 88 | \inherits FrameGraphNode |
| 89 | \inqmlmodule Qt3D.Render |
| 90 | \since 5.5 |
| 91 | \brief When a NoDraw node is present in a FrameGraph branch, this |
| 92 | prevents the renderer from rendering any primitive. |
| 93 | |
| 94 | NoDraw should be used when the FrameGraph needs to set up some render |
| 95 | states or clear some buffers without requiring any mesh to be drawn. It has |
| 96 | the same effect as having a Qt3DRender::QRenderPassFilter that matches none |
| 97 | of available Qt3DRender::QRenderPass instances of the scene without the |
| 98 | overhead cost of actually performing the filtering. |
| 99 | |
| 100 | When disabled, a NoDraw node won't prevent the scene from being rendered. |
| 101 | Toggling the enabled property is therefore a way to make a NoDraw active or |
| 102 | inactive. |
| 103 | |
| 104 | NoDraw is usually used as a child of a ClearBuffers node to prevent from |
| 105 | drawing the scene when there are multiple render passes. |
| 106 | |
| 107 | \code |
| 108 | |
| 109 | Viewport { |
| 110 | CameraSelector { |
| 111 | ClearBuffers { |
| 112 | buffers: ClearBuffers.ColorDepthBuffer |
| 113 | NoDraw { } // Prevents from drawing anything |
| 114 | } |
| 115 | RenderPassFilter { |
| 116 | ... |
| 117 | } |
| 118 | RenderPassFilter { |
| 119 | ... |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | \endcode |
| 125 | */ |
| 126 | |
| 127 | /*! |
| 128 | The constructor creates an instance with the specified \a parent. |
| 129 | */ |
| 130 | QNoDraw::QNoDraw(QNode *parent) |
| 131 | : QFrameGraphNode(parent) |
| 132 | { |
| 133 | } |
| 134 | |
| 135 | /*! \internal */ |
| 136 | QNoDraw::~QNoDraw() |
| 137 | { |
| 138 | } |
| 139 | |
| 140 | } // namespace Qt3DRender |
| 141 | |
| 142 | QT_END_NAMESPACE |
| 143 | |