summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/qt3d/qgltf/Wine.qml2
-rw-r--r--examples/qt3d/qt3d.pro4
-rw-r--r--src/core/aspects/qaspectmanager.cpp4
-rw-r--r--src/core/aspects/qaspectmanager_p.h1
-rw-r--r--src/core/jobs/qaspectjobmanager.cpp10
-rw-r--r--src/core/qpostman.cpp13
-rw-r--r--src/input/backend/keyboardmousedeviceintegration_p.h11
-rw-r--r--src/plugins/sceneparsers/assimp/assimpparser.cpp5
-rw-r--r--src/plugins/sceneparsers/gltf/gltfparser.cpp135
-rw-r--r--src/plugins/sceneparsers/gltf/gltfparser.h3
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem.cpp65
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem_p.h1
-rw-r--r--src/render/backend/entity.cpp6
-rw-r--r--src/render/backend/renderer.cpp3
-rw-r--r--src/render/backend/renderview.cpp15
-rw-r--r--src/render/defaults/qdiffusemapmaterial.cpp2
-rw-r--r--src/render/defaults/qdiffusemapmaterial.h2
-rw-r--r--src/render/defaults/qdiffusespecularmapmaterial.h4
-rw-r--r--src/render/defaults/qnormaldiffusemapmaterial.h4
-rw-r--r--src/render/defaults/qnormaldiffusespecularmapmaterial.h6
-rw-r--r--src/render/framegraph/framegraphnode.cpp1
-rw-r--r--src/render/frontend/qrenderaspect.cpp2
-rw-r--r--src/render/graphicshelpers/graphicscontext.cpp5
-rw-r--r--src/render/graphicshelpers/graphicscontext_p.h37
-rw-r--r--src/render/graphicshelpers/graphicshelperes2.cpp9
-rw-r--r--src/render/graphicshelpers/graphicshelperes2_p.h66
-rw-r--r--src/render/graphicshelpers/graphicshelpergl2.cpp9
-rw-r--r--src/render/graphicshelpers/graphicshelpergl2_p.h65
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3.cpp9
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_3.cpp9
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_3_p.h65
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_p.h65
-rw-r--r--src/render/graphicshelpers/graphicshelpergl4.cpp5
-rw-r--r--src/render/graphicshelpers/graphicshelpergl4_p.h65
-rw-r--r--src/render/graphicshelpers/graphicshelperinterface_p.h65
-rw-r--r--src/render/io/objloader.cpp99
-rw-r--r--src/render/texture/qabstracttextureprovider.h2
-rw-r--r--src/render/texture/qtextureimage.cpp6
-rw-r--r--src/render/texture/qtextureproviders.cpp2
-rw-r--r--tools/qgltf/qgltf.cpp101
40 files changed, 626 insertions, 357 deletions
diff --git a/examples/qt3d/qgltf/Wine.qml b/examples/qt3d/qgltf/Wine.qml
index 4fab28479..b24e9de3f 100644
--- a/examples/qt3d/qgltf/Wine.qml
+++ b/examples/qt3d/qgltf/Wine.qml
@@ -54,7 +54,7 @@ Entity {
},
SceneLoader
{
- source: "qrc:/models/wine.gltf"
+ source: "qrc:/models/wine.qgltf"
}
]
}
diff --git a/examples/qt3d/qt3d.pro b/examples/qt3d/qt3d.pro
index afa4cce79..829eb2789 100644
--- a/examples/qt3d/qt3d.pro
+++ b/examples/qt3d/qt3d.pro
@@ -44,9 +44,11 @@ SUBDIRS += \
instanced-arrays-qml \
picking-qml \
transforms-qml \
- qgltf \
lights
+# qmake seems to break in some CI configurations, disable this for now
+#SUBDIRS += qgltf
+
# TODO Port the old examples to new APIs
#SUBDIRS += qt3d
qtHaveModule(widgets): SUBDIRS += assimp-cpp \
diff --git a/src/core/aspects/qaspectmanager.cpp b/src/core/aspects/qaspectmanager.cpp
index 3c7816081..80faef768 100644
--- a/src/core/aspects/qaspectmanager.cpp
+++ b/src/core/aspects/qaspectmanager.cpp
@@ -68,6 +68,7 @@ QAspectManager::QAspectManager(QObject *parent)
, m_changeArbiter(new QChangeArbiter(this))
, m_serviceLocator(new QServiceLocator())
, m_waitForEndOfExecLoop(0)
+ , m_waitForQuit(0)
{
qRegisterMetaType<QSurface *>("QSurface*");
m_runMainLoop.fetchAndStoreOrdered(0);
@@ -227,6 +228,7 @@ void QAspectManager::exec()
qCDebug(Aspects) << Q_FUNC_INFO << "Exiting event loop";
m_waitForEndOfExecLoop.release(1);
+ m_waitForQuit.acquire(1);
}
void QAspectManager::quit()
@@ -244,6 +246,8 @@ void QAspectManager::quit()
// We need to wait for the QAspectManager exec loop to terminate
m_waitForEndOfExecLoop.acquire(1);
+ m_waitForQuit.release(1);
+
qCDebug(Aspects) << Q_FUNC_INFO << "Exited event loop";
}
diff --git a/src/core/aspects/qaspectmanager_p.h b/src/core/aspects/qaspectmanager_p.h
index 9224a90bf..88ceceb29 100644
--- a/src/core/aspects/qaspectmanager_p.h
+++ b/src/core/aspects/qaspectmanager_p.h
@@ -107,6 +107,7 @@ private:
QAtomicInt m_terminated;
QScopedPointer<QServiceLocator> m_serviceLocator;
QSemaphore m_waitForEndOfExecLoop;
+ QSemaphore m_waitForQuit;
};
} // namespace Qt3DCore
diff --git a/src/core/jobs/qaspectjobmanager.cpp b/src/core/jobs/qaspectjobmanager.cpp
index b527e15e8..32f024acb 100644
--- a/src/core/jobs/qaspectjobmanager.cpp
+++ b/src/core/jobs/qaspectjobmanager.cpp
@@ -44,7 +44,6 @@
#include <QThread>
#include <QCoreApplication>
#include <QtCore/QFuture>
-#include <QtCore/QFutureWatcher>
QT_BEGIN_NAMESPACE
@@ -75,6 +74,7 @@ void QAspectJobManager::enqueueJobs(const QVector<QAspectJobPtr> &jobQueue)
// Convert QJobs to Tasks
QHash<QAspectJob *, AspectTaskRunnable *> tasksMap;
QVector<RunnableInterface *> taskList;
+ taskList.reserve(jobQueue.size());
Q_FOREACH (const QAspectJobPtr &job, jobQueue) {
AspectTaskRunnable *task = new AspectTaskRunnable();
task->m_job = job;
@@ -107,9 +107,7 @@ void QAspectJobManager::enqueueJobs(const QVector<QAspectJobPtr> &jobQueue)
void QAspectJobManager::waitForAllJobs()
{
- QFutureWatcher<void> futureWatcher;
- futureWatcher.setFuture(m_threadPooler->future());
- futureWatcher.waitForFinished();
+ m_threadPooler->future().waitForFinished();
}
void QAspectJobManager::waitForPerThreadFunction(JobFunction func, void *arg)
@@ -124,9 +122,7 @@ void QAspectJobManager::waitForPerThreadFunction(JobFunction func, void *arg)
}
QFuture<void> future = m_threadPooler->mapDependables(taskList);
- QFutureWatcher<void> futureWatcher;
- futureWatcher.setFuture(future);
- futureWatcher.waitForFinished();
+ future.waitForFinished();
}
} // namespace Qt3DCore
diff --git a/src/core/qpostman.cpp b/src/core/qpostman.cpp
index fead32db3..35aa888df 100644
--- a/src/core/qpostman.cpp
+++ b/src/core/qpostman.cpp
@@ -86,6 +86,13 @@ void QPostman::sceneChangeEvent(const QSceneChangePtr &e)
notifyFrontendNode.invoke(this, Q_ARG(QSceneChangePtr, e));
}
+static inline QMetaMethod submitChangeBatchMethod()
+{
+ int idx = QPostman::staticMetaObject.indexOfMethod("submitChangeBatch()");
+ Q_ASSERT(idx != -1);
+ return QPostman::staticMetaObject.method(idx);
+}
+
/*!
* This will start or append \a change to a batch of changes from frontend
* nodes. Once the batch is complete, when the event loop returns, the batch is
@@ -98,8 +105,10 @@ void QPostman::notifyBackend(const QSceneChangePtr &change)
// otherwise start batch
// by calling a queued slot
Q_D(QPostman);
- if (d->m_batch.empty())
- QMetaObject::invokeMethod(this, "submitChangeBatch", Qt::QueuedConnection);
+ if (d->m_batch.empty()) {
+ static const QMetaMethod submitChangeBatch = submitChangeBatchMethod();
+ submitChangeBatch.invoke(this, Qt::QueuedConnection);
+ }
d->m_batch.push_back(change);
}
diff --git a/src/input/backend/keyboardmousedeviceintegration_p.h b/src/input/backend/keyboardmousedeviceintegration_p.h
index 6a824871f..5cbbcd9d5 100644
--- a/src/input/backend/keyboardmousedeviceintegration_p.h
+++ b/src/input/backend/keyboardmousedeviceintegration_p.h
@@ -37,6 +37,17 @@
#ifndef QT3DINPUT_INPUT_KEYBOARDMOUSEDEVICEINTEGRATION_P_H
#define QT3DINPUT_INPUT_KEYBOARDMOUSEDEVICEINTEGRATION_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <Qt3DInput/qinputdeviceintegration.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/sceneparsers/assimp/assimpparser.cpp b/src/plugins/sceneparsers/assimp/assimpparser.cpp
index 5ffc1a4c8..040fc3a8a 100644
--- a/src/plugins/sceneparsers/assimp/assimpparser.cpp
+++ b/src/plugins/sceneparsers/assimp/assimpparser.cpp
@@ -678,7 +678,8 @@ void AssimpParser::loadEmbeddedTexture(uint textureIndex)
uint textureSize = assimpTexture->mWidth *
(isCompressed ? assimpTexture->mHeight : 1);
// Set texture to RGBA8888
- char *textureContent = new char[textureSize * 4];
+ QByteArray textureContent;
+ textureContent.reserve(textureSize * 4);
for (uint i = 0; i < textureSize; i++) {
uint idx = i * 4;
aiTexel texel = assimpTexture->pcData[i];
@@ -687,7 +688,7 @@ void AssimpParser::loadEmbeddedTexture(uint textureIndex)
textureContent[idx + 2] = texel.b;
textureContent[idx + 3] = texel.a;
}
- imageData->setData(QByteArray(textureContent, textureSize * 4));
+ imageData->setData(textureContent);
texture->addTextureImage(imageData);
m_scene->m_embeddedTextures[textureIndex] = texture;
}
diff --git a/src/plugins/sceneparsers/gltf/gltfparser.cpp b/src/plugins/sceneparsers/gltf/gltfparser.cpp
index 0ede1ead2..6bfca2b55 100644
--- a/src/plugins/sceneparsers/gltf/gltfparser.cpp
+++ b/src/plugins/sceneparsers/gltf/gltfparser.cpp
@@ -72,6 +72,12 @@
#include <Qt3DRender/QTechnique>
#include <Qt3DRender/QTexture>
+#include <Qt3DRender/QPhongMaterial>
+#include <Qt3DRender/QDiffuseMapMaterial>
+#include <Qt3DRender/QDiffuseSpecularMapMaterial>
+#include <Qt3DRender/QNormalDiffuseMapMaterial>
+#include <Qt3DRender/QNormalDiffuseSpecularMapMaterial>
+
QT_BEGIN_NAMESPACE
using namespace Qt3DCore;
@@ -100,6 +106,8 @@ const QString KEY_YFOV = QStringLiteral("yfov");
const QString KEY_ZNEAR = QStringLiteral("znear");
const QString KEY_ZFAR = QStringLiteral("zfar");
const QString KEY_MATERIALS = QStringLiteral("materials");
+const QString KEY_EXTENSIONS = QStringLiteral("extensions");
+const QString KEY_COMMON_MAT = QStringLiteral("KHR_materials_common");
const QString KEY_TECHNIQUE = QStringLiteral("technique");
const QString KEY_VALUES = QStringLiteral("values");
const QString KEY_BUFFERS = QStringLiteral("buffers");
@@ -245,7 +253,9 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id)
Q_FOREACH (QGeometryRenderer *geometryRenderer, m_meshDict.values(mesh.toString())) {
QEntity *entity = new QEntity;
entity->addComponent(geometryRenderer);
- entity->addComponent(material(m_meshMaterialDict[geometryRenderer]));
+ QMaterial *mat = material(m_meshMaterialDict[geometryRenderer]);
+ if (mat)
+ entity->addComponent(mat);
entities.append(entity);
}
@@ -430,7 +440,7 @@ bool GLTFParser::isGLTFPath(const QString& path)
// might need to detect other things in the future, but would
// prefer to avoid doing a full parse.
QString suffix = finfo.suffix().toLower();
- return (suffix == QStringLiteral("json") || suffix == QStringLiteral("gltf"));
+ return (suffix == QStringLiteral("json") || suffix == QStringLiteral("gltf") || suffix == QStringLiteral("qgltf"));
}
void GLTFParser::renameFromJson(const QJsonObject &json, QObject * const object)
@@ -513,19 +523,8 @@ Qt3DCore::QEntity* GLTFParser::defaultScene()
return scene(m_defaultScene);
}
-QMaterial* GLTFParser::material(const QString &id)
+QMaterial *GLTFParser::materialWithCustomShader(const QString &id, const QJsonObject &jsonObj)
{
- if (m_materialCache.contains(id))
- return m_materialCache.value(id);
-
- QJsonObject mats = m_json.object().value(KEY_MATERIALS).toObject();
- if (!mats.contains(id)) {
- qCWarning(GLTFParserLog) << "unknown material" << id << "in GLTF file" << m_basePath;
- return NULL;
- }
-
- QJsonObject jsonObj = mats.value(id).toObject();
-
//Default ES2 Technique
QString techniqueName = jsonObj.value(KEY_TECHNIQUE).toString();
if (!m_techniques.contains(techniqueName)) {
@@ -614,6 +613,114 @@ QMaterial* GLTFParser::material(const QString &id)
mat->addParameter(new QParameter(param->name(), var));
} // of material technique-instance values iteration
+ return mat;
+}
+
+static inline QVariant vec4ToRgb(const QVariant &vec4Var)
+{
+ const QVector4D v = vec4Var.value<QVector4D>();
+ return QVariant(QColor::fromRgbF(v.x(), v.y(), v.z()));
+}
+
+QMaterial *GLTFParser::commonMaterial(const QJsonObject &jsonObj)
+{
+ QVariantHash params;
+ bool hasDiffuseMap = false;
+ bool hasSpecularMap = false;
+ bool hasNormalMap = false;
+
+ QJsonObject values = jsonObj.value(KEY_VALUES).toObject();
+ Q_FOREACH (const QString &vName, values.keys()) {
+ const QJsonValue val = values.value(vName);
+ QVariant var;
+ QString propertyName = vName;
+ if (vName == QStringLiteral("ambient") && val.isArray()) {
+ var = vec4ToRgb(parameterValueFromJSON(GL_FLOAT_VEC4, val));
+ } else if (vName == QStringLiteral("diffuse")) {
+ if (val.isString()) {
+ var = parameterValueFromJSON(GL_SAMPLER_2D, val);
+ hasDiffuseMap = true;
+ } else if (val.isArray()) {
+ var = vec4ToRgb(parameterValueFromJSON(GL_FLOAT_VEC4, val));
+ }
+ } else if (vName == QStringLiteral("specular")) {
+ if (val.isString()) {
+ var = parameterValueFromJSON(GL_SAMPLER_2D, val);
+ hasSpecularMap = true;
+ } else if (val.isArray()) {
+ var = vec4ToRgb(parameterValueFromJSON(GL_FLOAT_VEC4, val));
+ }
+ } else if (vName == QStringLiteral("shininess") && val.isDouble()) {
+ var = parameterValueFromJSON(GL_FLOAT, val);
+ } else if (vName == QStringLiteral("normalmap") && val.isString()) {
+ var = parameterValueFromJSON(GL_SAMPLER_2D, val);
+ propertyName = QStringLiteral("normal");
+ hasNormalMap = true;
+ } else if (vName == QStringLiteral("transparency")) {
+ qCWarning(GLTFParserLog) << "Semi-transparent common materials are not currently supported, ignoring alpha";
+ }
+ if (var.isValid())
+ params[propertyName] = var;
+ }
+
+ QMaterial *mat = Q_NULLPTR;
+ if (hasNormalMap) {
+ if (hasSpecularMap) {
+ mat = new QNormalDiffuseSpecularMapMaterial;
+ } else {
+ if (hasDiffuseMap)
+ mat = new QNormalDiffuseMapMaterial;
+ else
+ qCWarning(GLTFParserLog) << "Common material with normal and specular maps needs a diffuse map as well";
+ }
+ } else {
+ if (hasSpecularMap) {
+ if (hasDiffuseMap)
+ mat = new QDiffuseSpecularMapMaterial;
+ else
+ qCWarning(GLTFParserLog) << "Common material with specular map needs a diffuse map as well";
+ } else if (hasDiffuseMap) {
+ mat = new QDiffuseMapMaterial;
+ } else {
+ mat = new QPhongMaterial;
+ }
+ }
+
+ if (mat) {
+ for (QVariantHash::const_iterator it = params.constBegin(), itEnd = params.constEnd(); it != itEnd; ++it)
+ mat->setProperty(it.key().toUtf8(), it.value());
+ } else {
+ qCWarning(GLTFParserLog) << "Could not find a suitable built-in material for KHR_materials_common";
+ }
+
+ return mat;
+}
+
+QMaterial* GLTFParser::material(const QString &id)
+{
+ if (m_materialCache.contains(id))
+ return m_materialCache.value(id);
+
+ QJsonObject mats = m_json.object().value(KEY_MATERIALS).toObject();
+ if (!mats.contains(id)) {
+ qCWarning(GLTFParserLog) << "unknown material" << id << "in GLTF file" << m_basePath;
+ return NULL;
+ }
+
+ QJsonObject jsonObj = mats.value(id).toObject();
+
+ QMaterial *mat = Q_NULLPTR;
+
+ // Prefer common materials over custom shaders.
+ if (jsonObj.contains(KEY_EXTENSIONS)) {
+ QJsonObject extensions = jsonObj.value(KEY_EXTENSIONS).toObject();
+ if (extensions.contains(KEY_COMMON_MAT))
+ mat = commonMaterial(extensions.value(KEY_COMMON_MAT).toObject());
+ }
+
+ if (!mat)
+ mat = materialWithCustomShader(id, jsonObj);
+
m_materialCache[id] = mat;
return mat;
}
diff --git a/src/plugins/sceneparsers/gltf/gltfparser.h b/src/plugins/sceneparsers/gltf/gltfparser.h
index 0a4bbcfe9..be8bcaa50 100644
--- a/src/plugins/sceneparsers/gltf/gltfparser.h
+++ b/src/plugins/sceneparsers/gltf/gltfparser.h
@@ -169,6 +169,9 @@ private:
static QRenderState *buildStateEnable(int state);
static QRenderState *buildState(const QString& functionName, const QJsonValue &value, int &type);
+ QMaterial *materialWithCustomShader(const QString &id, const QJsonObject &jsonObj);
+ QMaterial *commonMaterial(const QJsonObject &jsonObj);
+
QJsonDocument m_json;
QString m_basePath;
bool m_parseDone;
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp
index ef839ae87..2e55c52ee 100644
--- a/src/quick3d/imports/scene3d/scene3ditem.cpp
+++ b/src/quick3d/imports/scene3d/scene3ditem.cpp
@@ -96,9 +96,8 @@ class Scene3DSGNode;
\li The window is closed
- \li This triggers the windowsChanged signal which the Scene3DRenderer
- uses to perform the necessary cleanups in the QSGRenderThread (destroys
- DebugLogger ...) with the shutdown slot (queued connection).
+ \li Scene3DItem is notified via itemChange() and calls shutdown() on Scene3DRenderer,
+ which performs the necessary cleanups in the QSGRenderThread (destroys DebugLogger ...).
\li The destroyed signal of the window is also connected to the
Scene3DRenderer. When triggered in the context of the main thread, the
@@ -163,7 +162,6 @@ public:
Q_CHECK_PTR(m_item->window());
QObject::connect(m_item->window(), &QQuickWindow::beforeRendering, this, &Scene3DRenderer::render, Qt::DirectConnection);
- QObject::connect(m_item, &QQuickItem::windowChanged, this, &Scene3DRenderer::onWindowChangedQueued, Qt::QueuedConnection);
ContextSaver saver;
@@ -215,36 +213,11 @@ public:
void synchronize();
-public Q_SLOTS:
- void render();
-
// Executed in the QtQuick render thread.
- void shutdown()
- {
- qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
-
- // Set to null so that subsequent calls to render
- // would return early
- m_item = Q_NULLPTR;
+ void shutdown();
- // Shutdown the Renderer Aspect while the OpenGL context
- // is still valid
- if (m_renderAspect)
- m_renderAspect->renderShutdown();
- }
-
- // SGThread
- void onWindowChangedQueued(QQuickWindow *w)
- {
- if (w == Q_NULLPTR) {
- qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
- shutdown();
- // Will only trigger something with the Loader case
- // The window closed cases is handled by the window's destroyed
- // signal
- QMetaObject::invokeMethod(m_cleaner, "cleanup");
- }
- }
+public Q_SLOTS:
+ void render();
private:
Scene3DItem *m_item; // Will be released by the QQuickWindow/QML Engine
@@ -565,6 +538,15 @@ void Scene3DItem::setMultisample(bool enable)
}
}
+void Scene3DItem::itemChange(ItemChange change, const ItemChangeData& value)
+{
+ // Are we being removed from the scene?
+ if (change == QQuickItem::ItemSceneChange && value.window == Q_NULLPTR)
+ m_renderer->shutdown();
+
+ QQuickItem::itemChange(change, value);
+}
+
QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *)
{
// If the node already exists
@@ -594,6 +576,25 @@ void Scene3DRenderer::synchronize()
m_multisample = m_item->multisample();
}
+void Scene3DRenderer::shutdown()
+{
+ qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
+
+ // Set to null so that subsequent calls to render
+ // would return early
+ m_item = Q_NULLPTR;
+
+ // Shutdown the Renderer Aspect while the OpenGL context
+ // is still valid
+ if (m_renderAspect)
+ m_renderAspect->renderShutdown();
+
+ // Will only trigger something with the Loader case
+ // The window closed cases is handled by the window's destroyed
+ // signal
+ QMetaObject::invokeMethod(m_cleaner, "cleanup");
+}
+
void Scene3DRenderer::setSGNode(Scene3DSGNode *node) Q_DECL_NOEXCEPT
{
m_node = node;
diff --git a/src/quick3d/imports/scene3d/scene3ditem_p.h b/src/quick3d/imports/scene3d/scene3ditem_p.h
index edb0b7b00..1b9335203 100644
--- a/src/quick3d/imports/scene3d/scene3ditem_p.h
+++ b/src/quick3d/imports/scene3d/scene3ditem_p.h
@@ -93,6 +93,7 @@ private Q_SLOTS:
void applyRootEntityChange();
private:
+ void itemChange(ItemChange change, const ItemChangeData& value);
QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *nodeData) Q_DECL_OVERRIDE;
QStringList m_aspects;
diff --git a/src/render/backend/entity.cpp b/src/render/backend/entity.cpp
index 48a7c738d..745e54735 100644
--- a/src/render/backend/entity.cpp
+++ b/src/render/backend/entity.cpp
@@ -364,6 +364,7 @@ template<>
QList<HLayer> Entity::componentsHandle<Layer>() const
{
QList<HLayer> layerHandles;
+ layerHandles.reserve(m_layerComponents.size());
Q_FOREACH (const QNodeId &id, m_layerComponents)
layerHandles.append(m_nodeManagers->layerManager()->lookupHandle(id));
return layerHandles;
@@ -373,6 +374,7 @@ template<>
QList<HShaderData> Entity::componentsHandle<ShaderData>() const
{
QList<HShaderData> shaderDataHandles;
+ shaderDataHandles.reserve(m_shaderDataComponents.size());
Q_FOREACH (const QNodeId &id, m_shaderDataComponents)
shaderDataHandles.append(m_nodeManagers->shaderDataManager()->lookupHandle(id));
return shaderDataHandles;
@@ -388,6 +390,7 @@ template<>
QList<HLight> Entity::componentsHandle<Light>() const
{
QList<HLight> lightHandles;
+ lightHandles.reserve(m_lightComponents.size());
Q_FOREACH (const QNodeId &id, m_lightComponents)
lightHandles.append(m_nodeManagers->lightManager()->lookupHandle(id));
return lightHandles;
@@ -429,6 +432,7 @@ template<>
QList<Layer *> Entity::renderComponents<Layer>() const
{
QList<Layer *> layers;
+ layers.reserve(m_layerComponents.size());
Q_FOREACH (const QNodeId &id, m_layerComponents)
layers.append(m_nodeManagers->layerManager()->lookupResource(id));
return layers;
@@ -438,6 +442,7 @@ template<>
QList<ShaderData *> Entity::renderComponents<ShaderData>() const
{
QList<ShaderData *> shaderDatas;
+ shaderDatas.reserve(m_shaderDataComponents.size());
Q_FOREACH (const QNodeId &id, m_shaderDataComponents)
shaderDatas.append(m_nodeManagers->shaderDataManager()->lookupResource(id));
return shaderDatas;
@@ -447,6 +452,7 @@ template<>
QList<Light *> Entity::renderComponents<Light>() const
{
QList<Light *> lights;
+ lights.reserve(m_lightComponents.size());
Q_FOREACH (const QNodeId &id, m_lightComponents)
lights.append(m_nodeManagers->lightManager()->lookupResource(id));
return lights;
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index dbb91359c..e2d4ef768 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -378,6 +378,8 @@ void Renderer::shutdown()
{
// TO DO: Check that this works with iOs and other cases
if (m_surface) {
+ m_running.fetchAndStoreOrdered(0);
+
m_graphicsContext->makeCurrent(m_surface);
// Stop and destroy the OpenGL logger
if (m_debugLogger) {
@@ -958,6 +960,7 @@ Attribute *Renderer::updateBuffersAndAttributes(Geometry *geometry, RenderComman
Attribute *indexAttribute = Q_NULLPTR;
uint estimatedCount = 0;
+ m_dirtyAttributes.reserve(m_dirtyAttributes.size() + geometry->attributes().size());
Q_FOREACH (const QNodeId &attributeId, geometry->attributes()) {
// TO DO: Improvement we could store handles and use the non locking policy on the attributeManager
Attribute *attribute = m_nodesManager->attributeManager()->lookupResource(attributeId);
diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp
index e630e7a8b..ac7c9cf78 100644
--- a/src/render/backend/renderview.cpp
+++ b/src/render/backend/renderview.cpp
@@ -362,7 +362,7 @@ void RenderView::sort()
// where two uniforms, referencing the same texture eventually have 2 different
// texture unit values
if (cachedUniforms.contains(it.key())) {
- const QUniformValue *refValue = cachedUniforms[it.key()];
+ const QUniformValue *refValue = cachedUniforms.value(it.key());
if (*const_cast<QUniformValue *>(refValue) == *it.value()) {
destroyUniformValue(it.value(), m_allocator);
it = uniforms.erase(it);
@@ -475,6 +475,7 @@ void RenderView::buildRenderCommands(Entity *node, const Plane *planes)
parametersFromMaterialEffectTechnique(&parameters, m_manager->parameterManager(), material, effect, technique);
// 1 RenderCommand per RenderPass pass on an Entity with a Mesh
+ m_commands.reserve(m_commands.size() + passes.size());
Q_FOREACH (RenderPass *pass, passes) {
// Add the RenderPass Parameters
@@ -508,6 +509,7 @@ void RenderView::buildRenderCommands(Entity *node, const Plane *planes)
// Replace with more sophisticated mechanisms later.
std::sort(m_lightSources.begin(), m_lightSources.end(), LightSourceCompare(node));
QVector<LightSource> activeLightSources; // NB! the total number of lights here may still exceed MAX_LIGHTS
+ activeLightSources.reserve(m_lightSources.count());
int lightCount = 0;
for (int i = 0; i < m_lightSources.count() && lightCount < MAX_LIGHTS; ++i) {
activeLightSources.append(m_lightSources[i]);
@@ -622,8 +624,8 @@ void RenderView::setDefaultUniformBlockShaderDataValue(QUniformPack &uniformPack
// Build name-value map for the block
m_data->m_uniformBlockBuilder.buildActiveUniformNameValueMapStructHelper(shaderData, structName);
// Set uniform values for each entrie of the block name-value map
- QHash<QString, QVariant>::const_iterator activeValuesIt = m_data->m_uniformBlockBuilder.activeUniformNamesToValue.begin();
- const QHash<QString, QVariant>::const_iterator activeValuesEnd = m_data->m_uniformBlockBuilder.activeUniformNamesToValue.end();
+ QHash<QString, QVariant>::const_iterator activeValuesIt = m_data->m_uniformBlockBuilder.activeUniformNamesToValue.constBegin();
+ const QHash<QString, QVariant>::const_iterator activeValuesEnd = m_data->m_uniformBlockBuilder.activeUniformNamesToValue.constEnd();
while (activeValuesIt != activeValuesEnd) {
setUniformValue(uniformPack, activeValuesIt.key(), activeValuesIt.value());
@@ -764,9 +766,8 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, RenderPass *rPass,
}
// Lights
- const QString LIGHT_ARRAY_NAME = QStringLiteral("lights");
const QString LIGHT_COUNT_NAME = QStringLiteral("lightCount");
- const QString LIGHT_POSITION_NAME = QStringLiteral("position");
+ const QString LIGHT_POSITION_NAME = QStringLiteral(".position");
int lightIdx = 0;
Q_FOREACH (const LightSource &lightSource, activeLightSources) {
@@ -777,8 +778,8 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, RenderPass *rPass,
Q_FOREACH (Light *light, lightSource.lights) {
if (lightIdx == MAX_LIGHTS)
break;
- QString structName = QString(QStringLiteral("%1[%2]")).arg(LIGHT_ARRAY_NAME).arg(lightIdx);
- setUniformValue(command->m_uniforms, structName + QLatin1Char('.') + LIGHT_POSITION_NAME, worldPos);
+ const QString structName = QStringLiteral("lights[") + QString::number(lightIdx) + QLatin1Char(']');
+ setUniformValue(command->m_uniforms, structName + LIGHT_POSITION_NAME, worldPos);
setDefaultUniformBlockShaderDataValue(command->m_uniforms, shader, light, structName);
++lightIdx;
}
diff --git a/src/render/defaults/qdiffusemapmaterial.cpp b/src/render/defaults/qdiffusemapmaterial.cpp
index 8ef50b250..1188b6ae1 100644
--- a/src/render/defaults/qdiffusemapmaterial.cpp
+++ b/src/render/defaults/qdiffusemapmaterial.cpp
@@ -234,7 +234,7 @@ QColor QDiffuseMapMaterial::specular() const
float QDiffuseMapMaterial::shininess() const
{
Q_D(const QDiffuseMapMaterial);
- return d->m_diffuseParameter->value().toFloat();
+ return d->m_shininessParameter->value().toFloat();
}
/*!
diff --git a/src/render/defaults/qdiffusemapmaterial.h b/src/render/defaults/qdiffusemapmaterial.h
index d948ae7aa..5367abe9d 100644
--- a/src/render/defaults/qdiffusemapmaterial.h
+++ b/src/render/defaults/qdiffusemapmaterial.h
@@ -53,7 +53,7 @@ class QT3DRENDERSHARED_EXPORT QDiffuseMapMaterial : public QMaterial
Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged)
Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
- Q_PROPERTY(QAbstractTextureProvider *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTextureProvider *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
public:
diff --git a/src/render/defaults/qdiffusespecularmapmaterial.h b/src/render/defaults/qdiffusespecularmapmaterial.h
index 12b8c6fbf..096c4ce88 100644
--- a/src/render/defaults/qdiffusespecularmapmaterial.h
+++ b/src/render/defaults/qdiffusespecularmapmaterial.h
@@ -52,8 +52,8 @@ class QT3DRENDERSHARED_EXPORT QDiffuseSpecularMapMaterial : public QMaterial
Q_OBJECT
Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
- Q_PROPERTY(QAbstractTextureProvider *specular READ specular WRITE setSpecular NOTIFY specularChanged)
- Q_PROPERTY(QAbstractTextureProvider *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTextureProvider *specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTextureProvider *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
public:
diff --git a/src/render/defaults/qnormaldiffusemapmaterial.h b/src/render/defaults/qnormaldiffusemapmaterial.h
index 945eaa616..835c0a155 100644
--- a/src/render/defaults/qnormaldiffusemapmaterial.h
+++ b/src/render/defaults/qnormaldiffusemapmaterial.h
@@ -52,8 +52,8 @@ class QT3DRENDERSHARED_EXPORT QNormalDiffuseMapMaterial : public QMaterial
Q_OBJECT
Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged)
- Q_PROPERTY(QAbstractTextureProvider *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
- Q_PROPERTY(QAbstractTextureProvider *normal READ normal WRITE setNormal NOTIFY normalChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTextureProvider *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTextureProvider *normal READ normal WRITE setNormal NOTIFY normalChanged)
Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
diff --git a/src/render/defaults/qnormaldiffusespecularmapmaterial.h b/src/render/defaults/qnormaldiffusespecularmapmaterial.h
index 502656aef..2e72cc0fa 100644
--- a/src/render/defaults/qnormaldiffusespecularmapmaterial.h
+++ b/src/render/defaults/qnormaldiffusespecularmapmaterial.h
@@ -50,9 +50,9 @@ class QT3DRENDERSHARED_EXPORT QNormalDiffuseSpecularMapMaterial : public QMateri
{
Q_OBJECT
Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
- Q_PROPERTY(QAbstractTextureProvider *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
- Q_PROPERTY(QAbstractTextureProvider *normal READ normal WRITE setNormal NOTIFY normalChanged)
- Q_PROPERTY(QAbstractTextureProvider *specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTextureProvider *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTextureProvider *normal READ normal WRITE setNormal NOTIFY normalChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTextureProvider *specular READ specular WRITE setSpecular NOTIFY specularChanged)
Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
diff --git a/src/render/framegraph/framegraphnode.cpp b/src/render/framegraph/framegraphnode.cpp
index d1718b7e5..1c913b281 100644
--- a/src/render/framegraph/framegraphnode.cpp
+++ b/src/render/framegraph/framegraphnode.cpp
@@ -137,6 +137,7 @@ FrameGraphNode *FrameGraphNode::parent() const
QList<FrameGraphNode *> FrameGraphNode::children() const
{
QList<FrameGraphNode *> children;
+ children.reserve(m_childrenHandles.size());
Q_FOREACH (HFrameGraphNode handle, m_childrenHandles) {
FrameGraphNode **child = m_manager->data(handle);
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp
index a35513d9a..d77b04640 100644
--- a/src/render/frontend/qrenderaspect.cpp
+++ b/src/render/frontend/qrenderaspect.cpp
@@ -368,7 +368,7 @@ QVector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
}
// Only add dependency if not already present
- QVector<QWeakPointer<QAspectJob> > dependencies = pickBoundingVolumeJob->dependencies();
+ const QVector<QWeakPointer<QAspectJob> > dependencies = pickBoundingVolumeJob->dependencies();
if (std::find(dependencies.begin(), dependencies.end(), d->m_updateBoundingVolumeJob) == dependencies.end())
pickBoundingVolumeJob->addDependency(d->m_updateBoundingVolumeJob);
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp
index 92f5abbf4..e94611010 100644
--- a/src/render/graphicshelpers/graphicscontext.cpp
+++ b/src/render/graphicshelpers/graphicscontext.cpp
@@ -687,6 +687,11 @@ void GraphicsContext::blendEquation(GLenum mode)
m_glHelper->blendEquation(mode);
}
+void GraphicsContext::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
+{
+ m_glHelper->blendFunci(buf, sfactor, dfactor);
+}
+
void GraphicsContext::alphaTest(GLenum mode1, GLenum mode2)
{
m_glHelper->alphaTest(mode1, mode2);
diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h
index 8436166f4..c377d237b 100644
--- a/src/render/graphicshelpers/graphicscontext_p.h
+++ b/src/render/graphicshelpers/graphicscontext_p.h
@@ -169,32 +169,33 @@ public:
QGraphicsApiFilter *contextInfo() const;
// Wrapper methods
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0);
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances);
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex = 0);
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count);
- void setVerticesPerPatch(GLint verticesPerPatch);
- void blendEquation(GLenum mode);
void alphaTest(GLenum mode1, GLenum mode2);
- void depthTest(GLenum mode);
- void depthMask(GLenum mode);
- void cullFace(GLenum mode);
- void frontFace(GLenum mode);
+ void bindBufferBase(GLenum target, GLuint bindingIndex, GLuint buffer);
void bindFragOutputs(GLuint shader, const QHash<QString, int> &outputs);
- void bindUniform(const QVariant &v, const ShaderUniform &description);
void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
- void bindBufferBase(GLenum target, GLuint bindingIndex, GLuint buffer);
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer);
- void enableAlphaCoverage();
- void disableAlphaCoverage();
+ void bindUniform(const QVariant &v, const ShaderUniform &description);
+ void blendEquation(GLenum mode);
+ void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor);
GLuint boundFrameBufferObject();
+ void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer);
void clearColor(const QColor &color);
- void enableClipPlane(int clipPlane);
+ void cullFace(GLenum mode);
+ void depthMask(GLenum mode);
+ void depthTest(GLenum mode);
+ void disableAlphaCoverage();
void disableClipPlane(int clipPlane);
- GLint maxClipPlaneCount();
- void enablePrimitiveRestart(int restartIndex);
void disablePrimitiveRestart();
+ void drawArrays(GLenum primitiveType, GLint first, GLsizei count);
+ void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances);
+ void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex = 0);
+ void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0);
+ void enableAlphaCoverage();
+ void enableClipPlane(int clipPlane);
+ void enablePrimitiveRestart(int restartIndex);
+ void frontFace(GLenum mode);
+ GLint maxClipPlaneCount();
void pointSize(bool programmable, GLfloat value);
+ void setVerticesPerPatch(GLint verticesPerPatch);
// Helper methods
static GLint elementType(GLint type);
diff --git a/src/render/graphicshelpers/graphicshelperes2.cpp b/src/render/graphicshelpers/graphicshelperes2.cpp
index 2072df3f4..86e526d61 100644
--- a/src/render/graphicshelpers/graphicshelperes2.cpp
+++ b/src/render/graphicshelpers/graphicshelperes2.cpp
@@ -219,6 +219,15 @@ void GraphicsHelperES2::blendEquation(GLenum mode)
m_funcs->glBlendEquation(mode);
}
+void GraphicsHelperES2::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
+{
+ Q_UNUSED(buf);
+ Q_UNUSED(sfactor);
+ Q_UNUSED(dfactor);
+
+ qWarning() << "glBlendFunci() not supported by OpenGL ES 2.0";
+}
+
void GraphicsHelperES2::alphaTest(GLenum, GLenum)
{
qCWarning(Render::Rendering) << Q_FUNC_INFO << "AlphaTest not available with OpenGL ES 2.0";
diff --git a/src/render/graphicshelpers/graphicshelperes2_p.h b/src/render/graphicshelpers/graphicshelperes2_p.h
index f7d675b82..5d75137e9 100644
--- a/src/render/graphicshelpers/graphicshelperes2_p.h
+++ b/src/render/graphicshelpers/graphicshelperes2_p.h
@@ -64,47 +64,49 @@ public:
virtual ~GraphicsHelperES2();
// QGraphicHelperInterface interface
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
- void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
- void useProgram(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
- void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
- void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
void alphaTest(GLenum mode1, GLenum mode2) Q_DECL_OVERRIDE;
- void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void depthMask(GLenum mode) Q_DECL_OVERRIDE;
- void cullFace(GLenum mode) Q_DECL_OVERRIDE;
- void frontFace(GLenum mode) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
- GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
- void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindBufferBase(GLenum target, GLuint index, GLuint buffer) Q_DECL_OVERRIDE;
+ void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
+ void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
void bindFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
+ void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
+ void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) Q_DECL_OVERRIDE;
GLuint boundFrameBufferObject() Q_DECL_OVERRIDE;
+ void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
bool checkFrameBufferComplete() Q_DECL_OVERRIDE;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
- bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
+ void cullFace(GLenum mode) Q_DECL_OVERRIDE;
+ void depthMask(GLenum mode) Q_DECL_OVERRIDE;
+ void depthTest(GLenum mode) Q_DECL_OVERRIDE;
+ void disableAlphaCoverage() Q_DECL_OVERRIDE;
+ void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
+ void disablePrimitiveRestart() Q_DECL_OVERRIDE;
+ void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
+ void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
- void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
- void bindBufferBase(GLenum target, GLuint index, GLuint buffer) Q_DECL_OVERRIDE;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
- uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
- void disablePrimitiveRestart() Q_DECL_OVERRIDE;
- void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ void frontFace(GLenum mode) Q_DECL_OVERRIDE;
QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE;
QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE;
+ void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
+ void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
+ QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
+ bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void useProgram(GLuint programId) Q_DECL_OVERRIDE;
+ void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
+
private:
QOpenGLFunctions *m_funcs;
diff --git a/src/render/graphicshelpers/graphicshelpergl2.cpp b/src/render/graphicshelpers/graphicshelpergl2.cpp
index c21a6eeba..a73833b28 100644
--- a/src/render/graphicshelpers/graphicshelpergl2.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl2.cpp
@@ -202,6 +202,15 @@ void GraphicsHelperGL2::blendEquation(GLenum mode)
m_funcs->glBlendEquation(mode);
}
+void GraphicsHelperGL2::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
+{
+ Q_UNUSED(buf);
+ Q_UNUSED(sfactor);
+ Q_UNUSED(dfactor);
+
+ qWarning() << "glBlendFunci() not supported by OpenGL 2.0 (since OpenGL 4.0)";
+}
+
void GraphicsHelperGL2::alphaTest(GLenum mode1, GLenum mode2)
{
m_funcs->glEnable(GL_ALPHA_TEST);
diff --git a/src/render/graphicshelpers/graphicshelpergl2_p.h b/src/render/graphicshelpers/graphicshelpergl2_p.h
index 6d7a7e8f6..62016c9e8 100644
--- a/src/render/graphicshelpers/graphicshelpergl2_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl2_p.h
@@ -66,47 +66,48 @@ public:
GraphicsHelperGL2();
// QGraphicHelperInterface interface
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
- void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
- void useProgram(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
- void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
- void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
void alphaTest(GLenum mode1, GLenum mode2) Q_DECL_OVERRIDE;
- void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void depthMask(GLenum mode) Q_DECL_OVERRIDE;
- void cullFace(GLenum mode) Q_DECL_OVERRIDE;
- void frontFace(GLenum mode) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
- GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
- void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindBufferBase(GLenum target, GLuint index, GLuint buffer) Q_DECL_OVERRIDE;
+ void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
+ void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
void bindFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
+ void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
+ void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) Q_DECL_OVERRIDE;
GLuint boundFrameBufferObject() Q_DECL_OVERRIDE;
+ void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
bool checkFrameBufferComplete() Q_DECL_OVERRIDE;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
- bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
+ void cullFace(GLenum mode) Q_DECL_OVERRIDE;
+ void depthMask(GLenum mode) Q_DECL_OVERRIDE;
+ void depthTest(GLenum mode) Q_DECL_OVERRIDE;
+ void disableAlphaCoverage() Q_DECL_OVERRIDE;
+ void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
+ void disablePrimitiveRestart() Q_DECL_OVERRIDE;
+ void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
+ void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
- void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
- void bindBufferBase(GLenum target, GLuint index, GLuint buffer) Q_DECL_OVERRIDE;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
- uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
- void disablePrimitiveRestart() Q_DECL_OVERRIDE;
- void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ void frontFace(GLenum mode) Q_DECL_OVERRIDE;
QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE;
QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE;
+ void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
+ void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
+ QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
+ bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void useProgram(GLuint programId) Q_DECL_OVERRIDE;
+ void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
private:
QOpenGLFunctions_2_0 *m_funcs;
diff --git a/src/render/graphicshelpers/graphicshelpergl3.cpp b/src/render/graphicshelpers/graphicshelpergl3.cpp
index 0f48348e4..181093cbc 100644
--- a/src/render/graphicshelpers/graphicshelpergl3.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl3.cpp
@@ -230,6 +230,15 @@ void GraphicsHelperGL3::blendEquation(GLenum mode)
m_funcs->glBlendEquation(mode);
}
+void GraphicsHelperGL3::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
+{
+ Q_UNUSED(buf);
+ Q_UNUSED(sfactor);
+ Q_UNUSED(dfactor);
+
+ qWarning() << "glBlendFunci() not supported by OpenGL 3.0 (since OpenGL 4.0)";
+}
+
void GraphicsHelperGL3::alphaTest(GLenum, GLenum)
{
qCWarning(Render::Rendering) << "AlphaTest not available with OpenGL 3.2 core";
diff --git a/src/render/graphicshelpers/graphicshelpergl3_3.cpp b/src/render/graphicshelpers/graphicshelpergl3_3.cpp
index 3cc06482f..e5e7c23e1 100644
--- a/src/render/graphicshelpers/graphicshelpergl3_3.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl3_3.cpp
@@ -227,6 +227,15 @@ void GraphicsHelperGL3_3::blendEquation(GLenum mode)
m_funcs->glBlendEquation(mode);
}
+void GraphicsHelperGL3_3::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
+{
+ Q_UNUSED(buf);
+ Q_UNUSED(sfactor);
+ Q_UNUSED(dfactor);
+
+ qWarning() << "glBlendFunci() not supported by OpenGL 3.3 (since OpenGL 4.0)";
+}
+
void GraphicsHelperGL3_3::alphaTest(GLenum, GLenum)
{
qCWarning(Render::Rendering) << "AlphaTest not available with OpenGL 3.2 core";
diff --git a/src/render/graphicshelpers/graphicshelpergl3_3_p.h b/src/render/graphicshelpers/graphicshelpergl3_3_p.h
index 11344db63..625720d06 100644
--- a/src/render/graphicshelpers/graphicshelpergl3_3_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl3_3_p.h
@@ -67,47 +67,48 @@ public:
GraphicsHelperGL3_3();
// QGraphicHelperInterface interface
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
- void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
- void useProgram(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
- void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
- void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
void alphaTest(GLenum mode1, GLenum mode2) Q_DECL_OVERRIDE;
- void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void depthMask(GLenum mode) Q_DECL_OVERRIDE;
- void cullFace(GLenum mode) Q_DECL_OVERRIDE;
- void frontFace(GLenum mode) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
- GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
- void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindBufferBase(GLenum target, GLuint index, GLuint buffer) Q_DECL_OVERRIDE;
+ void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
+ void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
void bindFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
+ void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
+ void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) Q_DECL_OVERRIDE;
GLuint boundFrameBufferObject() Q_DECL_OVERRIDE;
+ void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
bool checkFrameBufferComplete() Q_DECL_OVERRIDE;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
- bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
+ void cullFace(GLenum mode) Q_DECL_OVERRIDE;
+ void depthMask(GLenum mode) Q_DECL_OVERRIDE;
+ void depthTest(GLenum mode) Q_DECL_OVERRIDE;
+ void disableAlphaCoverage() Q_DECL_OVERRIDE;
+ void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
+ void disablePrimitiveRestart() Q_DECL_OVERRIDE;
+ void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
+ void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
- void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
- void bindBufferBase(GLenum target, GLuint bindingIndex, GLuint buffer) Q_DECL_OVERRIDE;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
- uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
- void disablePrimitiveRestart() Q_DECL_OVERRIDE;
- void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ void frontFace(GLenum mode) Q_DECL_OVERRIDE;
QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE;
QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE;
+ void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
+ void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
+ QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
+ bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void useProgram(GLuint programId) Q_DECL_OVERRIDE;
+ void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
private:
QOpenGLFunctions_3_3_Core *m_funcs;
diff --git a/src/render/graphicshelpers/graphicshelpergl3_p.h b/src/render/graphicshelpers/graphicshelpergl3_p.h
index 9297998fa..59337a690 100644
--- a/src/render/graphicshelpers/graphicshelpergl3_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl3_p.h
@@ -67,47 +67,48 @@ public:
GraphicsHelperGL3();
// QGraphicHelperInterface interface
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
- void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
- void useProgram(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
- void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
- void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
void alphaTest(GLenum mode1, GLenum mode2) Q_DECL_OVERRIDE;
- void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void depthMask(GLenum mode) Q_DECL_OVERRIDE;
- void cullFace(GLenum mode) Q_DECL_OVERRIDE;
- void frontFace(GLenum mode) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
- GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
- void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindBufferBase(GLenum target, GLuint index, GLuint buffer) Q_DECL_OVERRIDE;
+ void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
+ void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
void bindFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
+ void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
+ void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) Q_DECL_OVERRIDE;
GLuint boundFrameBufferObject() Q_DECL_OVERRIDE;
+ void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
bool checkFrameBufferComplete() Q_DECL_OVERRIDE;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
- bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
+ void cullFace(GLenum mode) Q_DECL_OVERRIDE;
+ void depthMask(GLenum mode) Q_DECL_OVERRIDE;
+ void depthTest(GLenum mode) Q_DECL_OVERRIDE;
+ void disableAlphaCoverage() Q_DECL_OVERRIDE;
+ void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
+ void disablePrimitiveRestart() Q_DECL_OVERRIDE;
+ void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
+ void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
- void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
- void bindBufferBase(GLenum target, GLuint bindingIndex, GLuint buffer) Q_DECL_OVERRIDE;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
- uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
- void disablePrimitiveRestart() Q_DECL_OVERRIDE;
- void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ void frontFace(GLenum mode) Q_DECL_OVERRIDE;
QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE;
QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE;
+ void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
+ void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
+ QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
+ bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void useProgram(GLuint programId) Q_DECL_OVERRIDE;
+ void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
private:
QOpenGLFunctions_3_2_Core *m_funcs;
diff --git a/src/render/graphicshelpers/graphicshelpergl4.cpp b/src/render/graphicshelpers/graphicshelpergl4.cpp
index dfd09cafd..74f7b4d4f 100644
--- a/src/render/graphicshelpers/graphicshelpergl4.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl4.cpp
@@ -216,6 +216,11 @@ void GraphicsHelperGL4::blendEquation(GLenum mode)
m_funcs->glBlendEquation(mode);
}
+void GraphicsHelperGL4::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
+{
+ m_funcs->glBlendFunci(buf, sfactor, dfactor);
+}
+
void GraphicsHelperGL4::alphaTest(GLenum, GLenum)
{
qCWarning(Render::Rendering) << "AlphaTest not available with OpenGL 3.2 core";
diff --git a/src/render/graphicshelpers/graphicshelpergl4_p.h b/src/render/graphicshelpers/graphicshelpergl4_p.h
index b91653775..0ed007482 100644
--- a/src/render/graphicshelpers/graphicshelpergl4_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl4_p.h
@@ -66,47 +66,48 @@ public:
GraphicsHelperGL4();
// QGraphicHelperInterface interface
- void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
- void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
- void useProgram(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
- QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
- void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
- void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
void alphaTest(GLenum mode1, GLenum mode2) Q_DECL_OVERRIDE;
- void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void depthMask(GLenum mode) Q_DECL_OVERRIDE;
- void cullFace(GLenum mode) Q_DECL_OVERRIDE;
- void frontFace(GLenum mode) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
- GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
- void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindBufferBase(GLenum target, GLuint index, GLuint buffer) Q_DECL_OVERRIDE;
+ void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
+ void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
void bindFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
+ void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void blendEquation(GLenum mode) Q_DECL_OVERRIDE;
+ void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) Q_DECL_OVERRIDE;
GLuint boundFrameBufferObject() Q_DECL_OVERRIDE;
+ void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
bool checkFrameBufferComplete() Q_DECL_OVERRIDE;
- void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) Q_DECL_OVERRIDE;
- bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ GLuint createFrameBufferObject() Q_DECL_OVERRIDE;
+ void cullFace(GLenum mode) Q_DECL_OVERRIDE;
+ void depthMask(GLenum mode) Q_DECL_OVERRIDE;
+ void depthTest(GLenum mode) Q_DECL_OVERRIDE;
+ void disableAlphaCoverage() Q_DECL_OVERRIDE;
+ void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
+ void disablePrimitiveRestart() Q_DECL_OVERRIDE;
+ void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE;
+ void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
- void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) Q_DECL_OVERRIDE;
- void bindUniform(const QVariant &v, const ShaderUniform &description) Q_DECL_OVERRIDE;
- void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) Q_DECL_OVERRIDE;
- void bindBufferBase(GLenum target, GLuint bindingIndex, GLuint buffer) Q_DECL_OVERRIDE;
- void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE;
- uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
- GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
- void disablePrimitiveRestart() Q_DECL_OVERRIDE;
- void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ void frontFace(GLenum mode) Q_DECL_OVERRIDE;
QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE;
QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE;
+ void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) Q_DECL_OVERRIDE;
+ void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE;
+ GLint maxClipPlaneCount() Q_DECL_OVERRIDE;
+ QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
+ void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
+ bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE;
+ uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE;
+ void useProgram(GLuint programId) Q_DECL_OVERRIDE;
+ void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE;
private:
QOpenGLFunctions_4_3_Core *m_funcs;
diff --git a/src/render/graphicshelpers/graphicshelperinterface_p.h b/src/render/graphicshelpers/graphicshelperinterface_p.h
index 6fca95516..15c950253 100644
--- a/src/render/graphicshelpers/graphicshelperinterface_p.h
+++ b/src/render/graphicshelpers/graphicshelperinterface_p.h
@@ -74,47 +74,48 @@ public:
};
virtual ~GraphicsHelperInterface() {}
- virtual void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) = 0;
- virtual void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) = 0;
- virtual void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) = 0;
- virtual void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex = 0) = 0;
- virtual void drawArrays(GLenum primitiveType, GLint first, GLsizei count) = 0;
- virtual void setVerticesPerPatch(GLint verticesPerPatch) = 0;
- virtual void useProgram(GLuint programId) = 0;
- virtual QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) = 0;
- virtual QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) = 0;
- virtual QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) = 0;
- virtual void vertexAttribDivisor(GLuint index, GLuint divisor) = 0;
- virtual void blendEquation(GLenum mode) = 0;
virtual void alphaTest(GLenum mode1, GLenum mode2) = 0;
- virtual void depthTest(GLenum mode) = 0;
- virtual void depthMask(GLenum mode) = 0;
- virtual void cullFace(GLenum mode) = 0;
- virtual void frontFace(GLenum mode) = 0;
- virtual void enableAlphaCoverage() = 0;
- virtual void disableAlphaCoverage() = 0;
- virtual GLuint createFrameBufferObject() = 0;
- virtual void releaseFrameBufferObject(GLuint frameBufferId) = 0;
+ virtual void bindBufferBase(GLenum target, GLuint index, GLuint buffer) = 0;
+ virtual void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) = 0;
+ virtual void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) = 0;
virtual void bindFrameBufferObject(GLuint frameBufferId) = 0;
+ virtual void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0;
+ virtual void bindUniform(const QVariant &v, const ShaderUniform &description) = 0;
+ virtual void blendEquation(GLenum mode) = 0;
+ virtual void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) = 0;
virtual GLuint boundFrameBufferObject() = 0;
+ virtual void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) = 0;
virtual bool checkFrameBufferComplete() = 0;
- virtual void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) = 0;
- virtual bool supportsFeature(Feature feature) const = 0;
+ virtual GLuint createFrameBufferObject() = 0;
+ virtual void cullFace(GLenum mode) = 0;
+ virtual void depthMask(GLenum mode) = 0;
+ virtual void depthTest(GLenum mode) = 0;
+ virtual void disableAlphaCoverage() = 0;
+ virtual void disableClipPlane(int clipPlane) = 0;
+ virtual void disablePrimitiveRestart() = 0;
+ virtual void drawArrays(GLenum primitiveType, GLint first, GLsizei count) = 0;
+ virtual void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) = 0;
virtual void drawBuffers(GLsizei n, const int *bufs) = 0;
- virtual void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) = 0;
- virtual void bindUniform(const QVariant &v, const ShaderUniform &description) = 0;
- virtual void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0;
- virtual void bindBufferBase(GLenum target, GLuint index, GLuint buffer) = 0;
- virtual void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) = 0;
- virtual uint uniformByteSize(const ShaderUniform &description) = 0;
+ virtual void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex = 0) = 0;
+ virtual void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) = 0;
+ virtual void enableAlphaCoverage() = 0;
virtual void enableClipPlane(int clipPlane) = 0;
- virtual void disableClipPlane(int clipPlane) = 0;
- virtual GLint maxClipPlaneCount() = 0;
virtual void enablePrimitiveRestart(int primitiveRestartIndex) = 0;
- virtual void disablePrimitiveRestart() = 0;
- virtual void pointSize(bool programmable, GLfloat value) = 0;
+ virtual void frontFace(GLenum mode) = 0;
virtual QSize getRenderBufferDimensions(GLuint renderBufferId) = 0;
virtual QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) = 0;
+ virtual void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) = 0;
+ virtual GLint maxClipPlaneCount() = 0;
+ virtual void pointSize(bool programmable, GLfloat value) = 0;
+ virtual QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) = 0;
+ virtual QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) = 0;
+ virtual QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) = 0;
+ virtual void releaseFrameBufferObject(GLuint frameBufferId) = 0;
+ virtual void setVerticesPerPatch(GLint verticesPerPatch) = 0;
+ virtual bool supportsFeature(Feature feature) const = 0;
+ virtual uint uniformByteSize(const ShaderUniform &description) = 0;
+ virtual void useProgram(GLuint programId) = 0;
+ virtual void vertexAttribDivisor(GLuint index, GLuint divisor) = 0;
};
diff --git a/src/render/io/objloader.cpp b/src/render/io/objloader.cpp
index 87085c1de..da1af4003 100644
--- a/src/render/io/objloader.cpp
+++ b/src/render/io/objloader.cpp
@@ -129,48 +129,61 @@ bool ObjLoader::load(::QIODevice *ioDev, const QString &subMesh)
line = line.simplified();
if (line.length() > 0 && line.at(0) != QChar::fromLatin1('#')) {
- QTextStream lineStream(&line, QIODevice::ReadOnly);
- QString token;
- lineStream >> token;
-
- if (token == QStringLiteral("v")) {
- if (!skipping) {
- float x, y, z;
- lineStream >> x >> y >> z;
- positions.append(QVector3D( x, y, z ));
+ const QVector<QStringRef> tokens = line.splitRef(QChar::fromLatin1(' '));
+
+ if (tokens.first() == QStringLiteral("v")) {
+ if (tokens.size() < 4) {
+ qCWarning(Render::Io) << "Unsupported number of components in vertex";
} else {
- positionsOffset++;
+ if (!skipping) {
+ float x = tokens.at(1).toFloat();
+ float y = tokens.at(2).toFloat();
+ float z = tokens.at(3).toFloat();
+ positions.append(QVector3D( x, y, z ));
+ } else {
+ positionsOffset++;
+ }
}
- } else if (token == QStringLiteral("vt") && m_loadTextureCoords) {
- if (!skipping) {
- // Process texture coordinate
- float s,t;
- lineStream >> s >> t;
- //FlipUVs
- t = 1.0f - t;
- texCoords.append(QVector2D(s, t));
+ } else if (tokens.first() == QStringLiteral("vt") && m_loadTextureCoords) {
+ if (tokens.size() < 3) {
+ qCWarning(Render::Io) << "Unsupported number of components in texture coordinate";
} else {
- texCoordsOffset++;
+ if (!skipping) {
+ // Process texture coordinate
+ float s = tokens.at(1).toFloat();
+ float t = tokens.at(2).toFloat();
+ //FlipUVs
+ t = 1.0f - t;
+ texCoords.append(QVector2D( s, t ));
+ } else {
+ texCoordsOffset++;
+ }
}
- } else if (token == QStringLiteral("vn")) {
- if (!skipping) {
- float x, y, z;
- lineStream >> x >> y >> z;
- normals.append(QVector3D( x, y, z ));
+ } else if (tokens.first() == QStringLiteral("vn")) {
+ if (tokens.size() < 4) {
+ qCWarning(Render::Io) << "Unsupported number of components in vertex normal";
} else {
- normalsOffset++;
+ if (!skipping) {
+ float x = tokens.at(1).toFloat();
+ float y = tokens.at(2).toFloat();
+ float z = tokens.at(3).toFloat();
+ normals.append(QVector3D( x, y, z ));
+ } else {
+ normalsOffset++;
+ }
}
- } else if (!skipping && token == QStringLiteral("f")) {
+ } else if (!skipping && tokens.first() == QStringLiteral("f")) {
// Process face
++faceCount;
+
+ int faceVertices = tokens.size() - 1;
+
QVector<FaceIndices> face;
- int faceVertices = 0;
- while (!lineStream.atEnd()) {
- QString faceString;
- lineStream >> faceString;
+ face.reserve(faceVertices);
+ for (int i = 0; i < faceVertices; i++) {
FaceIndices faceIndices;
- QStringList indices = faceString.split(QChar::fromLatin1('/'));
+ const QVector<QStringRef> indices = tokens.at(i + 1).split(QChar::fromLatin1('/'));
switch (indices.size()) {
case 3:
faceIndices.normalIndex = indices.at(2).toInt() - 1 - normalsOffset; // fall through
@@ -184,7 +197,6 @@ bool ObjLoader::load(::QIODevice *ioDev, const QString &subMesh)
}
face.append(faceIndices);
- ++faceVertices;
}
// If number of edges in face is greater than 3,
@@ -207,11 +219,14 @@ bool ObjLoader::load(::QIODevice *ioDev, const QString &subMesh)
}
// end of face
- } else if ( token == QStringLiteral("o") ) {
- if (!subMesh.isEmpty() ) {
- QString objName;
- lineStream >> objName;
- skipping = subMeshMatch.indexIn(objName) < 0;
+ } else if (tokens.first() == QStringLiteral("o")) {
+ if (tokens.size() < 2) {
+ qCWarning(Render::Io) << "Missing submesh name";
+ } else {
+ if (!subMesh.isEmpty() ) {
+ QString objName = tokens.at(1).toString();
+ skipping = subMeshMatch.indexIn(objName) < 0;
+ }
}
}
} // end of input line
@@ -346,14 +361,12 @@ void ObjLoader::updateIndices(const QVector<QVector3D> &positions,
if (hasNormals)
m_normals.resize(vertexCount);
- foreach (const FaceIndices &faceIndices, faceIndexMap.keys()) {
- const int i = faceIndexMap.value(faceIndices);
-
- m_points[i] = positions[faceIndices.positionIndex];
+ for (QHash<FaceIndices, unsigned int>::const_iterator it = faceIndexMap.begin(), endIt = faceIndexMap.end(); it != endIt; ++it) {
+ m_points[it.value()] = positions[it.key().positionIndex];
if (hasTexCoords)
- m_texCoords[i] = std::numeric_limits<unsigned int>::max() != faceIndices.texCoordIndex ? texCoords[faceIndices.texCoordIndex] : QVector2D();
+ m_texCoords[it.value()] = std::numeric_limits<unsigned int>::max() != it.key().texCoordIndex ? texCoords[it.key().texCoordIndex] : QVector2D();
if (hasNormals)
- m_normals[i] = normals[faceIndices.normalIndex];
+ m_normals[it.value()] = normals[it.key().normalIndex];
}
// Now iterate over the face indices and lookup the unique vertex index
diff --git a/src/render/texture/qabstracttextureprovider.h b/src/render/texture/qabstracttextureprovider.h
index bd13b59ea..093d20864 100644
--- a/src/render/texture/qabstracttextureprovider.h
+++ b/src/render/texture/qabstracttextureprovider.h
@@ -334,4 +334,6 @@ private:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(Qt3DRender::QAbstractTextureProvider *)
+
#endif // QT3DRENDER_QABSTRACTTEXTUREPROVIDER_H
diff --git a/src/render/texture/qtextureimage.cpp b/src/render/texture/qtextureimage.cpp
index 2fdf16469..6b4684742 100644
--- a/src/render/texture/qtextureimage.cpp
+++ b/src/render/texture/qtextureimage.cpp
@@ -66,7 +66,11 @@ public:
QTexImageDataPtr operator ()() Q_DECL_FINAL
{
QTexImageDataPtr dataPtr;
- if (m_url.isLocalFile() || m_url.scheme() == QStringLiteral("qrc")) {
+ if (m_url.isLocalFile() || m_url.scheme() == QStringLiteral("qrc")
+#ifdef Q_OS_ANDROID
+ || m_url.scheme() == QStringLiteral("assets")
+#endif
+ ) {
QString source = Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(m_url);
dataPtr.reset(new QTexImageData());
if (dataPtr->setCompressedFile(source))
diff --git a/src/render/texture/qtextureproviders.cpp b/src/render/texture/qtextureproviders.cpp
index 1a42ebe9e..ec5133138 100644
--- a/src/render/texture/qtextureproviders.cpp
+++ b/src/render/texture/qtextureproviders.cpp
@@ -128,7 +128,7 @@ QTexture2DArray::~QTexture2DArray()
Constructs a new Qt3DRender::QTexture3D instance with \a parent as parent.
*/
QTexture3D::QTexture3D(QNode *parent)
- : QAbstractTextureProvider(Target2D, parent)
+ : QAbstractTextureProvider(Target3D, parent)
{
}
diff --git a/tools/qgltf/qgltf.cpp b/tools/qgltf/qgltf.cpp
index 9a6e73cab..02de0224b 100644
--- a/tools/qgltf/qgltf.cpp
+++ b/tools/qgltf/qgltf.cpp
@@ -229,6 +229,8 @@ struct Options {
ETC1
};
TextureCompression texComp;
+ bool commonMat;
+ bool shaders;
bool showLog;
} opts;
@@ -1190,12 +1192,12 @@ bool Exporter::nodeIsUseful(const Importer::Node *n) const
void Exporter::copyExternalTextures(const QString &inputFilename)
{
- // External textures needs copying only when output dir was specified.
- if (!opts.outDir.isEmpty()) {
- foreach (const QString &textureFilename, m_importer->externalTextures()) {
- QString dst = opts.outDir + textureFilename;
- QString src = QFileInfo(inputFilename).path() + QStringLiteral("/") + textureFilename;
- m_files.insert(QFileInfo(dst).fileName());
+ foreach (const QString &textureFilename, m_importer->externalTextures()) {
+ const QString dst = opts.outDir + textureFilename;
+ m_files.insert(QFileInfo(dst).fileName());
+ // External textures need copying only when output dir was specified.
+ if (!opts.outDir.isEmpty()) {
+ const QString src = QFileInfo(inputFilename).path() + QStringLiteral("/") + textureFilename;
if (QFileInfo(src).absolutePath() != QFileInfo(dst).absolutePath()) {
if (opts.showLog)
qDebug().noquote() << "Copying" << src << "to" << dst;
@@ -1265,6 +1267,7 @@ private:
QString semantic;
uint type;
};
+ QString commonTechniqueName;
QString vertShader;
QString fragShader;
QVector<Param> attributes;
@@ -1551,6 +1554,7 @@ void GltfExporter::initShaderInfo()
ProgramInfo p;
p = ProgramInfo();
+ p.commonTechniqueName = "PHONG"; // diffuse RGBA, specular RGBA
p.vertShader = "color.vert";
p.fragShader = "color.frag";
p.attributes << ProgramInfo::Param("position", "vertexPosition", "POSITION", GLT_FLOAT_VEC3);
@@ -1567,6 +1571,7 @@ void GltfExporter::initShaderInfo()
m_progs << p;
p = ProgramInfo();
+ p.commonTechniqueName = "PHONG"; // diffuse texture, specular RGBA
p.vertShader = "diffusemap.vert";
p.fragShader = "diffusemap.frag";
p.attributes << ProgramInfo::Param("position", "vertexPosition", "POSITION", GLT_FLOAT_VEC3);
@@ -1584,6 +1589,7 @@ void GltfExporter::initShaderInfo()
m_progs << p;
p = ProgramInfo();
+ p.commonTechniqueName = "PHONG"; // diffuse texture, specular texture
p.vertShader = "diffusemap.vert";
p.fragShader = "diffusespecularmap.frag";
p.attributes << ProgramInfo::Param("position", "vertexPosition", "POSITION", GLT_FLOAT_VEC3);
@@ -1601,6 +1607,7 @@ void GltfExporter::initShaderInfo()
m_progs << p;
p = ProgramInfo();
+ p.commonTechniqueName = "PHONG"; // diffuse texture, specular RGBA, normalmap texture
p.vertShader = "normaldiffusemap.vert";
p.fragShader = "normaldiffusemap.frag";
p.attributes << ProgramInfo::Param("position", "vertexPosition", "POSITION", GLT_FLOAT_VEC3);
@@ -1620,6 +1627,7 @@ void GltfExporter::initShaderInfo()
m_progs << p;
p = ProgramInfo();
+ p.commonTechniqueName = "PHONG"; // diffuse texture, specular texture, normalmap texture
p.vertShader = "normaldiffusemap.vert";
p.fragShader = "normaldiffusespecularmap.frag";
p.attributes << ProgramInfo::Param("position", "vertexPosition", "POSITION", GLT_FLOAT_VEC3);
@@ -1743,6 +1751,23 @@ static inline QJsonArray vec2jsvec(const QVector<float> &v)
return arr;
}
+static inline void promoteColorsToRGBA(QJsonObject *obj)
+{
+ QJsonObject::iterator it = obj->begin(), itEnd = obj->end();
+ while (it != itEnd) {
+ QJsonArray arr = it.value().toArray();
+ if (arr.count() == 3) {
+ const QString key = it.key();
+ if (key == QStringLiteral("ambient")
+ || key == QStringLiteral("diffuse")
+ || key == QStringLiteral("specular"))
+ arr.append(1);
+ *it = arr;
+ }
+ ++it;
+ }
+}
+
void GltfExporter::exportMaterials(QJsonObject &materials, QHash<QString, QString> *textureNameMap)
{
for (uint i = 0; i < m_importer->materialCount(); ++i) {
@@ -1801,7 +1826,8 @@ void GltfExporter::exportMaterials(QJsonObject &materials, QHash<QString, QStrin
opaque = false;
vals[it.key()] = col2jsvec(it.value(), alpha);
}
- material["values"] = vals;
+ if (opts.shaders)
+ material["values"] = vals;
ProgramInfo *prog = chooseProgram(i);
TechniqueInfo techniqueInfo;
@@ -1821,13 +1847,37 @@ void GltfExporter::exportMaterials(QJsonObject &materials, QHash<QString, QStrin
m_usedPrograms.insert(prog);
}
- if (opts.showLog)
- qDebug().noquote() << "Material #" << i << "->" << techniqueInfo.name;
+ if (opts.shaders) {
+ if (opts.showLog)
+ qDebug().noquote() << "Material #" << i << "->" << techniqueInfo.name;
- material["technique"] = techniqueInfo.name;
- if (opts.genCore) {
- material["techniqueCore"] = techniqueInfo.coreName;
- material["techniqueGL2"] = techniqueInfo.gl2Name;
+ material["technique"] = techniqueInfo.name;
+ if (opts.genCore) {
+ material["techniqueCore"] = techniqueInfo.coreName;
+ material["techniqueGL2"] = techniqueInfo.gl2Name;
+ }
+ }
+
+ if (opts.commonMat) {
+ // The built-in shaders we output are of little use in practice.
+ // Ideally we want Qt3D's own standard materials in order to have our
+ // models participate in lighting for example. To achieve this, output
+ // a KHR_materials_common block which Qt3D's loader will recognize and
+ // prefer over the shader-based techniques.
+ if (!prog->commonTechniqueName.isEmpty()) {
+ QJsonObject commonMat;
+ commonMat["technique"] = prog->commonTechniqueName;
+ // Set the values as-is. "normalmap" is our own extension, not in the spec.
+ // However, RGB colors have to be promoted to RGBA since the spec uses
+ // vec4, and all types are pre-defined for common material values.
+ promoteColorsToRGBA(&vals);
+ commonMat["values"] = vals;
+ if (!opaque)
+ commonMat["transparent"] = true;
+ QJsonObject extensions;
+ extensions["KHR_materials_common"] = commonMat;
+ material["extensions"] = extensions;
+ }
}
materials[matInfo.name] = material;
@@ -1876,6 +1926,9 @@ void GltfExporter::exportParameter(QJsonObject &dst, const QVector<ProgramInfo::
void GltfExporter::exportTechniques(QJsonObject &obj, const QString &basename)
{
+ if (!opts.shaders)
+ return;
+
QJsonObject shaders;
QHash<QString, QString> shaderMap;
foreach (ProgramInfo *prog, m_usedPrograms) {
@@ -2360,21 +2413,11 @@ void GltfExporter::save(const QString &inputFilename)
}
m_obj["samplers"] = samplers;
- // Just a dummy light, never referenced.
- QJsonObject lights;
- QJsonObject light;
- QJsonObject pointLight;
- pointLight["color"] = col2jsvec(QVector<float>() << 1 << 1 << 1);
- light["point"] = pointLight;
- light["type"] = QStringLiteral("point");
- lights["light_1"] = light;
- m_obj["lights"] = lights;
-
exportTechniques(m_obj, basename);
m_doc.setObject(m_obj);
- QString gltfName = opts.outDir + basename + QStringLiteral(".gltf");
+ QString gltfName = opts.outDir + basename + QStringLiteral(".qgltf");
f.setFileName(gltfName);
if (opts.showLog)
qDebug().noquote() << (opts.genBin ? "Writing (binary JSON)" : "Writing") << gltfName;
@@ -2426,9 +2469,9 @@ int main(int argc, char **argv)
cmdLine.addVersionOption();
QCommandLineOption outDirOpt(QStringLiteral("d"), QStringLiteral("Place all output data into <dir>"), QStringLiteral("dir"));
cmdLine.addOption(outDirOpt);
- QCommandLineOption binOpt(QStringLiteral("b"), QStringLiteral("Store binary JSON data in the .gltf file"));
+ QCommandLineOption binOpt(QStringLiteral("b"), QStringLiteral("Store binary JSON data in the .qgltf file"));
cmdLine.addOption(binOpt);
- QCommandLineOption compactOpt(QStringLiteral("m"), QStringLiteral("Store compact JSON in the .gltf file"));
+ QCommandLineOption compactOpt(QStringLiteral("m"), QStringLiteral("Store compact JSON in the .qgltf file"));
cmdLine.addOption(compactOpt);
QCommandLineOption compOpt(QStringLiteral("c"), QStringLiteral("qCompress() vertex/index data in the .bin file"));
cmdLine.addOption(compOpt);
@@ -2442,6 +2485,10 @@ int main(int argc, char **argv)
cmdLine.addOption(coreOpt);
QCommandLineOption etc1Opt(QStringLiteral("1"), QStringLiteral("Generate ETC1 compressed textures by invoking etc1tool (PNG only)"));
cmdLine.addOption(etc1Opt);
+ QCommandLineOption noCommonMatOpt(QStringLiteral("T"), QStringLiteral("Do not generate KHR_materials_common block"));
+ cmdLine.addOption(noCommonMatOpt);
+ QCommandLineOption noShadersOpt(QStringLiteral("S"), QStringLiteral("Do not generate shaders/programs/techniques"));
+ cmdLine.addOption(noShadersOpt);
QCommandLineOption silentOpt(QStringLiteral("s"), QStringLiteral("Silence debug output"));
cmdLine.addOption(silentOpt);
cmdLine.process(app);
@@ -2461,6 +2508,8 @@ int main(int argc, char **argv)
}
opts.genCore = cmdLine.isSet(coreOpt);
opts.texComp = cmdLine.isSet(etc1Opt) ? Options::ETC1 : Options::NoTextureCompression;
+ opts.commonMat = !cmdLine.isSet(noCommonMatOpt);
+ opts.shaders = !cmdLine.isSet(noShadersOpt);
opts.showLog = !cmdLine.isSet(silentOpt);
if (!opts.outDir.isEmpty()) {
if (!opts.outDir.endsWith('/'))