diff options
-rw-r--r-- | src/render/backend/rendertexture.cpp | 8 | ||||
-rw-r--r-- | src/render/backend/rendertexture_p.h | 1 | ||||
-rw-r--r-- | src/render/frontend/qtexture.cpp | 18 | ||||
-rw-r--r-- | src/render/frontend/qtexture.h | 5 |
4 files changed, 31 insertions, 1 deletions
diff --git a/src/render/backend/rendertexture.cpp b/src/render/backend/rendertexture.cpp index 1f29a6559..906562466 100644 --- a/src/render/backend/rendertexture.cpp +++ b/src/render/backend/rendertexture.cpp @@ -70,6 +70,7 @@ RenderTexture::RenderTexture() , m_magnificationFilter(QTexture::Nearest) , m_minificationFilter(QTexture::Nearest) , m_wrapMode(QTexture::ClampToEdge) + , m_maximumAnisotropy(1.0f) , m_isDirty(false) , m_filtersAndWrapUpdated(false) , m_lock(new QMutex()) @@ -114,6 +115,7 @@ void RenderTexture::setPeer(QTexture *peer) m_magnificationFilter = peer->magnificationFilter(); m_minificationFilter = peer->minificationFilter(); m_wrapMode = peer->wrapMode(); + m_maximumAnisotropy = peer->maximumAnisotropy(); // See where it is best to handle source and loading Q_FOREACH (TexImageDataPtr imgData, peer->imageData()) m_imageData.append(imgData); @@ -242,7 +244,7 @@ void RenderTexture::updateWrapAndFilters() m_gl->setWrapMode(static_cast<QOpenGLTexture::WrapMode>(m_wrapMode)); m_gl->setMinMagFilters(static_cast<QOpenGLTexture::Filter>(m_minificationFilter), static_cast<QOpenGLTexture::Filter>(m_magnificationFilter)); - + m_gl->setMaximumAnisotropy(m_maximumAnisotropy); } @@ -311,6 +313,10 @@ void RenderTexture::sceneChangeEvent(const QSceneChangePtr &e) QTexture::Target oldTarget = m_target; m_target = static_cast<QTexture::Target>(propertyChange->value().toInt()); m_isDirty = (oldTarget != m_target); + } else if (propertyChange->propertyName() == QByteArrayLiteral("maximumAnisotropy")) { + float oldMaximumAnisotropy = m_maximumAnisotropy; + m_maximumAnisotropy = propertyChange->value().toFloat(); + m_filtersAndWrapUpdated = !qFuzzyCompare(oldMaximumAnisotropy, m_maximumAnisotropy); } } } diff --git a/src/render/backend/rendertexture_p.h b/src/render/backend/rendertexture_p.h index 39dc162bf..a807c822e 100644 --- a/src/render/backend/rendertexture_p.h +++ b/src/render/backend/rendertexture_p.h @@ -98,6 +98,7 @@ private: QTexture::Filter m_magnificationFilter; QTexture::Filter m_minificationFilter; QTexture::WrapMode m_wrapMode; + float m_maximumAnisotropy; QList<TexImageDataPtr> m_imageData; bool m_isDirty; bool m_filtersAndWrapUpdated; diff --git a/src/render/frontend/qtexture.cpp b/src/render/frontend/qtexture.cpp index 842c3ccd0..f5f08ff79 100644 --- a/src/render/frontend/qtexture.cpp +++ b/src/render/frontend/qtexture.cpp @@ -67,6 +67,7 @@ public : , m_magFilter(QTexture::Nearest) , m_wrapMode(QTexture::ClampToEdge) , m_status(QTexture::Loading) + , m_maximumAnisotropy(1.0f) {} void copy(const QNodePrivate *ref) Q_DECL_OVERRIDE; @@ -84,6 +85,7 @@ public : // FIXME, store per direction QTexture::WrapMode m_wrapMode; QTexture::Status m_status; + float m_maximumAnisotropy; }; void QTexturePrivate::copy(const QNodePrivate *ref) @@ -376,6 +378,22 @@ QTexture::WrapMode QTexture::wrapMode() const return d->m_wrapMode; } +void QTexture::setMaximumAnisotropy(float anisotropy) +{ + Q_D(QTexture); + if (!qFuzzyCompare(d->m_maximumAnisotropy, anisotropy)) { + d->m_maximumAnisotropy = anisotropy; + emit maximumAnisotropyChanged(); + d->notifyPropertyChange(QByteArrayLiteral("maximumAnisotropy"), anisotropy); + } +} + +float QTexture::maximumAnisotropy() const +{ + Q_D(const QTexture); + return d->m_maximumAnisotropy; +} + } // namespace Qt3D QT_END_NAMESPACE diff --git a/src/render/frontend/qtexture.h b/src/render/frontend/qtexture.h index 6f26cc37c..5934a322f 100644 --- a/src/render/frontend/qtexture.h +++ b/src/render/frontend/qtexture.h @@ -71,6 +71,7 @@ class QT3DRENDERERSHARED_EXPORT QTexture : public QNode Q_PROPERTY(int depth READ depth WRITE setDepth NOTIFY depthChanged) Q_PROPERTY(Filter magnificationFilter READ magnificationFilter WRITE setMagnificationFilter NOTIFY magnificationFilterChanged) Q_PROPERTY(Filter minificationFilter READ minificationFilter WRITE setMinificationFilter NOTIFY minificationFilterChanged) + Q_PROPERTY(float maximumAnisotropy READ maximumAnisotropy WRITE setMaximumAnisotropy NOTIFY maximumAnisotropyChanged) public: explicit QTexture(QNode *parent = 0); @@ -262,6 +263,9 @@ public: void setWrapMode(WrapMode wrapMode); WrapMode wrapMode() const; + void setMaximumAnisotropy(float anisotropy); + float maximumAnisotropy() const; + void setSize(int width, int height=1, int depth=1); void setWidth(int width); @@ -283,6 +287,7 @@ Q_SIGNALS: void depthChanged(); void magnificationFilterChanged(); void minificationFilterChanged(); + void maximumAnisotropyChanged(); protected: QTexture(QTexturePrivate &dd, QNode *parent = 0); |