summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-01-28 14:34:26 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-02-08 15:02:02 +0000
commitaf3eb98b22a83275335d6ac702ed7ba0e8b394bb (patch)
tree984d41b72e18ed0448b9ecbfdda6c5ad0e27abdc /src
parent6ac96d11449769118dc1f5b443fc7112bed3facc (diff)
Make ctor of QAbstractTextureProvider protected
That enforces to use one of the subclasses. Change-Id: Idba7300ed322954ba6866c4a262ad4ee74c024e5 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/sceneparsers/assimp/assimpparser.cpp4
-rw-r--r--src/render/defaults/qdiffusemapmaterial.cpp2
-rw-r--r--src/render/defaults/qdiffusespecularmapmaterial.cpp4
-rw-r--r--src/render/defaults/qnormaldiffusemapmaterial.cpp4
-rw-r--r--src/render/defaults/qnormaldiffusespecularmapmaterial.cpp6
-rw-r--r--src/render/frontend/qabstracttextureprovider.h3
-rw-r--r--src/render/io/gltfparser.cpp48
7 files changed, 36 insertions, 35 deletions
diff --git a/src/plugins/sceneparsers/assimp/assimpparser.cpp b/src/plugins/sceneparsers/assimp/assimpparser.cpp
index ea11e3b15..c29226fad 100644
--- a/src/plugins/sceneparsers/assimp/assimpparser.cpp
+++ b/src/plugins/sceneparsers/assimp/assimpparser.cpp
@@ -593,7 +593,7 @@ void AssimpParser::loadMesh(uint meshIndex)
void AssimpParser::loadEmbeddedTexture(uint textureIndex)
{
aiTexture *assimpTexture = m_scene->m_aiScene->mTextures[textureIndex];
- QAbstractTextureProvider *texture = new QAbstractTextureProvider(QAbstractTextureProvider::Target2D);
+ QAbstractTextureProvider *texture = new QTexture2D();
TexImageDataPtr textureData(new TexImageData(0, 0));
bool isCompressed = assimpTexture->mHeight == 0;
@@ -773,7 +773,7 @@ void AssimpParser::copyMaterialTextures(QMaterial *material, aiMaterial *assimpM
// Load texture if not already loaded
bool textureLoaded = true;
if (!m_scene->m_materialTextures.contains(fullPath)) {
- QAbstractTextureProvider *tex = new QAbstractTextureProvider(QAbstractTextureProvider::Target2D);
+ QAbstractTextureProvider *tex = new QTexture2D();
QImage textureImage;
if (!textureImage.load(fullPath) || !textureImage.isNull()) {
tex->setFromQImage(textureImage);
diff --git a/src/render/defaults/qdiffusemapmaterial.cpp b/src/render/defaults/qdiffusemapmaterial.cpp
index 8b16b8f4a..f1a4f4992 100644
--- a/src/render/defaults/qdiffusemapmaterial.cpp
+++ b/src/render/defaults/qdiffusemapmaterial.cpp
@@ -60,7 +60,7 @@ namespace Qt3D {
QDiffuseMapMaterialPrivate::QDiffuseMapMaterialPrivate(QDiffuseMapMaterial *qq)
: QMaterialPrivate(qq)
, m_diffuseMapEffect(new QEffect())
- , m_diffuseTexture(new QAbstractTextureProvider(QAbstractTextureProvider::Target2D))
+ , m_diffuseTexture(new QTexture2D())
, m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
, m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture))
, m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.95f, 0.95f, 0.95f, 1.0f)))
diff --git a/src/render/defaults/qdiffusespecularmapmaterial.cpp b/src/render/defaults/qdiffusespecularmapmaterial.cpp
index ce0abe9f2..0df8a8082 100644
--- a/src/render/defaults/qdiffusespecularmapmaterial.cpp
+++ b/src/render/defaults/qdiffusespecularmapmaterial.cpp
@@ -61,8 +61,8 @@ namespace Qt3D {
QDiffuseSpecularMapMaterialPrivate::QDiffuseSpecularMapMaterialPrivate(QDiffuseSpecularMapMaterial *qq)
: QMaterialPrivate(qq)
, m_diffuseSpecularMapEffect(new QEffect())
- , m_diffuseTexture(new QAbstractTextureProvider(QAbstractTextureProvider::Target2D))
- , m_specularTexture(new QAbstractTextureProvider(QAbstractTextureProvider::Target2D))
+ , m_diffuseTexture(new QTexture2D())
+ , m_specularTexture(new QTexture2D())
, m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
, m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture))
, m_specularParameter(new QParameter(QStringLiteral("specularTexture"), m_specularTexture))
diff --git a/src/render/defaults/qnormaldiffusemapmaterial.cpp b/src/render/defaults/qnormaldiffusemapmaterial.cpp
index cead0c51a..a07abb10b 100644
--- a/src/render/defaults/qnormaldiffusemapmaterial.cpp
+++ b/src/render/defaults/qnormaldiffusemapmaterial.cpp
@@ -61,8 +61,8 @@ namespace Qt3D {
QNormalDiffuseMapMaterialPrivate::QNormalDiffuseMapMaterialPrivate(QNormalDiffuseMapMaterial *qq)
: QMaterialPrivate(qq)
, m_normalDiffuseEffect(new QEffect())
- , m_diffuseTexture(new QAbstractTextureProvider(QAbstractTextureProvider::Target2D))
- , m_normalTexture(new QAbstractTextureProvider(QAbstractTextureProvider::Target2D))
+ , m_diffuseTexture(new QTexture2D())
+ , m_normalTexture(new QTexture2D())
, m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.1f, 0.1f, 0.1f, 1.0f)))
, m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture))
, m_normalParameter(new QParameter(QStringLiteral("normalTexture"), m_normalTexture))
diff --git a/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp b/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp
index fb9d2fa97..88e6deb74 100644
--- a/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp
+++ b/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp
@@ -60,9 +60,9 @@ namespace Qt3D {
QNormalDiffuseSpecularMapMaterialPrivate::QNormalDiffuseSpecularMapMaterialPrivate(QNormalDiffuseSpecularMapMaterial *qq)
: QMaterialPrivate(qq)
, m_normalDiffuseSpecularEffect(new QEffect())
- , m_diffuseTexture(new QAbstractTextureProvider(QAbstractTextureProvider::Target2D))
- , m_normalTexture(new QAbstractTextureProvider(QAbstractTextureProvider::Target2D))
- , m_specularTexture(new QAbstractTextureProvider(QAbstractTextureProvider::Target2D))
+ , m_diffuseTexture(new QTexture2D())
+ , m_normalTexture(new QTexture2D())
+ , m_specularTexture(new QTexture2D())
, m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
, m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture))
, m_normalParameter(new QParameter(QStringLiteral("normalTexture"), m_normalTexture))
diff --git a/src/render/frontend/qabstracttextureprovider.h b/src/render/frontend/qabstracttextureprovider.h
index 85a38d6ab..ed60b20c3 100644
--- a/src/render/frontend/qabstracttextureprovider.h
+++ b/src/render/frontend/qabstracttextureprovider.h
@@ -249,8 +249,6 @@ public:
CompareNone = 0x0000 // GL_NONE
};
- // Those will be made protected to only allow creation of a QAbstractTextureProvider through subclasses
- explicit QAbstractTextureProvider(Target target, QNode *parent = 0);
~QAbstractTextureProvider();
@@ -318,6 +316,7 @@ Q_SIGNALS:
protected:
explicit QAbstractTextureProvider(QNode *parent = 0);
+ explicit QAbstractTextureProvider(Target target, QNode *parent = 0);
QAbstractTextureProvider(QAbstractTextureProviderPrivate &dd, QNode *parent = 0);
void copy(const QNode *ref) Q_DECL_OVERRIDE;
void setStatus(Status status);
diff --git a/src/render/io/gltfparser.cpp b/src/render/io/gltfparser.cpp
index b135fc3b0..710170bf0 100644
--- a/src/render/io/gltfparser.cpp
+++ b/src/render/io/gltfparser.cpp
@@ -792,38 +792,40 @@ void GLTFParser::processJSONImage( QString id, QJsonObject jsonObj)
void GLTFParser::processJSONTexture( QString id, QJsonObject jsonObj)
{
- int target = jsonObj.value(KEY_TARGET).toInt();
- QAbstractTextureProvider* tex = new QAbstractTextureProvider(static_cast<QAbstractTextureProvider::Target>(target));
+ Q_UNUSED(id)
+ Q_UNUSED(jsonObj)
+// int target = jsonObj.value(KEY_TARGET).toInt();
+// QAbstractTextureProvider* tex = new QAbstractTextureProvider(static_cast<QAbstractTextureProvider::Target>(target));
- // TODO: Choose suitable internal format - may vary on OpenGL context type
- //int pixelFormat = jsonObj.value(KEY_FORMAT).toInt();
- //int internalFormat = jsonObj.value(KEY_INTERNAL_FORMAT).toInt();
+// // TODO: Choose suitable internal format - may vary on OpenGL context type
+// //int pixelFormat = jsonObj.value(KEY_FORMAT).toInt();
+// //int internalFormat = jsonObj.value(KEY_INTERNAL_FORMAT).toInt();
- tex->setFormat(QAbstractTextureProvider::RGBA8_UNorm /* static_cast<QOpenGLTexture::TextureFormat>(internalFormat)*/);
+// tex->setFormat(QAbstractTextureProvider::RGBA8_UNorm /* static_cast<QOpenGLTexture::TextureFormat>(internalFormat)*/);
- QString samplerId = jsonObj.value(KEY_SAMPLER).toString();
- QString source = jsonObj.value(KEY_SOURCE).toString();
- if (!m_images.contains(source)) {
- qCWarning(Render::Io) << "texture" << id << "references missing image" << source;
- return;
- }
+// QString samplerId = jsonObj.value(KEY_SAMPLER).toString();
+// QString source = jsonObj.value(KEY_SOURCE).toString();
+// if (!m_images.contains(source)) {
+// qCWarning(Render::Io) << "texture" << id << "references missing image" << source;
+// return;
+// }
- tex->setFromQImage(m_images[source]);
+// tex->setFromQImage(m_images[source]);
- QJsonObject samplersDict(m_json.object().value(KEY_SAMPLERS).toObject());
- if (!samplersDict.contains(samplerId)) {
- qCWarning(Render::Io) << "texture" << id << "references unknown sampler" << samplerId;
- return;
- }
+// QJsonObject samplersDict(m_json.object().value(KEY_SAMPLERS).toObject());
+// if (!samplersDict.contains(samplerId)) {
+// qCWarning(Render::Io) << "texture" << id << "references unknown sampler" << samplerId;
+// return;
+// }
- QJsonObject sampler = samplersDict.value(samplerId).toObject();
+// QJsonObject sampler = samplersDict.value(samplerId).toObject();
- tex->setWrapMode(QTextureWrapMode(static_cast<QTextureWrapMode::WrapMode>(sampler.value(KEY_WRAP_S).toInt())));
- tex->setMinificationFilter(static_cast<QAbstractTextureProvider::Filter>(sampler.value(KEY_MIN_FILTER).toInt()));
- tex->setMagnificationFilter(static_cast<QAbstractTextureProvider::Filter>(sampler.value(KEY_MAG_FILTER).toInt()));
+// tex->setWrapMode(QTextureWrapMode(static_cast<QTextureWrapMode::WrapMode>(sampler.value(KEY_WRAP_S).toInt())));
+// tex->setMinificationFilter(static_cast<QAbstractTextureProvider::Filter>(sampler.value(KEY_MIN_FILTER).toInt()));
+// tex->setMagnificationFilter(static_cast<QAbstractTextureProvider::Filter>(sampler.value(KEY_MAG_FILTER).toInt()));
- m_textures[id] = tex;
+// m_textures[id] = tex;
}
void GLTFParser::processJSONTechnique( QString id, QJsonObject jsonObj )