/**************************************************************************** ** ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). ** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt3D module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL3$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in ** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include "qt3dquick3drenderplugin.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void initResources() { Q_INIT_RESOURCE(defaults); } QT_BEGIN_NAMESPACE static const struct { const char *type; int major, minor; } qmldir [] = { // Materials { "PhongMaterial", 2, 0 }, { "DiffuseMapMaterial", 2, 0 }, { "DiffuseSpecularMapMaterial", 2, 0 }, { "NormalDiffuseMapAlphaMaterial", 2, 0 }, { "NormalDiffuseMapMaterial", 2, 0 }, { "NormalDiffuseSpecularMapMaterial", 2, 0 }, { "PerVertexColorMaterial", 2, 0 }, // FrameGraphs { "ForwardRenderer", 2, 0 }, // Entities { "SkyboxEntity", 2, 0 } }; QVariantList Quick3DShaderDataArrayToVariantListConverter(Qt3D::Render::Quick::Quick3DShaderDataArray *array) { QList arrayValues = array->values(); QVariantList values; values.reserve(arrayValues.size()); Q_FOREACH (Qt3D::QShaderData *data, arrayValues) values.append(QVariant::fromValue(data)); return values; } void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri) { // Init resources for defaults QML files initResources(); // Converters QMetaType::registerConverter(Quick3DShaderDataArrayToVariantListConverter); // @uri Qt3D.Render qmlRegisterUncreatableType(uri, 2, 0, "QAbstractSceneLoader", "QAbstractScene is abstract"); qmlRegisterExtendedType(uri, 2, 0, "SceneLoader"); // qmlRegisterCustomType(uri, 2, 0, "Effect", new Qt3D::Render::Quick::ShaderPropertyParser()); qmlRegisterExtendedType(uri, 2, 0, "Effect"); qmlRegisterExtendedType(uri, 2, 0, "Technique"); qmlRegisterType(uri, 2, 0, "Annotation"); qmlRegisterType(uri, 2, 0, "OpenGLFilter"); qmlRegisterUncreatableType(uri, 2, 0, "QParameter", "Quick3D should instantiate Quick3DParameter only"); qmlRegisterType(uri, 2, 0, "Parameter"); qmlRegisterType(uri, 2, 0, "ParameterMapping"); qmlRegisterExtendedType(uri, 2, 0, "Material"); qmlRegisterExtendedType(uri, 2, 0, "RenderPass"); qmlRegisterType(uri, 2, 0, "ShaderProgram"); qmlRegisterUncreatableType(uri, 2, 0, "QShaderData", "Quick3D should instantiate Quick3DShaderData only"); qmlRegisterType(uri, 2, 0, "ShaderDataArray"); qmlRegisterType(uri, 2, 0, "ShaderData"); // Textures qmlRegisterType(uri, 2, 0, "WrapMode");//, QStringLiteral("QTextureWrapMode cannot be created from QML")); qmlRegisterUncreatableType(uri, 2, 0, "Texture", QStringLiteral("Texture should be created from one of the subclasses")); qmlRegisterExtendedType(uri, 2, 0, "Texture1D"); qmlRegisterExtendedType(uri, 2, 0, "Texture1DArray"); qmlRegisterExtendedType(uri, 2, 0, "Texture2D"); qmlRegisterExtendedType(uri, 2, 0, "Texture2DArray"); qmlRegisterExtendedType(uri, 2, 0, "Texture3D"); qmlRegisterExtendedType(uri, 2, 0, "TextureCubeMap"); qmlRegisterExtendedType(uri, 2, 0, "TextureCubeMapArray"); qmlRegisterExtendedType(uri, 2, 0, "Texture2DMultisample"); qmlRegisterExtendedType(uri, 2, 0, "Texture2DMultisampleArray"); qmlRegisterExtendedType(uri, 2, 0, "TextureRectangle"); qmlRegisterExtendedType(uri, 2, 0, "TextureBuffer"); qmlRegisterUncreatableType(uri, 2, 0, "QAbstractTextureImage", QStringLiteral("QAbstractTextureImage is abstract")); qmlRegisterType(uri, 2, 0, "TextureImage"); // Meshes qmlRegisterUncreatableType(uri, 2, 0, "QAbstractMesh", QStringLiteral("QAbstractMesh is abstract")); qmlRegisterType(uri, 2, 0, "Mesh"); qmlRegisterType(uri, 2, 0, "CuboidMesh"); qmlRegisterType(uri, 2, 0, "CylinderMesh"); qmlRegisterType(uri, 2, 0, "PlaneMesh"); qmlRegisterType(uri, 2, 0, "TorusMesh"); qmlRegisterType(uri, 2, 0, "SphereMesh"); // Layers qmlRegisterType(uri, 2, 0, "Layer"); qmlRegisterType(uri, 2, 0, "LayerFilter"); // Lights qmlRegisterUncreatableType(uri, 2, 0, "QAbstractLight", QStringLiteral("QAbstractLight is abstract")); qmlRegisterType(uri, 2, 0, "PointLight"); qmlRegisterType(uri, 2, 0, "DirectionalLight"); qmlRegisterType(uri, 2, 0, "SpotLight"); // FrameGraph qmlRegisterExtendedType(uri, 2, 0, "CameraSelector"); qmlRegisterExtendedType(uri, 2, 0, "RenderPassFilter"); qmlRegisterExtendedType(uri, 2, 0, "TechniqueFilter"); qmlRegisterExtendedType(uri, 2, 0, "Viewport"); qmlRegisterExtendedType(uri, 2, 0, "RenderTargetSelector"); qmlRegisterType(uri, 2, 0, "ClearBuffer"); qmlRegisterUncreatableType(uri, 2, 0, "FrameGraphNode", QStringLiteral("FrameGraphNode is a base class")); qmlRegisterExtendedType(uri, 2, 0, "StateSet"); qmlRegisterType(uri, 2, 0, "NoDraw"); qmlRegisterType(uri, 2, 0, "FrameGraph"); // RenderTarget qmlRegisterType(uri, 2, 0, "RenderAttachment"); qmlRegisterExtendedType(uri, 2, 0, "RenderTarget"); // Sorting qmlRegisterType(uri, 2, 0, "SortCriterion"); qmlRegisterExtendedType(uri, 2, 0, "SortMethod"); // RenderStates qmlRegisterUncreatableType(uri, 2, 0, "RenderState", QStringLiteral("QRenderState is a base class")); qmlRegisterType(uri, 2, 0, "BlendState"); qmlRegisterType(uri, 2, 0, "BlendStateSeparate"); qmlRegisterType(uri, 2, 0, "BlendEquation"); qmlRegisterType(uri, 2, 0, "AlphaTest"); qmlRegisterType(uri, 2, 0, "DepthTest"); qmlRegisterType(uri, 2, 0, "DepthMask"); qmlRegisterType(uri, 2, 0, "CullFace"); qmlRegisterType(uri, 2, 0, "FrontFace"); qmlRegisterType(uri, 2, 0, "StencilTest"); qmlRegisterType(uri, 2, 0, "ScissorTest"); qmlRegisterType(uri, 2, 0, "Dithering"); qmlRegisterType(uri, 2, 0, "AlphaCoverage"); qmlRegisterType(uri, 2, 0, "PolygonOffset"); qmlRegisterType(uri, 2, 0, "ColorMask"); // Register types provided as QML files compiled into the plugin for (int i = 0; i < int(sizeof(qmldir) / sizeof(qmldir[0])); i++) { QString path = QStringLiteral("qrc:/Qt3D/Render/defaults/qml/"); qmlRegisterType(QUrl(path + qmldir[i].type + QStringLiteral(".qml")), uri, qmldir[i].major, qmldir[i].minor, qmldir[i].type); } } QT_END_NAMESPACE