diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-05-11 10:11:46 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-05-20 11:12:35 +0000 |
commit | 01758638fad44c7e05123269171c5e2e7ca0b062 (patch) | |
tree | 4e7c27472512f77018cab33ba9d4a6fca034bc19 /src | |
parent | de7f96bb4046592d5b7491565d77414ab22a6ffe (diff) |
Added QTextureData
QTextureGenerator will have to return this object which
will allow to asynchronously create the whole texture and
provide all the necessary information the backend expects.
Change-Id: I71bdf85ac8e3aa3befd187c5f3d768045dd15ea2
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/render/texture/qtexturedata.cpp | 273 | ||||
-rw-r--r-- | src/render/texture/qtexturedata.h | 119 | ||||
-rw-r--r-- | src/render/texture/texture.pri | 7 |
3 files changed, 397 insertions, 2 deletions
diff --git a/src/render/texture/qtexturedata.cpp b/src/render/texture/qtexturedata.cpp new file mode 100644 index 000000000..d7682183f --- /dev/null +++ b/src/render/texture/qtexturedata.cpp @@ -0,0 +1,273 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtexturedata.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +class QTextureDataPrivate +{ +public: + QAbstractTexture::Target m_target; + QAbstractTexture::TextureFormat m_format; + int m_width = 0; + int m_height = 0; + int m_depth = 0; + int m_layers = 0; + bool m_autoMipMap = false; + float m_maximumAnisotropy = 0.0f; + QAbstractTexture::Filter m_minFilter; + QAbstractTexture::Filter m_magFilter; + QTextureWrapMode::WrapMode m_wrapModeX; + QTextureWrapMode::WrapMode m_wrapModeY; + QTextureWrapMode::WrapMode m_wrapModeZ; + QAbstractTexture::ComparisonFunction m_comparisonFunction; + QAbstractTexture::ComparisonMode m_comparisonMode; + QVector<QTextureImageDataPtr> m_imagesData; + +}; + +QTextureData::QTextureData() + : d_ptr(new QTextureDataPrivate()) +{ +} + +QTextureData::~QTextureData() +{ + delete d_ptr; +} + +QAbstractTexture::Target QTextureData::target() const +{ + Q_D(const QTextureData); + return d->m_target; +} + +void QTextureData::setTarget(QAbstractTexture::Target target) +{ + Q_D(QTextureData); + d->m_target = target; +} + +QAbstractTexture::TextureFormat QTextureData::format() const +{ + Q_D(const QTextureData); + return d->m_format; +} + +void QTextureData::setFormat(QAbstractTexture::TextureFormat format) +{ + Q_D(QTextureData); + d->m_format = format; +} + +int QTextureData::width() const +{ + Q_D(const QTextureData); + return d->m_width; +} + +void QTextureData::setWidth(int width) +{ + Q_D(QTextureData); + d->m_width = width; +} + +int QTextureData::height() const +{ + Q_D(const QTextureData); + return d->m_height; +} + +void QTextureData::setHeight(int height) +{ + Q_D(QTextureData); + d->m_height = height; +} + +int QTextureData::depth() const +{ + Q_D(const QTextureData); + return d->m_depth; +} + +void QTextureData::setDepth(int depth) +{ + Q_D(QTextureData); + d->m_depth = depth; +} + +int QTextureData::layers() const +{ + Q_D(const QTextureData); + return d->m_layers; +} + +void QTextureData::setLayers(int layers) +{ + Q_D(QTextureData); + d->m_layers = layers; +} + +bool QTextureData::isAutoMipMapGenerationEnabled() const +{ + Q_D(const QTextureData); + return d->m_autoMipMap; +} + +void QTextureData::setAutoMipMapGenerationEnabled(bool autoMipMap) +{ + Q_D(QTextureData); + d->m_autoMipMap = autoMipMap; +} + +float QTextureData::maximumAnisotropy() const +{ + Q_D(const QTextureData); + return d->m_maximumAnisotropy; +} + +void QTextureData::setMaximumAnisotropy(float maximumAnisotropy) +{ + Q_D(QTextureData); + d->m_maximumAnisotropy = maximumAnisotropy; +} + +QAbstractTexture::Filter QTextureData::minificationFilter() const +{ + Q_D(const QTextureData); + return d->m_minFilter; +} + +void QTextureData::setMinificationFilter(QAbstractTexture::Filter filter) +{ + Q_D(QTextureData); + d->m_minFilter = filter; +} + +QAbstractTexture::Filter QTextureData::magnificationFilter() const +{ + Q_D(const QTextureData); + return d->m_magFilter; +} + +void QTextureData::setMagnificationFilter(QAbstractTexture::Filter filter) +{ + Q_D(QTextureData); + d->m_magFilter = filter; +} + +QTextureWrapMode::WrapMode QTextureData::wrapModeX() const +{ + Q_D(const QTextureData); + return d->m_wrapModeX; +} + +void QTextureData::setWrapModeX(QTextureWrapMode::WrapMode wrapModeX) +{ + Q_D(QTextureData); + d->m_wrapModeX = wrapModeX; +} + +QTextureWrapMode::WrapMode QTextureData::wrapModeY() const +{ + Q_D(const QTextureData); + return d->m_wrapModeY; +} + +void QTextureData::setWrapModeY(QTextureWrapMode::WrapMode wrapModeY) +{ + Q_D(QTextureData); + d->m_wrapModeY = wrapModeY; +} + +QTextureWrapMode::WrapMode QTextureData::wrapModeZ() const +{ + Q_D(const QTextureData); + return d->m_wrapModeZ; +} + +void QTextureData::setWrapModeZ(QTextureWrapMode::WrapMode wrapModeZ) +{ + Q_D(QTextureData); + d->m_wrapModeZ = wrapModeZ; +} + +QAbstractTexture::ComparisonFunction QTextureData::comparisonFunction() const +{ + Q_D(const QTextureData); + return d->m_comparisonFunction; +} + +void QTextureData::setComparisonFunction(QAbstractTexture::ComparisonFunction comparisonFunction) +{ + Q_D(QTextureData); + d->m_comparisonFunction = comparisonFunction; +} + +QAbstractTexture::ComparisonMode QTextureData::comparisonMode() const +{ + Q_D(const QTextureData); + return d->m_comparisonMode; +} + +void QTextureData::setComparisonMode(QAbstractTexture::ComparisonMode comparisonMode) +{ + Q_D(QTextureData); + d->m_comparisonMode = comparisonMode; +} + +QVector<QTextureImageDataPtr> QTextureData::imageData() const +{ + Q_D(const QTextureData); + return d->m_imagesData; +} + +void QTextureData::addImageData(const QTextureImageDataPtr &imageData) +{ + Q_D(QTextureData); + d->m_imagesData.push_back(imageData); +} + +} // Qt3DRender + +QT_END_NAMESPACE diff --git a/src/render/texture/qtexturedata.h b/src/render/texture/qtexturedata.h new file mode 100644 index 000000000..a86a3ec45 --- /dev/null +++ b/src/render/texture/qtexturedata.h @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DRENDER_QTEXTUREDATA_H +#define QT3DRENDER_QTEXTUREDATA_H + +#include <Qt3DRender/qt3drender_global.h> +#include <Qt3DRender/qabstracttexture.h> +#include <Qt3DRender/qtextureimagedata.h> +#include <Qt3DRender/qtexturewrapmode.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +class QTextureDataPrivate; + +class QT3DRENDERSHARED_EXPORT QTextureData +{ +public: + QTextureData(); + ~QTextureData(); + + QAbstractTexture::Target target() const; + void setTarget(QAbstractTexture::Target target); + + QAbstractTexture::TextureFormat format() const; + void setFormat(QAbstractTexture::TextureFormat); + + int width() const; + void setWidth(int width); + + int height() const; + void setHeight(int height); + + int depth() const; + void setDepth(int depth); + + int layers() const; + void setLayers(int layers); + + bool isAutoMipMapGenerationEnabled() const; + void setAutoMipMapGenerationEnabled(bool isAutoMipMapGenerationEnabled); + + float maximumAnisotropy() const; + void setMaximumAnisotropy(float maximumAnisotropy); + + QAbstractTexture::Filter minificationFilter() const; + void setMinificationFilter(QAbstractTexture::Filter filter); + + QAbstractTexture::Filter magnificationFilter() const; + void setMagnificationFilter(QAbstractTexture::Filter filter); + + QTextureWrapMode::WrapMode wrapModeX() const; + void setWrapModeX(QTextureWrapMode::WrapMode wrapModeX); + + QTextureWrapMode::WrapMode wrapModeY() const; + void setWrapModeY(QTextureWrapMode::WrapMode wrapModeY); + + QTextureWrapMode::WrapMode wrapModeZ() const; + void setWrapModeZ(QTextureWrapMode::WrapMode wrapModeZ); + + QAbstractTexture::ComparisonFunction comparisonFunction() const; + void setComparisonFunction(QAbstractTexture::ComparisonFunction comparisonFunction); + + QAbstractTexture::ComparisonMode comparisonMode() const; + void setComparisonMode(QAbstractTexture::ComparisonMode comparisonMode); + + QVector<QTextureImageDataPtr> imageData() const; + void addImageData(const QTextureImageDataPtr &imageData); + +private: + Q_DECLARE_PRIVATE(QTextureData) + QTextureDataPrivate *d_ptr; +}; + +typedef QSharedPointer<QTextureData> QTextureDataPtr; + +} // Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_QTEXTUREDATA_H diff --git a/src/render/texture/texture.pri b/src/render/texture/texture.pri index f77541572..68aacd574 100644 --- a/src/render/texture/texture.pri +++ b/src/render/texture/texture.pri @@ -14,7 +14,8 @@ HEADERS += \ $$PWD/qabstracttexture_p.h \ $$PWD/qtextureimagedatagenerator.h \ $$PWD/qtextureimagedata_p.h \ - $$PWD/qtextureimagedata.h + $$PWD/qtextureimagedata.h \ + $$PWD/qtexturedata.h SOURCES += \ $$PWD/qabstracttextureimage.cpp \ @@ -25,4 +26,6 @@ SOURCES += \ $$PWD/textureimage.cpp \ $$PWD/qabstracttexture.cpp \ $$PWD/qtexture.cpp \ - $$PWD/qtextureimagedata.cpp + $$PWD/qtextureimagedata.cpp \ + $$PWD/qtexturedata.cpp + |