diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2014-08-18 16:50:15 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2014-08-19 13:02:29 +0200 |
commit | d25201871706c9fa7ee52791e60b300010f7f8dd (patch) | |
tree | 9893e2dbded0bcf31be79b2c1329a84d7ce8cf03 /src/render/frontend | |
parent | 87a07e40e65f2a2540c9fdf579205e3d479d50e4 (diff) |
Added QRenderAttachment
Will be used by QRenderTarget to specify a list of attachments to use with the
FBO.
Change-Id: I9b2c5383884e5d21df2646edc2a00337a45dcf69
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/frontend')
-rw-r--r-- | src/render/frontend/qrenderattachment.cpp | 194 | ||||
-rw-r--r-- | src/render/frontend/qrenderattachment.h | 118 | ||||
-rw-r--r-- | src/render/frontend/qrenderattachment_p.h | 71 | ||||
-rw-r--r-- | src/render/frontend/render-frontend.pri | 7 |
4 files changed, 388 insertions, 2 deletions
diff --git a/src/render/frontend/qrenderattachment.cpp b/src/render/frontend/qrenderattachment.cpp new file mode 100644 index 000000000..ebe3f6c93 --- /dev/null +++ b/src/render/frontend/qrenderattachment.cpp @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** 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 "qrenderattachment_p.h" +#include "qrenderattachment.h" +#include "qtexture.h" +#include <Qt3DCore/qscenepropertychange.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +QRenderAttachmentPrivate::QRenderAttachmentPrivate(QRenderAttachment *qq) + : QNodePrivate(qq) + , m_texture(Q_NULLPTR) + , m_type(QRenderAttachment::ColorAttachment) + , m_mipLevel(0) + , m_layer(0) + , m_face(QRenderAttachment::CubeMapNegativeX) +{ +} + +QRenderAttachment::QRenderAttachment(QNode *parent) + : QNode(*new QRenderAttachmentPrivate(this), parent) +{ +} + +QRenderAttachment::QRenderAttachment(QRenderAttachmentPrivate &dd, QNode *parent) + : QNode(dd, parent) +{ +} + +void QRenderAttachment::copy(const QNode *ref) +{ + QNode::copy(ref); + const QRenderAttachment *rA = qobject_cast<const QRenderAttachment *>(ref); + if (rA != Q_NULLPTR) { + setType(rA->type()); + // TO DO: Send a clone once Texture is a QNode subclass + setTexture(rA->texture()); + } +} + +void QRenderAttachment::setType(QRenderAttachment::RenderAttachmentType type) +{ + Q_D(QRenderAttachment); + if (type != d->m_type) { + d->m_type = type; + emit typeChanged(); + if (d->m_changeArbiter != Q_NULLPTR) { + QScenePropertyChangePtr change(new QScenePropertyChange(NodeUpdated, this)); + change->setPropertyName(QByteArrayLiteral("type")); + change->setValue(type); + notifyObservers(change); + } + } +} + +QRenderAttachment::RenderAttachmentType QRenderAttachment::type() const +{ + Q_D(const QRenderAttachment); + return d->m_type; +} + +void QRenderAttachment::setTexture(QTexture *texture) +{ + Q_D(QRenderAttachment); + if (texture != d->m_texture) { + d->m_texture = texture; + emit textureChanged(); + if (d->m_changeArbiter != Q_NULLPTR) { + QScenePropertyChangePtr change(new QScenePropertyChange(NodeUpdated, this)); + change->setPropertyName(QByteArrayLiteral("texture")); + // TO DO: Send a clone once Texture is a QNode subclass + change->setValue(QVariant::fromValue(texture)); + notifyObservers(change); + } + } +} + +QTexture *QRenderAttachment::texture() const +{ + Q_D(const QRenderAttachment); + return d->m_texture; +} + +void QRenderAttachment::setMipLevel(int level) +{ + Q_D(QRenderAttachment); + if (d->m_mipLevel != level) { + d->m_mipLevel = level; + emit mipLevelChanged(); + if (d->m_changeArbiter != Q_NULLPTR) { + QScenePropertyChangePtr change(new QScenePropertyChange(NodeUpdated, this)); + change->setPropertyName(QByteArrayLiteral("mipLevel")); + change->setValue(level); + notifyObservers(change); + } + } +} + +int QRenderAttachment::mipLevel() const +{ + Q_D(const QRenderAttachment); + return d->m_mipLevel; +} + +void QRenderAttachment::setLayer(int layer) +{ + Q_D(QRenderAttachment); + if (d->m_layer != layer) { + d->m_layer = layer; + emit layerChanged(); + if (d->m_changeArbiter != Q_NULLPTR) { + QScenePropertyChangePtr change(new QScenePropertyChange(NodeUpdated, this)); + change->setPropertyName(QByteArrayLiteral("layer")); + change->setValue(layer); + notifyObservers(change); + } + } +} + +int QRenderAttachment::layer() const +{ + Q_D(const QRenderAttachment); + return d->m_layer; +} + +void QRenderAttachment::setFace(QRenderAttachment::CubeMapFace face) +{ + Q_D(QRenderAttachment); + if (d->m_face != face) { + d->m_face = face; + emit faceChanged(); + if (d->m_changeArbiter != Q_NULLPTR) { + QScenePropertyChangePtr change(new QScenePropertyChange(NodeUpdated, this)); + change->setPropertyName(QByteArrayLiteral("face")); + change->setValue(face); + notifyObservers(change); + } + } +} + +QRenderAttachment::CubeMapFace QRenderAttachment::face() const +{ + Q_D(const QRenderAttachment); + return d->m_face; +} + +QNode *QRenderAttachment::doClone(QNode *clonedParent) const +{ + return new QRenderAttachment(clonedParent); +} + +} // Qt3D + +QT_END_NAMESPACE diff --git a/src/render/frontend/qrenderattachment.h b/src/render/frontend/qrenderattachment.h new file mode 100644 index 000000000..2a446c160 --- /dev/null +++ b/src/render/frontend/qrenderattachment.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef QT3D_QRENDERATTACHMENT_H +#define QT3D_QRENDERATTACHMENT_H + +#include <Qt3DCore/qnode.h> +#include <Qt3DRenderer/qt3drenderer_global.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +class QTexture; +class QRenderAttachmentPrivate; + +class QT3DRENDERERSHARED_EXPORT QRenderAttachment : public QNode +{ + Q_OBJECT + Q_ENUMS(RenderAttachmentType) + Q_ENUMS(CubeMapFace) + Q_PROPERTY(RenderAttachmentType type READ type WRITE setType NOTIFY typeChanged) + Q_PROPERTY(Qt3D::QTexture *texture READ texture WRITE setTexture NOTIFY textureChanged) + Q_PROPERTY(int mipLevel READ mipLevel WRITE setMipLevel NOTIFY mipLevelChanged) + Q_PROPERTY(int layer READ layer WRITE setLayer NOTIFY layerChanged) + Q_PROPERTY(CubeMapFace face READ face WRITE setFace NOTIFY faceChanged) + +public: + enum RenderAttachmentType { + ColorAttachment, + DepthAttachment, + StencilAttachment, + DepthStencilAttachment + }; + + enum CubeMapFace { + CubeMapPositiveX = 0x8515, // GL_TEXTURE_CUBE_MAP_POSITIVE_X + CubeMapNegativeX = 0x8516, // GL_TEXTURE_CUBE_MAP_NEGATIVE_X + CubeMapPositiveY = 0x8517, // GL_TEXTURE_CUBE_MAP_POSITIVE_Y + CubeMapNegativeY = 0x8518, // GL_TEXTURE_CUBE_MAP_NEGATIVE_Y + CubeMapPositiveZ = 0x8519, // GL_TEXTURE_CUBE_MAP_POSITIVE_Z + CubeMapNegativeZ = 0x851A // GL_TEXTURE_CUBE_MAP_NEGATIVE_Z + }; + + explicit QRenderAttachment(QNode *parent = 0); + void copy(const QNode *ref) Q_DECL_OVERRIDE; + + void setType(RenderAttachmentType type); + RenderAttachmentType type() const; + + void setTexture(QTexture *texture); + QTexture *texture() const; + + void setMipLevel(int level); + int mipLevel() const; + + void setLayer(int layer); + int layer() const; + + void setFace(CubeMapFace face); + CubeMapFace face() const; + +Q_SIGNALS: + void typeChanged(); + void textureChanged(); + void mipLevelChanged(); + void layerChanged(); + void faceChanged(); + +protected: + Q_DECLARE_PRIVATE(QRenderAttachment) + QRenderAttachment(QRenderAttachmentPrivate &dd, QNode *parent = 0); + QNode *doClone(QNode *clonedParent) const Q_DECL_OVERRIDE; +}; + +} // Qt3D + +QT_END_NAMESPACE + +#endif // QT3D_QRENDERATTACHMENT_H diff --git a/src/render/frontend/qrenderattachment_p.h b/src/render/frontend/qrenderattachment_p.h new file mode 100644 index 000000000..1acc6b1b2 --- /dev/null +++ b/src/render/frontend/qrenderattachment_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef QT3D_QRENDERATTACHMENT_P_H +#define QT3D_QRENDERATTACHMENT_P_H + +#include <Qt3DCore/private/qnode_p.h> +#include <Qt3DRenderer/qrenderattachment.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +class QTexture; + +class QRenderAttachmentPrivate : public QNodePrivate +{ +public: + QRenderAttachmentPrivate(QRenderAttachment *qq); + Q_DECLARE_PUBLIC(QRenderAttachment) + + QTexture *m_texture; + QRenderAttachment::RenderAttachmentType m_type; + int m_mipLevel; + int m_layer; + QRenderAttachment::CubeMapFace m_face; +}; + +} // Qt3D + +QT_END_NAMESPACE + +#endif // QT3D_QRENDERATTACHMENT_P_H diff --git a/src/render/frontend/render-frontend.pri b/src/render/frontend/render-frontend.pri index c9e7bb8d2..594c6bfd7 100644 --- a/src/render/frontend/render-frontend.pri +++ b/src/render/frontend/render-frontend.pri @@ -56,7 +56,9 @@ HEADERS += \ $$PWD/qstenciltest.h \ $$PWD/qscissortest.h \ $$PWD/qdithering.h \ - $$PWD/qrenderstate.h + $$PWD/qrenderstate.h \ + $$PWD/qrenderattachment.h \ + $$PWD/qrenderattachment_p.h SOURCES += \ $$PWD/qmaterial.cpp \ @@ -94,4 +96,5 @@ SOURCES += \ $$PWD/qstenciltest.cpp \ $$PWD/qscissortest.cpp \ $$PWD/qdithering.cpp \ - $$PWD/qrenderstate.cpp + $$PWD/qrenderstate.cpp \ + $$PWD/qrenderattachment.cpp |