diff options
author | Julian De Bhal <julian.debhal@nokia.com> | 2012-06-07 10:34:02 +1000 |
---|---|---|
committer | Julian De Bhal <julian.debhal@nokia.com> | 2012-06-07 10:35:04 +1000 |
commit | 2f6f43649a89975ce93c07950f0935d3e66c1b7c (patch) | |
tree | f126edc5a2f539cc6ff9870b91d7cc7ba152c95a | |
parent | c40249daff37d40bbaf02e7eade1358b08445755 (diff) | |
parent | 3d3cf97dec3347d2bd0a429cbfa139b4d3cadfea (diff) | |
download | qt3d-2f6f43649a89975ce93c07950f0935d3e66c1b7c.tar.gz |
Merge branch 'master' into HEAD
Change-Id: I13eed9e813518f4e2c54c5cb460cb54ec7f8678d
136 files changed, 1006 insertions, 2412 deletions
diff --git a/.gitignore b/.gitignore index 11ef70690..3689593c6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,72 @@ src/threed/qt3dversion.h tmp Makefile* *.pdb +bin/* include/* *_resource.rc +*~ +*.a +*.la +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +.qmake.cache +.qmake.vars +*.prl +moc_*.cpp +qrc_*.cpp +ui_*.h + +# Test generated files +tst_* +!tst_*.* +tst_*.log +tst_*.debug +tst_*~ + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.vcxproj +*.vcxproj.filters +*.vcxproj.user + +# MinGW generated files +*.Debug +*.Release + +# Examples and demoes +examples/*/*/* +!examples/*/*/*[.]* +!examples/*/*/README +examples/*/*/*[.]app +examples/*/*/*[.]exe +examples/*/*/*/*[.]exe +demos/*/*/* +!demos/*/*/*[.]* +demos/*/*/*[.]app +demos/*/*/*[.]exe +demos/*/*/*/*[.]exe +tutorials/*/*/* +!tutorials/*/*/*[.]* +tutorials/*/*/*[.]app +tutorials/*/*/*[.]exe +tutorials/*/*/*/*[.]exe + +#unit tests executables (other than those named tst_*) +tests/benchmarks/qarray/qarray +tests/benchmarks/qglbuilder_perf/qglbuilder_perf diff --git a/3rdparty/assimp/assimp.pri b/3rdparty/assimp/assimp.pri index 20eb27d48..e6050dac3 100644 --- a/3rdparty/assimp/assimp.pri +++ b/3rdparty/assimp/assimp.pri @@ -3,6 +3,7 @@ # AssImp expects this to be defined on debug builds CONFIG(debug, debug|release) : DEFINES+=_DEBUG +CONFIG += exceptions win32:DEFINES+=_CRT_SECURE_NO_WARNINGS diff --git a/3rdparty/assimp/code/3DSConverter.cpp b/3rdparty/assimp/code/3DSConverter.cpp index dda417324..4ede10f60 100644 --- a/3rdparty/assimp/code/3DSConverter.cpp +++ b/3rdparty/assimp/code/3DSConverter.cpp @@ -712,7 +712,7 @@ void Discreet3DSImporter::GenerateNodeGraph(aiScene* pcOut) if (0 == mRootNode->mChildren.size()) { ////////////////////////////////////////////////////////////////////////////// - // It seems the file is so fucked up that it has not even a hierarchy. + // It seems the file is so messed up that it has not even a hierarchy. // generate a flat hiearachy which looks like this: // // ROOT_NODE diff --git a/3rdparty/assimp/code/3DSLoader.cpp b/3rdparty/assimp/code/3DSLoader.cpp index a5d2a9b04..c2f1bebae 100644 --- a/3rdparty/assimp/code/3DSLoader.cpp +++ b/3rdparty/assimp/code/3DSLoader.cpp @@ -1321,14 +1321,10 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out, ReadChunk(&chunk); const unsigned int diff = chunk.Size - sizeof(Discreet3DS::Chunk); - bool bGamma = false; - // Get the type of the chunk switch(chunk.Flag) { case Discreet3DS::CHUNK_LINRGBF: - bGamma = true; - case Discreet3DS::CHUNK_RGBF: if (sizeof(float) * 3 > diff) { *out = clrError; @@ -1340,7 +1336,6 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out, break; case Discreet3DS::CHUNK_LINRGBB: - bGamma = true; case Discreet3DS::CHUNK_RGBB: if (sizeof(char) * 3 > diff) { *out = clrError; diff --git a/3rdparty/assimp/code/ASEParser.cpp b/3rdparty/assimp/code/ASEParser.cpp index e0bf057d1..c62785f30 100644 --- a/3rdparty/assimp/code/ASEParser.cpp +++ b/3rdparty/assimp/code/ASEParser.cpp @@ -1890,7 +1890,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh& sMesh) unsigned int index, faceIdx = 0xffffffff; // FIXME: rewrite this and find out how to interpret the normals - // correctly. This is crap. + // correctly. // Smooth the vertex and face normals together. The result // will be edgy then, but otherwise everything would be soft ... diff --git a/3rdparty/assimp/code/BoostWorkaround/boost/tuple/tuple.hpp b/3rdparty/assimp/code/BoostWorkaround/boost/tuple/tuple.hpp index d23f28a98..2245a8db1 100644 --- a/3rdparty/assimp/code/BoostWorkaround/boost/tuple/tuple.hpp +++ b/3rdparty/assimp/code/BoostWorkaround/boost/tuple/tuple.hpp @@ -257,7 +257,7 @@ namespace boost { return t; } - // Constructs a tuple with 2 elements (fucking idiot, use std::pair instead!) + // Constructs a tuple with 2 elements (TODO: use std::pair instead!) template <typename T0,typename T1> inline tuple <T0,T1> make_tuple (const T0& t0, const T1& t1) { diff --git a/3rdparty/assimp/code/COBLoader.cpp b/3rdparty/assimp/code/COBLoader.cpp index 4fa801d73..020de05d1 100644 --- a/3rdparty/assimp/code/COBLoader.cpp +++ b/3rdparty/assimp/code/COBLoader.cpp @@ -1032,9 +1032,9 @@ void COBImporter::ReadPolH_Binary(COB::Scene& out, StreamReaderLE& reader, const v.y = reader.GetF4(); } - const size_t numfuck = reader.GetI4(); - msh.faces.reserve(numfuck); - for (size_t i = 0; i < numfuck; ++i) { + const size_t NNN = reader.GetI4(); + msh.faces.reserve(NNN); + for (size_t i = 0; i < NNN; ++i) { // XXX backface culling flag is 0x10 in flags // hole? diff --git a/3rdparty/assimp/code/ColladaLoader.cpp b/3rdparty/assimp/code/ColladaLoader.cpp index a1e1b2cf4..b95d6bee8 100644 --- a/3rdparty/assimp/code/ColladaLoader.cpp +++ b/3rdparty/assimp/code/ColladaLoader.cpp @@ -301,10 +301,10 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll out->mAngleInnerCone = AI_DEG_TO_RAD( srcLight->mFalloffAngle ); - // ... some extension magic. FUCKING COLLADA. + // ... some extension magic if (srcLight->mOuterAngle == 10e10f) { - // ... some deprecation magic. FUCKING FCOLLADA. + // ... some deprecation magic if (srcLight->mPenumbraAngle == 10e10f) { // Need to rely on falloff_exponent. I don't know how to interpret it, so I need to guess .... @@ -358,7 +358,7 @@ void ColladaLoader::BuildCamerasForNode( const ColladaParser& pParser, const Col out->mClipPlaneNear = srcCamera->mZNear; // ... but for the rest some values are optional - // and we need to compute the others in any combination. FUCKING COLLADA. + // and we need to compute the others in any combination if (srcCamera->mAspect != 10e10f) out->mAspect = srcCamera->mAspect; @@ -520,7 +520,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: std::copy( pSrcMesh->mPositions.begin() + pStartVertex, pSrcMesh->mPositions.begin() + pStartVertex + numVertices, dstMesh->mVertices); - // normals, if given. HACK: (thom) Due to the fucking Collada spec we never + // normals, if given. HACK: (thom) Due to the unclear Collada spec we never // know if we have the same number of normals as there are positions. So we // also ignore any vertex attribute if it has a different count if ( pSrcMesh->mNormals.size() >= pStartVertex + numVertices) @@ -611,7 +611,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: throw DeadlyImportError( "Data type mismatch while resolving mesh joints"); // sanity check: we rely on the vertex weights always coming as pairs of BoneIndex-WeightIndex if ( pSrcController->mWeightInputJoints.mOffset != 0 || pSrcController->mWeightInputWeights.mOffset != 1) - throw DeadlyImportError( "Unsupported vertex_weight adresssing scheme. Fucking collada spec."); + throw DeadlyImportError( "Unsupported vertex_weight adresssing scheme."); // create containers to collect the weights for each bone size_t numBones = jointNames.mStrings.size(); diff --git a/3rdparty/assimp/code/ColladaParser.cpp b/3rdparty/assimp/code/ColladaParser.cpp index 2513b9297..b34c485e3 100644 --- a/3rdparty/assimp/code/ColladaParser.cpp +++ b/3rdparty/assimp/code/ColladaParser.cpp @@ -487,7 +487,7 @@ void ColladaParser::ReadController( Collada::Controller& pController) else if ( IsElement( "skin")) { // read the mesh it refers to. According to the spec this could also be another - // controller, but I refuse to implement every bullshit idea they've come up with + // controller, but I refuse to implement every idea they've come up with int sourceIndex = GetAttribute( "source"); pController.mMeshId = mReader->getAttributeValue( sourceIndex) + 1; } @@ -1088,10 +1088,6 @@ void ColladaParser::ReadEffectLibrary() if ( mReader->getNodeType() == irr::io::EXN_ELEMENT) { if ( IsElement( "effect")) { - // read ID. Do I have to repeat my ranting about "optional" attributes? - // Alex: .... no, not necessary. Please shut up and leave more space for - // me to complain about the fucking Collada spec with its fucking - // 'optional' attributes ... int attrID = GetAttribute( "id"); std::string id = mReader->getAttributeValue( attrID); @@ -1603,7 +1599,7 @@ void ColladaParser::ReadSource() } else if ( IsElement( "technique_common")) { - // I don't fucking care for your profiles bullshit + // ignore } else if ( IsElement( "accessor")) { @@ -2045,7 +2041,7 @@ void ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pPer { // warn if the vertex channel does not refer to the <vertices> element in the same mesh if ( input.mAccessor != pMesh->mVertexID) - ThrowException( "Unsupported vertex referencing scheme. I fucking hate Collada."); + ThrowException( "Unsupported vertex referencing scheme."); continue; } diff --git a/3rdparty/assimp/code/JoinVerticesProcess.cpp b/3rdparty/assimp/code/JoinVerticesProcess.cpp index 633b8c1ca..507c87cee 100644 --- a/3rdparty/assimp/code/JoinVerticesProcess.cpp +++ b/3rdparty/assimp/code/JoinVerticesProcess.cpp @@ -144,7 +144,6 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // A little helper to find locally close vertices faster. // Try to reuse the lookup table from the last step. const static float epsilon = 1e-5f; - float posEpsilonSqr; SpatialSort* vertexFinder = NULL; SpatialSort _vertexFinder; @@ -155,14 +154,12 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) if (avf) { SpatPair& blubb = (*avf)[meshIndex]; vertexFinder = &blubb.first; - posEpsilonSqr = blubb.second; } } if (!vertexFinder) { // bad, need to compute it. _vertexFinder.Fill(pMesh->mVertices, pMesh->mNumVertices, sizeof( aiVector3D)); vertexFinder = &_vertexFinder; - posEpsilonSqr = ComputePositionEpsilon(pMesh); } // Squared because we check against squared length of the vector difference diff --git a/3rdparty/assimp/code/LWOAnimation.cpp b/3rdparty/assimp/code/LWOAnimation.cpp index dd6fbafba..67b01f901 100644 --- a/3rdparty/assimp/code/LWOAnimation.cpp +++ b/3rdparty/assimp/code/LWOAnimation.cpp @@ -434,7 +434,6 @@ void AnimResolver::GetKeys(std::vector<aiVectorKey>& out, // Iterate through all three arrays at once - it's tricky, but // rather interesting to implement. - double lasttime = std::min(envl_x->keys[0].time,std::min(envl_y->keys[0].time,envl_z->keys[0].time)); cur_x = envl_x->keys.begin(); cur_y = envl_y->keys.begin(); @@ -448,7 +447,7 @@ void AnimResolver::GetKeys(std::vector<aiVectorKey>& out, if ((*cur_x).time == (*cur_y).time && (*cur_x).time == (*cur_z).time ) { // we have a keyframe for all of them defined .. great, - // we don't need to fucking interpolate here ... + // we don't need to interpolate here ... fill.mTime = (*cur_x).time; fill.mValue.x = (*cur_x).value; @@ -501,7 +500,6 @@ void AnimResolver::GetKeys(std::vector<aiVectorKey>& out, InterpolateTrack(out,fill,(end_y ? (*cur_x) : (*cur_y)).time); } } - lasttime = fill.mTime; out.push_back(fill); if ( end_x && end_y && end_z ) /* finished? */ diff --git a/3rdparty/assimp/code/MD5Loader.cpp b/3rdparty/assimp/code/MD5Loader.cpp index 65a1533d0..d29c691cb 100644 --- a/3rdparty/assimp/code/MD5Loader.cpp +++ b/3rdparty/assimp/code/MD5Loader.cpp @@ -360,10 +360,9 @@ void MD5Importer::LoadMD5MeshFile () if (pScene->mRootNode->mChildren[1]->mNumChildren) /* start at the right hierarchy level */ SkeletonMeshBuilder skeleton_maker(pScene,pScene->mRootNode->mChildren[1]->mChildren[0]); #else - std::vector<MD5::MeshDesc>::const_iterator end = meshParser.mMeshes.end(); - + const std::vector<MD5::MeshDesc>::const_iterator end = meshParser.mMeshes.end(); // FIX: MD5 files exported from Blender can have empty meshes - for (std::vector<MD5::MeshDesc>::const_iterator it = meshParser.mMeshes.begin(),end = meshParser.mMeshes.end(); it != end;++it) { + for (std::vector<MD5::MeshDesc>::const_iterator it = meshParser.mMeshes.begin(); it != end;++it) { if (!(*it).mFaces.empty() && !(*it).mVertices.empty()) ++pScene->mNumMaterials; } diff --git a/3rdparty/assimp/code/MDLMaterialLoader.cpp b/3rdparty/assimp/code/MDLMaterialLoader.cpp index 5791c328f..d7b5f564e 100644 --- a/3rdparty/assimp/code/MDLMaterialLoader.cpp +++ b/3rdparty/assimp/code/MDLMaterialLoader.cpp @@ -786,7 +786,7 @@ void MDLImporter::SkipSkinLump_3DGS_MDL7( } // ------------------------------------------------------------------------------------------------ -// What the fuck does this function do? Can't remember +// What does this function do? Can't remember void MDLImporter::ParseSkinLump_3DGS_MDL7( const unsigned char* szCurrent, const unsigned char** szCurrentOut, diff --git a/3rdparty/assimp/code/OgreImporter.cpp b/3rdparty/assimp/code/OgreImporter.cpp index 350e65ee1..63cc94787 100644 --- a/3rdparty/assimp/code/OgreImporter.cpp +++ b/3rdparty/assimp/code/OgreImporter.cpp @@ -514,8 +514,6 @@ void OgreImporter::LoadSkeleton(std::string FileName, vector<Bone> &Bones, vecto if (!SkeletonFile) throw DeadlyImportError(string("Failed to create XML Reader for ")+FileName); - //Quick note: Whoever read this should know this one thing: irrXml fucking sucks!!! - XmlRead(SkeletonFile); if (string("skeleton")!=SkeletonFile->getNodeName()) throw DeadlyImportError("No <skeleton> node in SkeletonFile: "+FileName); diff --git a/3rdparty/assimp/code/Q3DLoader.cpp b/3rdparty/assimp/code/Q3DLoader.cpp index 4ba27c394..af0ec0633 100644 --- a/3rdparty/assimp/code/Q3DLoader.cpp +++ b/3rdparty/assimp/code/Q3DLoader.cpp @@ -368,7 +368,7 @@ void Q3DImporter::InternReadFile( const std::string& pFile, // We don't need the rest, but we need to know where - // this fucking chunk ends. + // this chunk ends. unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4()); // skip the background file name diff --git a/3rdparty/assimp/code/STLLoader.cpp b/3rdparty/assimp/code/STLLoader.cpp index 894124f2f..234ad009e 100644 --- a/3rdparty/assimp/code/STLLoader.cpp +++ b/3rdparty/assimp/code/STLLoader.cpp @@ -370,7 +370,7 @@ bool STLImporter::LoadBinaryFile() } aiColor4D* clr = &pMesh->mColors[0][pMesh->mNumFaces*3]; clr->a = 1.0f; - if (bIsMaterialise) // fuck, this is reversed + if (bIsMaterialise) // this is reversed { clr->r = (color & 0x31u) / 31.0f; clr->g = ((color & (0x31u<<5))>>5u) / 31.0f; diff --git a/3rdparty/assimp/code/TerragenLoader.cpp b/3rdparty/assimp/code/TerragenLoader.cpp index 3a19d17e4..33bbe3721 100644 --- a/3rdparty/assimp/code/TerragenLoader.cpp +++ b/3rdparty/assimp/code/TerragenLoader.cpp @@ -120,8 +120,6 @@ void TerragenImporter::InternReadFile( const std::string& pFile, throw DeadlyImportError( "TER: Magic string \'TERRAIN\' not found" ); unsigned int x = 0,y = 0,mode = 0; - float rad = 6370.f; - aiNode* root = pScene->mRootNode = new aiNode(); root->mName.Set("<TERRAGEN.TERRAIN>"); @@ -163,10 +161,6 @@ void TerragenImporter::InternReadFile( const std::string& pFile, root->mTransformation.c3 = reader.GetF4(); } // mapping == 1: earth radius - else if (!::strncmp(head,AI_TERR_CHUNK_CRAD,4)) - { - rad = reader.GetF4(); - } // mapping mode else if (!::strncmp(head,AI_TERR_CHUNK_CRVM,4)) { diff --git a/3rdparty/assimp/include/aiTypes.h b/3rdparty/assimp/include/aiTypes.h index f3b236de7..f56cac074 100644 --- a/3rdparty/assimp/include/aiTypes.h +++ b/3rdparty/assimp/include/aiTypes.h @@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <memory.h> #include <math.h> #include <stddef.h> +#include <string.h> // Our compile configuration #include "aiDefines.h" @@ -66,10 +67,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <new> // for std::nothrow_t #include <string> // for aiString::Set(const std::string&) -#if defined(__QNXNTO__) -#include <string.h> -#endif - namespace Assimp { //! @cond never namespace Intern { diff --git a/demos/qt3d/cubehouse/projectivetextureeffect.cpp b/demos/qt3d/cubehouse/projectivetextureeffect.cpp index 55885c966..af1e5616d 100644 --- a/demos/qt3d/cubehouse/projectivetextureeffect.cpp +++ b/demos/qt3d/cubehouse/projectivetextureeffect.cpp @@ -75,6 +75,8 @@ void ProjectiveTextureEffect::update(QGLPainter *painter, QGLPainter::Updates up recalulateObjectLinearTexgenMatrix(); matrixDirty = false; } + if (!program()) + return; program()->setUniformValue("objectLinearTexgenMatrix", objectLinearTexgenMatrix); diff --git a/demos/qt3d/pageflip/pageflipmath.cpp b/demos/qt3d/pageflip/pageflipmath.cpp index 8f6d85561..4853fc28a 100644 --- a/demos/qt3d/pageflip/pageflipmath.cpp +++ b/demos/qt3d/pageflip/pageflipmath.cpp @@ -41,6 +41,7 @@ #include "pageflipmath_p.h" #include <QtCore/qmath.h> +#include <string.h> QT_BEGIN_NAMESPACE @@ -53,8 +54,8 @@ PageFlipMath::PageFlipMath() m_showPageReverse = false; m_startCorner = BottomRight; - qMemSet(vertices, 0, sizeof(vertices)); - qMemSet(pageCount, 0, sizeof(pageCount)); + memset(vertices, 0, sizeof(vertices)); + memset(pageCount, 0, sizeof(pageCount)); } PageFlipMath::~PageFlipMath() diff --git a/demos/qt3d/photobrowser3d/thumbnaileffect.cpp b/demos/qt3d/photobrowser3d/thumbnaileffect.cpp index bb60500fb..d85deba5d 100644 --- a/demos/qt3d/photobrowser3d/thumbnaileffect.cpp +++ b/demos/qt3d/photobrowser3d/thumbnaileffect.cpp @@ -145,7 +145,6 @@ void ThumbnailEffect::setActive(QGLPainter *painter, bool flag) void ThumbnailEffect::update (QGLPainter *painter, QGLPainter::Updates updates) { - Q_ASSERT(d->program); if ((updates & QGLPainter::UpdateMatrices) != 0) { d->program->setUniformValue(d->matrixUniform, diff --git a/demos/quick3d/flickr3d/flickr3d.pro b/demos/quick3d/flickr3d/flickr3d.pro index 15348a2e2..823cbbf41 100644 --- a/demos/quick3d/flickr3d/flickr3d.pro +++ b/demos/quick3d/flickr3d/flickr3d.pro @@ -8,7 +8,8 @@ ICON_FILE = ../icon.png QML_FILES = \ qml/Flickr3d.qml \ - qml/desktop.qml + qml/desktop.qml \ + qml/RssModel.qml QML_INFRA_FILES = \ $$QML_FILES \ @@ -18,7 +19,8 @@ QML_INFRA_FILES = \ qml/default_sky_up.png \ qml/default_sky_east.png \ qml/default_sky_south.png \ - qml/default_sky_west.png + qml/default_sky_west.png \ + CATEGORY = demos include(../../../pkg.pri) diff --git a/demos/quick3d/flickr3d/qml/Flickr3d.qml b/demos/quick3d/flickr3d/qml/Flickr3d.qml index 35993cd1a..7d077f863 100644 --- a/demos/quick3d/flickr3d/qml/Flickr3d.qml +++ b/demos/quick3d/flickr3d/qml/Flickr3d.qml @@ -60,21 +60,57 @@ Viewport { loops: Animation.Infinite } + RssModel { id: rssModel } + + Item3D { + transform: [ + Rotation3D { axis: Qt.vector3d(1, 0, 0); angle: 90 }, + Translation3D { translate: Qt.vector3d(0, 1, 0) } + ] + + Cylinder { + levelOfDetail: 1 + length: 2.0 + radius: 2.8 + effect: Effect { + color: "#ccccdd" + } + } + } + Skybox { source: "./" } - Cube { - effect: Effect { - color: "#aaca00" - texture: "qtlogo.png" - decal: true + Component { + id: octoDisplayDelegate + Item3D { + transform: [ + Translation3D { translate: Qt.vector3d(0, 0, 2.6) }, + // index is a special variable that comes from model instancing + Rotation3D { axis: Qt.vector3d(0, 1, 0); angle: (360 / 16) * (index * 2 + 1) } + ] + Item3D { + enabled: index > -1 && index < 9 + transform: [ + Rotation3D { axis: Qt.vector3d(1, 0, 0); angle: 90 } + ] + Quad { + effect: Effect { + //The current texture downloading does not operate as network URLs are unsupported + //in qt 5. + //texture: model.imagePath + texture: "qtlogo.png" + blending: true + } + } + } } } - MouseArea { - anchors.fill: parent - //this mousearea simply stops users from trying to move the viewpoint in - //what is meant to be a fixed scene. + Repeater { + delegate: octoDisplayDelegate + model: rssModel } } + diff --git a/src/plugins/sceneformats/obj/qglobjscene.cpp b/demos/quick3d/flickr3d/qml/RssModel.qml index f2203b9e8..b5b9d78b9 100644 --- a/src/plugins/sceneformats/obj/qglobjscene.cpp +++ b/demos/quick3d/flickr3d/qml/RssModel.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the Qt3D module of the Qt Toolkit. +** This file is part of the Qt3D examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -39,36 +39,29 @@ ** ****************************************************************************/ -#include "qglobjscene.h" -#include "qglbuilder.h" -#include "qglscenenode.h" +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 -QT_BEGIN_NAMESPACE +XmlListModel { + property string tags : "" -QGLObjScene::QGLObjScene(QGLSceneNode *defaultNode, QObject *parent) - : QGLAbstractScene(parent) - , mainObject(defaultNode) -{ - defaultNode->setParent(this); -} + function commasep(x) + { + return x.replace(' ',','); + } -QGLObjScene::~QGLObjScene() -{ -} + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+commasep(tags)+"&" : "")+"format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" -QList<QObject *> QGLObjScene::objects() const -{ - QList<QObject *> objs; - objs.append(mainObject); - QList<QGLSceneNode *> children = mainObject->allChildren(); - for (int index = 0; index < children.count(); ++index) - objs.append(children.at(index)); - return objs; + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "tags"; query: "media:category/string()" } + XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } + XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } + XmlRole { name: "photoType"; query: "media:content/@type/string()" } + XmlRole { name: "photoAuthor"; query: "author/string()" } + XmlRole { name: "photoDate"; query: "pubDate/string()" } } - -QGLSceneNode *QGLObjScene::mainNode() const -{ - return mainObject; -} - -QT_END_NAMESPACE diff --git a/demos/quick3d/tea_service/qml/TeaService.qml b/demos/quick3d/tea_service/qml/TeaService.qml index b0820e967..fad643fd8 100644 --- a/demos/quick3d/tea_service/qml/TeaService.qml +++ b/demos/quick3d/tea_service/qml/TeaService.qml @@ -52,6 +52,28 @@ Viewport { eye: Qt.vector3d(0, 3, 10) } + Effect { + id: effect_china + material: china + } + + Effect { + id: effect_china_hightlight + material: china_highlight; + } + + Effect { + id: effect_metal + material: metal + } + + Effect { + id: effect_metal_highlight + material: metal_highlight; + } + + + Item3D { id: teapot transform: [ @@ -71,24 +93,20 @@ Viewport { Item3D { id: body mesh: Mesh { source: "teapot-body.bez" } - effect: Effect { - material: china - } + effect: effect_china - onHoverEnter: { effect.material = china_highlight } - onHoverLeave: { effect.material = china } + onHoverEnter: { effect = effect_china_hightlight } + onHoverLeave: { effect = effect_china } onClicked: { teapot.bounce = true } } Item3D { id: handle mesh: Mesh { source: "teapot-handle.bez" } - effect: Effect { - material: china - } + effect: effect_china - onHoverEnter: { effect.material = china_highlight } - onHoverLeave: { effect.material = china } + onHoverEnter: { effect = effect_china_hightlight } + onHoverLeave: { effect = effect_china } onClicked: { if (teapot.state == "facing_left" || teapot.state == "pour_left") { @@ -106,12 +124,11 @@ Viewport { Item3D { id: spout mesh: Mesh { source: "teapot-spout.bez" } - effect: Effect { - material: china - } + effect: effect_china + - onHoverEnter: { effect.material = china_highlight } - onHoverLeave: { effect.material = china } + onHoverEnter: { effect = effect_china_hightlight } + onHoverLeave: { effect = effect_china } onClicked: { if (teapot.state == "facing_left") { teapot.state = "pour_left"; diff --git a/demos/quick3d/tea_service/qml/Teacup.qml b/demos/quick3d/tea_service/qml/Teacup.qml index 230dfb0db..fd3e9fae6 100644 --- a/demos/quick3d/tea_service/qml/Teacup.qml +++ b/demos/quick3d/tea_service/qml/Teacup.qml @@ -49,12 +49,10 @@ Item3D { Item3D { mesh: teacup_mesh - effect: Effect { - material: china - } + effect: effect_china - onHoverEnter: { effect.material = china_highlight } - onHoverLeave: { effect.material = china } + onHoverEnter: { effect = effect_china_hightlight } + onHoverLeave: { effect = effect_china } onClicked: { top.bounce = true } y: top.spoonY diff --git a/demos/quick3d/tea_service/qml/Teaspoon.qml b/demos/quick3d/tea_service/qml/Teaspoon.qml index 880d29a6f..2aab89f94 100644 --- a/demos/quick3d/tea_service/qml/Teaspoon.qml +++ b/demos/quick3d/tea_service/qml/Teaspoon.qml @@ -54,13 +54,11 @@ Item3D { axis: Qt.vector3d(1, 0, 0) } mesh: teaspoon_mesh - effect: Effect { - material: metal - } + effect: effect_metal property bool bounce: false - onHoverEnter: { effect.material = metal_highlight } - onHoverLeave: { effect.material = metal } + onHoverEnter: { effect= effect_metal_highlight } + onHoverLeave: { effect = effect_metal } onClicked: { teaspoon1.bounce = true } SequentialAnimation on y_lift { diff --git a/demos/quick3d/tea_service/tea_service.pro b/demos/quick3d/tea_service/tea_service.pro index d3ef30fa1..a6440ef39 100644 --- a/demos/quick3d/tea_service/tea_service.pro +++ b/demos/quick3d/tea_service/tea_service.pro @@ -28,4 +28,7 @@ OTHER_FILES += \ $$QML_INFRA_FILES \ tea_service.rc +INSTALL_DIRS = qml +mt: INSTALL_FILES = mt.qml + RC_FILE = tea_service.rc diff --git a/doc/src/examples/teapot-qml.qdoc b/doc/src/examples/teapot-qml.qdoc index 8217d9ad8..db5bce16f 100644 --- a/doc/src/examples/teapot-qml.qdoc +++ b/doc/src/examples/teapot-qml.qdoc @@ -32,22 +32,22 @@ This example shows to use QML in Qt3D to display a teapot on the screen. The QML is fairly simple: - \snippet quick3d/teapot_qml/qml/teapot.qml 1 + \snippet ../../tutorials/quick3d/teapot_qml/qml/teapot.qml 1 \image teapot-qml-screenshot.png The example starts by importing the Qt and Qt3D QML modules: - \snippet quick3d/teapot_qml/qml/teapot.qml 2 + \snippet ../../tutorials/quick3d/teapot_qml/qml/teapot.qml 2 Then we create a viewport of size 640x480 to display the teapot: - \snippet quick3d/teapot_qml/qml/teapot.qml 3 + \snippet ../../tutorials/quick3d/teapot_qml/qml/teapot.qml 3 And now we create a \l Item3D to display the teapot with a default lit material effect: - \snippet quick3d/teapot_qml/qml/teapot.qml 4 + \snippet ../../tutorials/quick3d/teapot_qml/qml/teapot.qml 4 The teapot data itself is loaded from \c{teapot.bez}, which contains Bezier patch data that describes the geometry of the teapot. @@ -55,15 +55,15 @@ Let's make the teapot a little more interesting by adding a material to simulate bone china: - \snippet quick3d/teapot_bounce_qml/qml/teapot-bounce.qml 1 - \snippet quick3d/teapot_bounce_qml/qml/teapot-bounce.qml 2 + \snippet ../../tutorials/quick3d/teapot_bounce_qml/qml/teapot-bounce.qml 1 + \snippet ../../tutorials/quick3d/teapot_bounce_qml/qml/teapot-bounce.qml 2 \image teapot-china-screenshot.png To make the teapot even more interesting, we can cause it to bounce up and down using a QML animation item: - \snippet quick3d/teapot_bounce_qml/qml/teapot-bounce.qml 3 + \snippet ../../tutorials/quick3d/teapot_bounce_qml/qml/teapot-bounce.qml 3 This QML teapot example can be compared with the \l{qt3d/teapot}{C++ version}. Using QML is briefer than C++, and easier to modify to adjust diff --git a/examples/quick3d/lander/qml/Jet.qml b/examples/quick3d/lander/qml/Jet.qml index 09b0e2be2..dff8de6d9 100644 --- a/examples/quick3d/lander/qml/Jet.qml +++ b/examples/quick3d/lander/qml/Jet.qml @@ -70,7 +70,7 @@ Item3D { } Quad { - y: -1.0 + y: -0.5 pretransform: Rotation3D { axis: Qt.vector3d(1, 0, 0); angle: 90 } effect: flame } @@ -108,8 +108,8 @@ Item3D { void main(void) { - mediump vec4 col1 = texture2D(qt_Texture0, texCoord.st); - mediump vec4 col2 = texture2D(texture2, texCoord.st); + mediump vec4 col1 = texture2D(qt_Texture0, vec2(texCoord.s, - texCoord.t)); + mediump vec4 col2 = texture2D(texture2, vec2(texCoord.s, - texCoord.t)); gl_FragColor = mix(col1, col2, interpolationFactor); } " diff --git a/src/imports/threed/billboarditem3d.cpp b/src/imports/threed/billboarditem3d.cpp index 61fb4b9fe..6149bb8f1 100644 --- a/src/imports/threed/billboarditem3d.cpp +++ b/src/imports/threed/billboarditem3d.cpp @@ -41,6 +41,7 @@ #include "billboarditem3d.h" #include "qgraphicsbillboardtransform.h" +#include "qquickeffect.h" /*! \qmlclass BillboardItem3D BillboardItem3D @@ -126,6 +127,16 @@ void BillboardItem3D::draw(QGLPainter *painter) if (!isInitialized()) initialize(painter); + if (!m_bConnectedToOpenGLContextSignal) { + QOpenGLContext* pOpenGLContext = QOpenGLContext::currentContext(); + if (pOpenGLContext) { + bool Ok = QObject::connect(pOpenGLContext, SIGNAL(aboutToBeDestroyed()), this, SLOT(handleOpenglContextIsAboutToBeDestroyed()), Qt::DirectConnection); + Q_UNUSED(Ok); // quell compiler warning + Q_ASSERT(Ok); + m_bConnectedToOpenGLContextSignal = true; + } + } + //Setup picking int prevId = painter->objectPickId(); painter->setObjectPickId(objectPickId()); @@ -168,3 +179,10 @@ void BillboardItem3D::draw(QGLPainter *painter) painter->setObjectPickId(prevId); } +void BillboardItem3D::handleOpenglContextIsAboutToBeDestroyed() +{ + if (effect()) { + effect()->openglContextIsAboutToBeDestroyed(); + } +} + diff --git a/src/imports/threed/billboarditem3d.h b/src/imports/threed/billboarditem3d.h index c83b29521..23e8c7ba2 100644 --- a/src/imports/threed/billboarditem3d.h +++ b/src/imports/threed/billboarditem3d.h @@ -60,8 +60,12 @@ public: void draw(QGLPainter *painter); +private Q_SLOTS: + void handleOpenglContextIsAboutToBeDestroyed(); + private: bool m_preserveUpVector; + bool m_bConnectedToOpenGLContextSignal; }; QT_END_NAMESPACE diff --git a/src/imports/threed/skybox.cpp b/src/imports/threed/skybox.cpp index d7c3200a0..09bb67d1a 100644 --- a/src/imports/threed/skybox.cpp +++ b/src/imports/threed/skybox.cpp @@ -87,6 +87,7 @@ Skybox::Skybox(QObject *parent) , m_scene(0) , m_view(0) , m_camera(new QGLCamera(this)) + , m_bConnectedToOpenGLContextSignal(false) { m_view = qobject_cast<Viewport*>(parent); @@ -221,6 +222,7 @@ void Skybox::setViewport(Viewport *view) void Skybox::scanLocalDir(const QString &imagePath) { m_imagePath = imagePath; + m_bConnectedToOpenGLContextSignal = false; QStringList notFound; const char **exp = EXPECTED_NAMES; for ( ; *exp; ++exp) @@ -295,10 +297,21 @@ void Skybox::setSource(const QUrl &source) } } -void Skybox::draw(QGLPainter *painter) const +void Skybox::draw(QGLPainter *painter) { if (!m_view) return; + + if (!m_bConnectedToOpenGLContextSignal) { + QOpenGLContext* pOpenGLContext = QOpenGLContext::currentContext(); + if (pOpenGLContext) { + bool Ok = QObject::connect(pOpenGLContext, SIGNAL(aboutToBeDestroyed()), this, SLOT(handleOpenglContextIsAboutToBeDestroyed()), Qt::DirectConnection); + Q_UNUSED(Ok); // quell compiler warning + Q_ASSERT(Ok); + m_bConnectedToOpenGLContextSignal = true; + } + } + painter->modelViewMatrix().push(); painter->modelViewMatrix().setToIdentity(); @@ -316,6 +329,13 @@ void Skybox::draw(QGLPainter *painter) const painter->modelViewMatrix().pop(); } +void Skybox::handleOpenglContextIsAboutToBeDestroyed() +{ + for (int ix = 0; ix<6; ++ix) { + m_faces[ix]->material()->texture()->cleanupResources(); + } +} + /*! \internal */ diff --git a/src/imports/threed/skybox.h b/src/imports/threed/skybox.h index 12219f1ec..aea46b3fa 100644 --- a/src/imports/threed/skybox.h +++ b/src/imports/threed/skybox.h @@ -71,7 +71,7 @@ public: ~Skybox(); QUrl source() const { return m_source; } void setSource(const QUrl &url); - void draw(QGLPainter *painter) const; + void draw(QGLPainter *painter); Viewport *viewport() const { return m_view; @@ -88,6 +88,9 @@ Q_SIGNALS: protected: bool event(QEvent *event); +private Q_SLOTS: + void handleOpenglContextIsAboutToBeDestroyed(); + private: void scanLocalDir(const QString &imagePath); @@ -100,6 +103,7 @@ private: QGLSceneNode *m_faces[6]; Viewport *m_view; QGLCamera *m_camera; + bool m_bConnectedToOpenGLContextSignal; }; QT_END_NAMESPACE diff --git a/src/imports/threed/threed.cpp b/src/imports/threed/threed.cpp index 5dd5e7a4c..4854169ab 100644 --- a/src/imports/threed/threed.cpp +++ b/src/imports/threed/threed.cpp @@ -85,6 +85,7 @@ QT_BEGIN_NAMESPACE class QThreedQmlModule : public QQmlExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") public: virtual void registerTypes(const char *uri) { @@ -131,4 +132,3 @@ QT_END_NAMESPACE #include "threed.moc" -Q_EXPORT_PLUGIN2(qthreedqmlplugin, QT_PREPEND_NAMESPACE(QThreedQmlModule)); diff --git a/src/imports/threed/viewport.cpp b/src/imports/threed/viewport.cpp index f4f314c8b..e81c0fe34 100644 --- a/src/imports/threed/viewport.cpp +++ b/src/imports/threed/viewport.cpp @@ -222,7 +222,6 @@ public: bool fovzoom; bool blending; bool itemsInitialized; - bool needsRepaint; QGLCamera *camera; QGLLightParameters *light; QGLLightModel *lightModel; @@ -282,7 +281,6 @@ ViewportPrivate::ViewportPrivate() , fovzoom(true) , blending(false) , itemsInitialized(false) - , needsRepaint(true) , camera(0) , light(0) , lightModel(0) @@ -401,6 +399,8 @@ Viewport::Viewport(QQuickItem *parent) // the update() function gets called when a re-render is needed. setFlags(QQuickItem::ItemHasContents); + connect(this, SIGNAL(widthChanged()), this, SIGNAL(viewportChanged())); + connect(this, SIGNAL(heightChanged()), this, SIGNAL(viewportChanged())); connect(this, SIGNAL(viewportChanged()), this, SLOT(update3d())); setCamera(new QGLCamera(this)); @@ -546,7 +546,7 @@ void Viewport::setPicking(bool value) if (value != d->picking) { d->picking = value; - if (d->picking) + if (d->picking && d->canvas) { connect(d->canvas, SIGNAL(beforeRendering()), this, SLOT(objectForPoint()), Qt::DirectConnection); @@ -554,8 +554,9 @@ void Viewport::setPicking(bool value) } else { - disconnect(d->canvas, SIGNAL(beforeRendering()), - this, SLOT(objectForPoint())); + if (d->canvas) + disconnect(d->canvas, SIGNAL(beforeRendering()), + this, SLOT(objectForPoint())); d->pickingRenderInitialized = false; } emit viewportChanged(); @@ -794,7 +795,7 @@ qreal ViewportSubsurface::aspectRatio() const Called by QQuickPaintedItem to refresh the content. - \sa beforeRendering() setRenderMode() + \sa beforeRendering(), setRenderMode() */ void Viewport::paint(QPainter *painter) { @@ -840,7 +841,7 @@ void Viewport::beforeRendering() // (Qt::DirectConnection) - not in the GUI/main thread of the app. // Beware of thread-safety issues. - if (!isVisible() || !d->needsRepaint) + if (!isVisible()) return; Q_ASSERT(d->canvas); @@ -865,8 +866,6 @@ void Viewport::beforeRendering() d->setRenderSettings(&painter); render(&painter); - - d->needsRepaint = false; } void Viewport::render(QGLPainter *painter) @@ -1209,7 +1208,6 @@ void Viewport::objectForPoint() void Viewport::update3d() { update(); - d->needsRepaint = true; } /*! @@ -1218,7 +1216,6 @@ void Viewport::update3d() void Viewport::cameraChanged() { update(); - d->needsRepaint = true; } static inline void sendEnterEvent(QObject *object) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro deleted file mode 100644 index 19979051e..000000000 --- a/src/plugins/plugins.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = sceneformats diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri deleted file mode 100644 index 54d7da432..000000000 --- a/src/plugins/qpluginbase.pri +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = lib -isEmpty(QT_MAJOR_VERSION) { - VERSION=4.7.0 -} else { - VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} -} -CONFIG += qt plugin - -win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release -TARGET = $$qtLibraryTarget($$TARGET) -contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols - -include(qt_targets.pri) - -wince*:LIBS += $$QMAKE_LIBS_GUI diff --git a/src/plugins/qt_targets.pri b/src/plugins/qt_targets.pri deleted file mode 100644 index 3b2046ea7..000000000 --- a/src/plugins/qt_targets.pri +++ /dev/null @@ -1,4 +0,0 @@ -QMAKE_TARGET_COMPANY = Nokia Corporation and/or its subsidiary(-ies) -QMAKE_TARGET_PRODUCT = Qt4 -QMAKE_TARGET_DESCRIPTION = C++ application development framework. -QMAKE_TARGET_COPYRIGHT = Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) diff --git a/src/plugins/sceneformats/assimp/README.txt b/src/plugins/sceneformats/assimp/README.txt deleted file mode 100644 index cabf1bdd8..000000000 --- a/src/plugins/sceneformats/assimp/README.txt +++ /dev/null @@ -1,12 +0,0 @@ -This importer uses the Asset Importer library available from: - -http://assimp.sourceforge.net/ - -Copyright (c) 2008-2010 ASSIMP Development Team -All rights reserved. - -For convenience a stripped down source tree is included in this distribution. See the license -included at $QT3D_SOURCE/3rdparty/assimp/LICENCE, or at http://assimp.sourceforge.net/main_license.html - -To use your own build of AssImp, modify the assimp.pro file and/or export the environment variables -specified there. diff --git a/src/plugins/sceneformats/assimp/ai_plugin.h b/src/plugins/sceneformats/assimp/ai_plugin.h deleted file mode 100644 index ea0696785..000000000 --- a/src/plugins/sceneformats/assimp/ai_plugin.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef AI_PLUGIN_H -#define AI_PLUGIN_H - -#include "qglsceneformatplugin.h" - -QT_BEGIN_NAMESPACE - -class QAiScenePlugin : public QObject, public QGLSceneFormatFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QGLSceneFormatFactoryInterface) - Q_PLUGIN_METADATA(IID "com.trolltech.Qt.QGLSceneFormatFactoryInterface" FILE "ai_scene_plugin.json") -public: - QAiScenePlugin(); - ~QAiScenePlugin(); - virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const; -}; - -QT_END_NAMESPACE - -#endif // AI_PLUGIN_H diff --git a/src/plugins/sceneformats/assimp/ai_scene_plugin.json b/src/plugins/sceneformats/assimp/ai_scene_plugin.json deleted file mode 100644 index a0c272e2b..000000000 --- a/src/plugins/sceneformats/assimp/ai_scene_plugin.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "Keys": [ - "3d", - "3ds", - "ac", - "ac3d", - "acc", - "ase", - "ask", - "b3d", - "blend", - "bvh", - "cob", - "csm", - "dae", - "dxf", - "enff", - "hmp", - "irr", - "irrmesh", - "lwo", - "lws", - "lxo", - "md2", - "md3", - "md5anim", - "md5camera", - "md5mesh", - "mdc", - "mdl", - "mesh.xml", - "mot", - "ms3d", - "ndo", - "nff", - "obj", - "off", - "pk3", - "ply", - "prj", - "q3o", - "q3s", - "raw", - "scn", - "smd", - "stl", - "ter", - "uc", - "vta", - "x", - "xml" - ] -} diff --git a/src/plugins/sceneformats/assimp/assimp.pro b/src/plugins/sceneformats/assimp/assimp.pro deleted file mode 100644 index 5a0fca51d..000000000 --- a/src/plugins/sceneformats/assimp/assimp.pro +++ /dev/null @@ -1,47 +0,0 @@ -TARGET = qsceneai -QT += 3d - -load(qt_plugin) - -include(../../qpluginbase.pri) -HEADERS += qailoader.h \ - qaiscene.h \ - qaiscenehandler.h \ - qaimesh.h \ - ailoaderiostream.h \ - ailoaderiosystem.h \ - ai_plugin.h -SOURCES += \ - qailoader.cpp \ - qaiscene.cpp \ - qaiscenehandler.cpp \ - qaimesh.cpp \ - ailoaderiostream.cpp \ - ailoaderiosystem.cpp \ - ai_plugin.cpp - -OTHER_FILES += \ - ai_scene_plugin.json - - - -DESTDIR = $$QT.3d.plugins/sceneformats -target.path = $$[QT_INSTALL_PLUGINS]/sceneformats -INSTALLS += target - -# suppress warnings about std::copy using unsafe parameters -win32: DEFINES +=_SCL_SECURE_NO_WARNINGS - -system_ai { - !isEmpty(QMAKE_INCDIR_AI):INCLUDEPATH += $$QMAKE_INCDIR_AI - !isEmpty(QMAKE_LIBDIR_AI):LIBS += -L$$QMAKE_LIBDIR_AI - - !isEmpty(QMAKE_LIBS_AI):LIBS += -l$$QMAKE_LIBS_AI - else { - win32:LIBS += -llibai-1_3 - else:LIBS += -lai - } -} else { - include(../../../../3rdparty/assimp/assimp.pri) -} - diff --git a/src/plugins/sceneformats/bezier/bezier.pro b/src/plugins/sceneformats/bezier/bezier.pro deleted file mode 100644 index 870d6970c..000000000 --- a/src/plugins/sceneformats/bezier/bezier.pro +++ /dev/null @@ -1,21 +0,0 @@ -TARGET = qscenebezier -QT += 3d - -load(qt_plugin) - -include(../../qpluginbase.pri) - -HEADERS += qglbezierscene.h \ - qglbezierscenehandler.h \ - bezier_plugin.h -SOURCES += \ - qglbezierscene.cpp \ - qglbezierscenehandler.cpp \ - bezier_plugin.cpp - -OTHER_FILES += \ - bezier_scene_plugin.json - -DESTDIR = $$QT.3d.plugins/sceneformats -target.path = $$[QT_INSTALL_PLUGINS]/sceneformats -INSTALLS += target diff --git a/src/plugins/sceneformats/bezier/bezier_plugin.cpp b/src/plugins/sceneformats/bezier/bezier_plugin.cpp deleted file mode 100644 index 91a81afe6..000000000 --- a/src/plugins/sceneformats/bezier/bezier_plugin.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "bezier_plugin.h" -#include "qglbezierscenehandler.h" - -QT_BEGIN_NAMESPACE - -QGLBezierScenePlugin::QGLBezierScenePlugin() {} -QGLBezierScenePlugin::~QGLBezierScenePlugin() {} - -QGLSceneFormatHandler *QGLBezierScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const -{ - Q_UNUSED(device); - Q_UNUSED(url); - Q_UNUSED(format); - return new QGLBezierSceneHandler; -} - -QT_END_NAMESPACE - - diff --git a/src/plugins/sceneformats/bezier/bezier_plugin.h b/src/plugins/sceneformats/bezier/bezier_plugin.h deleted file mode 100644 index 83b40b726..000000000 --- a/src/plugins/sceneformats/bezier/bezier_plugin.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BEZIER_PLUGIN_H -#define BEZIER_PLUGIN_H - -#include "qglsceneformatplugin.h" - -QT_BEGIN_NAMESPACE - -class QGLBezierScenePlugin : public QObject, public QGLSceneFormatFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QGLSceneFormatFactoryInterface) - Q_PLUGIN_METADATA(IID "com.trolltech.Qt.QGLSceneFormatFactoryInterface" FILE "bezier_scene_plugin.json") -public: - QGLBezierScenePlugin(); - ~QGLBezierScenePlugin(); - virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const; -}; - -QT_END_NAMESPACE - -#endif // BEZIER_PLUGIN_H diff --git a/src/plugins/sceneformats/bezier/bezier_scene_plugin.json b/src/plugins/sceneformats/bezier/bezier_scene_plugin.json deleted file mode 100644 index d91418547..000000000 --- a/src/plugins/sceneformats/bezier/bezier_scene_plugin.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Keys": [ - "bezier", - "bez" - ] -} diff --git a/src/plugins/sceneformats/obj/obj.pro b/src/plugins/sceneformats/obj/obj.pro deleted file mode 100644 index 73bd0e8ec..000000000 --- a/src/plugins/sceneformats/obj/obj.pro +++ /dev/null @@ -1,21 +0,0 @@ -TARGET = qsceneobj -QT += 3d - -load(qt_plugin) - -include(../../qpluginbase.pri) - -HEADERS += qglobjscene.h \ - qglobjscenehandler.h \ - obj_plugin.h -SOURCES += \ - qglobjscene.cpp \ - qglobjscenehandler.cpp \ - obj_plugin.cpp - -OTHER_FILES += \ - obj_scene_plugin.json - -DESTDIR = $$QT.3d.plugins/sceneformats -target.path = $$[QT_INSTALL_PLUGINS]/sceneformats -INSTALLS += target diff --git a/src/plugins/sceneformats/obj/obj_plugin.cpp b/src/plugins/sceneformats/obj/obj_plugin.cpp deleted file mode 100644 index ae88ae374..000000000 --- a/src/plugins/sceneformats/obj/obj_plugin.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "obj_plugin.h" -#include "qglobjscenehandler.h" - -QT_BEGIN_NAMESPACE - -QGLObjScenePlugin::QGLObjScenePlugin() {} -QGLObjScenePlugin::~QGLObjScenePlugin() {} - -QGLSceneFormatHandler *QGLObjScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const -{ - Q_UNUSED(device); - Q_UNUSED(url); - Q_UNUSED(format); - return new QGLObjSceneHandler; -} - -QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/obj/obj_plugin.h b/src/plugins/sceneformats/obj/obj_plugin.h deleted file mode 100644 index de9283a23..000000000 --- a/src/plugins/sceneformats/obj/obj_plugin.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef OBJ_PLUGIN_H -#define OBJ_PLUGIN_H - -#include "qglsceneformatplugin.h" - -QT_BEGIN_NAMESPACE - -class QGLObjScenePlugin : public QObject, public QGLSceneFormatFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QGLSceneFormatFactoryInterface) - Q_PLUGIN_METADATA(IID "com.trolltech.Qt.QGLSceneFormatFactoryInterface" FILE "obj_scene_plugin.json") -public: - QGLObjScenePlugin(); - ~QGLObjScenePlugin(); - virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const; -}; - -QT_END_NAMESPACE - -#endif // OBJ_PLUGIN_H diff --git a/src/plugins/sceneformats/obj/obj_scene_plugin.json b/src/plugins/sceneformats/obj/obj_scene_plugin.json deleted file mode 100644 index b33d38205..000000000 --- a/src/plugins/sceneformats/obj/obj_scene_plugin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Keys": [ - "obj" - ] -} diff --git a/src/plugins/sceneformats/obj/qglobjscene.h b/src/plugins/sceneformats/obj/qglobjscene.h deleted file mode 100644 index 8a7074c73..000000000 --- a/src/plugins/sceneformats/obj/qglobjscene.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLOBJSCENE_H -#define QGLOBJSCENE_H - -#include "qglabstractscene.h" - -QT_BEGIN_NAMESPACE - -class QGLBuilder; -class QGLSceneNode; - -//! [1] -class QGLObjScene : public QGLAbstractScene -{ - Q_OBJECT -public: -//! [1] - explicit QGLObjScene(QGLSceneNode *defaultNode, QObject *parent = 0); - virtual ~QGLObjScene(); - -//! [2] - QList<QObject *> objects() const; - QGLSceneNode *mainNode() const; -//! [2] - -private: - QGLSceneNode *mainObject; -//! [3] -}; -//! [3] - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/sceneformats/obj/qglobjscenehandler.cpp b/src/plugins/sceneformats/obj/qglobjscenehandler.cpp deleted file mode 100644 index aea28126c..000000000 --- a/src/plugins/sceneformats/obj/qglobjscenehandler.cpp +++ /dev/null @@ -1,468 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglobjscenehandler.h" -#include "qglobjscene.h" -#include "qvector2darray.h" -#include "qvector3darray.h" -#include "qglbuilder.h" - -#include <QtCore/qiodevice.h> -#include <QtCore/qfile.h> -#include <QtGui/qimage.h> - -QT_BEGIN_NAMESPACE - -QGLObjSceneHandler::QGLObjSceneHandler() - : QGLSceneFormatHandler() - , smoothing(QGL::Faceted) - , smoothingForced(false) -{ -} - -// Documentation for OBJ and MTL files from: -// http://www.fileformat.info/format/wavefrontobj/egff.htm -// http://www.fileformat.info/format/material/ - -static int objSkipWS(const QByteArray& line, int posn) -{ - while (posn < line.size() && (line[posn] == ' ' || line[posn] == '\t')) - ++posn; - return posn; -} - -static int objSkipNonWS(const QByteArray& line, int posn, int stopch) -{ - while (posn < line.size() && - line[posn] != ' ' && line[posn] != '\t' && line[posn] != stopch) - ++posn; - return posn; -} - -static qreal objReadFloat(const QByteArray& line, int *posn) -{ - *posn = objSkipWS(line, *posn); - int end = objSkipNonWS(line, *posn, 0); - qreal value; - if (end > *posn) - value = qreal(line.mid(*posn, end - *posn).toDouble()); - else - value = 0.0f; - *posn = end; - return value; -} - -static int objReadInteger(const QByteArray& line, int *posn) -{ - *posn = objSkipWS(line, *posn); - int end = objSkipNonWS(line, *posn, '/'); - int value; - if (end > *posn) - value = line.mid(*posn, end - *posn).toInt(); - else - value = 0; - //*posn = objSkipNonWS(line, end, 0); - *posn = end; - return value; -} - -static int objReadSlashInteger(const QByteArray& line, int *posn) -{ - if (*posn >= line.size() || line[*posn] != '/') - return 0; - ++(*posn); - int end = objSkipNonWS(line, *posn, '/'); - int value; - if (end > *posn) - value = line.mid(*posn, end - *posn).toInt(); - else - value = 0; - //*posn = objSkipNonWS(line, end, 0); - *posn = end; - return value; -} - -static QColor objReadColor(const QByteArray& line, int posn) -{ - qreal red = objReadFloat(line, &posn); - qreal green = objReadFloat(line, &posn); - qreal blue = objReadFloat(line, &posn); - qreal alpha = 1.0f; - posn = objSkipWS(line, posn); - if (posn < line.size()) - alpha = objReadFloat(line, &posn); - return QColor::fromRgbF(red, green, blue, alpha); -} - -void QGLObjSceneHandler::decodeOptions(const QString &options) -{ - if (options.contains(QLatin1String("ForceSmooth"))) - { - smoothingForced = true; - smoothing = QGL::Smooth; - } - else - { - smoothingForced = true; - smoothing = QGL::Faceted; - } -} - -QGLAbstractScene *QGLObjSceneHandler::read() -{ - QByteArray line; - QByteArray keyword; - int posn, index, count; - int tindex, nindex; - QVector3DArray positions; - QVector2DArray texCoords; - QVector3DArray normals; - qreal x, y, z; - quint32 fields = 0; - QGLMaterial *material = 0; - QGLSceneNode *defaultNode; - - // Create the geometry builder and start an initial Faceted section. - QGLBuilder builder; - builder.newSection(smoothing); - QGLSceneNode *root = builder.sceneNode(); - palette = root->palette(); - defaultNode = root; - defaultNode->setObjectName(QLatin1String("__main")); - builder.pushNode(); - - QGeometryData op; - while (!device()->atEnd()) { - // Read the next line, including any backslash continuations. - line = device()->readLine().trimmed(); - while (line.endsWith('\\')) { - line.truncate(line.size() - 1); - if (device()->atEnd()) - break; - line += device()->readLine().trimmed(); - } - if (line.startsWith('#') || line.isEmpty()) - continue; // Skip comments and blank lines. - - // Extract the keyword at the start of the line. - posn = 0; - while (posn < line.size() && - line[posn] != ' ' && line[posn] != '\t') - ++posn; - keyword = line.left(posn); - - // Determine how to process this line from the keyword. - if (keyword == "v") { - x = objReadFloat(line, &posn); - y = objReadFloat(line, &posn); - z = objReadFloat(line, &posn); - positions.append(x, y, z); - } else if (keyword == "vt") { - x = objReadFloat(line, &posn); - y = objReadFloat(line, &posn); - texCoords.append(x, y); - } else if (keyword == "vn") { - x = objReadFloat(line, &posn); - y = objReadFloat(line, &posn); - z = objReadFloat(line, &posn); - normals.append(x, y, z); - } else if (keyword == "f") { - posn = objSkipWS(line, posn); - count = 0; - //QGeometryData op; //(dlist, QGL::TRIANGLE_FAN); - op = QGeometryData(); // clear leaves field definitions - while (posn < line.size()) { - // Note: we currently only read the initial vertex - // index and also use it for texture co-ordinates - // and normals. e.g. "2/2", "3/3", etc. This will - // need to be fixed to handle "2/1", "3/7", etc. - index = objReadInteger(line, &posn); - tindex = objReadSlashInteger(line, &posn); - nindex = objReadSlashInteger(line, &posn); - if (index < 0) - index = positions.count() + index; - else if (index > 0) - --index; // Indices in obj are 1-based. - if (index >= 0 && index < positions.count()) - op.appendVertex(positions[index]); - if (tindex < 0) - tindex = texCoords.count() + tindex; - else if (tindex > 0) - --tindex; // Indices in obj are 1-based. - else - tindex = -1; - if (tindex >= 0 && tindex < texCoords.count()) - op.appendTexCoord(texCoords[tindex]); - if (nindex < 0) - nindex = normals.count() + nindex; - else if (nindex > 0) - --nindex; // Indices in obj are 1-based. - else - nindex = -1; - if (nindex >= 0 && nindex < normals.count()) - op.appendNormal(normals[nindex]); - ++count; - posn = objSkipNonWS(line, posn, 0); - posn = objSkipWS(line, posn); - } - // if geometry has already been added with a different combination - // of fields start a new section - // the primitive doesn't get posted to the section until op.end() - if (op.fields() != fields) - { - if (fields && builder.currentNode()->count() > 0) - builder.newSection(smoothing); - fields = op.fields(); - } - builder.addTriangleFan(op); - } else if (keyword == "usemtl") { - // Specify a material for the faces that follow. - posn = objSkipWS(line, posn); - QByteArray rest = line.mid(posn); - QString materialName = QString::fromLocal8Bit(rest.constData(), rest.size()); - if (!materialName.isEmpty() && - materialName != QLatin1String("(null)")) { - index = palette->indexOf(materialName); - if (index != -1) { - QGLSceneNode *node = builder.newNode(); - node->setMaterialIndex(index); - QGLMaterial *material = palette->material(index); - if (material->texture()) - node->setEffect(QGL::LitDecalTexture2D); - else - node->setEffect(QGL::LitMaterial); - } else { - qWarning() << "obj material" << materialName << "not found"; - material = 0; - } - } - } else if (keyword == "mtllib") { - // Load a material library. - posn = objSkipWS(line, posn); - QByteArray filename = line.mid(posn); - loadMaterialLibrary(QString::fromLocal8Bit(filename.constData(), filename.size())); - } else if (keyword == "s") { - if (!smoothingForced) - { - // Set smoothing on or off. - posn = objSkipWS(line, posn); - index = objSkipNonWS(line, posn, 0); - QByteArray arg = line.mid(posn, index - posn); - QGL::Smoothing smooth; - if (arg == "on" || arg == "1") - smooth = QGL::Smooth; - else - smooth = QGL::Faceted; - if (smoothing != smooth) { - smoothing = smooth; - builder.newSection(smooth); - } - } - } else if (keyword == "g" || keyword == "o") { - // Label the faces that follow as part of a named group or object. - posn = objSkipWS(line, posn); - QByteArray rest = line.mid(posn); - QString objectName = QString::fromLocal8Bit(rest.constData(), rest.size()); - QGLSceneNode *node = builder.currentNode(); - // if content has already been added to a current group, then - // create a new node in the scene graph for the group, otherwise - // just label the existing group with this name - QGLSceneNode *p = qobject_cast<QGLSceneNode*>(node->parent()); - if (node->count() > 0 && p && p->objectName().isEmpty()) - { - node = p; - } - else - { - builder.popNode(); - node = builder.currentNode(); - builder.pushNode(); - } - node->setObjectName(objectName); - } else { - qWarning() << "unsupported obj command: " << keyword.constData(); - } - } - - // Create a scene from the geometry - return new QGLObjScene(builder.finalizedSceneNode()); -} - -QGLAbstractScene *QGLObjSceneHandler::download() -{ - qWarning() << "Network loading of obj files using this plugin is not implemented."; - return NULL; -} - -void QGLObjSceneHandler::loadMaterialLibrary(const QString& name) -{ - QUrl materialUrl = url().resolved(name); - if (materialUrl.scheme() == QLatin1String("file")) { - QFile file(materialUrl.toLocalFile()); - if (!file.open(QIODevice::ReadOnly)) - qWarning() << "QGLObjSceneHandler::loadMaterialLibrary: could not open:" << materialUrl.toLocalFile(); - else - loadMaterials(&file); - } else { - // TODO - qWarning("QGLObjSceneHandler::loadMaterialLibrary: non-file urls not supported"); - } -} - -void QGLObjSceneHandler::loadMaterials(QIODevice *device) -{ - QByteArray line; - QByteArray keyword; - int posn, index; - QGLMaterial *material = 0; - QString materialName; - QString textureName; - - while (!device->atEnd()) { - // Read the next line, including any backslash continuations. - line = device->readLine().trimmed(); - while (line.endsWith('\\')) { - line.truncate(line.size() - 1); - if (device->atEnd()) - break; - line += device->readLine().trimmed(); - } - if (line.startsWith('#') || line.isEmpty()) - continue; // Skip comments and blank lines. - - // Extract the keyword at the start of the line. - posn = 0; - while (posn < line.size() && - line[posn] != ' ' && line[posn] != '\t') - ++posn; - keyword = line.left(posn); - - // Determine how to process this line from the keyword. - if (keyword == "newmtl") { - // Start a new material definition. - posn = objSkipWS(line, posn); - QByteArray rest = line.mid(posn); - materialName = QString::fromLocal8Bit(rest.constData(), rest.size()); - index = palette->indexOf(materialName); - if (index != -1) { - qWarning() << "redefining obj material:" << materialName; - material = palette->material(index); - } else { - material = new QGLMaterial(); - material->setObjectName(materialName); - palette->addMaterial(material); - } - } else if (keyword == "Ka") { - // Ambient color of the material. - if (material) - material->setAmbientColor(objReadColor(line, posn)); - } else if (keyword == "Kd") { - // Diffuse color of the material. - if (material) - material->setDiffuseColor(objReadColor(line, posn)); - } else if (keyword == "Ks") { - // Specular color of the material. - if (material) - material->setSpecularColor(objReadColor(line, posn)); - } else if (keyword == "map_Kd") { - // Texture associated with the material. - posn = objSkipWS(line, posn); - QByteArray rest = line.mid(posn); - textureName = QString::fromLocal8Bit(rest.constData(), rest.size()); - QGLTexture2D *texture = loadTexture(textureName); - if (texture) { - index = palette->indexOf(materialName); - if (index >= 0) { - QGLMaterial *material = palette->material(index); - texture->setParent(material); - material->setTexture(texture); - } else { - delete texture; - } - } - } else if (keyword == "d") { - // "Dissolve factor" of the material, which is its opacity. - if (material) { - qreal alpha = objReadFloat(line, &posn); - QColor ambient = material->ambientColor(); - QColor diffuse = material->diffuseColor(); - ambient.setAlphaF(alpha); - diffuse.setAlphaF(alpha); - material->setAmbientColor(ambient); - material->setDiffuseColor(diffuse); - } - } else if (keyword == "Ns") { - // Specular exponent of the material. - if (material) - material->setShininess(qRound(objReadFloat(line, &posn))); - } else if (keyword == "illum") { - // Illumination model - ignored at present. - } else if (keyword == "Ni") { - // Optical density - ignored at present. - } else { - qWarning() << "unsupported obj material command: " << keyword.constData(); - } - } -} - -QGLTexture2D *QGLObjSceneHandler::loadTexture(const QString& name) -{ - QUrl textureUrl = url().resolved(name); - if (textureUrl.scheme() == QLatin1String("file")) { - QFile file(textureUrl.toLocalFile()); - if (!file.open(QIODevice::ReadOnly)) { - qWarning() << "QGLObjSceneHandler::loadTexture: could not open:" << textureUrl.toLocalFile(); - return 0; - } else { - file.close(); - QImage image(textureUrl.toLocalFile()); - QGLTexture2D *tex = new QGLTexture2D(); - tex->setImage(image); - return tex; - } - } else { - // TODO - qWarning("QGLObjSceneHandler::loadTexture: non-file urls not supported"); - return 0; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/obj/qglobjscenehandler.h b/src/plugins/sceneformats/obj/qglobjscenehandler.h deleted file mode 100644 index 0f62bc370..000000000 --- a/src/plugins/sceneformats/obj/qglobjscenehandler.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLOBJSCENEHANDLER_H -#define QGLOBJSCENEHANDLER_H - -#include "qglsceneformatplugin.h" -#include "qglmaterialcollection.h" -#include <QtCore/qmap.h> -#include <QtCore/qset.h> - -QT_BEGIN_NAMESPACE - -//! [1] -class QGLObjSceneHandler : public QGLSceneFormatHandler -{ -public: - QGLObjSceneHandler(); - QGLAbstractScene *read(); - QGLAbstractScene *download(); -//! [1] - void decodeOptions(const QString &options); - -private: - void loadMaterialLibrary(const QString& name); - void loadMaterials(QIODevice *device); - QGLTexture2D *loadTexture(const QString& name); - - QSharedPointer<QGLMaterialCollection> palette; - QGL::Smoothing smoothing; - bool smoothingForced; -//! [2] -}; -//! [2] - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/sceneformats/sceneformats.pro b/src/plugins/sceneformats/sceneformats.pro deleted file mode 100644 index dd44a5dff..000000000 --- a/src/plugins/sceneformats/sceneformats.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = subdirs - -old_importer { - SUBDIRS = bezier obj -} else { - SUBDIRS = bezier assimp -} diff --git a/src/quick3d/cube.h b/src/quick3d/cube.h index 378132e70..1eb9316a1 100644 --- a/src/quick3d/cube.h +++ b/src/quick3d/cube.h @@ -44,17 +44,17 @@ // This is a dummy header for defining the interface of "Cube.qml" to qdoc. -#include "item3d.h" +#include "qquickitem3d.h" QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class Cube : public Item3D +class Cube : public QQuickItem3D { Q_OBJECT public: - Cube(QObject *parent = 0) : Item3D(parent) {} + Cube(QObject *parent = 0) : QQuickItem3D(parent) {} ~Cube() {} }; diff --git a/src/quick3d/qmlres.cpp b/src/quick3d/qmlres.cpp index cfa9b1dca..e124c3a65 100644 --- a/src/quick3d/qmlres.cpp +++ b/src/quick3d/qmlres.cpp @@ -149,6 +149,7 @@ int q_quick3d_main(const char *entryPointQmlFile, const char *category, int argc f.setSamples(16); QQuickView view; view.setFormat(f); + view.setResizeMode(QQuickView::SizeRootObjectToView); QString qml = q_get_qmldir(QLatin1String(entryPointQmlFile), QLatin1String(category)); view.setSource(QUrl::fromLocalFile(qml)); if (QGuiApplication::arguments().contains(QLatin1String("-maximize"))) diff --git a/src/quick3d/qquickitem3d.cpp b/src/quick3d/qquickitem3d.cpp index 9623b6ee3..01f57550b 100644 --- a/src/quick3d/qquickitem3d.cpp +++ b/src/quick3d/qquickitem3d.cpp @@ -234,23 +234,23 @@ that Item3D based delegates hide themselves when their index is -1 as shown in the photoroom example: - \snippet quick3d/photoroom/qml/photoroom.qml 1 + \snippet ../../examples/quick3d/photoroom/qml/photoroom.qml 1 However Item3D does not use the width or height properties, so most positioners and views will not work. Use a \l{http://doc.qt.nokia.com/4.7/qml-repeater.html}{Repeater} element to generate Item3Ds from model data. For example: - \snippet quick3d/photoroom/qml/photoroom.qml 2 + \snippet ../../examples/quick3d/photoroom/qml/photoroom.qml 2 Models can be used normally, so \l{http://doc.qt.nokia.com/4.7/qdeclarativemodels.html#listmodel}{ListModel}, \l{http://doc.qt.nokia.com/4.7/qdeclarativemodels.html#qstringlist}{QStringList} etc. work just like they would with two dimensional Items. For example: - \snippet quick3d/photoroom/qml/photoroom.qml 0 + \snippet ../../examples/quick3d/photoroom/qml/photoroom.qml 0 - \sa{http://doc.qt.nokia.com/4.7/qdeclarativemodels.html#qml-data-models}{QML Data Models} + \sa {http://doc.qt.nokia.com/4.7/qdeclarativemodels.html#qml-data-models}{QML Data Models} */ diff --git a/src/src.pro b/src/src.pro index 48385ea6e..370362fdf 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,4 +1,3 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS = threed quick3d imports -SUBDIRS += plugins diff --git a/src/threed/arrays/qarray.h b/src/threed/arrays/qarray.h index 6a609b142..64ca679ef 100644 --- a/src/threed/arrays/qarray.h +++ b/src/threed/arrays/qarray.h @@ -350,7 +350,7 @@ Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::release() if (!m_data->ref.deref()) { if (QTypeInfo<T>::isComplex) free(m_start, m_end - m_start); - qFree(m_data); + ::free(m_data); } } else if (this->isPrealloc(m_start)) { if (QTypeInfo<T>::isComplex) @@ -375,7 +375,7 @@ template <typename T, int PreallocSize> Q_INLINE_TEMPLATE typename QArray<T, PreallocSize>::Data *QArray<T, PreallocSize>::copyData(const T *src, int size, int capacity) { Data *data = reinterpret_cast<Data *> - (qMalloc(sizeof(Data) + sizeof(T) * (capacity - 1))); + (malloc(sizeof(Data) + sizeof(T) * (capacity - 1))); Q_CHECK_PTR(data); data->ref.store(1); data->capacity = capacity; @@ -390,7 +390,7 @@ Q_INLINE_TEMPLATE typename QArray<T, PreallocSize>::Data *QArray<T, PreallocSize } QT_CATCH(...) { while (copied-- > 0) (--dst)->~T(); - qFree(data); + ::free(data); QT_RETHROW; } return data; @@ -402,14 +402,14 @@ Q_INLINE_TEMPLATE void QArray<T, PreallocSize>::reallocate(int capacity) int size = m_end - m_start; if (!QTypeInfo<T>::isStatic) { Data *data = reinterpret_cast<Data *> - (qRealloc(m_data, sizeof(Data) + sizeof(T) * (capacity - 1))); + (realloc(m_data, sizeof(Data) + sizeof(T) * (capacity - 1))); Q_CHECK_PTR(data); data->capacity = capacity; m_data = data; } else { Data *data = copyData(m_data->array, size, capacity); free(m_data->array, size); - qFree(m_data); + ::free(m_data); m_data = data; } m_start = m_data->array; @@ -500,7 +500,7 @@ Q_OUTOFLINE_TEMPLATE void QArray<T, PreallocSize>::setSize(int size) } else { int capacity = qArrayAllocMore(size, 0, sizeof(T)); Data *data = reinterpret_cast<Data *> - (qMalloc(sizeof(Data) + sizeof(T) * (capacity - 1))); + (malloc(sizeof(Data) + sizeof(T) * (capacity - 1))); Q_CHECK_PTR(data); m_data = data; m_data->ref.store(1); diff --git a/src/threed/arrays/qcustomdataarray.cpp b/src/threed/arrays/qcustomdataarray.cpp index 214f10a68..d48327d6a 100644 --- a/src/threed/arrays/qcustomdataarray.cpp +++ b/src/threed/arrays/qcustomdataarray.cpp @@ -155,7 +155,7 @@ QCustomDataArray::QCustomDataArray(const QArray<QVector2D>& other) if (size > 0) { const QVector2D *src = other.constData(); float *dst = m_array.extend(size * 2); - qMemCopy(dst, src, size * sizeof(QVector2D)); + memcpy(dst, src, size * sizeof(QVector2D)); } } @@ -177,7 +177,7 @@ QCustomDataArray::QCustomDataArray(const QArray<QVector3D>& other) if (size > 0) { const QVector3D *src = other.constData(); float *dst = m_array.extend(size * 3); - qMemCopy(dst, src, size * sizeof(QVector3D)); + memcpy(dst, src, size * sizeof(QVector3D)); } } @@ -199,7 +199,7 @@ QCustomDataArray::QCustomDataArray(const QArray<QVector4D>& other) if (size > 0) { const QVector4D *src = other.constData(); float *dst = m_array.extend(size * 4); - qMemCopy(dst, src, size * sizeof(QVector4D)); + memcpy(dst, src, size * sizeof(QVector4D)); } } @@ -218,7 +218,7 @@ QCustomDataArray::QCustomDataArray(const QArray<QColor4ub>& other) m_elementComponents(1) { int size = other.size(); - qMemCopy(m_array.extend(size), other.constData(), sizeof(QColor4ub) * size); + memcpy(m_array.extend(size), other.constData(), sizeof(QColor4ub) * size); } /*! @@ -448,33 +448,33 @@ void QCustomDataArray::setAt(int index, const QVariant& value) case QVariant::Vector2D: Q_ASSERT(m_elementType == QCustomDataArray::Vector2D); *(reinterpret_cast<QVector2D *>(m_array.data() + index * 2)) - = qVariantValue<QVector2D>(value); + = qvariant_cast<QVector2D>(value); break; case QVariant::Vector3D: Q_ASSERT(m_elementType == QCustomDataArray::Vector3D); *(reinterpret_cast<QVector3D *>(m_array.data() + index * 3)) - = qVariantValue<QVector3D>(value); + = qvariant_cast<QVector3D>(value); break; case QVariant::Vector4D: Q_ASSERT(m_elementType == QCustomDataArray::Vector4D); *(reinterpret_cast<QVector4D *>(m_array.data() + index * 4)) - = qVariantValue<QVector4D>(value); + = qvariant_cast<QVector4D>(value); break; case QVariant::Color: // Convert QColor into QColor4ub. Q_ASSERT(m_elementType == QCustomDataArray::Color); *(reinterpret_cast<QColor4ub *>(m_array.data() + index)) - = QColor4ub(qVariantValue<QColor>(value)); + = QColor4ub(qvariant_cast<QColor>(value)); break; case QVariant::UserType: if (value.userType() == qMetaTypeId<QColor4ub>()) { Q_ASSERT(m_elementType == QCustomDataArray::Color); *(reinterpret_cast<QColor4ub *>(m_array.data() + index)) - = qVariantValue<QColor4ub>(value); + = qvariant_cast<QColor4ub>(value); break; } // Fall through. @@ -753,25 +753,25 @@ void QCustomDataArray::append(const QVariant& value) break; case QVariant::Vector2D: - append(qVariantValue<QVector2D>(value)); + append(qvariant_cast<QVector2D>(value)); break; case QVariant::Vector3D: - append(qVariantValue<QVector3D>(value)); + append(qvariant_cast<QVector3D>(value)); break; case QVariant::Vector4D: - append(qVariantValue<QVector4D>(value)); + append(qvariant_cast<QVector4D>(value)); break; case QVariant::Color: // Convert QColor into QColor4ub. - append(QColor4ub(qVariantValue<QColor>(value))); + append(QColor4ub(qvariant_cast<QColor>(value))); break; case QVariant::UserType: if (value.userType() == qMetaTypeId<QColor4ub>()) { - append(qVariantValue<QColor4ub>(value)); + append(qvariant_cast<QColor4ub>(value)); break; } // Fall through. @@ -812,7 +812,7 @@ QArray<QVector2D> QCustomDataArray::toVector2DArray() const if (size > 0) { QVector2D *dst = result.extend(size); const float *src = m_array.constData(); - qMemCopy(dst, src, size * sizeof(QVector2D)); + memcpy(dst, src, size * sizeof(QVector2D)); } return result; } @@ -834,7 +834,7 @@ QArray<QVector3D> QCustomDataArray::toVector3DArray() const if (size > 0) { QVector3D *dst = result.extend(size); const float *src = m_array.constData(); - qMemCopy(dst, src, size * sizeof(QVector3D)); + memcpy(dst, src, size * sizeof(QVector3D)); } return result; } @@ -856,7 +856,7 @@ QArray<QVector4D> QCustomDataArray::toVector4DArray() const if (size > 0) { QVector4D *dst = result.extend(size); const float *src = m_array.constData(); - qMemCopy(dst, src, size * sizeof(QVector4D)); + memcpy(dst, src, size * sizeof(QVector4D)); } return result; } diff --git a/src/threed/effects/qglcolladafxeffect.cpp b/src/threed/effects/qglcolladafxeffect.cpp index 0339b8ddb..97cc84810 100644 --- a/src/threed/effects/qglcolladafxeffect.cpp +++ b/src/threed/effects/qglcolladafxeffect.cpp @@ -148,12 +148,12 @@ inline void QGLColladaFxEffectPrivate::setTextureUniform(QOpenGLShaderProgram *p QString texVariableName = QString(QLatin1String("texCoord%1")).arg(*textureUnit); painter->glActiveTexture(GL_TEXTURE0 + *textureUnit); texture->bind(); - program->setUniformValue(sourceVariableName.toAscii().data(), *textureUnit); + program->setUniformValue(sourceVariableName.toLatin1().data(), *textureUnit); } else { // It's just a const value, so set it that way in the fragment shader. - program->setUniformValue(qVariableName.toAscii().data(), fallbackColor); + program->setUniformValue(qVariableName.toLatin1().data(), fallbackColor); } } diff --git a/src/threed/effects/qglcolladafxeffectfactory.cpp b/src/threed/effects/qglcolladafxeffectfactory.cpp index 4a0826972..c2ccc36d9 100644 --- a/src/threed/effects/qglcolladafxeffectfactory.cpp +++ b/src/threed/effects/qglcolladafxeffectfactory.cpp @@ -1586,13 +1586,13 @@ QStringList QGLColladaFxEffectFactory::generateCodeElements( QGLColladaFxEffect* { QStringList parts; parts << indent << QLatin1String("<code sid=\"") << baseSid << QLatin1String("VertexShader\">") - << QString::fromAscii(effect->vertexShader()) << QLatin1String("</code>"); + << QString::fromLatin1(effect->vertexShader()) << QLatin1String("</code>"); result << parts.join(QLatin1String("")); } { QStringList parts; parts << indent << QLatin1String("<code sid=\"") << baseSid << QLatin1String("FragmentShader\">") - << QString::fromAscii(effect->fragmentShader()) << QLatin1String("</code>\n"); + << QString::fromLatin1(effect->fragmentShader()) << QLatin1String("</code>\n"); result << parts.join(QLatin1String("")); } return result; diff --git a/src/threed/effects/qglflatcoloreffect.cpp b/src/threed/effects/qglflatcoloreffect.cpp index dd4969c36..7bd9452ad 100644 --- a/src/threed/effects/qglflatcoloreffect.cpp +++ b/src/threed/effects/qglflatcoloreffect.cpp @@ -196,6 +196,8 @@ void QGLFlatColorEffect::update return; } #endif + if (!d->program) + return; if ((updates & QGLPainter::UpdateColor) != 0) { if (painter->isPicking()) d->program->setUniformValue(d->colorUniform, painter->pickColor()); @@ -341,6 +343,8 @@ void QGLPerVertexColorEffect::update return; } #endif + if (!d->program) + return; if ((updates & QGLPainter::UpdateMatrices) != 0) { d->program->setUniformValue (d->matrixUniform, painter->combinedMatrix()); diff --git a/src/threed/effects/qglflattextureeffect.cpp b/src/threed/effects/qglflattextureeffect.cpp index 79914ebcd..133fbb93e 100644 --- a/src/threed/effects/qglflattextureeffect.cpp +++ b/src/threed/effects/qglflattextureeffect.cpp @@ -223,6 +223,8 @@ void QGLFlatTextureEffect::update return; } #endif + if (!d->program) + return; if ((updates & QGLPainter::UpdateMatrices) != 0) { d->program->setUniformValue (d->matrixUniform, painter->combinedMatrix()); @@ -362,6 +364,8 @@ void QGLFlatDecalTextureEffect::update return; } #endif + if (!d->program) + return; if ((updates & QGLPainter::UpdateColor) != 0) d->program->setUniformValue(d->colorUniform, painter->color()); if ((updates & QGLPainter::UpdateMatrices) != 0) { diff --git a/src/threed/effects/qgllitmaterialeffect.cpp b/src/threed/effects/qgllitmaterialeffect.cpp index fb242b9fc..939177179 100644 --- a/src/threed/effects/qgllitmaterialeffect.cpp +++ b/src/threed/effects/qgllitmaterialeffect.cpp @@ -496,6 +496,8 @@ void QGLLitMaterialEffect::update } #endif QOpenGLShaderProgram *program = d->program; + if (!program) + return; if ((updates & QGLPainter::UpdateMatrices) != 0) { program->setUniformValue(d->matrixUniform, painter->combinedMatrix()); program->setUniformValue(d->modelViewUniform, painter->modelViewMatrix()); diff --git a/src/threed/effects/qglshaderprogrameffect.cpp b/src/threed/effects/qglshaderprogrameffect.cpp index 903d735f3..a2fb0b501 100644 --- a/src/threed/effects/qglshaderprogrameffect.cpp +++ b/src/threed/effects/qglshaderprogrameffect.cpp @@ -793,6 +793,8 @@ void QGLShaderProgramEffect::update(QGLPainter *painter, QGLPainter::Updates upd } #endif #if !defined(QGL_FIXED_FUNCTION_ONLY) + if (!d->program) + return; if ((updates & QGLPainter::UpdateColor) != 0 && d->color != -1) d->program->setUniformValue(d->color, painter->color()); if ((updates & QGLPainter::UpdateMatrices) != 0) { diff --git a/src/threed/geometry/qgeometrydata.cpp b/src/threed/geometry/qgeometrydata.cpp index c48bd0b2f..d4263dc13 100644 --- a/src/threed/geometry/qgeometrydata.cpp +++ b/src/threed/geometry/qgeometrydata.cpp @@ -164,8 +164,8 @@ QGeometryDataPrivate::QGeometryDataPrivate() , boxValid(true) , bufferStrategy(QGeometryData::BufferIfPossible | QGeometryData::KeepClientData) { - qMemSet(key, -1, ATTR_CNT); - qMemSet(size, 0, ATTR_CNT); + memset(key, -1, ATTR_CNT); + memset(size, 0, ATTR_CNT); } QGeometryDataPrivate::~QGeometryDataPrivate() @@ -187,8 +187,8 @@ QGeometryDataPrivate *QGeometryDataPrivate::clone() const temp->modified = modified; temp->bb = bb; temp->fields = fields; - qMemCopy(temp->key, key, ATTR_CNT); - qMemCopy(temp->size, size, ATTR_CNT); + memcpy(temp->key, key, ATTR_CNT); + memcpy(temp->size, size, ATTR_CNT); temp->count = count; temp->reserved = reserved; temp->boxValid = boxValid; diff --git a/src/threed/geometry/qglsection.cpp b/src/threed/geometry/qglsection.cpp index 14abea38f..c0274c060 100644 --- a/src/threed/geometry/qglsection.cpp +++ b/src/threed/geometry/qglsection.cpp @@ -433,9 +433,9 @@ static bool qCompareByAttributes(const QLogicalVertex &a, const QLogicalVertex & if (v1.type() == (QVariant::Type)QMetaType::Float) return qFskCompare(v1.toFloat(), v2.toFloat()); else if (v1.type() == QVariant::Vector2D) - return qFskCompare(qVariantValue<QVector2D>(v1), qVariantValue<QVector2D>(v2)); + return qFskCompare(qvariant_cast<QVector2D>(v1), qvariant_cast<QVector2D>(v2)); else if (v1.type() == QVariant::Vector3D) - return qFskCompare(qVariantValue<QVector3D>(v1), qVariantValue<QVector3D>(v2)); + return qFskCompare(qvariant_cast<QVector3D>(v1), qvariant_cast<QVector3D>(v2)); else return v1 == v2; } diff --git a/src/threed/network/qdownloadmanager.cpp b/src/threed/network/qdownloadmanager.cpp index 73d211ef0..888a7bdc2 100644 --- a/src/threed/network/qdownloadmanager.cpp +++ b/src/threed/network/qdownloadmanager.cpp @@ -170,7 +170,7 @@ void QDownloadManager::netReplyDone() //Check if we have a relative URL if (url.isRelative()) { url.setScheme(reply->url().scheme()); - url.setEncodedHost(reply->url().encodedHost()); + url.setHost(reply->url().host()); } //Reissue redirected request. diff --git a/src/threed/painting/qglpainter.cpp b/src/threed/painting/qglpainter.cpp index 611c94a36..1586b4c46 100644 --- a/src/threed/painting/qglpainter.cpp +++ b/src/threed/painting/qglpainter.cpp @@ -51,6 +51,7 @@ #include <QPaintEngine> #include <QVarLengthArray> #include <QMap> +#include <QDebug> #if !defined(QT_NO_THREAD) #include <QThreadStorage> @@ -111,6 +112,7 @@ QT_BEGIN_NAMESPACE QGLPainterPrivate::QGLPainterPrivate() : ref(1), + badShaderCount(0), eye(QGL::NoEye), lightModel(0), defaultLightModel(0), @@ -352,9 +354,39 @@ bool QGLPainter::begin if (!context) context = QOpenGLContext::currentContext(); + if (!context) + { + qWarning() << "##### Attempt to begin painter with no GL context!"; + return false; + } + + // Initialize the QOpenGLFunctions parent class. + initializeGLFunctions(); + + // Determine if the OpenGL implementation is fixed-function or not. + bool isFixedFunction = !hasOpenGLFeature(QOpenGLFunctions::Shaders); + if (!isFixedFunction) + isFixedFunction = !QOpenGLShaderProgram::hasOpenGLShaderPrograms(); + if (!isFixedFunction) + { + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QFunctionPointer res = ctx->getProcAddress("glCreateShader"); + if (!res) + { + res = ctx->getProcAddress("glCreateShaderObject"); + if (!res) + { + res = ctx->getProcAddress("glCreateShaderObjectARB"); + } + } + if (!res) + isFixedFunction = !res; + } + // Find the QGLPainterPrivate for the context, or create a new one. d_ptr = painterPrivateCache()->fromContext(context); d_ptr->ref.ref(); + d_ptr->isFixedFunction = isFixedFunction; if (d_ptr->renderSequencer) { d_ptr->renderSequencer->reset(); @@ -393,11 +425,6 @@ bool QGLPainter::begin d_ptr->modelViewMatrix.setDirty(true); d_ptr->projectionMatrix.setDirty(true); - // Initialize the QOpenGLFunctions parent class. - initializeGLFunctions(); - - // Determine if the OpenGL implementation is fixed-function or not. - d_ptr->isFixedFunction = !hasOpenGLFeature(QOpenGLFunctions::Shaders); return true; } @@ -1363,8 +1390,7 @@ void QGLPainter::update() } if ((updates & UpdateViewport) != 0) { QRect viewport = currentSurface()->viewportGL(); - glViewport(viewport.x(), viewport.y(), - viewport.width(), viewport.height()); + glViewport(0, 0, viewport.width(), viewport.height()); } if (updates != 0) d->effect->update(this, updates); diff --git a/src/threed/painting/qglpainter_p.h b/src/threed/painting/qglpainter_p.h index b301b18a4..99f8175d6 100644 --- a/src/threed/painting/qglpainter_p.h +++ b/src/threed/painting/qglpainter_p.h @@ -94,6 +94,7 @@ public: ~QGLPainterPrivate(); QAtomicInt ref; + QAtomicInt badShaderCount; QOpenGLContext *context; QMatrix4x4Stack projectionMatrix; QMatrix4x4Stack modelViewMatrix; diff --git a/src/threed/scene/qglabstractscene.cpp b/src/threed/scene/qglabstractscene.cpp index bef37c214..9e0d141c8 100644 --- a/src/threed/scene/qglabstractscene.cpp +++ b/src/threed/scene/qglabstractscene.cpp @@ -43,8 +43,8 @@ #include "qglsceneformatplugin.h" #include "qglpicknode.h" -// copied private header -#include "qfactoryloader_p.h" +#include "qaiscenehandler.h" +#include "qglbezierscenehandler.h" #include <QtCore/qfile.h> #include <QtCore/qfileinfo.h> @@ -56,9 +56,48 @@ #include <QtCore/qdir.h> #include <QtCore/qpluginloader.h> #include <QBuffer> +#include <QSharedPointer> QT_BEGIN_NAMESPACE +/* + Internal. + Format handlers. +*/ + +class ISceneLoaderInfo +{ +public: + virtual ~ISceneLoaderInfo() {} + virtual QStringList supportedFormats() const = 0; + virtual QGLSceneFormatHandler* createHandler() const = 0; +}; + +template <typename T> +class SceneLoaderInfo : public ISceneLoaderInfo +{ +public: + QStringList supportedFormats() const { + return T::supportedFormats(); + } + QGLSceneFormatHandler* createHandler() const { + return new T; + } +}; + +const QList< QSharedPointer<ISceneLoaderInfo> >& getSceneLoaderInfos() +{ + static QList< QSharedPointer<ISceneLoaderInfo> > infos; + if (infos.empty()) { + infos.push_back( QSharedPointer<ISceneLoaderInfo>(new SceneLoaderInfo<QAiSceneHandler>()) ); + infos.push_back( QSharedPointer<ISceneLoaderInfo>(new SceneLoaderInfo<QGLBezierSceneHandler>()) ); + } + return infos; +} +typedef QMap< QString, QSharedPointer<ISceneLoaderInfo> > FormatMap; +Q_GLOBAL_STATIC(FormatMap,qFormatMap) + + /*! \class QGLAbstractScene \brief The QGLAbstractScene class represents a 3D scene consisting of zero or more QGLSceneNode instances. @@ -331,12 +370,6 @@ QList<QGLSceneAnimation *> QGLAbstractScene::animations() const \sa objects() */ -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, - ("com.trolltech.Qt.QGLSceneFormatFactoryInterface", - QLatin1String("/sceneformats"))) -#endif - /*! Loads a scene from \a device in the specified \a format using the registered scene format plugins. If \a format is an empty @@ -384,8 +417,6 @@ QGLAbstractScene *QGLAbstractScene::loadScene checkSupportedFormats(); QStringList keys = m_Formats; - QFactoryLoader *l = loader(); - // If the format is not specified, then use the filename/url extension. QString fmt = format; if (fmt.isEmpty()) { @@ -411,36 +442,29 @@ QGLAbstractScene *QGLAbstractScene::loadScene if (index >= 0) fmt = suffix; } + if (fmt.isEmpty()) + return 0; - // Find the plugin that handles the format and ask it to create a handler. - if (QGLSceneFormatFactoryInterface *factory - = qobject_cast<QGLSceneFormatFactoryInterface*> - (l->instance(fmt))) { - QGLSceneFormatHandler *handler = factory->create(device, url, fmt); - if (handler) { - handler->setDevice(device); - handler->setUrl(url); - handler->setFormat(format); - if (!options.isEmpty()) - handler->decodeOptions(options); - QGLAbstractScene *scene = 0; - if (!device) { - scene = handler->download(); - } else { - scene = handler->read(); - } - return scene; - } + FormatMap::const_iterator It = qFormatMap()->find(fmt); + if (It==qFormatMap()->end()) { + qWarning("Could not create handler for format %s",qPrintable(fmt)); + return 0; } + QGLSceneFormatHandler *handler = It.value().data()->createHandler(); + Q_ASSERT(handler); + handler->setDevice(device); + handler->setUrl(url); + handler->setFormat(format); + if (!options.isEmpty()) + handler->decodeOptions(options); + QGLAbstractScene *scene = 0; + if (!device) { + scene = handler->download(); + } else { + scene = handler->read(); + } + return scene; - // If we get here, then the format is not supported by any of the plugins. -#ifndef QT_NO_DEBUG - qWarning("Could not create handler for format %s" - "- check plugins are installed correctly in %s", - qPrintable(fmt), - qPrintable(QLibraryInfo::location(QLibraryInfo::PluginsPath))); -#endif - return 0; #else // QT_NO_LIBRARY || QT_NO_SETTINGS Q_UNUSED(device); Q_UNUSED(url); @@ -516,7 +540,7 @@ QGLAbstractScene *QGLAbstractScene::loadScene { QUrl fileUrl(fileName); - if (fileUrl.scheme()!="http" && fileUrl.scheme()!="ftp") { + if (fileUrl.scheme()!=QLatin1String("http") && fileUrl.scheme()!=QLatin1String("ftp")) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { @@ -559,10 +583,6 @@ QGLAbstractScene *QGLAbstractScene::loadScene Otherwise (when \a t is QGLAbstractScene::AsSuffix) it is simply a list of file name suffixes. - - Note that this function may be expensive to - call since it scans for available plugins, and loads each one it - finds to get an accurate report of formats supported at run-time. */ QStringList QGLAbstractScene::supportedFormats(QGLAbstractScene::FormatListType t) { @@ -580,11 +600,24 @@ QStringList QGLAbstractScene::supportedFormats(QGLAbstractScene::FormatListType void QGLAbstractScene::checkSupportedFormats() { if (!m_bFormatListReady) { - QFactoryLoader *l = loader(); - m_Formats = l->keys(); + Q_ASSERT(m_Formats.empty()); + Q_ASSERT(qFormatMap()->empty()); + + const QList< QSharedPointer<ISceneLoaderInfo> >& rSceneLoaderInfos = getSceneLoaderInfos(); + for (QList< QSharedPointer<ISceneLoaderInfo> >::const_iterator It=rSceneLoaderInfos.begin(); It!=rSceneLoaderInfos.end(); ++It) { + QStringList formats = It->data()->supportedFormats(); + foreach (QString sss, formats) { + sss = sss.toLower(); + if (!m_Formats.contains(sss,Qt::CaseInsensitive)) { + m_Formats.append(sss); + qFormatMap()->insert(sss,*It); + } + } + } + m_FormatsFilter.clear(); foreach (QString f, m_Formats) { - m_FormatsFilter.append(f.prepend("*.")); + m_FormatsFilter.append(f.prepend(QLatin1String("*."))); } m_bFormatListReady = true; } diff --git a/src/threed/scene/qglsceneformatplugin.h b/src/threed/scene/qglsceneformatplugin.h index 9add799e6..5c5be5126 100644 --- a/src/threed/scene/qglsceneformatplugin.h +++ b/src/threed/scene/qglsceneformatplugin.h @@ -100,7 +100,7 @@ public: virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format = QString()) const = 0; }; -Q_DECLARE_INTERFACE(QGLSceneFormatFactoryInterface, "com.trolltech.Qt.QGLSceneFormatFactoryInterface") +Q_DECLARE_INTERFACE(QGLSceneFormatFactoryInterface, "org.qt-project.Qt.QGLSceneFormatFactoryInterface") QT_END_NAMESPACE diff --git a/src/plugins/sceneformats/assimp/ailoaderiostream.cpp b/src/threed/scene_ai/ailoaderiostream.cpp index ecc6fe2ce..bc2c3659e 100644 --- a/src/plugins/sceneformats/assimp/ailoaderiostream.cpp +++ b/src/threed/scene_ai/ailoaderiostream.cpp @@ -66,9 +66,9 @@ size_t AiLoaderIOStream::Read( void* pvBuffer, size_t pSize, size_t pCount) qWarning("AI read error: %s\n", qPrintable(m_device->errorString())); if ((pSize * pCount) != res) // AI will treat as error { - long unsigned int pSizeP = pSize; - long unsigned int pCountP = pCount; - long unsigned int pRes = res; + long unsigned int pSizeP = (long unsigned int)pSize; + long unsigned int pCountP = (long unsigned int)pCount; + long unsigned int pRes = (long unsigned int)res; qWarning("read mismatch requested size: %lu x count: %lu = %lu != %lu actuall read\n", pSizeP, pCountP, (pSizeP * pCountP), pRes); } diff --git a/src/plugins/sceneformats/assimp/ailoaderiostream.h b/src/threed/scene_ai/ailoaderiostream.h index fa24ecab5..fa24ecab5 100644 --- a/src/plugins/sceneformats/assimp/ailoaderiostream.h +++ b/src/threed/scene_ai/ailoaderiostream.h diff --git a/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp b/src/threed/scene_ai/ailoaderiosystem.cpp index 50b00dcf6..223860013 100644 --- a/src/plugins/sceneformats/assimp/ailoaderiosystem.cpp +++ b/src/threed/scene_ai/ailoaderiosystem.cpp @@ -60,6 +60,7 @@ AiLoaderIOSystem::~AiLoaderIOSystem() bool AiLoaderIOSystem::Exists(const char* path) const { + Q_UNUSED(path) return m_device->isReadable(); } @@ -95,7 +96,7 @@ Assimp::IOStream* AiLoaderIOSystem::Open(const char* pFile, const char* pMode) } char mode_str[4]; - qMemSet(mode_str, '\0', 4); + memset(mode_str, '\0', 4); int i = 0; for (const char *ptr = pMode; i < 4 && *ptr; ++ptr) { @@ -140,7 +141,7 @@ Assimp::IOStream* AiLoaderIOSystem::Open(const char* pFile, const char* pMode) if (!res) { std::string err("Error: could not open subsequent file:"); - err.append(pFile).append("--").append(f->errorString().toAscii().constData()); + err.append(pFile).append("--").append(f->errorString().toLatin1().constData()); Assimp::DefaultLogger::get()->warn(err); delete f; return 0; diff --git a/src/plugins/sceneformats/assimp/ailoaderiosystem.h b/src/threed/scene_ai/ailoaderiosystem.h index c3d4c4527..c3d4c4527 100644 --- a/src/plugins/sceneformats/assimp/ailoaderiosystem.h +++ b/src/threed/scene_ai/ailoaderiosystem.h diff --git a/src/plugins/sceneformats/assimp/qailoader.cpp b/src/threed/scene_ai/qailoader.cpp index d866c2fa4..14871aa02 100644 --- a/src/plugins/sceneformats/assimp/qailoader.cpp +++ b/src/threed/scene_ai/qailoader.cpp @@ -103,7 +103,7 @@ static inline bool qHasTextures(const QGLSceneNode *node) void QAiLoader::loadMesh(aiMesh *mesh) { - QString name = QString::fromUtf8(mesh->mName.data, mesh->mName.length); + QString name = QString::fromUtf8(mesh->mName.data, int(mesh->mName.length)); // qDebug() << "loadMesh" << name << "with" << mesh->mNumVertices << "vertices" // << "and" << mesh->mNumFaces << "faces"; @@ -129,7 +129,7 @@ void QAiLoader::loadMesh(aiMesh *mesh) { QString error = QLatin1String("Bad primitive type in mesh %1 : %2"); error = error.arg(name).arg(mesh->mPrimitiveTypes); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); + Assimp::DefaultLogger::get()->warn(error.toLatin1().constData()); } } @@ -147,7 +147,7 @@ void QAiLoader::loadMesh(aiMesh *mesh) "Found color information in mesh %1, channel %2" "- per vertex color not yet supported"); error = error.arg(name).arg(i); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); + Assimp::DefaultLogger::get()->warn(error.toLatin1().constData()); break; } } @@ -157,14 +157,14 @@ void QAiLoader::loadMesh(aiMesh *mesh) // TODO: Implement skeletal animation QString error = QLatin1String("Bones in mesh %1 not yet supported"); error.arg(name); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); + Assimp::DefaultLogger::get()->warn(error.toLatin1().constData()); } if (mesh->HasTangentsAndBitangents()) { // TODO: Implement normal maps - here and in the texture import QString error = QLatin1String("Tangents for normal map in mesh %1 not yet supported"); error.arg(name); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); + Assimp::DefaultLogger::get()->warn(error.toLatin1().constData()); } } } @@ -198,7 +198,7 @@ void QAiLoader::loadNodes(aiNode *nodeList, QGLSceneNode *parentNode) { node = new QGLSceneNode(parentNode); m_nodes.append(node); - QString name = QString::fromUtf8(nodeList->mName.data, nodeList->mName.length); + QString name = QString::fromUtf8(nodeList->mName.data, int(nodeList->mName.length)); if (name.isEmpty()) name = QString(QLatin1String("aiNode %1")).arg(m_nodes.size()); node->setObjectName(name); @@ -243,9 +243,9 @@ QGLSceneNode *QAiLoader::loadMeshes() m_root = m_builder.finalizedSceneNode(); QString name = m_handler->url().path(); - int pos = name.lastIndexOf("/"); + int pos = name.lastIndexOf(QLatin1Char('/')); if (pos == -1) - pos = name.lastIndexOf("\\"); + pos = name.lastIndexOf(QLatin1Char('\\')); if (pos != -1) name = name.mid(pos+1); m_root->setObjectName(name); @@ -282,7 +282,7 @@ QGLSceneNode *QAiLoader::loadMeshes() QUrl url = m_handler->url(); message = message.arg(url.toString()).arg(m_meshes.size()) .arg(m_nodes.size()).arg(m_root->palette()->size()); - Assimp::DefaultLogger::get()->warn(message.toAscii().constData()); + Assimp::DefaultLogger::get()->warn(message.toLatin1().constData()); } //#define DEBUG_ME @@ -318,7 +318,7 @@ QList<QGLSceneAnimation *> QAiLoader::loadAnimations() m_animations.clear(); for (unsigned int i=0; i<m_scene->mNumAnimations; ++i) { - m_animations.append( new QGLSceneAnimation( QString(m_scene->mAnimations[i]->mName.data), 0 ) ); + m_animations.append( new QGLSceneAnimation( QLatin1String(m_scene->mAnimations[i]->mName.data), 0 ) ); } return m_animations; @@ -439,8 +439,8 @@ void QAiLoader::loadTextures(aiMaterial *ma, QGLMaterial *mq) if (texCount && texType != aiTextureType_DIFFUSE) { QString error = QLatin1String("Unsupported texture type \"%1\" in material \"%2\"."); - error.arg(typeNames[i]).arg(mq->objectName()); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); + error.arg(QLatin1String(typeNames[i]), mq->objectName()); + Assimp::DefaultLogger::get()->warn(error.toLatin1().constData()); } } } @@ -453,13 +453,13 @@ void QAiLoader::loadTextures(aiMaterial *ma, QGLMaterial *mq) { QString error = QLatin1String("Multi-textures not supported: \"%1\" has %2"); error.arg(mq->objectName()).arg(texCount); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); + Assimp::DefaultLogger::get()->warn(error.toLatin1().constData()); } else { aiString path; ma->Get(AI_MATKEY_TEXTURE_DIFFUSE(0), path); - QString qpath = QString::fromUtf8(path.data, path.length); + const QString qpath = QString::fromUtf8(path.data, int(path.length)); QUrl url = ensureResource(qpath); if (url.isEmpty()) { @@ -467,7 +467,7 @@ void QAiLoader::loadTextures(aiMaterial *ma, QGLMaterial *mq) { QString error = QLatin1String("Could not load texture: %1 for material %2"); error.arg(url.toString()).arg(mq->objectName()); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); + Assimp::DefaultLogger::get()->warn(error.toLatin1().constData()); } } else @@ -484,7 +484,7 @@ void QAiLoader::loadTextures(aiMaterial *ma, QGLMaterial *mq) void QAiLoader::loadMaterial(aiMaterial *ma) { QGLMaterial *mq = new QGLMaterial; - mq->setObjectName("___DEFAULT_NAME___"); + mq->setObjectName(QStringLiteral("___DEFAULT_NAME___")); bool isTwoSided = false; bool isWireframe = false; diff --git a/src/plugins/sceneformats/assimp/qailoader.h b/src/threed/scene_ai/qailoader.h index 988ba224e..988ba224e 100644 --- a/src/plugins/sceneformats/assimp/qailoader.h +++ b/src/threed/scene_ai/qailoader.h diff --git a/src/plugins/sceneformats/assimp/qaimesh.cpp b/src/threed/scene_ai/qaimesh.cpp index 918f36af0..87ef7b0da 100644 --- a/src/plugins/sceneformats/assimp/qaimesh.cpp +++ b/src/threed/scene_ai/qaimesh.cpp @@ -89,7 +89,7 @@ void QAiMesh::loadTriangles(QGLBuilder &builder) if (m_mesh->mNumUVComponents[t] != 2) Assimp::DefaultLogger::get()->warn("Tex co-ords only supports U & V"); QGLMaterial *m = builder.currentNode()->material(); - if (m && m->textureUrl().path().endsWith(".dds", Qt::CaseInsensitive)) + if (m && m->textureUrl().path().endsWith(QStringLiteral(".dds"), Qt::CaseInsensitive)) { for (unsigned int i = 0; i < m_mesh->mNumVertices; ++i) data.appendTexCoord(qv2d_inv(m_mesh->mTextureCoords[t][i]), static_cast<QGL::VertexAttribute>(QGL::TextureCoord0 + t)); @@ -122,7 +122,7 @@ void QAiMesh::build(QGLBuilder &builder, bool showWarnings) { QString error = QLatin1String("Mesh %1 has zero vertex/face count"); error.arg(name.isEmpty() ? QString(QLatin1String("<unnamed mesh>")) : name); - Assimp::DefaultLogger::get()->warn(error.toAscii().constData()); + Assimp::DefaultLogger::get()->warn(error.toLatin1().constData()); } return; } diff --git a/src/plugins/sceneformats/assimp/qaimesh.h b/src/threed/scene_ai/qaimesh.h index 87dc75460..87dc75460 100644 --- a/src/plugins/sceneformats/assimp/qaimesh.h +++ b/src/threed/scene_ai/qaimesh.h diff --git a/src/plugins/sceneformats/assimp/qaiscene.cpp b/src/threed/scene_ai/qaiscene.cpp index 5634855f9..5634855f9 100644 --- a/src/plugins/sceneformats/assimp/qaiscene.cpp +++ b/src/threed/scene_ai/qaiscene.cpp diff --git a/src/plugins/sceneformats/assimp/qaiscene.h b/src/threed/scene_ai/qaiscene.h index e1543a595..e1543a595 100644 --- a/src/plugins/sceneformats/assimp/qaiscene.h +++ b/src/threed/scene_ai/qaiscene.h diff --git a/src/plugins/sceneformats/assimp/qaiscenehandler.cpp b/src/threed/scene_ai/qaiscenehandler.cpp index 27add9b28..5d4c77317 100644 --- a/src/plugins/sceneformats/assimp/qaiscenehandler.cpp +++ b/src/threed/scene_ai/qaiscenehandler.cpp @@ -214,6 +214,61 @@ void QAiSceneHandler::decodeOptions(const QString &options) } } +QStringList QAiSceneHandler::supportedFormats() { + QStringList result; + result.reserve(60); + result.append(QStringLiteral("3d")); + result.append(QStringLiteral("3ds")); + result.append(QStringLiteral("ac")); + result.append(QStringLiteral("ac3d")); + result.append(QStringLiteral("acc")); + result.append(QStringLiteral("ase")); + result.append(QStringLiteral("ask")); + result.append(QStringLiteral("b3d")); + result.append(QStringLiteral("blend")); + result.append(QStringLiteral("bvh")); + result.append(QStringLiteral("cob")); + result.append(QStringLiteral("csm")); + result.append(QStringLiteral("dae")); + result.append(QStringLiteral("dxf")); + result.append(QStringLiteral("enff")); + result.append(QStringLiteral("hmp")); + result.append(QStringLiteral("irr")); + result.append(QStringLiteral("irrmesh")); + result.append(QStringLiteral("lwo")); + result.append(QStringLiteral("lws")); + result.append(QStringLiteral("lxo")); + result.append(QStringLiteral("md2")); + result.append(QStringLiteral("md3")); + result.append(QStringLiteral("md5anim")); + result.append(QStringLiteral("md5camera")); + result.append(QStringLiteral("md5mesh")); + result.append(QStringLiteral("mdc")); + result.append(QStringLiteral("mdl")); + result.append(QStringLiteral("mesh.xml")); + result.append(QStringLiteral("mot")); + result.append(QStringLiteral("ms3d")); + result.append(QStringLiteral("ndo")); + result.append(QStringLiteral("nff")); + result.append(QStringLiteral("obj")); + result.append(QStringLiteral("off")); + result.append(QStringLiteral("pk3")); + result.append(QStringLiteral("ply")); + result.append(QStringLiteral("prj")); + result.append(QStringLiteral("q3o")); + result.append(QStringLiteral("q3s")); + result.append(QStringLiteral("raw")); + result.append(QStringLiteral("scn")); + result.append(QStringLiteral("smd")); + result.append(QStringLiteral("stl")); + result.append(QStringLiteral("ter")); + result.append(QStringLiteral("uc")); + result.append(QStringLiteral("vta")); + result.append(QStringLiteral("x")); + result.append(QStringLiteral("xml")); + return result; +} + QGLAbstractScene *QAiSceneHandler::read() { AiLoaderIOSystem *ios = new AiLoaderIOSystem(device(), url()); @@ -238,7 +293,7 @@ QGLAbstractScene *QAiSceneHandler::read() QUrl u = url(); if (u.scheme() != QLatin1String("file")) { - path = u.toEncoded(); + path = QLatin1String(u.toEncoded()); } else { path = u.toLocalFile(); } @@ -260,7 +315,7 @@ QGLAbstractScene *QAiSceneHandler::read() // the importer owns the scene, so when the it goes out of scope on exiting // this function the scene will get destroyed - const aiScene* scene = m_importer.ReadFile(path.toAscii().constData(), m_options); + const aiScene* scene = m_importer.ReadFile(path.toLatin1().constData(), m_options); if (!scene) { @@ -400,7 +455,7 @@ void QAiSceneHandler::downloadComplete(QByteArray *sceneData) m_importer.SetIOHandler(ios); QString path; - path = url().toEncoded(); + path = QLatin1String(url().toEncoded()); Assimp::Logger *log = 0; Assimp::Logger::LogSeverity severity = Assimp::Logger::NORMAL; diff --git a/src/plugins/sceneformats/assimp/qaiscenehandler.h b/src/threed/scene_ai/qaiscenehandler.h index 45c7a2c66..489c046e7 100644 --- a/src/plugins/sceneformats/assimp/qaiscenehandler.h +++ b/src/threed/scene_ai/qaiscenehandler.h @@ -83,6 +83,8 @@ public: QAiSceneHandler(); ~QAiSceneHandler(); + static QStringList supportedFormats(); + QGLAbstractScene *read(); QGLAbstractScene *download(); diff --git a/src/threed/scene_ai/scene_ai.pri b/src/threed/scene_ai/scene_ai.pri new file mode 100644 index 000000000..794d990f6 --- /dev/null +++ b/src/threed/scene_ai/scene_ai.pri @@ -0,0 +1,21 @@ +INCLUDEPATH += $$PWD +VPATH += $$PWD +HEADERS += \ + scene_ai/qaiscenehandler.h \ + scene_ai/qaiscene.h \ + scene_ai/qaimesh.h \ + scene_ai/qailoader.h \ + scene_ai/ailoaderiosystem.h \ + scene_ai/ailoaderiostream.h +SOURCES += \ + scene_ai/qaiscenehandler.cpp \ + scene_ai/qaiscene.cpp \ + scene_ai/qaimesh.cpp \ + scene_ai/qailoader.cpp \ + scene_ai/ailoaderiosystem.cpp \ + scene_ai/ailoaderiostream.cpp + + +# suppress warnings about std::copy using unsafe parameters +win32: DEFINES +=_SCL_SECURE_NO_WARNINGS +include(../../../3rdparty/assimp/assimp.pri) diff --git a/src/plugins/sceneformats/bezier/qglbezierscene.cpp b/src/threed/scene_bezier/qglbezierscene.cpp index fe864f257..fe864f257 100644 --- a/src/plugins/sceneformats/bezier/qglbezierscene.cpp +++ b/src/threed/scene_bezier/qglbezierscene.cpp diff --git a/src/plugins/sceneformats/bezier/qglbezierscene.h b/src/threed/scene_bezier/qglbezierscene.h index 156e2266f..156e2266f 100644 --- a/src/plugins/sceneformats/bezier/qglbezierscene.h +++ b/src/threed/scene_bezier/qglbezierscene.h diff --git a/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp b/src/threed/scene_bezier/qglbezierscenehandler.cpp index 58ea68c60..5e5a1a4f5 100644 --- a/src/plugins/sceneformats/bezier/qglbezierscenehandler.cpp +++ b/src/threed/scene_bezier/qglbezierscenehandler.cpp @@ -47,6 +47,10 @@ QT_BEGIN_NAMESPACE +QStringList QGLBezierSceneHandler::supportedFormats() { + return QStringList(QLatin1String("bez")); +} + QGLAbstractScene *QGLBezierSceneHandler::read() { QTextStream stream(device()); diff --git a/src/plugins/sceneformats/bezier/qglbezierscenehandler.h b/src/threed/scene_bezier/qglbezierscenehandler.h index 59f8945f9..ff77d577b 100644 --- a/src/plugins/sceneformats/bezier/qglbezierscenehandler.h +++ b/src/threed/scene_bezier/qglbezierscenehandler.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE class QGLBezierSceneHandler : public QGLSceneFormatHandler { public: + static QStringList supportedFormats(); QGLAbstractScene *read(); QGLAbstractScene *download(); }; diff --git a/src/threed/scene_bezier/scene_bezier.pri b/src/threed/scene_bezier/scene_bezier.pri new file mode 100644 index 000000000..5fb11f3ed --- /dev/null +++ b/src/threed/scene_bezier/scene_bezier.pri @@ -0,0 +1,8 @@ +INCLUDEPATH += $$PWD +VPATH += $$PWD +HEADERS += \ + scene_bezier/qglbezierscenehandler.h \ + scene_bezier/qglbezierscene.h +SOURCES += \ + scene_bezier/qglbezierscenehandler.cpp \ + scene_bezier/qglbezierscene.cpp diff --git a/src/threed/textures/qgltexture2d.cpp b/src/threed/textures/qgltexture2d.cpp index 239942707..46898546b 100644 --- a/src/threed/textures/qgltexture2d.cpp +++ b/src/threed/textures/qgltexture2d.cpp @@ -130,7 +130,7 @@ QGLTexture2DPrivate::~QGLTexture2DPrivate() if (url.isEmpty()) { qWarning("OPENGL RESOURCE LEAK: texture(created from Image) has non-released resources:"); } else { - qWarning("OPENGL RESOURCE LEAK: texture '%s' has non-released resources:", url.toString().toAscii().constData()); + qWarning("OPENGL RESOURCE LEAK: texture '%s' has non-released resources:", url.toString().toLatin1().constData()); } for (QList<QGLTexture2DTextureInfo*>::iterator It=textureInfo.begin(); It!=textureInfo.end(); ++It) { if ((*It)->isLiteral==false && (*It)->tex.textureId()) { @@ -715,20 +715,22 @@ bool QGLTexture2DPrivate::cleanupResources() { if (!textureInfo.empty()) { QOpenGLContext *ctx = QOpenGLContext::currentContext(); - Q_ASSERT(ctx!=0); - for (QList<QGLTexture2DTextureInfo*>::iterator It=textureInfo.begin(); It!=textureInfo.end();) { - QGLTexture2DTextureInfo *texInfo = *It; - QOpenGLContext *ictx = const_cast<QOpenGLContext*>(texInfo->tex.context()); - Q_ASSERT(ictx!=0); - if (QOpenGLContext::areSharing(ictx, ctx)) { - if (!texInfo->isLiteral && texInfo->tex.textureId()) { - GLuint id = texInfo->tex.textureId(); - glDeleteTextures(1, &id); - texInfo->tex.clearId(); + if (ctx) + { + for (QList<QGLTexture2DTextureInfo*>::iterator It=textureInfo.begin(); It!=textureInfo.end();) { + QGLTexture2DTextureInfo *texInfo = *It; + QOpenGLContext *ictx = const_cast<QOpenGLContext*>(texInfo->tex.context()); + Q_ASSERT(ictx!=0); + if (QOpenGLContext::areSharing(ictx, ctx)) { + if (!texInfo->isLiteral && texInfo->tex.textureId()) { + GLuint id = texInfo->tex.textureId(); + glDeleteTextures(1, &id); + texInfo->tex.clearId(); + } + It = textureInfo.erase(It); + } else { + ++It; } - It = textureInfo.erase(It); - } else { - ++It; } } } @@ -896,6 +898,8 @@ void QGLTexture2D::textureRequestFinished(QByteArray* assetData) //Convert asset data to an image. QImage texImage; texImage.loadFromData(*assetData); + + setSize(texImage.size()); setImage(texImage.mirrored()); emit textureUpdated(); diff --git a/src/threed/threed.pri b/src/threed/threed.pri index 0c3e68cb2..9b4674569 100644 --- a/src/threed/threed.pri +++ b/src/threed/threed.pri @@ -7,6 +7,8 @@ include(geometry/geometry.pri) include(viewing/viewing.pri) include(math3d/math3d.pri) include(scene/scene.pri) +include(scene_ai/scene_ai.pri) +include(scene_bezier/scene_bezier.pri) include(network/network.pri) include(graphicsview/graphicsview.pri) include(textures/textures.pri) diff --git a/src/threed/viewing/qglmockview_p.h b/src/threed/viewing/qglmockview_p.h index 084db4659..a61b39186 100644 --- a/src/threed/viewing/qglmockview_p.h +++ b/src/threed/viewing/qglmockview_p.h @@ -42,17 +42,6 @@ #ifndef QGLMOCKVIEW_P_H #define QGLMOCKVIEW_P_H -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - QT_BEGIN_NAMESPACE class QOpenGLContext; diff --git a/src/threed/viewing/qglview.cpp b/src/threed/viewing/qglview.cpp index 9eb916bc4..3677c5eba 100644 --- a/src/threed/viewing/qglview.cpp +++ b/src/threed/viewing/qglview.cpp @@ -820,6 +820,9 @@ void QGLView::showEvent(QShowEvent *e) { Q_UNUSED(e); d->visible = true; + d->ensureContext(); + if (!d->initialized) + initializeGL(); } void QGLView::hideEvent(QHideEvent *e) @@ -834,7 +837,6 @@ void QGLView::exposeEvent(QExposeEvent *e) d->updateQueued = false; d->ensureContext(); - if (!d->initialized) initializeGL(); @@ -850,6 +852,9 @@ void QGLView::resizeEvent(QResizeEvent *e) Q_ASSERT(e->size() == r.size()); if (r.size() != d->viewport.size()) { + d->ensureContext(); + if (!d->initialized) + initializeGL(); resizeGL(r.width(), r.height()); d->viewport = r; } diff --git a/sync.profile b/sync.profile index 930b147e8..8bf1534e0 100644 --- a/sync.profile +++ b/sync.profile @@ -27,7 +27,6 @@ # %dependencies = ( "qtbase" => "refs/heads/master", - "qtsvg" => "refs/heads/master", "qtxmlpatterns" => "refs/heads/master", "qtdeclarative" => "refs/heads/master", "qtjsbackend" => "refs/heads/master", diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index f73157dfb..1f5b55b2e 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,2 +1,7 @@ TEMPLATE = subdirs -SUBDIRS = threed imports qml3d +SUBDIRS = threed imports + +contains(QT_CONFIG, qmltest) { + SUBDIRS += qml3d + !win32 : SUBDIRS += qml3d_visual +} diff --git a/tests/auto/qml3d/QtQuickTest/TestCase.qml b/tests/auto/qml3d/QtQuickTest/TestCase.qml deleted file mode 100644 index 9ba692697..000000000 --- a/tests/auto/qml3d/QtQuickTest/TestCase.qml +++ /dev/null @@ -1,254 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "testlogger.js" as TestLogger - -Item { - id: testCase - visible: false - - // Name of the test case to prefix the function name in messages. - property string name - - // Set to true to start the test running. - property bool when: true - - // Set to true once the test has completed. - property bool completed: false - - // Set to true when the test is running but not yet complete. - property bool running: false - - // Set to true if the test doesn't have to run (because some - // other test failed which this one depends on). - property bool optional: false - - // Internal private state - property string currentTestCase - property bool expectingFail - property string expectFailMsg - property bool prevWhen: true - property int testId: -1 - - TestReport { id: reporter } - - function fail(msg) { - if (!msg) - msg = ""; - if (expectingFail) { - TestLogger.log_expect_fail(currentTestCase, expectFailMsg, msg) - throw new Error("QtTest::expect_fail") - } else { - TestLogger.log_fail(currentTestCase, msg) - throw new Error("QtTest::fail") - } - } - - function fail2(msg, msg2) { - if (msg) - fail(msg + ": " + msg2) - else - fail(msg2) - } - - function verify(cond, msg) { - if (!cond) - fail(msg) - } - - function compare(actual, expected, msg) { - if (typeof actual == "number" && typeof expected == "number") { - // Use a fuzzy compare if the two values are floats - if (Math.abs(actual - expected) <= 0.00001) - return - } else if (typeof actual == "object" && typeof expected == "object") { - // Does the expected value look like a vector3d? - if ("x" in expected && "y" in expected && "z" in expected) { - if (Math.abs(actual.x - expected.x) <= 0.00001 && - Math.abs(actual.y - expected.y) <= 0.00001 && - Math.abs(actual.z - expected.z) <= 0.00001) - return - fail2(msg, "actual: Qt.vector3d(" + - actual.x + ", " + actual.y + ", " + actual.z + - "), expected: Qt.vector3d(" + - expected.x + ", " + expected.y + ", " + expected.z + - ")") - return - } - if (actual == expected) - return - } else if (actual == expected) { - return - } - fail2(msg, "actual: " + actual + ", expected: " + expected) - } - - function skip(msg) { - TestLogger.log_skip(currentTestCase, msg) - throw new Error("QtTest::skip") - } - - function expectFail(msg) { - expectingFail = true - expectFailMsg = msg - } - - property variant testCaseResult - - function runInternal(prop, dataDriven, arg, tag) { - currentTestCase = TestLogger.log_prefixed_name(name, prop) - if (dataDriven && tag) - currentTestCase += " [" + tag + "]" - expectingFail = false - var success = true - try { - testCaseResult = testCase[prop](arg) - if (expectingFail) { - success = false - TestLogger.log_expect_fail_pass(currentTestCase) - } else if (!dataDriven) { - TestLogger.log_pass(currentTestCase) - } - } catch (e) { - testCaseResult = [] - if (e.message == "QtTest::fail") { - success = false - } else if (e.message.indexOf("QtTest::") != 0) { - // Test threw an unrecognized exception - fail. - TestLogger.log_fail(currentTestCase, e.message) - success = false - } - } - return success - } - - function run() { - TestLogger.log_start_test(reporter) - var success = true - running = true - var testList = [] - for (var prop in testCase) { - if (prop.indexOf("test_") != 0) - continue - if (filterTestCases.length > 0) { - // if there is a list, only run the tests in the list - var excludeTest = true - for (var i = 0; i < filterTestCases.length && excludeTest; i++) - { - if (filterTestCases[i] == prop) - excludeTest = false - } - if (excludeTest) - continue - } - var tail = prop.lastIndexOf("_data"); - if (tail != -1 && tail == (prop.length - 5)) - continue - testList.push(prop) - } - testList.sort() - for (var index in testList) { - var prop = testList[index] - var datafunc = prop + "_data" - if (datafunc in testCase) { - if (runInternal(datafunc, true)) { - var table = testCaseResult - var successThis = true - var haveData = false - for (var index in table) { - haveData = true - var row = table[index] - if (!runInternal(prop, true, row, row.tag)) - successThis = false - } - if (!haveData) - TestLogger.log_message("WARNING: no data supplied for " + prop + "() by " + datafunc + "()") - if (successThis) { - var prefix; - if (name) - prefix = name + "::" - currentTestCase = prefix + prop + "()" - TestLogger.log_pass(currentTestCase) - } else { - success = false - } - } else { - success = false - } - } else { - if (!runInternal(prop, false)) - success = false - } - } - currentTestCase = "" - running = false - completed = true - TestLogger.log_complete_test(testId, reporter) - return success - } - - onWhenChanged: { - if (when != prevWhen) { - prevWhen = when - if (when && !completed && !running) - run() - } - } - - onOptionalChanged: { - if (!completed) { - if (optional) - TestLogger.log_optional_test(testId) - else - TestLogger.log_mandatory_test(testId) - } - } - - Component.onCompleted: { - testId = TestLogger.log_register_test(name) - if (optional) - TestLogger.log_optional_test(testId) - prevWhen = when - if (when && !completed && !running) - run() - } -} diff --git a/tests/auto/qml3d/QtQuickTest/qmldir b/tests/auto/qml3d/QtQuickTest/qmldir deleted file mode 100644 index 56f9177a5..000000000 --- a/tests/auto/qml3d/QtQuickTest/qmldir +++ /dev/null @@ -1 +0,0 @@ -TestCase 1.0 TestCase.qml diff --git a/tests/auto/qml3d/QtQuickTest/testlogger.js b/tests/auto/qml3d/QtQuickTest/testlogger.js deleted file mode 100644 index 11b17680c..000000000 --- a/tests/auto/qml3d/QtQuickTest/testlogger.js +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 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 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -.pragma library - -// We need a global place to store the results that can be -// shared between multiple TestCase instances. Because QML -// creates a separate scope for every inclusion of this file, -// we hijack the global "Qt" object to store our data. -function log_init_results() -{ - if (!Qt.testResults) { - Qt.testResults = { - suiteName: "", - reportedStart: false, - numPassed: 0, - numFailed: 0, - numSkipped: 0, - nextId: 0, - testCases: [], - reporter: null - } - } -} - -function log_fail(testcase, msg) -{ - if (!msg) - msg = "" - Qt.testResults.reporter.log_fail(testcase, msg); - ++Qt.testResults.numFailed -} - -function log_expect_fail(testcase, expectmsg, msg) -{ - if (!msg) - msg = "" - if (expectmsg) - Qt.testResults.reporter.log_expect_fail(testcase, expectmsg + " " + msg); - else - Qt.testResults.reporter.log_expect_fail(testcase, msg); - ++Qt.testResults.numPassed -} - -function log_expect_fail_pass(testcase) -{ - Qt.testResults.reporter.log_expect_fail_pass(testcase); - ++Qt.testResults.numFailed -} - -function log_skip(testcase, msg) -{ - if (!msg) - msg = "" - Qt.testResults.reporter.log_skip(testcase, msg); - ++Qt.testResults.numSkipped -} - -function log_pass(testcase) -{ - Qt.testResults.reporter.log_pass(testcase); - ++Qt.testResults.numPassed -} - -function log_message(msg) -{ - Qt.testResults.reporter.log_message(msg); -} - -function log_register_test(name) -{ - log_init_results() - if (name && !Qt.testResults.suiteName) - Qt.testResults.suiteName = name - var testId = Qt.testResults.nextId++ - Qt.testResults.testCases.push(testId) - return testId -} - -function log_optional_test(testId) -{ - log_init_results() - var index = Qt.testResults.testCases.indexOf(testId) - if (index >= 0) - Qt.testResults.testCases.splice(index, 1) -} - -function log_mandatory_test(testId) -{ - log_init_results() - var index = Qt.testResults.testCases.indexOf(testId) - if (index == -1) - Qt.testResults.testCases.push(testId) -} - -function log_start_test(reporter) -{ - log_init_results() - Qt.testResults.reporter = reporter - if (Qt.testResults.reportedStart) - return - Qt.testResults.reportedStart = true -} - -function log_complete_test(testId, reporter) -{ - var index = Qt.testResults.testCases.indexOf(testId) - if (index >= 0) - Qt.testResults.testCases.splice(index, 1) - if (!Qt.testResults.testCases.length) { - reporter.report(Qt.testResults.numPassed, - Qt.testResults.numFailed, - Qt.testResults.numSkipped) - Qt.quit() - } -} - -function log_prefixed_name(name, funcname) -{ - if (!name) - name = Qt.testResults.suiteName - if (name) - return name + "::" + funcname + "()" - else - return funcname + "()" -} diff --git a/tests/auto/qml3d/item3d/tst_missing_texture_coordinates.qml b/tests/auto/qml3d/item3d/tst_missing_texture_coordinates.qml index b9f24b72d..aa1a8739c 100644 --- a/tests/auto/qml3d/item3d/tst_missing_texture_coordinates.qml +++ b/tests/auto/qml3d/item3d/tst_missing_texture_coordinates.qml @@ -41,6 +41,7 @@ import Qt3D 1.0 import QtQuick 2.0 +import QtTest 1.0 Viewport { width: 1000 @@ -64,11 +65,14 @@ Viewport { onTriggered: Qt.quit() } - // This test is simply testing to see if the item crashes on startup, - // so this dummy test is probably not even required - function test_exists() - { - verify(testItem.visible); - Qt.quit(); + TestCase { + name: "NoTextureCoordinates" + // This test is simply testing to see if the item crashes on startup, + // so this dummy test is probably not even required + function test_exists() + { + verify(testItem.visible); + Qt.quit(); + } } } diff --git a/tests/auto/qml3d/qml3d.pro b/tests/auto/qml3d/qml3d.pro index 61bce3eb2..64250bf26 100644 --- a/tests/auto/qml3d/qml3d.pro +++ b/tests/auto/qml3d/qml3d.pro @@ -1,25 +1,20 @@ -load(qmltestcase.prf) TEMPLATE=app TARGET=tst_qml3d -CONFIG += warn_on +CONFIG += warn_on qmltestcase QT += qml opengl SOURCES += tst_qml3d.cpp -DEFINES -= QUICK_TEST_SOURCE_DIR -DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" win32:DEFINES+=_CRT_SECURE_NO_WARNINGS OTHER_FILES += \ + QtQuickTest/TestCase.qml \ lookat/tst_lookat.qml \ scale3d/tst_scale3d.qml \ modelview/tst_modelview.qml \ sphere/tst_sphere.qml \ - effect/tst_effect.qml \ viewport/tst_viewport.qml \ mesh/tst_mesh.qml \ - picking/tst_picking.qml \ item3d/tst_item3d.qml \ item3d/tst_missing_texture_coordinates.qml \ - item3d/tst_item3d_local_v_world.qml \ - -CONFIG+=insignificant_test # See QTBUG-25276 + item3d/tst_item3d_local_v_world.qml +TESTDATA = $$OTHER_FILES diff --git a/tests/auto/qml3d/sphere/tst_sphere.qml b/tests/auto/qml3d/sphere/tst_sphere.qml index 296f6438c..11d85eda1 100644 --- a/tests/auto/qml3d/sphere/tst_sphere.qml +++ b/tests/auto/qml3d/sphere/tst_sphere.qml @@ -79,7 +79,7 @@ Viewport { name: "Sphere" function test_defaults() { - compare(sphere1.radius, 1, "radius"); + compare(sphere1.radius, 0.5, "radius"); compare(sphere1.levelOfDetail, 5, "levelOfDetail"); compare(sphere1.axis, Qt.ZAxis, "axis"); } diff --git a/tests/auto/qml3d/effect/test.png b/tests/auto/qml3d_visual/effect/test.png Binary files differindex 80a4868f3..80a4868f3 100644 --- a/tests/auto/qml3d/effect/test.png +++ b/tests/auto/qml3d_visual/effect/test.png diff --git a/tests/auto/qml3d/effect/tst_effect.qml b/tests/auto/qml3d_visual/effect/tst_effect.qml index f3749c6f1..f3749c6f1 100644 --- a/tests/auto/qml3d/effect/tst_effect.qml +++ b/tests/auto/qml3d_visual/effect/tst_effect.qml diff --git a/tests/auto/qml3d/modelview/textures/amethyst.jpg b/tests/auto/qml3d_visual/modelview/textures/amethyst.jpg Binary files differindex 43a2c4409..43a2c4409 100644 --- a/tests/auto/qml3d/modelview/textures/amethyst.jpg +++ b/tests/auto/qml3d_visual/modelview/textures/amethyst.jpg diff --git a/tests/auto/qml3d/modelview/textures/bigblue.jpg b/tests/auto/qml3d_visual/modelview/textures/bigblue.jpg Binary files differindex 8a0bb6533..8a0bb6533 100644 --- a/tests/auto/qml3d/modelview/textures/bigblue.jpg +++ b/tests/auto/qml3d_visual/modelview/textures/bigblue.jpg diff --git a/tests/auto/qml3d/modelview/textures/blueweb.jpg b/tests/auto/qml3d_visual/modelview/textures/blueweb.jpg Binary files differindex 68f3d3507..68f3d3507 100644 --- a/tests/auto/qml3d/modelview/textures/blueweb.jpg +++ b/tests/auto/qml3d_visual/modelview/textures/blueweb.jpg diff --git a/tests/auto/qml3d/modelview/textures/pastelstuff.jpg b/tests/auto/qml3d_visual/modelview/textures/pastelstuff.jpg Binary files differindex 82da86e09..82da86e09 100644 --- a/tests/auto/qml3d/modelview/textures/pastelstuff.jpg +++ b/tests/auto/qml3d_visual/modelview/textures/pastelstuff.jpg diff --git a/tests/auto/qml3d/modelview/textures/qtlogo.png b/tests/auto/qml3d_visual/modelview/textures/qtlogo.png Binary files differindex 7d3e97eb3..7d3e97eb3 100644 --- a/tests/auto/qml3d/modelview/textures/qtlogo.png +++ b/tests/auto/qml3d_visual/modelview/textures/qtlogo.png diff --git a/tests/auto/qml3d/modelview/textures/threedgreen.jpg b/tests/auto/qml3d_visual/modelview/textures/threedgreen.jpg Binary files differindex 7624527ff..7624527ff 100644 --- a/tests/auto/qml3d/modelview/textures/threedgreen.jpg +++ b/tests/auto/qml3d_visual/modelview/textures/threedgreen.jpg diff --git a/tests/auto/qml3d/modelview/tst_modelview.qml b/tests/auto/qml3d_visual/modelview/tst_modelview.qml index 2f564c3e4..172eebe85 100644 --- a/tests/auto/qml3d/modelview/tst_modelview.qml +++ b/tests/auto/qml3d_visual/modelview/tst_modelview.qml @@ -162,7 +162,7 @@ Rectangle TestCase { id: modelViewTestAddingCase // when: false - name: "Quick3d ModelView Adding Data Test" + name: "Quick3d_ModelView_AddingData" function test_changing_stringList_model() { var viewportEmptyModelChildCount = viewport.children.length; @@ -222,7 +222,7 @@ Rectangle id: modelViewRemovingItemsTestCase // Wait for event loop before performing removal tests when: false - name: "Quick3d ModelView Removing Data Test" + name: "Quick3d_ModelView_RemovingData" function test_removing_from_listModel() { var viewportChildCount = viewport.children.length; diff --git a/tests/auto/qml3d/picking/tst_picking.qml b/tests/auto/qml3d_visual/picking/tst_picking.qml index 6dd621fa2..7275726bb 100644 --- a/tests/auto/qml3d/picking/tst_picking.qml +++ b/tests/auto/qml3d_visual/picking/tst_picking.qml @@ -148,8 +148,8 @@ Rectangle var y = viewport.height / 2; // Usually succeeds on the first run // console.log("objectForPoint(" + x + "," + y + "): " + viewport.objectForPoint(x,y) ); - if (viewport.objectForPoint(x,y) != null) - pickingTestCase.when = true; + // if (viewport.objectForPoint(x,y) != null) + // pickingTestCase.when = true; } } @@ -174,6 +174,7 @@ Rectangle property int midX : viewport.width / 2; property int midY : viewport.height / 2; function test_picking() { + skip("objectForPoint() function is not currently supported"); verify(!timedOut, "timed out"); verify(viewport.objectForPoint(0,0) == fullScreenQuad, "Didn't find full screen quad in top left corner"); diff --git a/tests/auto/qml3d_visual/qml3d_visual.pro b/tests/auto/qml3d_visual/qml3d_visual.pro new file mode 100644 index 000000000..553381cbb --- /dev/null +++ b/tests/auto/qml3d_visual/qml3d_visual.pro @@ -0,0 +1,14 @@ +TEMPLATE=app +TARGET=tst_qml3d_visual +CONFIG += warn_on qmltestcase +QT += qml opengl +SOURCES += tst_qml3d_visual.cpp + +win32:DEFINES+=_CRT_SECURE_NO_WARNINGS + +OTHER_FILES += \ + modelview/tst_modelview.qml \ + effect/tst_effect.qml \ + picking/tst_picking.qml + +TESTDATA = $$OTHER_FILES diff --git a/src/plugins/sceneformats/assimp/ai_plugin.cpp b/tests/auto/qml3d_visual/tst_qml3d_visual.cpp index 9e1dbd6be..16363c332 100644 --- a/src/plugins/sceneformats/assimp/ai_plugin.cpp +++ b/tests/auto/qml3d_visual/tst_qml3d_visual.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the Qt3D module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -39,22 +39,6 @@ ** ****************************************************************************/ -#include "ai_plugin.h" -#include "qaiscenehandler.h" - -QT_BEGIN_NAMESPACE - -QAiScenePlugin::QAiScenePlugin() {} -QAiScenePlugin::~QAiScenePlugin() {} - -QGLSceneFormatHandler *QAiScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const -{ - Q_UNUSED(device); - Q_UNUSED(url); - Q_UNUSED(format); - return new QAiSceneHandler; -} - -QT_END_NAMESPACE - +#include <QtQuickTest/quicktest.h> +QUICK_TEST_MAIN(qml3d_visual) diff --git a/tests/auto/threed/qbox3d/tst_qbox3d.cpp b/tests/auto/threed/qbox3d/tst_qbox3d.cpp index 73d17c72a..d6afeb6f8 100644 --- a/tests/auto/threed/qbox3d/tst_qbox3d.cpp +++ b/tests/auto/threed/qbox3d/tst_qbox3d.cpp @@ -1276,7 +1276,7 @@ void tst_QBox3D::properties() obj.setBox(QBox3D(QVector3D(1, 2, 3), QVector3D(4, 5, 6))); - QBox3D b = qVariantValue<QBox3D>(obj.property("box")); + QBox3D b = qvariant_cast<QBox3D>(obj.property("box")); QCOMPARE(b.minimum(), QVector3D(1, 2, 3)); QCOMPARE(b.maximum(), QVector3D(4, 5, 6)); @@ -1284,7 +1284,7 @@ void tst_QBox3D::properties() qVariantFromValue (QBox3D(QVector3D(-1, -2, -3), QVector3D(-4, -5, -6)))); - b = qVariantValue<QBox3D>(obj.property("box")); + b = qvariant_cast<QBox3D>(obj.property("box")); QCOMPARE(b.minimum(), QVector3D(-4, -5, -6)); QCOMPARE(b.maximum(), QVector3D(-1, -2, -3)); } diff --git a/tests/auto/threed/qglabstractsurface/tst_qglabstractsurface.cpp b/tests/auto/threed/qglabstractsurface/tst_qglabstractsurface.cpp index 1f1489289..cb178b03a 100644 --- a/tests/auto/threed/qglabstractsurface/tst_qglabstractsurface.cpp +++ b/tests/auto/threed/qglabstractsurface/tst_qglabstractsurface.cpp @@ -139,6 +139,11 @@ void tst_QGLAbstractSurface::fboSurface() QGLWindowSurface surface1(&glw); QVERIFY(surface1.activate()); +#ifdef Q_OS_MAC + // The geometry tests all thru this function will fail til this is fixed + QSKIP("Mac issue with this bug - is Y inverted on Mac?"); +#endif + #ifdef Q_OS_WIN // The geometry tests all thru this function will fail til this is fixed QSKIP("Windows QPA bug http://bugreports.qt-project.org/browse/QTBUG-24539"); @@ -242,6 +247,11 @@ void tst_QGLAbstractSurface::subSurface() QVERIFY(surface2.activate()); QVERIFY(QOpenGLContext::currentContext() == ctx); +#ifdef Q_OS_MAC + // The geometry tests all thru this function will fail til this is fixed + QSKIP("Mac issue with this bug - is Y inverted on Mac?"); +#endif + #ifdef Q_OS_WIN // The geometry tests all thru this function will fail til this is fixed QSKIP("Windows QPA bug http://bugreports.qt-project.org/browse/QTBUG-24539"); diff --git a/tests/auto/threed/qglmaterial/qglmaterial.pro b/tests/auto/threed/qglmaterial/qglmaterial.pro index 819b23fa5..5bad31f83 100644 --- a/tests/auto/threed/qglmaterial/qglmaterial.pro +++ b/tests/auto/threed/qglmaterial/qglmaterial.pro @@ -3,5 +3,6 @@ CONFIG += testcase TEMPLATE=app QT += testlib 3d CONFIG += warn_on +CONFIG += insignificant_test # See QTBUG-25757 SOURCES += tst_qglmaterial.cpp diff --git a/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp b/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp index 04693ab21..bb9f3b6a2 100644 --- a/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp +++ b/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp @@ -41,6 +41,8 @@ #include <QtTest/QtTest> #include <QtGui/QOpenGLContext> +#include <QOpenGLShaderProgram> + #include "qglmaterial.h" #include "qglcolormaterial.h" #include "qgltwosidedmaterial.h" @@ -239,8 +241,14 @@ void tst_QGLMaterial::initTestCase() { widget = new TestWidget(); widget->show(); - if (widget->context() == 0) + QOpenGLContext *ctx = widget->context(); + if (!QOpenGLShaderProgram::hasOpenGLShaderPrograms(ctx)) + QSKIP("Shaders not supported"); + if (!ctx || !ctx->isValid()) QSKIP("Could not create valid GL context"); + + // TODO: if there is no context the whole thing gets skipped. We should at + // least be able to test for properties, setters & getters and so on. } void tst_QGLMaterial::cleanupTestCase() @@ -708,7 +716,7 @@ void tst_QGLMaterial::standardMaterialDraw() { QSKIP("not currently working"); - if (!widget->context()->isValid()) + if (!widget->context() || !widget->context()->isValid()) QSKIP("GL Implementation not valid"); QGLMaterial mat1; diff --git a/tests/auto/threed/qplane3d/tst_qplane3d.cpp b/tests/auto/threed/qplane3d/tst_qplane3d.cpp index 07d48182d..fca463069 100644 --- a/tests/auto/threed/qplane3d/tst_qplane3d.cpp +++ b/tests/auto/threed/qplane3d/tst_qplane3d.cpp @@ -424,7 +424,7 @@ void tst_QPlane3D::properties() obj.setPlane(QPlane3D(QVector3D(1, 2, 3), QVector3D(4, 5, 6))); - QPlane3D p = qVariantValue<QPlane3D>(obj.property("plane")); + QPlane3D p = qvariant_cast<QPlane3D>(obj.property("plane")); QCOMPARE(p.origin(), QVector3D(1, 2, 3)); QCOMPARE(p.normal(), QVector3D(4, 5, 6)); @@ -432,7 +432,7 @@ void tst_QPlane3D::properties() qVariantFromValue (QPlane3D(QVector3D(-1, -2, -3), QVector3D(-4, -5, -6)))); - p = qVariantValue<QPlane3D>(obj.property("plane")); + p = qvariant_cast<QPlane3D>(obj.property("plane")); QCOMPARE(p.origin(), QVector3D(-1, -2, -3)); QCOMPARE(p.normal(), QVector3D(-4, -5, -6)); } diff --git a/tests/auto/threed/qray3d/tst_qray3d.cpp b/tests/auto/threed/qray3d/tst_qray3d.cpp index cb4e19cdd..4aecb2b4c 100644 --- a/tests/auto/threed/qray3d/tst_qray3d.cpp +++ b/tests/auto/threed/qray3d/tst_qray3d.cpp @@ -514,7 +514,7 @@ void tst_QRay3D::properties() obj.setRay(QRay3D(QVector3D(1, 2, 3), QVector3D(4, 5, 6))); - QRay3D r = qVariantValue<QRay3D>(obj.property("ray")); + QRay3D r = qvariant_cast<QRay3D>(obj.property("ray")); QCOMPARE(r.origin(), QVector3D(1, 2, 3)); QCOMPARE(r.direction(), QVector3D(4, 5, 6)); @@ -522,7 +522,7 @@ void tst_QRay3D::properties() qVariantFromValue (QRay3D(QVector3D(-1, -2, -3), QVector3D(-4, -5, -6)))); - r = qVariantValue<QRay3D>(obj.property("ray")); + r = qvariant_cast<QRay3D>(obj.property("ray")); QCOMPARE(r.origin(), QVector3D(-1, -2, -3)); QCOMPARE(r.direction(), QVector3D(-4, -5, -6)); } diff --git a/tests/auto/threed/qsphere3d/tst_qsphere3d.cpp b/tests/auto/threed/qsphere3d/tst_qsphere3d.cpp index 3291d51f8..5f303a223 100644 --- a/tests/auto/threed/qsphere3d/tst_qsphere3d.cpp +++ b/tests/auto/threed/qsphere3d/tst_qsphere3d.cpp @@ -213,14 +213,14 @@ void tst_QSphere3D::properties() obj.setSphere(QSphere3D(QVector3D(1, 2, 3), 4)); - QSphere3D s = qVariantValue<QSphere3D>(obj.property("sphere")); + QSphere3D s = qvariant_cast<QSphere3D>(obj.property("sphere")); QCOMPARE(s.center(), QVector3D(1, 2, 3)); QCOMPARE(s.radius(), qreal(4.0f)); obj.setProperty("sphere", qVariantFromValue(QSphere3D(QVector3D(-1, -2, -3), -4))); - s = qVariantValue<QSphere3D>(obj.property("sphere")); + s = qvariant_cast<QSphere3D>(obj.property("sphere")); QCOMPARE(s.center(), QVector3D(-1, -2, -3)); QCOMPARE(s.radius(), qreal(-4.0f)); } diff --git a/tests/auto/threed/qtriangle3d/tst_qtriangle3d.cpp b/tests/auto/threed/qtriangle3d/tst_qtriangle3d.cpp index 46ec01207..f6e113b53 100644 --- a/tests/auto/threed/qtriangle3d/tst_qtriangle3d.cpp +++ b/tests/auto/threed/qtriangle3d/tst_qtriangle3d.cpp @@ -684,7 +684,7 @@ void tst_QTriangle3D::properties() obj.setTriangle(QTriangle3D(QVector3D(1, 2, 3), QVector3D(4, 5, 6), QVector3D(7, 8, 9))); - QTriangle3D t = qVariantValue<QTriangle3D>(obj.property("triangle")); + QTriangle3D t = qvariant_cast<QTriangle3D>(obj.property("triangle")); QCOMPARE(t.p(), QVector3D(1, 2, 3)); QCOMPARE(t.q(), QVector3D(4, 5, 6)); QCOMPARE(t.r(), QVector3D(7, 8, 9)); @@ -695,7 +695,7 @@ void tst_QTriangle3D::properties() QVector3D(-4, -5, -6), QVector3D(-7, -8, -9)))); - t = qVariantValue<QTriangle3D>(obj.property("triangle")); + t = qvariant_cast<QTriangle3D>(obj.property("triangle")); QCOMPARE(t.p(), QVector3D(-1, -2, -3)); QCOMPARE(t.q(), QVector3D(-4, -5, -6)); QCOMPARE(t.r(), QVector3D(-7, -8, -9)); diff --git a/tests/benchmarks/qarray/tst_qarray.cpp b/tests/benchmarks/qarray/tst_qarray.cpp index faac81013..1fa1f374a 100644 --- a/tests/benchmarks/qarray/tst_qarray.cpp +++ b/tests/benchmarks/qarray/tst_qarray.cpp @@ -45,9 +45,7 @@ #include <QtCore/qvector.h> #include <QtCore/qlist.h> #include "qarray.h" -#ifndef QT_NO_STL #include <vector> -#endif //#define TEST_QLIST 1 @@ -108,11 +106,9 @@ void tst_QArray::append_data() name += QByteArray::number(size); QTest::newRow(name.constData()) << size << int(Test_Array); -#ifndef QT_NO_STL name = "std::vector--"; name += QByteArray::number(size); QTest::newRow(name.constData()) << size << int(Test_STLVector); -#endif } } @@ -145,14 +141,12 @@ void tst_QArray::append() for (int i = 0; i < size; ++i) buffer.append(float(i)); } -#ifndef QT_NO_STL } else if (type == Test_STLVector) { std::vector<float> buffer; QBENCHMARK { for (int i = 0; i < size; ++i) buffer.push_back(float(i)); } -#endif } } @@ -193,7 +187,6 @@ void tst_QArray::appendReserved() for (int i = 0; i < size; ++i) buffer.append(float(i)); } -#ifndef QT_NO_STL } else if (type == Test_STLVector) { std::vector<float> buffer; buffer.reserve(size); @@ -201,7 +194,6 @@ void tst_QArray::appendReserved() for (int i = 0; i < size; ++i) buffer.push_back(float(i)); } -#endif } } @@ -239,14 +231,12 @@ void tst_QArray::appendVector3D() for (int i = 0; i < size; ++i) buffer.append(QVector3D(i, i + 1, i + 2)); } -#ifndef QT_NO_STL } else if (type == Test_STLVector) { std::vector<QVector3D> buffer; QBENCHMARK { for (int i = 0; i < size; ++i) buffer.push_back(QVector3D(i, i + 1, i + 2)); } -#endif } } @@ -275,11 +265,9 @@ void tst_QArray::appendSmall_data() name += QByteArray::number(size); QTest::newRow(name.constData()) << size << int(Test_Array); -#ifndef QT_NO_STL name = "std::vector--"; name += QByteArray::number(size); QTest::newRow(name.constData()) << size << int(Test_STLVector); -#endif } } @@ -336,7 +324,6 @@ void tst_QArray::appendFourAtATime() float(i + 2), float(i + 3)); } } -#ifndef QT_NO_STL } else if (type == Test_STLVector) { std::vector<float> buffer; QBENCHMARK { @@ -347,7 +334,6 @@ void tst_QArray::appendFourAtATime() buffer.push_back(float(i + 3)); } } -#endif } } @@ -397,7 +383,6 @@ void tst_QArray::clear() for (int i = 0; i < size; ++i) buffer.append(float(i)); } -#ifndef QT_NO_STL } else if (type == Test_STLVector) { std::vector<float> buffer; QBENCHMARK { @@ -407,7 +392,6 @@ void tst_QArray::clear() for (int i = 0; i < size; ++i) buffer.push_back(float(i)); } -#endif } } @@ -421,9 +405,7 @@ void tst_QArray::randomAccess_data() #endif QTest::newRow("QVarLengthArray") << int(Test_VarLengthArray); QTest::newRow("QArray") << int(Test_Array); -#ifndef QT_NO_STL QTest::newRow("std::vector") << int(Test_STLVector); -#endif } // To force the values below to be computed and stored. @@ -481,7 +463,6 @@ void tst_QArray::randomAccess() sum += buffer.at(i); finalSum = sum; } -#ifndef QT_NO_STL } else if (type == Test_STLVector) { std::vector<int> buffer; for (int i = 0; i < 10000; ++i) @@ -494,7 +475,6 @@ void tst_QArray::randomAccess() sum += buffer[i]; finalSum = sum; } -#endif } } diff --git a/tutorials/quick3d/shadertut/meshes/teapot.bez b/tutorials/quick3d/shadertut/meshes/teapot.bez new file mode 100644 index 000000000..02b2ac447 --- /dev/null +++ b/tutorials/quick3d/shadertut/meshes/teapot.bez @@ -0,0 +1,340 @@ +32 +1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 +4,17,18,19,8,20,21,22,12,23,24,25,16,26,27,28 +19,29,30,31,22,32,33,34,25,35,36,37,28,38,39,40 +31,41,42,1,34,43,44,5,37,45,46,9,40,47,48,13 +13,14,15,16,49,50,51,52,53,54,55,56,57,58,59,60 +16,26,27,28,52,61,62,63,56,64,65,66,60,67,68,69 +28,38,39,40,63,70,71,72,66,73,74,75,69,76,77,78 +40,47,48,13,72,79,80,49,75,81,82,53,78,83,84,57 +57,58,59,60,85,86,87,88,89,90,91,92,93,94,95,96 +60,67,68,69,88,97,98,99,92,100,101,102,96,103,104,105 +69,76,77,78,99,106,107,108,102,109,110,111,105,112,113,114 +78,83,84,57,108,115,116,85,111,117,118,89,114,119,120,93 +121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136 +124,137,138,121,128,139,140,125,132,141,142,129,136,143,144,133 +133,134,135,136,145,146,147,148,149,150,151,152,69,153,154,155 +136,143,144,133,148,156,157,145,152,158,159,149,155,160,161,69 +162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177 +165,178,179,162,169,180,181,166,173,182,183,170,177,184,185,174 +174,175,176,177,186,187,188,189,190,191,192,193,194,195,196,197 +177,184,185,174,189,198,199,186,193,200,201,190,197,202,203,194 +204,204,204,204,207,208,209,210,211,211,211,211,212,213,214,215,4 +204,204,204,204,210,217,218,219,211,211,211,211,215,220,221,222,4 +204,204,204,204,219,224,225,226,211,211,211,211,222,227,228,229,4 +204,204,204,204,226,230,231,207,211,211,211,211,229,232,233,212,4 +212,213,214,215,234,235,236,237,238,239,240,241,242,243,244,245 +215,220,221,222,237,246,247,248,241,249,250,251,245,252,253,254 +222,227,228,229,248,255,256,257,251,258,259,260,254,261,262,263 +229,232,233,212,257,264,265,234,260,266,267,238,263,268,269,242 +270,270,270,270,279,280,281,282,275,276,277,278,271,272,273,274,4 +270,270,270,270,282,289,290,291,278,286,287,288,274,283,284,285,4 +270,270,270,270,291,298,299,300,288,295,296,297,285,292,293,294,4 +270,270,270,270,300,305,306,279,297,303,304,275,294,301,302,271,4 +306 +0.700000,0.450000,-0.000000 +0.700000,0.450000,0.392000 +0.392000,0.450000,0.700000 +0.000000,0.450000,0.700000 +0.668750,0.515625,-0.000000 +0.668750,0.515625,0.374500 +0.374500,0.515625,0.668750 +0.000000,0.515625,0.668750 +0.718750,0.515625,-0.000000 +0.718750,0.515625,0.402500 +0.402500,0.515625,0.718750 +0.000000,0.515625,0.718750 +0.750000,0.450000,-0.000000 +0.750000,0.450000,0.420000 +0.420000,0.450000,0.750000 +0.000000,0.450000,0.750000 +-0.392000,0.450000,0.700000 +-0.700000,0.450000,0.392000 +-0.700000,0.450000,-0.000000 +-0.374500,0.515625,0.668750 +-0.668750,0.515625,0.374500 +-0.668750,0.515625,-0.000000 +-0.402500,0.515625,0.718750 +-0.718750,0.515625,0.402500 +-0.718750,0.515625,-0.000000 +-0.420000,0.450000,0.750000 +-0.750000,0.450000,0.420000 +-0.750000,0.450000,-0.000000 +-0.700000,0.450000,-0.392000 +-0.392000,0.450000,-0.700000 +0.000000,0.450000,-0.700000 +-0.668750,0.515625,-0.374500 +-0.374500,0.515625,-0.668750 +0.000000,0.515625,-0.668750 +-0.718750,0.515625,-0.402500 +-0.402500,0.515625,-0.718750 +0.000000,0.515625,-0.718750 +-0.750000,0.450000,-0.420000 +-0.420000,0.450000,-0.750000 +0.000000,0.450000,-0.750000 +0.392000,0.450000,-0.700000 +0.700000,0.450000,-0.392000 +0.374500,0.515625,-0.668750 +0.668750,0.515625,-0.374500 +0.402500,0.515625,-0.718750 +0.718750,0.515625,-0.402500 +0.420000,0.450000,-0.750000 +0.750000,0.450000,-0.420000 +0.875000,0.187500,-0.000000 +0.875000,0.187500,0.490000 +0.490000,0.187500,0.875000 +0.000000,0.187500,0.875000 +1.000000,-0.075000,-0.000000 +1.000000,-0.075000,0.560000 +0.560000,-0.075000,1.000000 +0.000000,-0.075000,1.000000 +1.000000,-0.300000,-0.000000 +1.000000,-0.300000,0.560000 +0.560000,-0.300000,1.000000 +0.000000,-0.300000,1.000000 +-0.490000,0.187500,0.875000 +-0.875000,0.187500,0.490000 +-0.875000,0.187500,-0.000000 +-0.560000,-0.075000,1.000000 +-1.000000,-0.075000,0.560000 +-1.000000,-0.075000,-0.000000 +-0.560000,-0.300000,1.000000 +-1.000000,-0.300000,0.560000 +-1.000000,-0.300000,-0.000000 +-0.875000,0.187500,-0.490000 +-0.490000,0.187500,-0.875000 +0.000000,0.187500,-0.875000 +-1.000000,-0.075000,-0.560000 +-0.560000,-0.075000,-1.000000 +0.000000,-0.075000,-1.000000 +-1.000000,-0.300000,-0.560000 +-0.560000,-0.300000,-1.000000 +0.000000,-0.300000,-1.000000 +0.490000,0.187500,-0.875000 +0.875000,0.187500,-0.490000 +0.560000,-0.075000,-1.000000 +1.000000,-0.075000,-0.560000 +0.560000,-0.300000,-1.000000 +1.000000,-0.300000,-0.560000 +1.000000,-0.525000,-0.000000 +1.000000,-0.525000,0.560000 +0.560000,-0.525000,1.000000 +0.000000,-0.525000,1.000000 +0.750000,-0.637500,-0.000000 +0.750000,-0.637500,0.420000 +0.420000,-0.637500,0.750000 +0.000000,-0.637500,0.750000 +0.750000,-0.675000,-0.000000 +0.750000,-0.675000,0.420000 +0.420000,-0.675000,0.750000 +0.000000,-0.675000,0.750000 +-0.560000,-0.525000,1.000000 +-1.000000,-0.525000,0.560000 +-1.000000,-0.525000,-0.000000 +-0.420000,-0.637500,0.750000 +-0.750000,-0.637500,0.420000 +-0.750000,-0.637500,-0.000000 +-0.420000,-0.675000,0.750000 +-0.750000,-0.675000,0.420000 +-0.750000,-0.675000,-0.000000 +-1.000000,-0.525000,-0.560000 +-0.560000,-0.525000,-1.000000 +0.000000,-0.525000,-1.000000 +-0.750000,-0.637500,-0.420000 +-0.420000,-0.637500,-0.750000 +0.000000,-0.637500,-0.750000 +-0.750000,-0.675000,-0.420000 +-0.420000,-0.675000,-0.750000 +0.000000,-0.675000,-0.750000 +0.560000,-0.525000,-1.000000 +1.000000,-0.525000,-0.560000 +0.420000,-0.637500,-0.750000 +0.750000,-0.637500,-0.420000 +0.420000,-0.675000,-0.750000 +0.750000,-0.675000,-0.420000 +-0.800000,0.262500,-0.000000 +-0.800000,0.262500,0.150000 +-0.750000,0.375000,0.150000 +-0.750000,0.375000,-0.000000 +-1.150000,0.262500,-0.000000 +-1.150000,0.262500,0.150000 +-1.250000,0.375000,0.150000 +-1.250000,0.375000,-0.000000 +-1.350000,0.262500,-0.000000 +-1.350000,0.262500,0.150000 +-1.500000,0.375000,0.150000 +-1.500000,0.375000,-0.000000 +-1.350000,0.150000,-0.000000 +-1.350000,0.150000,0.150000 +-1.500000,0.150000,0.150000 +-1.500000,0.150000,-0.000000 +-0.750000,0.375000,-0.150000 +-0.800000,0.262500,-0.150000 +-1.250000,0.375000,-0.150000 +-1.150000,0.262500,-0.150000 +-1.500000,0.375000,-0.150000 +-1.350000,0.262500,-0.150000 +-1.500000,0.150000,-0.150000 +-1.350000,0.150000,-0.150000 +-1.350000,0.037500,-0.000000 +-1.350000,0.037500,0.150000 +-1.500000,-0.075000,0.150000 +-1.500000,-0.075000,-0.000000 +-1.250000,-0.187500,-0.000000 +-1.250000,-0.187500,0.150000 +-1.325000,-0.281250,0.150000 +-1.325000,-0.281250,-0.000000 +-1.000000,-0.300000,0.150000 +-0.950000,-0.450000,0.150000 +-0.950000,-0.450000,-0.000000 +-1.500000,-0.075000,-0.150000 +-1.350000,0.037500,-0.150000 +-1.325000,-0.281250,-0.150000 +-1.250000,-0.187500,-0.150000 +-0.950000,-0.450000,-0.150000 +-1.000000,-0.300000,-0.150000 +0.850000,-0.037500,-0.000000 +0.850000,-0.037500,0.330000 +0.850000,-0.450000,0.330000 +0.850000,-0.450000,-0.000000 +1.300000,-0.037500,-0.000000 +1.300000,-0.037500,0.330000 +1.550000,-0.337500,0.330000 +1.550000,-0.337500,-0.000000 +1.150000,0.300000,-0.000000 +1.150000,0.300000,0.125000 +1.200000,0.262500,0.125000 +1.200000,0.262500,-0.000000 +1.350000,0.450000,-0.000000 +1.350000,0.450000,0.125000 +1.650000,0.450000,0.125000 +1.650000,0.450000,-0.000000 +0.850000,-0.450000,-0.330000 +0.850000,-0.037500,-0.330000 +1.550000,-0.337500,-0.330000 +1.300000,-0.037500,-0.330000 +1.200000,0.262500,-0.125000 +1.150000,0.300000,-0.125000 +1.650000,0.450000,-0.125000 +1.350000,0.450000,-0.125000 +1.400000,0.487500,-0.000000 +1.400000,0.487500,0.125000 +1.762500,0.496875,0.125000 +1.762500,0.496875,-0.000000 +1.450000,0.487500,-0.000000 +1.450000,0.487500,0.075000 +1.725000,0.506250,0.075000 +1.725000,0.506250,-0.000000 +1.400000,0.450000,-0.000000 +1.400000,0.450000,0.075000 +1.600000,0.450000,0.075000 +1.600000,0.450000,-0.000000 +1.762500,0.496875,-0.125000 +1.400000,0.487500,-0.125000 +1.725000,0.506250,-0.075000 +1.450000,0.487500,-0.075000 +1.600000,0.450000,-0.075000 +1.400000,0.450000,-0.075000 +0.000000,0.825000,-0.000000 +0.000000,0.825000,0.001000 +0.001000,0.825000,-0.000000 +0.400000,0.825000,-0.000000 +0.400000,0.825000,0.225000 +0.225000,0.825000,0.400000 +0.000000,0.825000,0.400000 +0.000000,0.675000,-0.000000 +0.100000,0.600000,-0.000000 +0.100000,0.600000,0.056000 +0.056000,0.600000,0.100000 +0.000000,0.600000,0.100000 +-0.001000,0.825000,-0.000000 +-0.225000,0.825000,0.400000 +-0.400000,0.825000,0.225000 +-0.400000,0.825000,-0.000000 +-0.056000,0.600000,0.100000 +-0.100000,0.600000,0.056000 +-0.100000,0.600000,-0.000000 +0.000000,0.825000,-0.001000 +-0.400000,0.825000,-0.225000 +-0.225000,0.825000,-0.400000 +0.000000,0.825000,-0.400000 +-0.100000,0.600000,-0.056000 +-0.056000,0.600000,-0.100000 +0.000000,0.600000,-0.100000 +0.225000,0.825000,-0.400000 +0.400000,0.825000,-0.225000 +0.056000,0.600000,-0.100000 +0.100000,0.600000,-0.056000 +0.200000,0.525000,-0.000000 +0.200000,0.525000,0.112000 +0.112000,0.525000,0.200000 +0.000000,0.525000,0.200000 +0.650000,0.525000,-0.000000 +0.650000,0.525000,0.364000 +0.364000,0.525000,0.650000 +0.000000,0.525000,0.650000 +0.650000,0.450000,-0.000000 +0.650000,0.450000,0.364000 +0.364000,0.450000,0.650000 +0.000000,0.450000,0.650000 +-0.112000,0.525000,0.200000 +-0.200000,0.525000,0.112000 +-0.200000,0.525000,-0.000000 +-0.364000,0.525000,0.650000 +-0.650000,0.525000,0.364000 +-0.650000,0.525000,-0.000000 +-0.364000,0.450000,0.650000 +-0.650000,0.450000,0.364000 +-0.650000,0.450000,-0.000000 +-0.200000,0.525000,-0.112000 +-0.112000,0.525000,-0.200000 +0.000000,0.525000,-0.200000 +-0.650000,0.525000,-0.364000 +-0.364000,0.525000,-0.650000 +0.000000,0.525000,-0.650000 +-0.650000,0.450000,-0.364000 +-0.364000,0.450000,-0.650000 +0.000000,0.450000,-0.650000 +0.112000,0.525000,-0.200000 +0.200000,0.525000,-0.112000 +0.364000,0.525000,-0.650000 +0.650000,0.525000,-0.364000 +0.364000,0.450000,-0.650000 +0.650000,0.450000,-0.364000 +0.000000,-0.750000,-0.000000 +0.750000,-0.675000,-0.000000 +0.750000,-0.675000,-0.420000 +0.420000,-0.675000,-0.750000 +0.000000,-0.675000,-0.750000 +0.750000,-0.712500,-0.000000 +0.750000,-0.712500,-0.420000 +0.420000,-0.712500,-0.750000 +0.000000,-0.712500,-0.750000 +0.712500,-0.750000,-0.000000 +0.712500,-0.750000,-0.399000 +0.399000,-0.750000,-0.712500 +0.000000,-0.750000,-0.712500 +-0.420000,-0.675000,-0.750000 +-0.750000,-0.675000,-0.420000 +-0.750000,-0.675000,-0.000000 +-0.420000,-0.712500,-0.750000 +-0.750000,-0.712500,-0.420000 +-0.750000,-0.712500,-0.000000 +-0.399000,-0.750000,-0.712500 +-0.712500,-0.750000,-0.399000 +-0.712500,-0.750000,-0.000000 +-0.750000,-0.675000,0.420000 +-0.420000,-0.675000,0.750000 +0.000000,-0.675000,0.750000 +-0.750000,-0.712500,0.420000 +-0.420000,-0.712500,0.750000 +0.000000,-0.712500,0.750000 +-0.712500,-0.750000,0.399000 +-0.399000,-0.750000,0.712500 +0.000000,-0.750000,0.712500 +0.420000,-0.675000,0.750000 +0.750000,-0.675000,0.420000 +0.420000,-0.712500,0.750000 +0.750000,-0.712500,0.420000 +0.399000,-0.750000,0.712500 +0.712500,-0.750000,0.399000 diff --git a/tutorials/quick3d/shadertut/mt.qml b/tutorials/quick3d/shadertut/mt.qml index 95cbc2606..380764674 100644 --- a/tutorials/quick3d/shadertut/mt.qml +++ b/tutorials/quick3d/shadertut/mt.qml @@ -47,6 +47,6 @@ Item { width: 320 height: 480 - ShaderTutorial { + ShaderTutorial{ } } diff --git a/tutorials/quick3d/shadertut/qml/shader-tutorial-1-textures.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-1-textures.qml deleted file mode 100644 index 2be310ef1..000000000 --- a/tutorials/quick3d/shadertut/qml/shader-tutorial-1-textures.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt3D 1.0 - -Viewport { - width: 640; height: 480 - - TutorialTeapot { - effect: program - } - - ShaderProgram { - id: program - texture: "textures/qtlogo.png" - property real textureOffsetX : 1.0 - NumberAnimation on textureOffsetX - { - running: true; loops: Animation.Infinite - from: 0.0; to: 1.0; - duration: 1000 - } - - property string texture2: "textures/basket.jpg" - property real interpolationFactor : 1.0 - SequentialAnimation on interpolationFactor - { - running: true; loops: Animation.Infinite - NumberAnimation { from: 0.0; to: 1.0; duration: 2000 } - PauseAnimation { duration: 500 } - NumberAnimation { from: 1.0; to: 0.0; duration: 2000 } - PauseAnimation { duration: 500 } - } - - vertexShader: " - attribute highp vec4 qt_Vertex; - uniform mediump mat4 qt_ModelViewProjectionMatrix; - - attribute highp vec4 qt_MultiTexCoord0; - uniform mediump float textureOffsetX; - varying mediump vec4 texCoord; - - void main(void) - { - gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; - texCoord.st = vec2(-qt_MultiTexCoord0.s - textureOffsetX, - -qt_MultiTexCoord0.t); - texCoord.pq = vec2(-qt_MultiTexCoord0.s + textureOffsetX, - -qt_MultiTexCoord0.t); - } - " - fragmentShader: " - varying highp vec4 texCoord; - uniform sampler2D qt_Texture0; - uniform sampler2D texture2; - uniform mediump float interpolationFactor; - - void main(void) - { - mediump vec4 texture1Color = texture2D(qt_Texture0, texCoord.st); - mediump vec4 texture2Color = texture2D(texture2, texCoord.pq); - mediump vec4 textureColor = mix(texture1Color, texture2Color, interpolationFactor); - gl_FragColor = textureColor; - } - " - } -} diff --git a/tutorials/quick3d/shadertut/qml/shader-tutorial-2-vertex-shader.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-2-vertex-shader.qml deleted file mode 100644 index 49137ea6f..000000000 --- a/tutorials/quick3d/shadertut/qml/shader-tutorial-2-vertex-shader.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt3D 1.0 - -Viewport { - width: 640; height: 480 - - TutorialTeapot { - id: teapot - effect: program - xRotation: 30 - } - - ShaderProgram { - id: program - texture: "textures/qtlogo.png" - - property real textureOffsetX : 0.0 - property real squashFactor : 0.0 - NumberAnimation on textureOffsetX - { - running: true; loops: Animation.Infinite - from: 0.0; to: 1.0; - duration: 1000 - } - - SequentialAnimation on squashFactor - { - running: true; loops: Animation.Infinite - NumberAnimation { - from: 0.0; to: 1.0; duration: 1000 - easing.type: "InQuad" - } - PauseAnimation { - duration: 250 - } - NumberAnimation { - from: 1.0; to: 0.0; duration: 1000 - easing.type: "OutQuad" - } - } - - vertexShader: " - attribute highp vec4 qt_Vertex; - uniform mediump mat4 qt_ModelViewProjectionMatrix; - - attribute highp vec4 qt_MultiTexCoord0; - varying highp vec4 texCoord; - uniform mediump float textureOffsetX; - uniform mediump float squashFactor; - - void main(void) - { - const float modelSize = 2.0; - const float modelBottom = -1.0; - float newY = max(qt_Vertex.y - squashFactor * modelSize, - qt_Vertex.y * 0.01 + modelBottom); - gl_Position = qt_ModelViewProjectionMatrix * - vec4(qt_Vertex.x, newY, qt_Vertex.zw); - - texCoord = vec4(-qt_MultiTexCoord0.s - - textureOffsetX, - -qt_MultiTexCoord0.t, - qt_MultiTexCoord0.pq); - } - " - fragmentShader: " - varying highp vec4 texCoord; - uniform sampler2D qt_Texture0; - - void main(void) - { - mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st); - gl_FragColor = textureColor; - } - " - } -} diff --git a/tutorials/quick3d/shadertut/qml/shader-tutorial-3-transformed-coordinates.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-3-transformed-coordinates.qml deleted file mode 100644 index efe4aabb2..000000000 --- a/tutorials/quick3d/shadertut/qml/shader-tutorial-3-transformed-coordinates.qml +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt3D 1.0 - -Viewport { - width: 640; height: 480 - - - Item3D { - z: -8.0 - transform: [ - Rotation3D { - NumberAnimation on angle { - running: true; loops: Animation.Infinite - from: 0; to: 360; duration: 5000 - } - axis: Qt.vector3d(0, 0, 1.0) - } - ] - - TutorialTeapot {id: teapot1; effect: program; y:2.0; x:0.0} - TutorialTeapot {id: teapot2; effect: program; y:-1.0; x:-1.732} - TutorialTeapot {id: teapot3; effect: program; y:-1.0; x:1.732} - } - - ShaderProgram { - id: program - texture: "textures/qtlogo.png" - - property real textureOffsetX : 0.0 - property real squashFactor : 0.0 - NumberAnimation on textureOffsetX - { - running: true; loops: Animation.Infinite - from: 0.0; to: 1.0; - duration: 1000 - } - - SequentialAnimation on squashFactor - { - running: true; loops: Animation.Infinite - NumberAnimation { - from: 0.0; to: 1.0; duration: 1000 - easing.type: "InQuad" - } - PauseAnimation { - duration: 250 - } - NumberAnimation { - from: 1.0; to: 0.0; duration: 1000 - easing.type: "OutQuad" - } - } - - - vertexShader: " - attribute highp vec4 qt_Vertex; - uniform mediump mat4 qt_ModelViewProjectionMatrix; - - attribute mediump vec4 qt_MultiTexCoord0; - varying mediump vec4 texCoord; - - void main(void) - { - const float modelBottom = -4.0; - - vec4 workingPosition = qt_ModelViewProjectionMatrix * qt_Vertex; - float newY = max(workingPosition.y, - workingPosition.y * 0.15 + modelBottom); - workingPosition.y = newY; - gl_Position = workingPosition; - - texCoord = -qt_MultiTexCoord0; - } - " - fragmentShader: " - varying mediump vec4 texCoord; - uniform sampler2D qt_Texture0; - - void main(void) - { - mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st); - gl_FragColor = textureColor; - } - " - } -} diff --git a/tutorials/quick3d/shadertut/qml/shader-tutorial-lighting.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-lighting.qml deleted file mode 100644 index 87a55d613..000000000 --- a/tutorials/quick3d/shadertut/qml/shader-tutorial-lighting.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt3D 1.0 -import Qt3D.Shapes 1.0 - -Viewport { - width: 640; height: 480 - - - Cube { - id: teapot - effect: program -// xRotation: 30 - } - - ShaderProgram { - id: program - texture: "textures/qtlogo.png" - - vertexShader: " - attribute highp vec4 qt_Vertex; - uniform highp mat4 qt_ModelViewProjectionMatrix; - - attribute highp vec4 qt_MultiTexCoord0; - varying highp vec4 texCoord; - - void main(void) - { - gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; -// texCoord = -qt_MultiTexCoord0; - texCoord = qt_Vertex; - } - " - fragmentShader: " - varying highp vec4 texCoord; - uniform sampler2D qt_Texture0; - - void main(void) - { - mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st); -// gl_FragColor = textureColor; - gl_FragColor = vec4(texCoord.xyz , 1.0); - } - " - } -} diff --git a/tutorials/quick3d/shadertut/qml/shader-tutorial-varying.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial-varying.qml deleted file mode 100644 index fea323167..000000000 --- a/tutorials/quick3d/shadertut/qml/shader-tutorial-varying.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt3D examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt3D 1.0 - -Viewport { - width: 640; height: 480 - - Pane { - effect: ShaderProgram { - id: program - - vertexShader: " - attribute highp vec4 qt_Vertex; - uniform mediump mat4 qt_ModelViewProjectionMatrix; - - attribute highp vec4 qt_MultiTexCoord0; - varying highp vec4 texCoord; - - void main(void) - { - gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; - texCoord = vec4(qt_MultiTexCoord0.st, 0, 0); - } - " - fragmentShader: " - varying highp vec4 texCoord; - - void main(void) - { - gl_FragColor = vec4(mod(texCoord.x, 1.0), - mod(texCoord.y, 1.0), - 0.0, - 1.0); - } - " - } - } -} diff --git a/tutorials/quick3d/shadertut/qml/ShaderTutorial.qml b/tutorials/quick3d/shadertut/qml/shader-tutorial.qml index 4c26df8e2..b5e83227f 100644 --- a/tutorials/quick3d/shadertut/qml/ShaderTutorial.qml +++ b/tutorials/quick3d/shadertut/qml/shader-tutorial.qml @@ -42,7 +42,8 @@ import QtQuick 2.0 import Qt3D 1.0 Viewport { - width: parent.width; height: parent.height + width: 640; height: 480 + TutorialTeapot { id: teapot @@ -52,7 +53,7 @@ Viewport { ShaderProgram { id: program - texture: "qtlogo.png" + texture: "textures/qtlogo.png" vertexShader: " attribute highp vec4 qt_Vertex; diff --git a/tutorials/quick3d/shadertut/shadertut.pro b/tutorials/quick3d/shadertut/shadertut.pro index 0d37af691..198d98131 100644 --- a/tutorials/quick3d/shadertut/shadertut.pro +++ b/tutorials/quick3d/shadertut/shadertut.pro @@ -1,21 +1,21 @@ TEMPLATE = app TARGET = shadertut CONFIG += qt warn_on -QT += qml quick +QT += qml quick 3dquick SOURCES += main.cpp ICON_FILE = ../icon.png QML_FILES = \ + qml/ShaderTutorial.qml \ qml/desktop.qml \ qml/TutorialTeapot.qml \ qml/shader-tutorial-1-textures.qml \ qml/shader-tutorial-3-transformed-coordinates.qml \ qml/shader-tutorial-varying.qml \ qml/shader-tutorial-2-vertex-shader.qml \ - qml/shader-tutorial-lighting.qml \ - qml/ShaderTutorial.qml + qml/shader-tutorial-lighting.qml QML_INFRA_FILES = \ $$QML_FILES @@ -30,5 +30,4 @@ OTHER_FILES += \ mt.qml \ shadertut.rc \ $$QML_INFRA_FILES - RC_FILE = shadertut.rc diff --git a/tutorials/quick3d/shadertut/shadertut.rc b/tutorials/quick3d/shadertut/shadertut.rc deleted file mode 100644 index 1b6228c97..000000000 --- a/tutorials/quick3d/shadertut/shadertut.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "qtquick3d.ico" diff --git a/tutorials/quick3d/teapot_bounce_qml/teapot_bounce_qml.pro b/tutorials/quick3d/teapot_bounce_qml/teapot_bounce_qml.pro index 8f36d94b6..df683673b 100644 --- a/tutorials/quick3d/teapot_bounce_qml/teapot_bounce_qml.pro +++ b/tutorials/quick3d/teapot_bounce_qml/teapot_bounce_qml.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = teapot_bounce_qml CONFIG += qt warn_on -QT += declarative quick 3dquick +QT += qml quick 3dquick SOURCES += main.cpp |