/**************************************************************************** ** ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt3D module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "rendertechnique_p.h" #include #include #include #include #include #include #include #include #include #include #include #include QT_BEGIN_NAMESPACE namespace Qt3D { namespace Render { RenderTechnique::RenderTechnique() : QBackendNode() , m_openglFilter(new QOpenGLFilter()) { } RenderTechnique::~RenderTechnique() { cleanup(); delete m_openglFilter; } void RenderTechnique::cleanup() { } void RenderTechnique::updateFromPeer(QNode *peer) { m_parameterPack.clear(); m_renderPasses.clear(); m_annotationList.clear(); QTechnique *technique = static_cast(peer); if (technique != Q_NULLPTR) { Q_FOREACH (QParameter *p, technique->parameters()) m_parameterPack.appendParameter(p->uuid()); Q_FOREACH (QRenderPass *rPass, technique->renderPasses()) appendRenderPass(rPass->uuid()); Q_FOREACH (QAnnotation *annotation, technique->annotations()) appendAnnotation(annotation->uuid()); // Copy OpenGLFilter info from frontend OpenGLFilter QOpenGLFilter *peerFilter = technique->openGLFilter(); m_openglFilter->copy(peerFilter); } } void RenderTechnique::sceneChangeEvent(const QSceneChangePtr &e) { QScenePropertyChangePtr propertyChange = qSharedPointerCast(e); switch (e->type()) { case NodeUpdated: { if (propertyChange->propertyName() == QByteArrayLiteral("openGLFilter")) { QOpenGLFilter *filter = propertyChange->value().value(); if (filter != Q_NULLPTR) { m_openglFilter->copy(filter); delete filter; } } break; } case NodeAdded: { if (propertyChange->propertyName() == QByteArrayLiteral("pass")) { appendRenderPass(propertyChange->value().toUuid()); } else if (propertyChange->propertyName() == QByteArrayLiteral("parameter")) { m_parameterPack.appendParameter(propertyChange->value().toUuid()); } else if (propertyChange->propertyName() == QByteArrayLiteral("annotation")) { appendAnnotation(propertyChange->value().toUuid()); } break; } case NodeRemoved: { if (propertyChange->propertyName() == QByteArrayLiteral("pass")) { removeRenderPass(propertyChange->value().toUuid()); } else if (propertyChange->propertyName() == QByteArrayLiteral("parameter")) { m_parameterPack.removeParameter(propertyChange->value().toUuid()); } else if (propertyChange->propertyName() == QByteArrayLiteral("annotation")) { removeAnnotation(propertyChange->value().toUuid()); } break; } default: break; } } QList RenderTechnique::parameters() const { return m_parameterPack.parameters(); } void RenderTechnique::appendRenderPass(const QUuid &renderPassId) { if (!m_renderPasses.contains(renderPassId)) m_renderPasses.append(renderPassId); } void RenderTechnique::removeRenderPass(const QUuid &renderPassId) { m_renderPasses.removeOne(renderPassId); } QList RenderTechnique::annotations() const { return m_annotationList; } QList RenderTechnique::renderPasses() const { return m_renderPasses; } QOpenGLFilter *RenderTechnique::openGLFilter() const { return m_openglFilter; } void RenderTechnique::appendAnnotation(const QUuid &criterionId) { if (!m_annotationList.contains(criterionId)) m_annotationList.append(criterionId); } void RenderTechnique::removeAnnotation(const QUuid &criterionId) { m_annotationList.removeOne(criterionId); } } // namespace Render } // namespace Qt3D QT_END_NAMESPACE