| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). | 
| 4 | ** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). | 
| 5 | ** Contact: https://www.qt.io/licensing/ | 
| 6 | ** | 
| 7 | ** This file is part of the Qt3D module of the Qt Toolkit. | 
| 8 | ** | 
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | 
| 10 | ** Commercial License Usage | 
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 12 | ** accordance with the commercial license agreement provided with the | 
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 16 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 17 | ** | 
| 18 | ** GNU Lesser General Public License Usage | 
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
| 20 | ** General Public License version 3 as published by the Free Software | 
| 21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
| 22 | ** packaging of this file. Please review the following information to | 
| 23 | ** ensure the GNU Lesser General Public License version 3 requirements | 
| 24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
| 25 | ** | 
| 26 | ** GNU General Public License Usage | 
| 27 | ** Alternatively, this file may be used under the terms of the GNU | 
| 28 | ** General Public License version 2.0 or (at your option) the GNU General | 
| 29 | ** Public license version 3 or any later version approved by the KDE Free | 
| 30 | ** Qt Foundation. The licenses are as published by the Free Software | 
| 31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
| 32 | ** included in the packaging of this file. Please review the following | 
| 33 | ** information to ensure the GNU General Public License requirements will | 
| 34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
| 35 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
| 36 | ** | 
| 37 | ** $QT_END_LICENSE$ | 
| 38 | ** | 
| 39 | ****************************************************************************/ | 
| 40 |  | 
| 41 | /*! | 
| 42 |  * \class Qt3DRender::QBlendEquation | 
| 43 |  * \inheaderfile Qt3DRender/QBlendEquation | 
| 44 |  * \brief The QBlendEquation class specifies the equation used for both the RGB | 
| 45 |  *  blend equation and the Alpha blend equation. | 
| 46 |  * \inmodule Qt3DRender | 
| 47 |  * \since 5.7 | 
| 48 |  * \ingroup renderstates | 
| 49 |  * | 
| 50 |  * The blend equation is used to determine how a new pixel is combined with a pixel | 
| 51 |  * already in the framebuffer. | 
| 52 |  */ | 
| 53 |  | 
| 54 | /*! | 
| 55 |     \qmltype BlendEquation | 
| 56 |     \instantiates Qt3DRender::QBlendEquation | 
| 57 |     \inherits RenderState | 
| 58 |     \inqmlmodule Qt3D.Render | 
| 59 |     \since 5.5 | 
| 60 |     \brief The BlendEquation class specifies the equation used for both the RGB | 
| 61 |      blend equation and the Alpha blend equation. | 
| 62 |  | 
| 63 |     The blend equation is used to determine how a new pixel is combined with a pixel | 
| 64 |     already in the framebuffer. | 
| 65 | */ | 
| 66 |  | 
| 67 | #include "qblendequation.h" | 
| 68 | #include "qblendequation_p.h" | 
| 69 | #include <Qt3DRender/private/qrenderstatecreatedchange_p.h> | 
| 70 |  | 
| 71 | QT_BEGIN_NAMESPACE | 
| 72 |  | 
| 73 | namespace Qt3DRender { | 
| 74 |  | 
| 75 | /*! | 
| 76 |  * The constructor creates a new blend state object with the specified \a parent. | 
| 77 |  */ | 
| 78 | QBlendEquation::QBlendEquation(QNode *parent) | 
| 79 |     : QRenderState(*new QBlendEquationPrivate, parent) | 
| 80 | { | 
| 81 | } | 
| 82 |  | 
| 83 | /*! \internal */ | 
| 84 | QBlendEquation::~QBlendEquation() | 
| 85 | { | 
| 86 | } | 
| 87 |  | 
| 88 | /*! | 
| 89 |   \enum Qt3DRender::QBlendEquation::BlendFunction | 
| 90 |  | 
| 91 |   \value Add GL_FUNC_ADD | 
| 92 |   \value Subtract GL_FUNC_SUBTRACT | 
| 93 |   \value ReverseSubtract GL_FUNC_REVERSE_SUBTRACT | 
| 94 |   \value Min GL_MIN | 
| 95 |   \value Max GL_MAX | 
| 96 | */ | 
| 97 |  | 
| 98 | /*! | 
| 99 |     \qmlproperty enumeration BlendEquation::blendFunction | 
| 100 |  | 
| 101 |     Holds the blend function, which determines how source and destination colors are combined. | 
| 102 |  */ | 
| 103 |  | 
| 104 | /*! | 
| 105 |     \property QBlendEquation::blendFunction | 
| 106 |  | 
| 107 |     Holds the blend function, which determines how source and destination colors are combined. | 
| 108 |  */ | 
| 109 |  | 
| 110 | QBlendEquation::BlendFunction QBlendEquation::blendFunction() const | 
| 111 | { | 
| 112 |     Q_D(const QBlendEquation); | 
| 113 |     return d->m_blendFunction; | 
| 114 | } | 
| 115 |  | 
| 116 | void QBlendEquation::setBlendFunction(QBlendEquation::BlendFunction blendFunction) | 
| 117 | { | 
| 118 |     Q_D(QBlendEquation); | 
| 119 |     if (d->m_blendFunction != blendFunction) { | 
| 120 |         d->m_blendFunction = blendFunction; | 
| 121 |         emit blendFunctionChanged(blendFunction); | 
| 122 |     } | 
| 123 | } | 
| 124 |  | 
| 125 | Qt3DCore::QNodeCreatedChangeBasePtr QBlendEquation::createNodeCreationChange() const | 
| 126 | { | 
| 127 |     auto creationChange = QRenderStateCreatedChangePtr<QBlendEquationData>::create(arguments: this); | 
| 128 |     auto &data = creationChange->data; | 
| 129 |     data.blendFunction = d_func()->m_blendFunction; | 
| 130 |     return creationChange; | 
| 131 | } | 
| 132 |  | 
| 133 | } // namespace Qt3DRender | 
| 134 |  | 
| 135 | QT_END_NAMESPACE | 
| 136 |  |